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

[core] Make DashboardLayout navigation responsive #3750

Merged

Conversation

apedroferreira
Copy link
Member

@apedroferreira apedroferreira commented Jul 3, 2024

Closes #3585

Make navigation menu open and close with a menu toggle in left side of the header in breakpoints under md.
Also centered logo + title in mobile screens.

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

Screen.Recording.2024-07-19.at.14.33.41.mov

@apedroferreira apedroferreira added feature: Components Button, input, table, etc. enhancement This is not a bug, nor a new feature mobile Targets mobile platform labels Jul 3, 2024
@apedroferreira apedroferreira self-assigned this Jul 3, 2024
@apedroferreira apedroferreira marked this pull request as ready for review July 3, 2024 10:36
@Janpot
Copy link
Member

Janpot commented Jul 3, 2024

There are some problems in the docs:

  • We may want to show off the navigation, even if the content is too small. e.g. like the current behavior

  • Expanding the navigation behaves erratically

    Screen.Recording.2024-07-03.at.12.50.11.mov

@apedroferreira apedroferreira requested review from a team and removed request for a team July 3, 2024 10:51
@apedroferreira
Copy link
Member Author

apedroferreira commented Jul 5, 2024

Added some fixes/improvements and addressed review feedback:

  • Center logo/title in mobile header relative to the whole header width (instead of in the remaining space after the menu icon)
  • Add initialNavigationOpen prop to start with mobile navigation open in the docs demos
  • Use persistent drawer instead of temporary drawer - fixes the issue with unstyled giant icons in docs which I couldn't really find the full cause for yet (maybe some conflict with the docs outside due to the way the temporary drawers are implemented, could be why the Drawer docs example has const container = window !== undefined ? () => window().document.body : undefined;), and this way in some cases even with the mobile drawer open users can interact with the dashboard so that might be an advantage. It seems a bit less performant though as it uses a margin transition (can still look a bit more into this maybe but I guess it's a good solution already).
    Updated video in the PR description with this new behavior.

@apedroferreira apedroferreira requested a review from a team July 5, 2024 15:45
Copy link
Member

@bharatkashyap bharatkashyap left a comment

Choose a reason for hiding this comment

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

Looks good! About initialNavigationOpen, I would expect the name of the prop to match more closely with the behaviour of opening the mobile navigation by default.

Perhaps mobileNavigationOpen

