Closed siriwatknp closed 1 year ago
It looks great. I guess we could also cover the docs pages.
It looks great. I guess we could also cover the docs pages.
I think the docs pages should be separated (there are architecture decisions that need to be decided) because they contain nested providers to show the default theme.
I think the docs pages should be separated
@siriwatknp ok 👍.
nested providers to show the default theme.
Regarding the theme providers structure, I would be in favor of simplifying the structure:
_app.js
-> Removing the theme provider, it would fix the playground that doesn't show the default look & feel of the components and keep the concerns isolated, e.g. for the full template pages that we host.docs/pages/*
-> have each page provide a Material UI theme, customized for the brand of MUI.MarkdownDocs.js
-> Remove all theme providersDemo.js
-> Remove all theme providersDemoSandboxed.js
-> Provide the Material UI raw theme or Joy UI raw theme depending on the product the demo is for.Hi, I'd like to help. Can I be assigned to the product-templates
page? :smiley:
Hey, I would also like to help! Can you assign me a page?
@EduardoSCosta Thanks! @jesrodri Assigned you for Design kits page.
Feel free to submit a PR and tag me @siriwatknp for review.
@siriwatknp , I'd love to help. Can you assign me the "Pricing" page? 😄
@siriwatknp I would like to contribute too. Can you assign me the "About" page?
@trizotti @brianlu2610 Done! feel free to submit a PR.
Hello folks, I would like to take on careers page.
,
as can be seen in mui.com/templates page here in testimonials section
Hi, me, @jesrodri and @trizotti are facing some errors, so I openned a draft PR and commented about these errors.
@EduardoSCosta @the-mgi For the section that is wrapped with <ThemeProvider theme={darkTheme}>
, you can remove it and add data-mui-color-scheme="dark"
to the next div instead.
diff --git a/docs/pages/careers.tsx b/docs/pages/careers.tsx
index b06294da66..1ae0709c22 100644
--- a/docs/pages/careers.tsx
+++ b/docs/pages/careers.tsx
@@ -476,8 +476,7 @@ function CareersContent() {
</Container>
{/* Next roles */}
{nextRolesData.length > 0 ? (
- <ThemeProvider theme={brandingDarkTheme}>
- <Box sx={{ bgcolor: 'primaryDark.700' }}>
+ <Box data-mui-color-scheme="dark" sx={{ bgcolor: 'primaryDark.700' }}>
<Container sx={{ py: { xs: 4, md: 8 } }}>
<Box
sx={{
@@ -531,7 +530,6 @@ function CareersContent() {
</Stack>
</Container>
</Box>
- </ThemeProvider>
) : null}
{/* Frequently asked questions */}
<Container sx={{ py: { xs: 4, sm: 6, md: 8 } }}>
@EduardoSCosta @the-mgi For the section that is wrapped with
<ThemeProvider theme={darkTheme}>
, you can remove it and adddata-mui-color-scheme="dark"
to the next div instead.diff --git a/docs/pages/careers.tsx b/docs/pages/careers.tsx index b06294da66..1ae0709c22 100644 --- a/docs/pages/careers.tsx +++ b/docs/pages/careers.tsx @@ -476,8 +476,7 @@ function CareersContent() { </Container> {/* Next roles */} {nextRolesData.length > 0 ? ( - <ThemeProvider theme={brandingDarkTheme}> - <Box sx={{ bgcolor: 'primaryDark.700' }}> + <Box data-mui-color-scheme="dark" sx={{ bgcolor: 'primaryDark.700' }}> <Container sx={{ py: { xs: 4, md: 8 } }}> <Box sx={{ @@ -531,7 +530,6 @@ function CareersContent() { </Stack> </Container> </Box> - </ThemeProvider> ) : null} {/* Frequently asked questions */} <Container sx={{ py: { xs: 4, sm: 6, md: 8 } }}>
thanks a lot brother. it is now good 🙌🏼
and @siriwatknp can you assign me the /x page? ofc if the previous PR seems good to you.
We are getting this CI error, and we don't no why :thinking:
Thanks, everyone for the help!
We need your help!
Help us migrate the website to start using CSS theme variables!
Progress
If you are interested to contribute, check out the How-to and add your name at the end of the bullet to let us know that you are working on it.
Once you have done the migration, open a PR with the title
[website] Migrate xxx page to use CSS theme variables
/
) #33545/core/
) https://github.com/mui/material-ui/pull/35366/x/
) https://github.com/mui/material-ui/pull/34922/templates/
) @EduardoSCosta https://github.com/mui/material-ui/pull/34913/design-kits/
) @jesrodri https://github.com/mui/material-ui/pull/34920/toolpad/
)~ this should be done in the Toolpad repo/pricing/
) @trizotti https://github.com/mui/material-ui/pull/34917/about/
) @brianlu2610 https://github.com/mui/material-ui/pull/34919/careers/
) @the-mgi https://github.com/mui/material-ui/pull/34908/blog/*
) https://github.com/mui/material-ui/pull/34976How-to
go to the page (in
docs/pages/
folder) that you want to work on. Let's takedocs/pages/templates.tsx
as an example.Replace
BrandingProvider
withBrandingCssVarsProvider
Start the development server via
yarn docs:dev
and goto/templates/
, you are likely to encounterWarning: Prop "className" did not match. Server:
or something similar. This is because some components in the page is relying on the runtime calculation to change the styles based on the color mode. Those conditions must be fixed as explained in the next step!Look at each component imported on the page, e.g.
TemplateHero.tsx
, and find the conditional expression like this:Then, replace the condition with
theme.applyDarkStyles()
:theme.applyDarkStyles
.Refresh the page, you should not see a warning coming from the
TemplateHero.tsx
(you might still see the warning but coming from other components on the page).Once you have fixed all the components, open a PR with the title
[website] Migrate xxx page to use CSS theme variables
and tag @siriwatknp as a reviewer.Migration patterns
Here are some use cases that you might encounter in the migration process.
1. Conditional expression in the prop that's not
sx
Example code:
Migrated code: Move the logic to
sx
prop:2. Usage from
theme.palette.*
Example code:
Migrated code: attach
(theme.vars || theme).*
:3. Conditional expression in
sx
propExample code:
Migrated code: Remove the condition and group into dark styles:
4. Conditional expression in
sx
prop (with nested selectors)Example code:
Migrated code: use array:
5.
img
switch between color modesFrom
StoreTemplatesBanner.tsx
.Example code:
Migrated code: use CSS
content: url(...)
:6. Section wrapped with
<ThemeProvider theme={darkTheme}>
Remove the
ThemeProvider
and adddata-mui-color-scheme="dark"
to the next div instead.Implementation details
BrandingCssVarsProvider.tsx
as a replacement for the existingBrandingProvider
. It is built on top of the publicCssVarsProvider
API specific for mui.com which contains custom theme tokens. Once a page is wrapped with the new provider, the components under it will start using CSS theme variables immediately which causes server-client inconsistency due to conditional expressions like thistheme.palette.mode === 'dark' ? theme.palette.grey[300] : theme.palette.grey[700]
The
applyDarkStyles()
util is added to the theme (this is specific to mui.com, not Material UI) to ease the migration because some components need to be backward compatible for some pages that haven't been migrated. This util is straightforward as the name implies. It will decide the approach to use based on the theme, so you don't have to know if the components are rendered in which provider. All you need to do is put the styles for dark mode to the util after the default styles. if the component is under the new BrandingCssVarsProvider:if the component is under the old BrandingProvider:
:where()
selector works.