-
Notifications
You must be signed in to change notification settings - Fork 8
Map layers panel #4281
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
Merged
Map layers panel #4281
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0cad4ff
map: added layers panel
SteRiccio 323743c
map layers panel: make it resizable
SteRiccio 3d5e130
code cleanup
SteRiccio 7ce59e9
unselect layer item when clicking outside marker
SteRiccio 6dcfac8
layout improvements
SteRiccio 4b02524
map layers panel: allow sorting points
SteRiccio f1a8491
layout adjustments
SteRiccio e6dba2d
solved Sonarcloud issues
SteRiccio 0827d88
map gutter: code cleanup
SteRiccio 14f7d61
code cleanup
SteRiccio 82ba0b8
code cleanup
SteRiccio 4428415
fixed layer heading click
SteRiccio 4f54cee
code cleanup
SteRiccio 63987e7
code cleanup
SteRiccio 56bd5b1
solved Copilot issues
SteRiccio 7bc88f4
added translation for "markers count"
SteRiccio 2120e8f
make MapLayersPanel only experimental
SteRiccio 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(npx tsc *)" | ||
| ] | ||
| } | ||
| } |
Binary file not shown.
652 changes: 326 additions & 326 deletions
652
.yarn/releases/yarn-4.16.0.cjs → .yarn/releases/yarn-4.17.0.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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,133 @@ | ||
| import { useCallback, useEffect, useRef, useState } from 'react' | ||
|
|
||
| type Params = { | ||
| containerRef: React.RefObject<HTMLElement | null> | ||
| initialWidth: number | ||
| minLeftWidth?: number | ||
| minRightWidth?: number | ||
| } | ||
|
|
||
| type Result = { | ||
| width: number | ||
| maxWidth: number | ||
| onGutterMouseDown: (e: React.MouseEvent) => void | ||
| onGutterKeyDown: (e: React.KeyboardEvent) => void | ||
| onGutterTouchStart: (e: React.TouchEvent) => void | ||
| } | ||
|
|
||
| const KEYBOARD_STEP = 10 | ||
|
|
||
| export const useHorizontalResize = ({ | ||
| containerRef, | ||
| initialWidth, | ||
| minLeftWidth = 0, | ||
| minRightWidth = 0, | ||
| }: Params): Result => { | ||
| const [width, setWidth] = useState(initialWidth) | ||
| const [containerWidth, setContainerWidth] = useState(0) | ||
| const widthRef = useRef(initialWidth) | ||
|
|
||
| useEffect(() => { | ||
| const container = containerRef.current | ||
| if (!container) return | ||
| setContainerWidth(container.clientWidth) | ||
| const observer = new ResizeObserver(() => setContainerWidth(container.clientWidth)) | ||
| observer.observe(container) | ||
| return () => observer.disconnect() | ||
| }, [containerRef]) | ||
|
|
||
| const clampWidth = useCallback( | ||
| (newWidth: number): number => { | ||
| const containerWidth = containerRef.current?.clientWidth ?? window.innerWidth | ||
| return Math.min(containerWidth - minRightWidth, Math.max(minLeftWidth, newWidth)) | ||
| }, | ||
| [containerRef, minLeftWidth, minRightWidth] | ||
| ) | ||
|
SteRiccio marked this conversation as resolved.
|
||
|
|
||
| const onGutterMouseDown = useCallback( | ||
| (e: React.MouseEvent) => { | ||
| e.preventDefault() | ||
| const startX = e.clientX | ||
| const startWidth = widthRef.current | ||
| document.body.style.cursor = 'ew-resize' | ||
| document.body.style.userSelect = 'none' | ||
|
|
||
| const onMouseMove = (moveEvent: MouseEvent) => { | ||
| const newWidth = clampWidth(startWidth + moveEvent.clientX - startX) | ||
| widthRef.current = newWidth | ||
| setWidth(newWidth) | ||
| } | ||
|
|
||
| const onMouseUp = () => { | ||
| document.body.style.cursor = '' | ||
| document.body.style.userSelect = '' | ||
| document.removeEventListener('mousemove', onMouseMove) | ||
| document.removeEventListener('mouseup', onMouseUp) | ||
| } | ||
|
|
||
| document.addEventListener('mousemove', onMouseMove) | ||
| document.addEventListener('mouseup', onMouseUp) | ||
| }, | ||
| [clampWidth] | ||
| ) | ||
|
|
||
| const onGutterKeyDown = useCallback( | ||
| (e: React.KeyboardEvent) => { | ||
| let delta = 0 | ||
| if (e.key === 'ArrowRight') { | ||
| delta = KEYBOARD_STEP | ||
| } else if (e.key === 'ArrowLeft') { | ||
| delta = -KEYBOARD_STEP | ||
| } else if (e.key === 'Home') { | ||
| e.preventDefault() | ||
| const newWidth = clampWidth(minLeftWidth) | ||
| widthRef.current = newWidth | ||
| setWidth(newWidth) | ||
| return | ||
| } else if (e.key === 'End') { | ||
| e.preventDefault() | ||
| const containerWidth = containerRef.current?.clientWidth ?? window.innerWidth | ||
| const newWidth = clampWidth(containerWidth - minRightWidth) | ||
| widthRef.current = newWidth | ||
| setWidth(newWidth) | ||
| return | ||
| } else { | ||
| return | ||
| } | ||
| e.preventDefault() | ||
| const newWidth = clampWidth(widthRef.current + delta) | ||
| widthRef.current = newWidth | ||
| setWidth(newWidth) | ||
| }, | ||
| [clampWidth, containerRef, minLeftWidth, minRightWidth] | ||
| ) | ||
|
|
||
| const onGutterTouchStart = useCallback( | ||
| (e: React.TouchEvent) => { | ||
| const touch = e.touches[0] | ||
| const startX = touch.clientX | ||
| const startWidth = widthRef.current | ||
|
|
||
| const onTouchMove = (moveEvent: TouchEvent) => { | ||
| moveEvent.preventDefault() | ||
| const currentTouch = moveEvent.touches[0] | ||
| const newWidth = clampWidth(startWidth + currentTouch.clientX - startX) | ||
| widthRef.current = newWidth | ||
| setWidth(newWidth) | ||
| } | ||
|
|
||
| const onTouchEnd = () => { | ||
| document.removeEventListener('touchmove', onTouchMove) | ||
| document.removeEventListener('touchend', onTouchEnd) | ||
| } | ||
|
|
||
| document.addEventListener('touchmove', onTouchMove, { passive: false }) | ||
| document.addEventListener('touchend', onTouchEnd) | ||
| }, | ||
| [clampWidth] | ||
| ) | ||
|
|
||
| const maxWidth = Math.max(0, containerWidth - minRightWidth) | ||
|
|
||
| return { width, maxWidth, onGutterMouseDown, onGutterKeyDown, onGutterTouchStart } | ||
| } | ||
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.
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.