-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(ui): make tool list panel resizable #2253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
duwenxin99
merged 10 commits into
googleapis:main
from
bennymagid:feat/ui-resizable-panel
Feb 18, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
733b54b
feat(ui): make tool list panel resizable
bennymagid c7cebba
fix: address code review comments
bennymagid c50bc24
Merge branch 'main' into feat/ui-resizable-panel
duwenxin99 b841377
Merge branch 'main' into feat/ui-resizable-panel
duwenxin99 cb51b14
Merge branch 'main' into feat/ui-resizable-panel
duwenxin99 f40f09f
Merge branch 'main' into feat/ui-resizable-panel
duwenxin99 aebaac8
Merge branch 'main' into feat/ui-resizable-panel
duwenxin99 e24e236
Merge branch 'main' into feat/ui-resizable-panel
duwenxin99 9203d4f
Merge branch 'main' into feat/ui-resizable-panel
duwenxin99 5fdbe60
Merge branch 'main' into feat/ui-resizable-panel
duwenxin99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // Copyright 2025 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| const STORAGE_KEY = 'toolbox-second-nav-width'; | ||
| const DEFAULT_WIDTH = 250; | ||
| const MIN_WIDTH = 200; | ||
| const MAX_WIDTH_PERCENT = 50; | ||
|
|
||
| /** | ||
| * Creates and attaches a resize handle to the second navigation panel | ||
| */ | ||
| export function initializeResize() { | ||
| const secondNav = document.querySelector('.second-nav'); | ||
| if (!secondNav) { | ||
| return; | ||
| } | ||
|
|
||
| // Create resize handle | ||
| const resizeHandle = document.createElement('div'); | ||
| resizeHandle.className = 'resize-handle'; | ||
| resizeHandle.setAttribute('aria-label', 'Resize panel'); | ||
| secondNav.appendChild(resizeHandle); | ||
|
|
||
| // Load saved width or use default | ||
| let initialWidth = DEFAULT_WIDTH; | ||
| try { | ||
| const savedWidth = localStorage.getItem(STORAGE_KEY); | ||
| if (savedWidth) { | ||
| const parsed = parseInt(savedWidth, 10); | ||
| if (!isNaN(parsed) && parsed >= MIN_WIDTH) { | ||
| initialWidth = parsed; | ||
| } | ||
| } | ||
| } catch (e) { | ||
| // localStorage may be unavailable in private browsing mode | ||
| console.warn('Failed to load saved panel width:', e); | ||
| } | ||
| setPanelWidth(secondNav, initialWidth); | ||
|
|
||
| // Setup resize functionality | ||
| let startX = 0; | ||
| let startWidth = 0; | ||
|
|
||
| const onMouseMove = (e) => { | ||
| const deltaX = e.clientX - startX; | ||
| const newWidth = startWidth + deltaX; | ||
| const maxWidth = (window.innerWidth * MAX_WIDTH_PERCENT) / 100; | ||
|
|
||
| const clampedWidth = Math.max(MIN_WIDTH, Math.min(newWidth, maxWidth)); | ||
| setPanelWidth(secondNav, clampedWidth); | ||
| }; | ||
|
|
||
| const onMouseUp = () => { | ||
| document.removeEventListener('mousemove', onMouseMove); | ||
| document.removeEventListener('mouseup', onMouseUp); | ||
|
|
||
| resizeHandle.classList.remove('active'); | ||
| document.body.style.cursor = ''; | ||
| document.body.style.userSelect = ''; | ||
|
|
||
| // Save width to localStorage | ||
| try { | ||
| localStorage.setItem(STORAGE_KEY, secondNav.offsetWidth.toString()); | ||
| } catch (e) { | ||
| // localStorage may be unavailable in private browsing mode | ||
| console.warn('Failed to save panel width:', e); | ||
| } | ||
| }; | ||
|
|
||
| resizeHandle.addEventListener('mousedown', (e) => { | ||
| startX = e.clientX; | ||
| startWidth = secondNav.offsetWidth; | ||
| resizeHandle.classList.add('active'); | ||
| document.body.style.cursor = 'ew-resize'; | ||
| document.body.style.userSelect = 'none'; | ||
| e.preventDefault(); | ||
|
|
||
| document.addEventListener('mousemove', onMouseMove); | ||
| document.addEventListener('mouseup', onMouseUp); | ||
| }); | ||
|
|
||
| // Handle window resize to enforce max width | ||
| window.addEventListener('resize', () => { | ||
| const currentWidth = secondNav.offsetWidth; | ||
| const maxWidth = (window.innerWidth * MAX_WIDTH_PERCENT) / 100; | ||
|
|
||
| if (currentWidth > maxWidth) { | ||
| setPanelWidth(secondNav, maxWidth); | ||
| try { | ||
| localStorage.setItem(STORAGE_KEY, maxWidth.toString()); | ||
| } catch (e) { | ||
| // localStorage may be unavailable in private browsing mode | ||
| console.warn('Failed to save panel width:', e); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Sets the width of the panel and updates flex property | ||
| */ | ||
| function setPanelWidth(panel, width) { | ||
| panel.style.flex = `0 0 ${width}px`; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.