-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
[DashboardLayout] Add hideNavigation prop #4231
Conversation
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.
Looks perfect, thank you! And that's exactly what I meant with the demo, good job finding it! :)
Just a few really minor changes suggested.
Also for the docs changes you can run:
pnpm proptypes
to generate proptypes the be read by the API documentation
pnpm docs:build:api
to build the API docs
pnpm docs:typescript:formatted
to format all the docs files based on the .tsx file
> | ||
{getDrawerContent(isDesktopMini, 'Desktop')} | ||
</Drawer> | ||
{!hideNavigation && <React.Fragment> |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Can we write it like {!hideNavigation ? ... : null}
? Just because we've been following that convention in the project.
@@ -360,6 +360,11 @@ export interface DashboardLayoutProps { | |||
toolbarActions?: {}; | |||
toolbarAccount?: AccountProps; | |||
}; | |||
/** | |||
* If the navigation bar and button should to be hidden |
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.
Can we rephrase it to Whether the navigation bar and menu icon should be hidden
?
@@ -460,6 +465,11 @@ function DashboardLayout(props: DashboardLayoutProps) { | |||
|
|||
const getMenuIcon = React.useCallback( | |||
(isExpanded: boolean) => { | |||
|
|||
if (hideNavigation) { |
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.
There's also a marginRight
on the boxes around these icons that we should not have if they're not shown.
So instead on line 566 we can probably have something kind of like:
{!hideNavigation ?
<React.Fragment><Box
sx={{
mr: { sm: disableCollapsibleSidebar ? 0 : 1 },
display: { md: 'none' },
}}
>
{getMenuIcon(isMobileNavigationExpanded)}
</Box>
<Box
sx={{
display: { xs: 'none', md: disableCollapsibleSidebar ? 'none' : 'block' },
mr: disableCollapsibleSidebar ? 0 : 1,
}}
>
{getMenuIcon(isDesktopNavigationExpanded)}
</Box></React.Fragment> : null}
const desktopNavigation = screen.queryByRole('navigation', { name: 'Desktop' }); | ||
const navigationToggle = screen.queryByLabelText('Collapse menu'); | ||
|
||
// Expect that the navigation and toggle button is not rendered |
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.
// Expect that the navigation and toggle button is not rendered | |
// Expect that the navigation and toggle button are not rendered |
@@ -109,6 +109,12 @@ The layout sidebar is collapsible to a mini-drawer (with icons only) in desktop | |||
|
|||
{{"demo": "DashboardLayoutNoMiniSidebar.js", "height": 400, "iframe": true}} | |||
|
|||
### Hiding the sidebar | |||
|
|||
The layout sidebar can be hidden if needed using the `hideNavigation` prop. |
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.
The layout sidebar can be hidden if needed using the `hideNavigation` prop. | |
The layout sidebar can be hidden if needed with the `hideNavigation` prop. |
import Typography from '@mui/material/Typography'; | ||
import { createTheme } from '@mui/material/styles'; | ||
|
||
const NAVIGATION = []; |
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.
We can just not pass this as it defaults to []
@@ -0,0 +1,88 @@ | |||
import * as React from 'react'; | |||
|
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.
empty line
|
||
const [pathname, setPathname] = React.useState('/dashboard'); | ||
|
||
const router = React.useMemo(() => { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
const demoWindow = window !== undefined ? window() : undefined; | ||
|
||
return ( | ||
// preview-start |
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.
You can remove // preview-start
and // preview-end
here and the code preview will show only the DashboardLayout which is the most important information.
215a0d1
to
bb41a09
Compare
0717262
to
d958950
Compare
@apedroferreira I will need your help with the |
Can you run |
I have done that multiple times now. I'm running it on windows, not really what's wrong here, can it be new line char issue or formatter issue? |
I see, when I run @mui/docs-infra @Janpot any knowledge on this issue? Is it an issue with the script? We're generally using the same script as https://github.com/mui/material-ui/blob/master/docs/scripts/formattedTSDemos.js. |
The line endings don't match. Maybe you hit "save" on the preview and the auto-formatter kicked in? |
There was no need to hit the save. Seems like some other issue. Even your commit didn't help here |
It did fix it, CI just found another issue, still had to run |
Great, Thanks! I was setting up WSL in my windows machine, to try fixing this |
Ok, let me know if you ever find what the issue was! |
Closes #4229
https://deploy-preview-4231--mui-toolpad-docs.netlify.app/toolpad/core/react-dashboard-layout