-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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
[system] Introduce mode
to CssVarsProvider
#29418
Conversation
@material-ui/system: parsed: +7.36% , gzip: +4.66% |
} as unknown as MediaQueryList); | ||
}); | ||
afterEach(() => { | ||
window.matchMedia = originalMatchmedia; |
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.
need to reset the matchMedia
, otherwise, it will affect some tests in the project.
docs/pages/joy.tsx
Outdated
@@ -0,0 +1,207 @@ | |||
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.
This file is for the preview demo. (will be deleted before merging).
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.
I really think we should use dark
and light
instead of day
and night
.
docs/pages/joy.tsx
Outdated
const { mode, setMode, colorScheme, setColorScheme } = useColorScheme(); | ||
|
||
// When mounted on client, now we can show the UI | ||
React.useEffect(() => setMounted(true), []); |
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.
Why do we need this?
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.
To prevent SSR className mismatch because on the server there is no mode | colorScheme
. Here is the explanation https://github.com/pacocoursey/next-themes#usetheme
This page is for demo only, will be removed before merging.
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.
LGTM 🤘
Summary
This PR separates
mode
fromcolorScheme
, so that the application can achieve the upcoming toggle on the Joy page (design link).The
mode
will always beday | night | system
. The application cannot replace or add more modes. However, they can have unlimited color schemes (light
,dark
is the default color scheme from the design system).Primer design system also apply this approach
Changes
Demo: https://deploy-preview-29418--material-ui.netlify.app/joy/
useColorScheme
providemode
andcolorScheme
.day
andnight
mode separately.