-
Notifications
You must be signed in to change notification settings - Fork 411
🐛(frontend) show full nested doc names with horizontal scroll support #1456
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
Open
Ovgodd
wants to merge
5
commits into
main
Choose a base branch
from
fix/1180-make-horizontal-overflow-panel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0a91db7
✨(frontend) add resizable left panel on desktop with persistence
Ovgodd cbd6731
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 08189b5
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 37bcb2f
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 3326f02
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 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
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
94 changes: 94 additions & 0 deletions
94
src/frontend/apps/impress/src/layouts/components/ResizableLeftPanel.tsx
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,94 @@ | ||
import { useCallback, useEffect, useRef, useState } from 'react'; | ||
import { | ||
ImperativePanelHandle, | ||
Panel, | ||
PanelGroup, | ||
PanelResizeHandle, | ||
} from 'react-resizable-panels'; | ||
|
||
import { useCunninghamTheme } from '@/cunningham'; | ||
import { LeftPanel } from '@/features/left-panel'; | ||
|
||
const MIN_PANEL_SIZE_PX = 300; | ||
const MAX_PANEL_SIZE_PX = 450; | ||
|
||
type ResizableLeftPanelProps = { | ||
children: React.ReactNode; | ||
onResizingChange?: (isResizing: boolean) => void; | ||
}; | ||
|
||
export const ResizableLeftPanel = ({ | ||
children, | ||
onResizingChange, | ||
}: ResizableLeftPanelProps) => { | ||
const { colorsTokens } = useCunninghamTheme(); | ||
const ref = useRef<ImperativePanelHandle>(null); | ||
const resizeTimeoutRef = useRef<number | undefined>(undefined); | ||
|
||
const [minPanelSize, setMinPanelSize] = useState(0); | ||
const [maxPanelSize, setMaxPanelSize] = useState(0); | ||
|
||
// Convert a target pixel width to a percentage of the current viewport width. | ||
// react-resizable-panels expects sizes in %, not px. | ||
const calculateDefaultSize = useCallback((targetWidth: number) => { | ||
const windowWidth = window.innerWidth; | ||
return (targetWidth / windowWidth) * 100; | ||
}, []); | ||
|
||
// Single resize listener that handles both panel size updates and transition disabling | ||
useEffect(() => { | ||
const handleResize = () => { | ||
// Update panel sizes (px -> %) | ||
const min = Math.round(calculateDefaultSize(MIN_PANEL_SIZE_PX)); | ||
const max = Math.round( | ||
Math.min(calculateDefaultSize(MAX_PANEL_SIZE_PX), 40), | ||
); | ||
setMinPanelSize(min); | ||
setMaxPanelSize(max); | ||
|
||
// Temporarily disable transitions to avoid flicker | ||
onResizingChange?.(true); | ||
if (resizeTimeoutRef.current) { | ||
clearTimeout(resizeTimeoutRef.current); | ||
} | ||
resizeTimeoutRef.current = window.setTimeout(() => { | ||
onResizingChange?.(false); | ||
}, 150); | ||
}; | ||
|
||
handleResize(); | ||
|
||
window.addEventListener('resize', handleResize); | ||
|
||
return () => { | ||
window.removeEventListener('resize', handleResize); | ||
if (resizeTimeoutRef.current) { | ||
clearTimeout(resizeTimeoutRef.current); | ||
} | ||
}; | ||
}, [calculateDefaultSize, onResizingChange]); | ||
|
||
return ( | ||
<PanelGroup autoSaveId="docs-left-panel-persistence" direction="horizontal"> | ||
<Panel | ||
ref={ref} | ||
order={0} | ||
defaultSize={minPanelSize} | ||
minSize={minPanelSize} | ||
maxSize={maxPanelSize} | ||
> | ||
<LeftPanel /> | ||
</Panel> | ||
<PanelResizeHandle | ||
style={{ | ||
borderRightWidth: '1px', | ||
borderRightStyle: 'solid', | ||
borderRightColor: colorsTokens['greyscale-200'], | ||
width: '1px', | ||
cursor: 'col-resize', | ||
}} | ||
/> | ||
<Panel order={1}>{children}</Panel> | ||
</PanelGroup> | ||
); | ||
}; |
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 @@ | ||
export * from './ResizableLeftPanel'; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not introduce in this PR but I can see there is differences on how the actions buttons are displayed between the top parent and the children, I think it should be
&:focus-visible
here.docs/src/frontend/apps/impress/src/features/docs/doc-tree/components/DocTree.tsx
Lines 243 to 246 in f059014