-
Notifications
You must be signed in to change notification settings - Fork 414
🐛(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
10
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.
+277
−43
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b10b27e
✨(frontend) add resizable left panel on desktop with persistence
Ovgodd cb650f2
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 649d7db
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd dfd77fa
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 9e74a71
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 55a5737
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 3115156
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 74eb0fb
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd d922cda
fixup! ✨(frontend) add resizable left panel on desktop with persistence
Ovgodd 4df1842
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
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
92 changes: 92 additions & 0 deletions
92
src/frontend/apps/impress/src/components/main-layout/MainLayoutContent.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,92 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { css } from 'styled-components'; | ||
|
||
import { Box } from '@/components'; | ||
import { useCunninghamTheme } from '@/cunningham'; | ||
import { LeftPanel } from '@/features/left-panel'; | ||
import { MAIN_LAYOUT_ID } from '@/layouts/conf'; | ||
import { useResponsiveStore } from '@/stores'; | ||
|
||
import { HEADER_HEIGHT } from '../../features/header/conf'; | ||
import { ResizableLeftPanel } from '../../features/left-panel/components/ResizableLeftPanel'; | ||
|
||
export interface MainLayoutContentProps { | ||
backgroundColor: 'white' | 'grey'; | ||
enableResizablePanel?: boolean; | ||
onResizingChange?: (isResizing: boolean) => void; | ||
} | ||
|
||
export function MainLayoutContent({ | ||
children, | ||
backgroundColor, | ||
enableResizablePanel = false, | ||
onResizingChange, | ||
}: PropsWithChildren<MainLayoutContentProps>) { | ||
const { isDesktop } = useResponsiveStore(); | ||
const { colorsTokens } = useCunninghamTheme(); | ||
const { t } = useTranslation(); | ||
const currentBackgroundColor = !isDesktop ? 'white' : backgroundColor; | ||
|
||
const mainContent = ( | ||
<Box | ||
as="main" | ||
role="main" | ||
aria-label={t('Main content')} | ||
id={MAIN_LAYOUT_ID} | ||
$align="center" | ||
$flex={1} | ||
$width="100%" | ||
$height={`calc(100dvh - ${HEADER_HEIGHT}px)`} | ||
$padding={{ | ||
all: isDesktop ? 'base' : '0', | ||
}} | ||
$background={ | ||
currentBackgroundColor === 'white' | ||
? colorsTokens['greyscale-000'] | ||
: colorsTokens['greyscale-050'] | ||
} | ||
$css={css` | ||
overflow-y: auto; | ||
overflow-x: clip; | ||
`} | ||
> | ||
{children} | ||
</Box> | ||
); | ||
|
||
if (!isDesktop) { | ||
return ( | ||
<> | ||
<LeftPanel /> | ||
{mainContent} | ||
</> | ||
); | ||
} | ||
|
||
if (enableResizablePanel) { | ||
return ( | ||
<ResizableLeftPanel | ||
leftPanel={<LeftPanel />} | ||
onResizingChange={onResizingChange} | ||
> | ||
{mainContent} | ||
</ResizableLeftPanel> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<Box | ||
$css={css` | ||
width: 300px; | ||
min-width: 300px; | ||
border-right: 1px solid ${colorsTokens['greyscale-200']}; | ||
`} | ||
> | ||
<LeftPanel /> | ||
</Box> | ||
{mainContent} | ||
</> | ||
); | ||
} |
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
96 changes: 96 additions & 0 deletions
96
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,96 @@ | ||
import { useCallback, useEffect, useRef, useState } from 'react'; | ||
import { | ||
ImperativePanelHandle, | ||
Panel, | ||
PanelGroup, | ||
PanelResizeHandle, | ||
} from 'react-resizable-panels'; | ||
|
||
import { useCunninghamTheme } from '@/cunningham'; | ||
|
||
type ResizableLeftPanelProps = { | ||
leftPanel: React.ReactNode; | ||
children: React.ReactNode; | ||
minPanelSizePx?: number; | ||
maxPanelSizePx?: number; | ||
onResizingChange?: (isResizing: boolean) => void; | ||
}; | ||
|
||
export const ResizableLeftPanel = ({ | ||
leftPanel, | ||
children, | ||
minPanelSizePx = 300, | ||
maxPanelSizePx = 450, | ||
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(minPanelSizePx)); | ||
const max = Math.round( | ||
Math.min(calculateDefaultSize(maxPanelSizePx), 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, minPanelSizePx, maxPanelSizePx]); | ||
|
||
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> | ||
); | ||
}; |
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