Skip to content
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

Merged
merged 16 commits into from
Oct 9, 2024

Conversation

vikasgurjar
Copy link
Contributor

@vikasgurjar vikasgurjar commented Oct 8, 2024

Closes #4229

  • I've read and followed the contributing guide on how to create great pull requests.
  • I've updated the relevant documentation for any new or updated feature.
  • I've linked relevant GitHub issue with "Closes #".
  • I've added a visual demonstration in the form of a screenshot or video.

image

https://deploy-preview-4231--mui-toolpad-docs.netlify.app/toolpad/core/react-dashboard-layout

@vikasgurjar vikasgurjar changed the title Add hideNavigation prop [core] Add hideNavigation prop Oct 8, 2024
@vikasgurjar vikasgurjar changed the title [core] Add hideNavigation prop [component: DashboardLayout] Add hideNavigation prop Oct 8, 2024
@vikasgurjar vikasgurjar changed the title [component: DashboardLayout] Add hideNavigation prop [DashboardLayout] Add hideNavigation prop Oct 8, 2024
@apedroferreira apedroferreira added the feature: Components Button, input, table, etc. label Oct 8, 2024
Copy link
Member

@apedroferreira apedroferreira left a 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.

Copy link
Member

@apedroferreira apedroferreira Oct 8, 2024

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
Copy link
Member

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) {
Copy link
Member

@apedroferreira apedroferreira Oct 8, 2024

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 = [];
Copy link
Member

@apedroferreira apedroferreira Oct 8, 2024

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';

Copy link
Member

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.

const demoWindow = window !== undefined ? window() : undefined;

return (
// preview-start
Copy link
Member

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.

@vikasgurjar
Copy link
Contributor Author

@apedroferreira I will need your help with the test_static build issue. Due to some conf mismatch I'm not able to fix the above issue. Can you guide on how to fix it?

@apedroferreira
Copy link
Member

apedroferreira commented Oct 9, 2024

@apedroferreira I will need your help with the test_static build issue. Due to some conf mismatch I'm not able to fix the above issue. Can you guide on how to fix it?

Can you run pnpm docs:typescript:formatted from the project root? That should do it.
Everything looks great btw, thanks for the changes!

@vikasgurjar
Copy link
Contributor Author

@apedroferreira I will need your help with the test_static build issue. Due to some conf mismatch I'm not able to fix the above issue. Can you guide on how to fix it?

Can you run pnpm docs:typescript:formatted from the project root? That should do it. Everything looks great btw, thanks for the changes!

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?

@apedroferreira
Copy link
Member

apedroferreira commented Oct 9, 2024

@apedroferreira I will need your help with the test_static build issue. Due to some conf mismatch I'm not able to fix the above issue. Can you guide on how to fix it?

Can you run pnpm docs:typescript:formatted from the project root? That should do it. Everything looks great btw, thanks for the changes!

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 pnpm docs:typescript:formatted (docs/scripts/formattedTSDemos script) on my Macbook there's a difference in the DashboardLayoutSidebarHidden.tsx.preview file compared to your current PR... Might be an OS thing, maybe line endings.

@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.

@Janpot
Copy link
Member

Janpot commented Oct 9, 2024

The line endings don't match. Maybe you hit "save" on the preview and the auto-formatter kicked in?

@vikasgurjar
Copy link
Contributor Author

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

@Janpot
Copy link
Member

Janpot commented Oct 9, 2024

It did fix it, CI just found another issue, still had to run pnpm prettier.

@vikasgurjar
Copy link
Contributor Author

It did fix it, CI just found another issue, still had to run pnpm prettier.

Great, Thanks! I was setting up WSL in my windows machine, to try fixing this

@apedroferreira
Copy link
Member

apedroferreira commented Oct 9, 2024

Ok, let me know if you ever find what the issue was!
Just added some small demo changes and will merge :)

@apedroferreira apedroferreira merged commit 06ca8df into mui:master Oct 9, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: Components Button, input, table, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow hiding the navigation bar and toggle button
3 participants