-
Notifications
You must be signed in to change notification settings - Fork 112
Fix mobile menu for KeystarUI docs #1472
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { Fragment, useEffect } from 'react'; | ||
| import { useEffect } from 'react'; | ||
| import { usePathname } from 'next/navigation'; | ||
|
|
||
| import { Button } from '@keystar/ui/button'; | ||
| import { menuIcon } from '@keystar/ui/icon/icons/menuIcon'; | ||
|
|
@@ -15,67 +16,55 @@ import { ColorSchemeMenu } from '../theme-switcher'; | |
|
|
||
| /** Responsively render sidebar navigation items. */ | ||
| export const Sidebar = ({ items }: { items: SidebarItem[] }) => { | ||
| // const [headerHeight, setHeaderHeight] = useState(NaN); | ||
| const { sidebarIsOpen, closeSidebar, toggleSidebar } = useSidebarContext(); | ||
| const pathname = usePathname(); | ||
|
|
||
| useEffect(() => { | ||
| addEventListener('popstate', closeSidebar); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wasn't working to close the menu Current experience: New experience: |
||
| return () => { | ||
| removeEventListener('popstate', closeSidebar); | ||
| }; | ||
| }, [closeSidebar]); | ||
| // Close the sidebar when the pathname changes | ||
| closeSidebar(); | ||
| }, [closeSidebar, pathname]); | ||
|
|
||
| return ( | ||
| <Fragment> | ||
| <div | ||
| data-open={sidebarIsOpen} | ||
| className={css({ | ||
| backgroundColor: tokenSchema.color.background.canvas, | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| position: 'fixed', | ||
| zIndex: 1, | ||
| <div | ||
| data-open={sidebarIsOpen} | ||
| className={css({ | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| position: 'fixed', | ||
| width: '100%', | ||
| zIndex: 1, | ||
| '&[data-open=true]': { | ||
| height: '100%', | ||
| }, | ||
| [breakpointQueries.above.mobile]: { | ||
| height: '100%', | ||
| width: SIDEBAR_WIDTH, | ||
| }, | ||
| })} | ||
| > | ||
| <SidebarHeader menuIsOpen={sidebarIsOpen} onMenuPress={toggleSidebar} /> | ||
|
|
||
| <Box | ||
| flex | ||
| minHeight={0} | ||
| backgroundColor="surface" | ||
| borderTopEndRadius={{ tablet: 'medium' }} | ||
| overflow="hidden auto" | ||
| paddingBottom="xlarge" | ||
| paddingTop={{ mobile: 'large', tablet: 'xlarge' }} | ||
| paddingEnd={{ mobile: 'large', tablet: 'xlarge' }} | ||
| data-open={sidebarIsOpen} | ||
| UNSAFE_className={css({ | ||
| [breakpointQueries.below.tablet]: { | ||
| width: '100vw', | ||
| '[data-open=true]': { | ||
| height: '100%', | ||
| '&[data-open=false]': { | ||
| display: 'none', | ||
| }, | ||
| }, | ||
| [breakpointQueries.above.mobile]: { | ||
| height: '100%', | ||
| width: SIDEBAR_WIDTH, | ||
| }, | ||
| })} | ||
| > | ||
| <SidebarHeader | ||
| menuIsOpen={sidebarIsOpen} | ||
| onMenuPress={toggleSidebar} | ||
| // onLayout={rect => setHeaderHeight(rect.height)} | ||
| /> | ||
|
|
||
| <Box | ||
| flex | ||
| backgroundColor="surface" | ||
| borderTopEndRadius={{ tablet: 'medium' }} | ||
| overflow="hidden auto" | ||
| paddingBottom="xlarge" | ||
| paddingTop={{ mobile: 'large', tablet: 'xlarge' }} | ||
| paddingEnd={{ mobile: 'large', tablet: 'xlarge' }} | ||
| data-open={sidebarIsOpen} | ||
| UNSAFE_className={css({ | ||
| [breakpointQueries.below.tablet]: { | ||
| '&[data-open=false]': { | ||
| display: 'none', | ||
| }, | ||
| }, | ||
| })} | ||
| > | ||
| <NavItems items={items} /> | ||
| </Box> | ||
| </div> | ||
| {/* <Box height={headerHeight} isHidden={{ above: 'mobile' }} /> */} | ||
| </Fragment> | ||
| <NavItems items={items} /> | ||
| </Box> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
|
|
@@ -84,11 +73,9 @@ export const Sidebar = ({ items }: { items: SidebarItem[] }) => { | |
|
|
||
| function SidebarHeader({ | ||
| menuIsOpen, | ||
| // onLayout, | ||
| onMenuPress, | ||
| }: { | ||
| menuIsOpen: boolean; | ||
| // onLayout: (rect: DOMRect) => void; | ||
| onMenuPress: () => void; | ||
| }) { | ||
| const menuLabel = 'Open navigation panel'; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,17 +4,10 @@ import withPreconstruct from '@preconstruct/next'; | |
| const nextConfig = { | ||
| eslint: { ignoreDuringBuilds: true }, | ||
| typescript: { ignoreBuildErrors: true }, | ||
| serverExternalPackages: ['esbuild'], | ||
| experimental: { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated, but Next.js was complaining about this experimental flag being deprecated and to use |
||
| serverComponentsExternalPackages: ['esbuild'], | ||
| externalDir: true, | ||
| }, | ||
| // reactStrictMode: true, | ||
| // webpack: config => ({ | ||
| // ...config, | ||
| // infrastructureLogging: { | ||
| // level: 'error', | ||
| // }, | ||
| // }), | ||
| }; | ||
|
|
||
| export default withPreconstruct(nextConfig); | ||
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.
This is so the main content takes up available space so we can push the footer to the bottom of the page without having to rely on viewport units