[material-ui][Alert] Convert to support zero runtime#41230
[material-ui][Alert] Convert to support zero runtime#41230siriwatknp merged 27 commits intomui:masterfrom
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.
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.
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
| "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.
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.
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.
Add an index page that links to each demo page.
| @@ -0,0 +1,72 @@ | |||
| 'use client'; | |||
There was a problem hiding this comment.
Generated from zero-render-mui-demos.mjs script.
| color, | ||
| severity, | ||
| variant, | ||
| colorSeverity: color || severity, |
There was a problem hiding this comment.
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. |
5f94965 to
b4b8cb1
Compare
|
Is there a preliminary benchmark in terms of asset sizes, build times or render timings? |
Waiting for #41317