|
1 | 1 | import Container from '@mui/material/Container' |
2 | 2 | import LinearProgress from '@mui/material/LinearProgress' |
3 | | -import { makeStyles, Theme } from '@mui/styles' |
4 | 3 | import { useNProgress } from '@tanem/react-nprogress' |
5 | 4 | import React from 'react' |
6 | 5 |
|
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 | | - |
21 | 6 | const Progress: React.FC<{ isAnimating: boolean }> = ({ isAnimating }) => { |
22 | 7 | const { animationDuration, isFinished, progress } = useNProgress({ |
23 | 8 | isAnimating, |
24 | 9 | }) |
25 | | - const classes = useStyles({ animationDuration, isFinished }) |
26 | 10 |
|
27 | 11 | 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 | + > |
29 | 20 | <LinearProgress |
30 | | - classes={{ bar1Determinate: classes.bar }} |
| 21 | + sx={{ |
| 22 | + '& .MuiLinearProgress-bar1Determinate': { |
| 23 | + transitionDuration: `${animationDuration}ms`, |
| 24 | + }, |
| 25 | + }} |
31 | 26 | value={progress * 100} |
32 | 27 | variant="determinate" |
33 | 28 | /> |
|
0 commit comments