"propDescriptions": {
"children": { "description": "The content of the dashboard." },
"initialNavigationOpen": {
"description": "Whether the mobile navigation drawer should start open."
Copy link
Member

Choose a reason for hiding this comment

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

Should this be external API? Why would users need this?
Besides, can't we, for demo purposes just force the large screen behavior. Maybe change the breakpoints or something. But in a hidden way, users shouldn't copy+paste our hacks accidentally.

Copy link
Member Author

@apedroferreira apedroferreira Jul 8, 2024

Choose a reason for hiding this comment

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

It should be internal API if possible, just not sure what the best way to do that is? Will try to find a solution. (edit: I guess we can just mark it as internal but it's still secretly usable?)

Also wasn't sure if it's better to have the mobile or the desktop version on the docs, so I guess we can try to use the desktop one there or change the breakpoints.

@apedroferreira

This comment was marked as outdated.

@apedroferreira
Copy link
Member Author

Addressed latest review feedback:

  • isDemoMode internal prop (just simply marked it as internal) that enables a lower breakpoint for mobile view + mobile navigation starts open, for now.

@apedroferreira
Copy link
Member Author

apedroferreira commented Jul 11, 2024

Solutions to the recent problems that have been raised:

  • Added breakpoints to the theme in the docs examples so that the first view usually shown in docs does not have a mobile menu.
  • Reverted back to a temporary variant of the navigation drawer as shown in the re-updated video example above, as I tried out the dashboard on my phone and this is a much better UX for mobile. This required a fix for the drawer in the docs, because the portal used by it defaults to the document outside the iframes (as reported by Jan in this PR already). Fixed it the same way as the responsive drawer example in https://mui.com/material-ui/react-drawer/#responsive-drawer, through the window prop in the AppProvider component where the iframe window can be set, which we're already using for similar issues with CSS variables theming in these demos.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 19, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 19, 2024
@apedroferreira apedroferreira changed the title Make DashboardLayout navigation responsive (Toolpad Core) [core] Make DashboardLayout navigation responsive Jul 19, 2024
@apedroferreira
Copy link
Member Author

This one should be good for a review, the themes in the demos are cleaner now!
Check this comment for the latest changes: #3750 (comment)

Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Let's go!

@apedroferreira apedroferreira merged commit aef3803 into mui:master Jul 19, 2024
14 checks passed
@apedroferreira apedroferreira deleted the dashboard-layout-responsive-nav branch July 19, 2024 15:30
@FabioZan86
Copy link

Dados #3585

Faça o menu de navegação abrir e fechar com um menu toggle no lado esquerdo do cabeçalho em breakpoints sob md. Também centralize o logotipo + título em telas móveis.

Documentação do DashboardLayout : https://deploy-preview-3750--mui-toolpad-docs.netlify.app/toolpad/core/react-dashboard-layout

Gravação.de.tela.2024-07-19.at.14.33.41.mov

Hello, very good! Can you make the code available?

@apedroferreira
Copy link
Member Author

apedroferreira commented Oct 21, 2024

Dados #3585
Faça o menu de navegação abrir e fechar com um menu toggle no lado esquerdo do cabeçalho em breakpoints sob md. Também centralize o logotipo + título em telas móveis.
Documentação do DashboardLayout : https://deploy-preview-3750--mui-toolpad-docs.netlify.app/toolpad/core/react-dashboard-layout
Gravação.de.tela.2024-07-19.at.14.33.41.mov

Hello, very good! Can you make the code available?

Hi, the features in this PR are already live in the latest version of @toolpad/core.
Let us know if you find any issues or anything missing!

@FabioZan86
Copy link

Dados #3585
Faça o menu de navegação abrir e fechar com um menu toggle no lado esquerdo do cabeçalho em breakpoints sob md. Também centralize o logotipo + título em telas móveis.
Documentação do DashboardLayout : https://deploy-preview-3750--mui-toolpad-docs.netlify.app/toolpad/core/react-dashboard-layout
Gravação.de.tela.2024-07-19.at.14.33.41.mov

Hello, very good! Can you make the code available?

Hi, the features in this PR are already live in the latest version of @toolpad/core. Let us know if you find any issues or anything missing!

Hi...How can I customize the layout with the toolpad/core? Make the vertical bars in the collected style as in the photo?
collapsed sheels

@apedroferreira
Copy link
Member Author

Dados #3585
Faça o menu de navegação abrir e fechar com um menu toggle no lado esquerdo do cabeçalho em breakpoints sob md. Também centralize o logotipo + título em telas móveis.
Documentação do DashboardLayout : https://deploy-preview-3750--mui-toolpad-docs.netlify.app/toolpad/core/react-dashboard-layout
Gravação.de.tela.2024-07-19.at.14.33.41.mov

Hello, very good! Can you make the code available?

Hi, the features in this PR are already live in the latest version of @toolpad/core. Let us know if you find any issues or anything missing!

Hi...How can I customize the layout with the toolpad/core? Make the vertical bars in the collected style as in the photo? collapsed sheels

So you want to have 2 columns on the left-side?
Right now it would be difficult to make the dashboard layout look exactly like that...
We will create slots that allow you to customize the layout a bit more, including one to override the navigation sidebar with any custom component.

I've created an issue in #4299, hopefully this feature will help!

@FabioZan86
Copy link

Dados #3585
Faça o menu de navegação abrir e fechar com um menu toggle no lado esquerdo do cabeçalho em breakpoints sob md. Também centralize o logotipo + título em telas móveis.
Documentação do DashboardLayout : https://deploy-preview-3750--mui-toolpad-docs.netlify.app/toolpad/core/react-dashboard-layout
Gravação.de.tela.2024-07-19.at.14.33.41.mov

Hello, very good! Can you make the code available?

Hi, the features in this PR are already live in the latest version of @toolpad/core. Let us know if you find any issues or anything missing!

Hi...How can I customize the layout with the toolpad/core? Make the vertical bars in the collected style as in the photo? collapsed sheels

So you want to have 2 columns on the left-side? Right now it would be difficult to make the dashboard layout look exactly like that... We will create slots that allow you to customize the layout a bit more, including one to override the navigation sidebar with any custom component.

I've created an issue in #4299, hopefully this feature will help!

The toolpad doesn't make customizing more dynamic, right? So I can leave it aside and use old components, discarding the toolpad core. I want to create a double drawer...

@apedroferreira
Copy link
Member Author

Dados #3585
Faça o menu de navegação abrir e fechar com um menu toggle no lado esquerdo do cabeçalho em breakpoints sob md. Também centralize o logotipo + título em telas móveis.
Documentação do DashboardLayout : https://deploy-preview-3750--mui-toolpad-docs.netlify.app/toolpad/core/react-dashboard-layout
Gravação.de.tela.2024-07-19.at.14.33.41.mov

Hello, very good! Can you make the code available?

Hi, the features in this PR are already live in the latest version of @toolpad/core. Let us know if you find any issues or anything missing!

Hi...How can I customize the layout with the toolpad/core? Make the vertical bars in the collected style as in the photo? collapsed sheels

So you want to have 2 columns on the left-side? Right now it would be difficult to make the dashboard layout look exactly like that... We will create slots that allow you to customize the layout a bit more, including one to override the navigation sidebar with any custom component.
I've created an issue in #4299, hopefully this feature will help!

The toolpad doesn't make customizing more dynamic, right? So I can leave it aside and use old components, discarding the toolpad core. I want to create a double drawer...

Depending on how specific the layout you want to create is, it might be difficult to adjust Toolpad Core to look exactly like it at the moment...
As we add more customization options it should eventually be possible, but not sure if simply being able to replace the current drawer and header with custom components will be enough for you, as that's one of the next upcoming features.
If it is, you can wait for that feature, otherwise maybe using standard Material UI components will be best for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: layout enhancement This is not a bug, nor a new feature feature: Components Button, input, table, etc. mobile Targets mobile platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DashboardLayout] Make navigation drawer responsive
5 participants