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

Add theme switcher to dashboard layout (Toolpad Core) #3674

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

apedroferreira
Copy link
Member

@apedroferreira apedroferreira commented Jun 12, 2024

WIP

@apedroferreira apedroferreira added the feature: Components Button, input, table, etc. label Jun 12, 2024
@apedroferreira apedroferreira self-assigned this Jun 12, 2024
@apedroferreira
Copy link
Member Author

apedroferreira commented Jun 13, 2024

There is an issue during SSR when using the dark mode in Next.js where the server can't read which mode it's supposed to use, so the app renders in light mode until the client-side sets the correct value for the dark mode.

From what I've tried/researched there's 2 possible solutions:

  1. Use cookies to store the theme mode - will eventually work but it's complicated as it has to be done in different ways for the app router and the pages router. The app router needs to use a server component and the pages router an alternative solution - these can be difficult and a bit messy to integrate with the library.
  2. Leave it as is and probably Pigment.css will provide a more elegant solution for this?

@Janpot
Copy link
Member

Janpot commented Jun 13, 2024

  1. We should be able to leverage css variables like we do on the docs homepage.

What if we do?

interface AppProviderProps {
  theme?: Theme | CssVarsTheme | { light: Theme, dark: Theme }; 
  // ...
}

We show the switcher when

  • { light: Theme, dark: Theme }
  • CssVarsTheme AND colorSchemes.light AND colorSchemes.dark are set
  • default theme = CssVarsTheme with both color schemes

Otherwise no theme switcher

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 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 Jun 25, 2024
@apedroferreira
Copy link
Member Author

All good in functionality, just missing documentation now.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 28, 2024
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. PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants