Skip to content

Commit 50fa7ef

Browse files
committed
Migrate material-ui example away from deprecated @mui/styles dep
1 parent 660ec33 commit 50fa7ef

3 files changed

Lines changed: 29 additions & 36 deletions

File tree

examples/material-ui/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"@emotion/react": "11.14.0",
1111
"@emotion/styled": "11.14.1",
1212
"@mui/material": "7.3.4",
13-
"@mui/styles": "6.4.8",
1413
"@tanem/react-nprogress": "latest",
1514
"@types/jest": "30.0.0",
1615
"@types/node": "22.18.9",

examples/material-ui/src/Progress.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
import Container from '@mui/material/Container'
22
import LinearProgress from '@mui/material/LinearProgress'
3-
import { makeStyles, Theme } from '@mui/styles'
43
import { useNProgress } from '@tanem/react-nprogress'
54
import React from 'react'
65

7-
const useStyles = makeStyles<
8-
Theme,
9-
Pick<ReturnType<typeof useNProgress>, 'animationDuration' | 'isFinished'>
10-
>({
11-
bar: ({ animationDuration }) => ({
12-
transitionDuration: `${animationDuration}ms`,
13-
}),
14-
container: ({ animationDuration, isFinished }) => ({
15-
opacity: isFinished ? 0 : 1,
16-
pointerEvents: 'none',
17-
transition: `opacity ${animationDuration}ms linear`,
18-
}),
19-
})
20-
216
const Progress: React.FC<{ isAnimating: boolean }> = ({ isAnimating }) => {
227
const { animationDuration, isFinished, progress } = useNProgress({
238
isAnimating,
249
})
25-
const classes = useStyles({ animationDuration, isFinished })
2610

2711
return (
28-
<Container classes={{ root: classes.container }} disableGutters={true}>
12+
<Container
13+
disableGutters={true}
14+
sx={{
15+
opacity: isFinished ? 0 : 1,
16+
pointerEvents: 'none',
17+
transition: `opacity ${animationDuration}ms linear`,
18+
}}
19+
>
2920
<LinearProgress
30-
classes={{ bar1Determinate: classes.bar }}
21+
sx={{
22+
'& .MuiLinearProgress-bar1Determinate': {
23+
transitionDuration: `${animationDuration}ms`,
24+
},
25+
}}
3126
value={progress * 100}
3227
variant="determinate"
3328
/>

examples/material-ui/src/index.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1+
import { GlobalStyles } from '@mui/material'
12
import Button from '@mui/material/Button'
23
import Container from '@mui/material/Container'
3-
import { makeStyles } from '@mui/styles'
44
import React, { useState } from 'react'
55
import { createRoot } from 'react-dom/client'
66

77
import Progress from './Progress'
88

9-
const useStyles = makeStyles({
10-
'@global': {
11-
body: {
12-
margin: 0,
13-
},
14-
},
15-
container: {
16-
alignItems: 'center',
17-
display: 'flex',
18-
height: '100vh',
19-
justifyContent: 'center',
20-
},
21-
})
22-
239
const App: React.FC = () => {
24-
const classes = useStyles()
2510
const [state, setState] = useState({
2611
isAnimating: false,
2712
key: 0,
2813
})
2914

3015
return (
3116
<>
17+
<GlobalStyles
18+
styles={{
19+
body: {
20+
margin: 0,
21+
},
22+
}}
23+
/>
3224
<Progress isAnimating={state.isAnimating} key={state.key} />
33-
<Container classes={{ root: classes.container }}>
25+
<Container
26+
sx={{
27+
alignItems: 'center',
28+
display: 'flex',
29+
height: '100vh',
30+
justifyContent: 'center',
31+
}}
32+
>
3433
<Button
3534
onClick={() => {
3635
setState((prevState) => ({

0 commit comments

Comments
 (0)