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 InitColorSchemeScript for Next.js App Router #42247

Merged
merged 25 commits into from
Jun 14, 2024

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented May 15, 2024

closes #38913


@siriwatknp siriwatknp changed the title [POC] add InitColorSchemeScript for Next.js App Router [POC] Add InitColorSchemeScript for Next.js App Router May 15, 2024
@siriwatknp siriwatknp added the proof of concept Studying and/or experimenting with a to be validated approach label May 15, 2024
@mui-bot
Copy link

mui-bot commented May 15, 2024

Netlify deploy preview

@material-ui/core: parsed: +Infinity% , gzip: +Infinity%
@mui/joy: parsed: +Infinity% , gzip: +Infinity%
@material-ui/lab: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Autocomplete: parsed: +Infinity% , gzip: +Infinity%
@material-ui/unstyled: parsed: +Infinity% , gzip: +Infinity%
Autocomplete: parsed: +Infinity% , gzip: +Infinity%
TextField: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Select: parsed: +Infinity% , gzip: +Infinity%
SpeedDialAction: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Menu: parsed: +Infinity% , gzip: +Infinity%
Tooltip: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Tooltip: parsed: +Infinity% , gzip: +Infinity%
SwipeableDrawer: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Drawer: parsed: +Infinity% , gzip: +Infinity%
TabList: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Snackbar: parsed: +Infinity% , gzip: +Infinity%
SpeedDial: parsed: +Infinity% , gzip: +Infinity%
Pagination: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/MenuButton: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/ChipDelete: parsed: +Infinity% , gzip: +Infinity%
and 266 more changes

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 0e38328

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 27, 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 10, 2024
@siriwatknp siriwatknp changed the title [POC] Add InitColorSchemeScript for Next.js App Router Add InitColorSchemeScript for Next.js App Router Jun 10, 2024
@siriwatknp siriwatknp marked this pull request as ready for review June 10, 2024 09:57
@siriwatknp siriwatknp added package: material-ui Specific to @mui/material enhancement This is not a bug, nor a new feature nextjs package: system Specific to @mui/system and removed proof of concept Studying and/or experimenting with a to be validated approach labels Jun 10, 2024
@zannager zannager requested a review from brijeshb42 June 10, 2024 11:38
Comment on lines +61 to +62
suppressHydrationWarning
nonce={typeof window === 'undefined' ? nonce : ''}
Copy link
Member Author

Choose a reason for hiding this comment

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

export { useColorScheme, getInitColorSchemeScript, CssVarsProvider, Experimental_CssVarsProvider };
export {
useColorScheme,
getInitColorSchemeScript,
Copy link
Member

Choose a reason for hiding this comment

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

Should we deprecate getInitColorSchemeScript? Or do we expect users to still use it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I think it can be removed but I'd do it in a separate PR and add note to the migration doc in the same PR.

Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

LGTM, let's remember to deprecate/remove getInitColorSchemeScript

@siriwatknp siriwatknp merged commit 58831f0 into mui:next Jun 14, 2024
22 checks passed
siriwatknp added a commit to siriwatknp/material-ui that referenced this pull request Jul 3, 2024
Copy link
Member

Choose a reason for hiding this comment

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

@siriwatknp This change blocks the monorepo upgrade for MUI X because we're using @mui/material@5:
https://app.netlify.com/sites/material-ui-x/deploys/66851d4bfe59880008524540#L240

Do you think we can keep using getInitColorSchemeScript here?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, I found a PR that should address this and left a comment there 🙂
#42829 (comment)

},
});

let warnedInitScriptOnce = false;

const getInitColorSchemeScript: typeof deprecatedGetInitColorSchemeScript = (params) => {
Copy link
Member

Choose a reason for hiding this comment

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

@siriwatknp
How about adding @deprecated jsdoc here?
A warning in IDE is a good developer experience, IMO.
What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is not a bug, nor a new feature nextjs package: material-ui Specific to @mui/material package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[system] Add nonce to CssVarsProvider and getInitColorSchemeScript() for CSP
4 participants