refactor(striker-ui): migrate MUI v4->5 on Decorator

main
Tsu-ba-me 3 years ago
parent de6038a3d5
commit 96f1d0db59
  1. 32
      striker-ui/components/Decorator.tsx

@ -1,4 +1,4 @@
import { makeStyles } from '@material-ui/core/styles'; import { styled } from '@mui/material/styles';
import { import {
BLUE, BLUE,
GREY, GREY,
@ -7,31 +7,41 @@ import {
BORDER_RADIUS, BORDER_RADIUS,
} from '../lib/consts/DEFAULT_THEME'; } from '../lib/consts/DEFAULT_THEME';
export type Colours = 'ok' | 'off' | 'error' | 'warning'; const PREFIX = 'Decorator';
const classes = {
ok: `${PREFIX}-ok`,
warning: `${PREFIX}-warning`,
error: `${PREFIX}-error`,
off: `${PREFIX}-off`,
};
const useStyles = makeStyles(() => ({ const StyledDiv = styled('div')(() => ({
decorator: {
width: '1.4em', width: '1.4em',
height: '100%', height: '100%',
borderRadius: BORDER_RADIUS, borderRadius: BORDER_RADIUS,
},
ok: { [`&.${classes.ok}`]: {
backgroundColor: BLUE, backgroundColor: BLUE,
}, },
warning: {
[`&.${classes.warning}`]: {
backgroundColor: PURPLE, backgroundColor: PURPLE,
}, },
error: {
[`&.${classes.error}`]: {
backgroundColor: RED, backgroundColor: RED,
}, },
off: {
[`&.${classes.off}`]: {
backgroundColor: GREY, backgroundColor: GREY,
}, },
})); }));
export type Colours = 'ok' | 'off' | 'error' | 'warning';
const Decorator = ({ colour }: { colour: Colours }): JSX.Element => { const Decorator = ({ colour }: { colour: Colours }): JSX.Element => {
const classes = useStyles(); return <StyledDiv className={classes[colour]} />;
return <div className={`${classes.decorator} ${classes[colour]}`} />;
}; };
export default Decorator; export default Decorator;

Loading…
Cancel
Save