-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[material-ui][Alert] Convert to support zero runtime #41230
Conversation
@@ -0,0 +1,45 @@ | |||
import { styled } from '@mui/zero-runtime'; | |||
import BasicAlerts from '../../../../../docs/data/material/components/alert/BasicAlerts'; |
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.
At first, I tried to pull all the demos programmatically and render them with lazy loading but not successful, so I'll just go with importing manually and revisit this when I have more time.
import { AppRouterCacheProvider } from '@mui/material-nextjs/v14-appRouter'; | ||
import { ThemeProvider } from '@mui/material/styles'; | ||
import theme from './theme'; |
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.
Add this to test that emotion still works with zero-runtime.
Alert
to support static extraction
Netlify deploy previewhttps://deploy-preview-41230--material-ui.netlify.app/ @material-ui/core: parsed: +0.06% , gzip: +0.07% Bundle size reportDetails of bundle changes (Toolpad) |
@siriwatknp let's create separate PR for setting up how we test the components. We already have the Badge, Autocomplete, Avatar migrated to use the variants API, it will be easier to review. We can clean this PR later to just show the changes that developers migrating the components will need to do. |
Ultimately I want to use the Slider as a template, because it has an example of both rtl and variants. We will need to solve #41217 first. |
I can open another PR to tackle the migration setup first. My goal is to render the Material UI component from |
Yeah, that's great. I will update my PRs once we have this 👌 |
apps/local-ui-lib/package.json
Outdated
@@ -3,6 +3,6 @@ | |||
"version": "0.0.1", | |||
"private": true, | |||
"dependencies": { | |||
"@mui/zero-runtime": "file:../../packages/zero-runtime/build" | |||
"@mui/zero-runtime": "file:../../packages/zero-runtime" |
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.
Mistake from other PR.
margin: 0; | ||
} | ||
@layer reset, mui; | ||
|
||
html, | ||
body { | ||
max-width: 100vw; | ||
overflow-x: hidden; | ||
} | ||
@layer reset { |
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 is to make the emotion overrides the globals.css
, not related to zero-runtime.
@@ -0,0 +1,44 @@ | |||
// eslint-disable-next-line @typescript-eslint/no-unused-vars |
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.
Add an index page that links to each demo page.
@@ -0,0 +1,72 @@ | |||
'use client'; |
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.
Generated from zero-render-mui-demos.mjs
script.
@@ -169,6 +182,7 @@ const Alert = React.forwardRef(function Alert(inProps, ref) { | |||
color, | |||
severity, | |||
variant, | |||
colorSeverity: color || severity, |
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 is required because we can't do:
...Object.entries(theme.palette)
.filter(([, value]) => value.main)
.map(([color]) => ({
// this will throw error because a function cannot read variable `color`.
props: ({ ownerState }) => color === (ownerState.color || ownerState.severity) && ownerState.variant === 'outlined',
style: {
color: theme.vars
? theme.vars.palette.Alert[`${color}Color`]
: getColor(theme.palette[color].light, 0.6),
border: `1px solid ${(theme.vars || theme).palette[color].light}`,
[`& .${alertClasses.icon}`]: theme.vars
? { color: theme.vars.palette.Alert[`${color}IconColor`] }
: {
color: theme.palette[color].main,
},
},
})),
So (ownerState.color || ownerState.severity) needs to be resolved before passing to ownerState.
@brijeshb42 @mnajdova It's ready for review. |
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
5f94965
to
b4b8cb1
Compare
Is there a preliminary benchmark in terms of asset sizes, build times or render timings? |
Waiting for #41317