Skip to content
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d416262
[release] v5.10.12
mnajdova Oct 31, 2022
a4ac85f
Remove autogenerated text
mnajdova Oct 31, 2022
9d0d4f3
Merge branch 'master' into release/5.10.12
mnajdova Oct 31, 2022
7e1815a
Updated changelog
mnajdova Oct 31, 2022
4a6bafb
Merge branch 'master' into release/5.10.12
mnajdova Oct 31, 2022
1e556dc
Updated changelog
mnajdova Oct 31, 2022
bf55df5
Merge branch 'release/5.10.12' of https://github.com/mnajdova/materia…
mnajdova Oct 31, 2022
2f2c1a3
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 4, 2022
696baf0
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 9, 2022
150fab6
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 14, 2022
2c1c0e1
[system] Explore different sx config
mnajdova Nov 14, 2022
aa8dab7
lint issues
mnajdova Nov 15, 2022
5593dc9
Refactor Joy's usage
mnajdova Nov 15, 2022
db412b5
Fix experimental sx
mnajdova Nov 15, 2022
c9b5e14
Fixes
mnajdova Nov 15, 2022
3c27f52
More fixes
mnajdova Nov 15, 2022
c71e273
Moved and fixed some tests
mnajdova Nov 15, 2022
457d61d
fixes & lint issues
mnajdova Nov 15, 2022
6205b27
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 15, 2022
2a282d1
Merge branch 'master' into chore/sx-improvements
mnajdova Nov 15, 2022
aab6ec2
Update packages/mui-joy/src/Box/Box.test.js
mnajdova Nov 16, 2022
5556acb
Update packages/mui-joy/src/styles/defaultTheme.ts
mnajdova Nov 16, 2022
d79f580
Resolve comments from review
mnajdova Nov 17, 2022
e23405b
Resolve comments from review
mnajdova Nov 17, 2022
d6756ea
Resolve review comments
mnajdova Nov 18, 2022
3d13353
prettier
mnajdova Nov 18, 2022
1bb3f11
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 18, 2022
0d71255
Update docs' system performance section
mnajdova Nov 21, 2022
a41f4b0
Convert to TS
mnajdova Nov 21, 2022
1d116d1
Use declaration file
mnajdova Nov 21, 2022
0393080
lint
mnajdova Nov 21, 2022
bcf632c
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 21, 2022
215a70e
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 21, 2022
54489dc
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 22, 2022
6109c6d
Merge branch 'master' into chore/sx-improvements
mnajdova Nov 22, 2022
eb4e6cb
Update @mui/material-next witht he latest sx config
mnajdova Nov 22, 2022
a719745
TS fixes
mnajdova Nov 22, 2022
d55b720
lint fixes
mnajdova Nov 22, 2022
8f4a288
lint
mnajdova Nov 22, 2022
95fc5e1
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 23, 2022
b7e3a5a
Make sx work for both MD2 and MD3
mnajdova Nov 25, 2022
ab6b951
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 28, 2022
15c3668
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 28, 2022
985012e
Update packages/mui-material-next/src/styles/extendTheme.ts
mnajdova Nov 29, 2022
ab13d5b
Add more tests
mnajdova Nov 29, 2022
2cbf11c
Merge branch 'chore/sx-improvements' of https://github.com/mnajdova/m…
mnajdova Nov 29, 2022
3b3f5b1
More generic solution to the `materialYouComponent` flag
mnajdova Nov 29, 2022
a387ed7
Resolve review comments
mnajdova Nov 30, 2022
e5039b0
lint
mnajdova Nov 30, 2022
21f55ab
Remove `experimental_sx`
mnajdova Nov 30, 2022
cf584ee
Small fixes & docs updates
mnajdova Nov 30, 2022
4cf4ce2
Fix test & translations
mnajdova Nov 30, 2022
9afb562
Apply suggestions from code review
mnajdova Dec 1, 2022
0debf67
Update packages/mui-joy/src/styles/CssVarsProvider.tsx
mnajdova Dec 1, 2022
d68bbe6
Update packages/mui-system/src/styleFunctionSx/styleFunctionSx.js
mnajdova Dec 1, 2022
80a221f
Update docs/data/system/experimental-api/extend-sx-prop/ExtendTheSxPr…
mnajdova Dec 1, 2022
c0ffaba
Update docs/data/system/experimental-api/extend-sx-prop/ChangeTheBeha…
mnajdova Dec 1, 2022
e42d74c
Update docs/data/system/experimental-api/extend-sx-prop/ChangeTheBeha…
mnajdova Dec 1, 2022
75b5374
Address review comments
mnajdova Dec 1, 2022
37c6b59
lint issues
mnajdova Dec 1, 2022
99a7021
types
mnajdova Dec 1, 2022
743c1c8
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Dec 6, 2022
4a5ecc5
Update docs/data/system/experimental-api/configure-the-sx-prop/config…
mnajdova Dec 7, 2022
ad8eb6d
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Dec 7, 2022
ff505be
Merge branch 'master' into chore/sx-improvements
mnajdova Dec 7, 2022
cdd96c9
prettier
mnajdova Dec 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import * as React from 'react';
import {
ThemeProvider,
createTheme,
experimental_sx as sx,
} from '@mui/material/styles';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import Chip from '@mui/material/Chip';
import Check from '@mui/icons-material/Check';

