-
Notifications
You must be signed in to change notification settings - Fork 415
🐛(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
Merged
Merged
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -75,3 +75,6 @@ db.sqlite3 | |
.vscode/ | ||
*.iml | ||
.devcontainer | ||
|
||
# Cursor rules | ||
.cursorrules |
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
110 changes: 110 additions & 0 deletions
110
src/frontend/apps/impress/src/features/left-panel/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,110 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { | ||
ImperativePanelHandle, | ||
Panel, | ||
PanelGroup, | ||
PanelResizeHandle, | ||
} from 'react-resizable-panels'; | ||
import { createGlobalStyle } from 'styled-components'; | ||
|
||
import { useCunninghamTheme } from '@/cunningham'; | ||
|
||
interface PanelStyleProps { | ||
$isResizing: boolean; | ||
} | ||
|
||
const PanelStyle = createGlobalStyle<PanelStyleProps>` | ||
${({ $isResizing }) => $isResizing && `body * { transition: none !important; }`} | ||
`; | ||
|
||
// Convert a target pixel width to a percentage of the current viewport width. | ||
// react-resizable-panels expects sizes in %, not px. | ||
const calculateDefaultSize = (targetWidth: number) => { | ||
const windowWidth = window.innerWidth; | ||
return (targetWidth / windowWidth) * 100; | ||
}; | ||
|
||
type ResizableLeftPanelProps = { | ||
leftPanel: React.ReactNode; | ||
children: React.ReactNode; | ||
minPanelSizePx?: number; | ||
maxPanelSizePx?: number; | ||
}; | ||
|
||
export const ResizableLeftPanel = ({ | ||
leftPanel, | ||
children, | ||
minPanelSizePx = 300, | ||
maxPanelSizePx = 450, | ||
}: ResizableLeftPanelProps) => { | ||
const [isResizing, setIsResizing] = useState(false); | ||
const { colorsTokens } = useCunninghamTheme(); | ||
const ref = useRef<ImperativePanelHandle>(null); | ||
const resizeTimeoutRef = useRef<number | undefined>(undefined); | ||
|
||
const [minPanelSize, setMinPanelSize] = useState(0); | ||
const [maxPanelSize, setMaxPanelSize] = useState(0); | ||
|
||
// Single resize listener that handles both panel size updates and transition disabling | ||
useEffect(() => { | ||
const handleResize = () => { | ||
// Update panel sizes (px -> %) | ||
const min = Math.round(calculateDefaultSize(minPanelSizePx)); | ||
const max = Math.round( | ||
Math.min(calculateDefaultSize(maxPanelSizePx), 40), | ||
); | ||
setMinPanelSize(min); | ||
setMaxPanelSize(max); | ||
|
||
// Temporarily disable transitions to avoid flicker | ||
setIsResizing(true); | ||
if (resizeTimeoutRef.current) { | ||
clearTimeout(resizeTimeoutRef.current); | ||
} | ||
resizeTimeoutRef.current = window.setTimeout(() => { | ||
setIsResizing(false); | ||
}, 150); | ||
}; | ||
|
||
handleResize(); | ||
|
||
window.addEventListener('resize', handleResize); | ||
|
||
return () => { | ||
window.removeEventListener('resize', handleResize); | ||
if (resizeTimeoutRef.current) { | ||
clearTimeout(resizeTimeoutRef.current); | ||
} | ||
}; | ||
}, [minPanelSizePx, maxPanelSizePx]); | ||
|
||
return ( | ||
<> | ||
<PanelStyle $isResizing={isResizing} /> | ||
<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> | ||
</> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
src/frontend/apps/impress/src/features/left-panel/components/index.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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './LeftPanel'; | ||
export * from './ResizableLeftPanel'; |
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