-
Notifications
You must be signed in to change notification settings - Fork 4k
Revamp mobile navigation #3282
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
nolannbiron
wants to merge
26
commits into
main
Choose a base branch
from
nolann/revamp-mobile-navigation
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.
+366
−194
Open
Revamp mobile navigation #3282
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
3a762dc
Revamp mobile navigation
nolannbiron bb850e5
Remove top/bottom sheet
nolannbiron a56216d
Update design and handle innerHeader
nolannbiron 451290a
Fix styling
nolannbiron f523575
Handle circular-corners
nolannbiron 2d5fc43
Fixes
nolannbiron e018b65
Put scrollbar back
nolannbiron 6659bfb
Missing comment
nolannbiron e848cf5
Fix layout
nolannbiron cdcd991
Fixes after review
nolannbiron 7b6dff7
Update comments
nolannbiron eef6d2f
Render TOCScrollContent only once
nolannbiron a2a852e
Always close sheet on pathname change
nolannbiron 92ae60f
Fix MobileMenu
nolannbiron abfba66
Update overlay
nolannbiron b8dc0e6
Fix dropdown
nolannbiron 098fe2d
fix padding
nolannbiron 8d88eb6
Revamp mobile navigation
nolannbiron ed007c8
Fix classes
nolannbiron ab4af82
chores
nolannbiron 15e0adc
Fix bun.lock
nolannbiron f855d49
Add usePreventScroll
nolannbiron bc8d59f
Fix z-index
nolannbiron 01db884
Fix padding
nolannbiron 06b8a27
Add tests for mobile menu
nolannbiron 040be0b
Fix spacing for innerHeader
nolannbiron 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,5 @@ | ||
--- | ||
'gitbook': minor | ||
--- | ||
|
||
Revamp mobile navigation |
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
57 changes: 0 additions & 57 deletions
57
packages/gitbook/src/components/Header/HeaderMobileMenu.tsx
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
packages/gitbook/src/components/Header/HeaderMobileMenuButton.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,35 @@ | ||
'use client'; | ||
|
||
import { Icon } from '@gitbook/icons'; | ||
|
||
import { useMobileMenuSheet } from '@/components/MobileMenu/useMobileMenuSheet'; | ||
import { tString, useLanguage } from '@/intl/client'; | ||
import { tcls } from '@/lib/tailwind'; | ||
|
||
/** | ||
* Button to show/hide the table of content on mobile. | ||
*/ | ||
export function HeaderMobileMenuButton( | ||
props: Partial<React.ButtonHTMLAttributes<HTMLButtonElement>> | ||
) { | ||
const language = useLanguage(); | ||
const { open, setOpen } = useMobileMenuSheet(); | ||
|
||
const toggleNavigation = () => { | ||
setOpen(!open); | ||
}; | ||
|
||
return ( | ||
<button | ||
{...props} | ||
aria-label={tString(language, 'table_of_contents_button_label')} | ||
onClick={toggleNavigation} | ||
className={tcls( | ||
'flex flex-row items-center rounded straight-corners:rounded-sm px-2 py-1', | ||
props.className | ||
)} | ||
> | ||
<Icon icon="bars" className="size-4 text-inherit" /> | ||
</button> | ||
); | ||
} |
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
26 changes: 26 additions & 0 deletions
26
packages/gitbook/src/components/MobileMenu/MobileMenuScript.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,26 @@ | ||
'use client'; | ||
|
||
import { useMobileMenuSheet } from '@/components/MobileMenu'; | ||
import { usePathname } from 'next/navigation'; | ||
import { useEffect } from 'react'; | ||
|
||
export function MobileMenuScript() { | ||
const pathname = usePathname(); | ||
const { open, setOpen } = useMobileMenuSheet(); | ||
|
||
// biome-ignore lint/correctness/useExhaustiveDependencies: Close the navigation when navigating to a page | ||
useEffect(() => { | ||
setOpen(false); | ||
}, [pathname]); | ||
|
||
useEffect(() => { | ||
// If the menu is open, we add a class to the body to prevent scrolling | ||
if (open) { | ||
document.body.style.overflow = 'hidden'; | ||
} else { | ||
document.body.style.overflow = 'auto'; | ||
} | ||
}, [open]); | ||
|
||
return null; | ||
} |
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,2 @@ | ||
export * from './useMobileMenuSheet'; | ||
export * from './MobileMenuScript'; |
12 changes: 12 additions & 0 deletions
12
packages/gitbook/src/components/MobileMenu/useMobileMenuSheet.ts
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,12 @@ | ||
import { create } from 'zustand'; | ||
|
||
/** | ||
* Hooks to manage the mobile menu sheet state. | ||
*/ | ||
export const useMobileMenuSheet = create<{ | ||
open: boolean; | ||
setOpen: (open: boolean) => void; | ||
}>((set) => ({ | ||
open: false, | ||
setOpen: (open) => set({ open }), | ||
})); |
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.
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.