const finalTheme = createTheme({
components: {
MuiChip: {
styleOverrides: {
root: sx({
// https://mui.com/system/getting-started/the-sx-prop/#spacing
px: 1,
py: 0.25,
// https://mui.com/system/borders/#border-radius
borderRadius: 1, // 4px as default.
}),
root: ({ theme }) =>
theme.unstable_sx({
// https://mui.com/system/getting-started/the-sx-prop/#spacing
px: 1,
py: 0.25,
// https://mui.com/system/borders/#border-radius
borderRadius: 1, // 4px as default.
}),
label: {
padding: 'initial',
},
icon: sx({
mr: 0.5,
ml: '-2px',
}),
icon: ({ theme }) =>
theme.unstable_sx({
mr: 0.5,
ml: '-2px',
}),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import * as React from 'react';
import {
ThemeProvider,
createTheme,
experimental_sx as sx,
} from '@mui/material/styles';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import Chip from '@mui/material/Chip';
import Check from '@mui/icons-material/Check';

const finalTheme = createTheme({
components: {
MuiChip: {
styleOverrides: {
root: sx({
// https://mui.com/system/getting-started/the-sx-prop/#spacing
px: 1,
py: 0.25,
// https://mui.com/system/borders/#border-radius
borderRadius: 1, // 4px as default.
}),
root: ({ theme }) =>
theme.unstable_sx({
// https://mui.com/system/getting-started/the-sx-prop/#spacing
px: 1,
py: 0.25,
// https://mui.com/system/borders/#border-radius
borderRadius: 1, // 4px as default.
}),
label: {
padding: 'initial',
},
icon: sx({
mr: 0.5,
ml: '-2px',
}),
icon: ({ theme }) =>
theme.unstable_sx({
mr: 0.5,
ml: '-2px',
}),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as React from 'react';
import { createTheme, ThemeProvider, Box, Stack } from '@mui/system';

// Retain type safety.

const theme = createTheme({
unstable_sxConfig: {
// You can now use the background key in sx
// by providing direct values from the palette
borderRadius: {
themeKey: 'shape',
},
},
shape: {
sm: 4,
md: 8,
lg: 12,
},
});

export default function ExtendSxProp() {
return (
<ThemeProvider theme={theme}>
<Stack direction="row" gap={1}>
<Box sx={{ borderRadius: 'sm', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
sm border radius
</Box>
<Box sx={{ borderRadius: 'md', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
md border radius
</Box>
<Box sx={{ borderRadius: 'lg', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
lg border radius
</Box>
</Stack>
</ThemeProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as React from 'react';
import { createTheme, ThemeProvider, Box, Stack } from '@mui/system';

// Retain type safety.
declare module '@mui/system' {
interface Shape {
sm: number;
md: number;
lg: number;
}
}

const theme = createTheme({
unstable_sxConfig: {
// You can now use the background key in sx
// by providing direct values from the palette
borderRadius: {
themeKey: 'shape',
},
},
shape: {
sm: 4,
md: 8,
lg: 12,
},
});

export default function ExtendSxProp() {
return (
<ThemeProvider theme={theme}>
<Stack direction="row" gap={1}>
<Box sx={{ borderRadius: 'sm', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
sm border radius
</Box>
<Box sx={{ borderRadius: 'md', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
md border radius
</Box>
<Box sx={{ borderRadius: 'lg', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
lg border radius
</Box>
</Stack>
</ThemeProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<ThemeProvider theme={theme}>
<Stack direction="row" gap={1}>
<Box sx={{ borderRadius: 'sm', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
sm border radius
</Box>
<Box sx={{ borderRadius: 'md', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
md border radius
</Box>
<Box sx={{ borderRadius: 'lg', bgcolor: '#007FFF', color: '#FFF', p: 1 }}>
lg border radius
</Box>
</Stack>
</ThemeProvider>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from 'react';
import { createTheme, ThemeProvider, Box } from '@mui/system';

const theme = createTheme({
unstable_sxConfig: {
// You can now use the background key in sx
// by providing direct values from the palette
background: {
themeKey: 'palette',
},
},
palette: {
primary: {
main: '#007FFF',
contrastText: '#FFFFFF',
},
},
});

export default function ExtendSxProp() {
return (
<ThemeProvider theme={theme}>
<Box
sx={{
background: 'primary.main',
color: 'primary.contrastText',
p: 1,
borderRadius: 2,
}}
>
Primary main background
</Box>
</ThemeProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from 'react';
import { createTheme, ThemeProvider, Box } from '@mui/system';

const theme = createTheme({
unstable_sxConfig: {
// You can now use the background key in sx
// by providing direct values from the palette
background: {
themeKey: 'palette',
},
},
palette: {
primary: {
main: '#007FFF',
contrastText: '#FFFFFF',
},
},
});

export default function ExtendSxProp() {
return (
<ThemeProvider theme={theme}>
<Box
sx={{
background: 'primary.main',
color: 'primary.contrastText',
p: 1,
borderRadius: 2,
}}
>
Primary main background
</Box>
</ThemeProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<ThemeProvider theme={theme}>
<Box
sx={{
background: 'primary.main',
color: 'primary.contrastText',
p: 1,
borderRadius: 2,
}}
>
Primary main background
</Box>
</ThemeProvider>
24 changes: 24 additions & 0 deletions docs/data/system/experimental-api/extend-sx-prop/extend-sx-prop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Extend the `sx` prop

<p class="description">Learn about the experimental API for extending or changing the behavior of the `sx` prop.</p>

## Extend the `sx` prop

If you wish to add new keys that would be processed by the `sx` prop, you can do that by extending the `unstable_sxConfig` option inside the theme.

{{"demo": "ExtendTheSxProp.js" }}

## Override some of the existing behavior

There is also a possibility to change some of the existing behavior. You can simply provide a custom config in the for the specific key.

{{"demo": "ChangeTheBehaviorSxProp.js" }}

## API

Each key in the `unstable_sx` config can define the following properties:

- `cssProperty` (_string_ [optional]): Indicates the css property, if it is different than the key
- `themeKey` (_string_ [optional]): The path of the theme mapping.
- `transform` (_(cssValue: unknown, userValue: unknown) => number | string | React.CSSProperties | CSSObject_ [optional]): Allows users to define a function that can transform the value before it is returned
- `style` (_(props: any) => CSSObject_ [optional]): Offers maximum customizability. Note that you need to make sure that the breakpoints values can be processed
6 changes: 3 additions & 3 deletions docs/data/system/getting-started/usage/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ It works with both Emotion and styled-components.
| Benchmark case | Code snippet | Time normalized |
| :-------------------------------- | :-------------------- | --------------- |
| a. Render 1,000 primitives | `<div className="…">` | 100ms |
| b. Render 1,000 components | `<Div>` | 120ms |
| c. Render 1,000 styled components | `<StyledDiv>` | 160ms |
| d. Render 1,000 Box | `<Box sx={…}>` | 370ms |
| b. Render 1,000 components | `<Div>` | 112ms |
| c. Render 1,000 styled components | `<StyledDiv>` | 181ms |
| d. Render 1,000 Box | `<Box sx={…}>` | 296ms |

<!-- #default-branch-switch -->

Expand Down
11 changes: 11 additions & 0 deletions docs/data/system/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ const pages = [
icon: 'CodeIcon',
children: pagesApi,
},
{
pathname: '/system/experimental-api',
title: 'Experimental APIs',
icon: 'ExperimentIcon',
children: [
{
pathname: '/system/experimental-api/extend-sx-prop',
title: 'Extend the `sx` prop',
Copy link
Member

@siriwatknp siriwatknp Dec 1, 2022

Choose a reason for hiding this comment

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

Suggested change
pathname: '/system/experimental-api/extend-sx-prop',
title: 'Extend the `sx` prop',
pathname: '/system/experimental-api/sx-config',
title: 'sx config',

How about renaming the page to sx config or configure sx prop and grouping these into the page:

  • override the default config (from Override some of the existing behavior )
  • add your own config (from Extend the sx prop)
  • API

cc @samuelsycamore might have a better name.

Copy link
Member Author

@mnajdova mnajdova Dec 1, 2022

Choose a reason for hiding this comment

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

Yeah, "Configure the sx prop" sounds better, as the page is both about extending and changing. Updated!

},
],
},
{
pathname: '/system/styles',
title: 'Styles',
Expand Down
11 changes: 3 additions & 8 deletions docs/data/system/styled/UsingWithSx.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import * as React from 'react';
import {
styled,
createTheme,
ThemeProvider,
experimental_sx as sx,
} from '@mui/system';
import { styled, createTheme, ThemeProvider } from '@mui/system';

const customTheme = createTheme({
palette: {
Expand All @@ -15,8 +10,8 @@ const customTheme = createTheme({
},
});

const MyThemeComponent = styled('div')(
sx({
const MyThemeComponent = styled('div')(({ theme }) =>
theme.unstable_sx({
color: 'primary.contrastText',
backgroundColor: 'primary.main',
padding: 1,
Expand Down
11 changes: 3 additions & 8 deletions docs/data/system/styled/UsingWithSx.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import * as React from 'react';
import {
styled,
createTheme,
ThemeProvider,
experimental_sx as sx,
} from '@mui/system';
import { styled, createTheme, ThemeProvider } from '@mui/system';

const customTheme = createTheme({
palette: {
Expand All @@ -15,8 +10,8 @@ const customTheme = createTheme({
},
});

const MyThemeComponent = styled('div')(
sx({
const MyThemeComponent = styled('div')(({ theme }) =>
theme.unstable_sx({
color: 'primary.contrastText',
backgroundColor: 'primary.main',
padding: 1,
Expand Down
6 changes: 3 additions & 3 deletions docs/data/system/styled/styled.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ const MyStyledButton = (props) => (

### How can I use the `sx` syntax with the `styled()` utility?

If you are one of those who prefers the `sx` syntax and wants to use it in both the `sx` prop and the `styled()` utility, you can use the `experimental_sx` utility from the `@mui/system`:
If you are one of those who prefers the `sx` syntax and wants to use it in both the `sx` prop and the `styled()` utility, you can use the `unstable_sx` utility from the `theme`:

{{"demo": "UsingWithSx.js", "defaultCodeOpen": true}}

The overhead added by using the `experimental_sx` utility is the same as if you were to use the `sx` prop on the component.
The overhead added by using the `unstable_sx` utility is the same as if you were to use the `sx` prop on the component.

> Note: You can use `experimental_sx` outside of the `styled()` utility, too; e.g., for defining `variants` in your custom theme.
> Note: You can use `unstable_sx` outside of the `styled()` utility, too; e.g., for defining `variants` in your custom theme.

## How to use components selector API

Expand Down
Loading