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

main
Tsu-ba-me 3 years ago
parent d7bed986ae
commit 21dd7577b2
  1. 68
      striker-ui/components/AnvilDrawer.tsx

@ -1,43 +1,53 @@
import { Divider, Drawer, List, ListItem, Box } from '@material-ui/core'; import { Box, Divider, Drawer, List, ListItem } from '@mui/material';
import { makeStyles, createStyles } from '@material-ui/core/styles'; import { styled } from '@mui/material/styles';
import DashboardIcon from '@material-ui/icons/Dashboard'; import DashboardIcon from '@mui/icons-material/Dashboard';
import { Dispatch, SetStateAction } from 'react'; import { Dispatch, SetStateAction } from 'react';
import { BodyText, HeaderText } from './Text'; import { BodyText, HeaderText } from './Text';
import { ICONS, ICON_SIZE } from '../lib/consts/ICONS'; import { ICONS, ICON_SIZE } from '../lib/consts/ICONS';
import { DIVIDER, GREY } from '../lib/consts/DEFAULT_THEME'; import { DIVIDER, GREY } from '../lib/consts/DEFAULT_THEME';
const PREFIX = 'AnvilDrawer';
const classes = {
list: `${PREFIX}-list`,
divider: `${PREFIX}-divider`,
text: `${PREFIX}-text`,
dashboardButton: `${PREFIX}-dashboardButton`,
dashboardIcon: `${PREFIX}-dashboardIcon`,
};
const StyledDrawer = styled(Drawer)(() => ({
[`& .${classes.list}`]: {
width: '200px',
},
[`& .${classes.divider}`]: {
backgroundColor: DIVIDER,
},
[`& .${classes.text}`]: {
paddingTop: '.5em',
paddingLeft: '1.5em',
},
[`& .${classes.dashboardButton}`]: {
paddingLeft: '.1em',
},
[`& .${classes.dashboardIcon}`]: {
fontSize: '2.3em',
color: GREY,
},
}));
interface DrawerProps { interface DrawerProps {
open: boolean; open: boolean;
setOpen: Dispatch<SetStateAction<boolean>>; setOpen: Dispatch<SetStateAction<boolean>>;
} }
const useStyles = makeStyles(() =>
createStyles({
list: {
width: '200px',
},
divider: {
background: DIVIDER,
},
text: {
paddingTop: '.5em',
paddingLeft: '1.5em',
},
dashboardButton: {
paddingLeft: '.1em',
},
dashboardIcon: {
fontSize: '2.3em',
color: GREY,
},
}),
);
const AnvilDrawer = ({ open, setOpen }: DrawerProps): JSX.Element => { const AnvilDrawer = ({ open, setOpen }: DrawerProps): JSX.Element => {
const classes = useStyles();
return ( return (
<Drawer <StyledDrawer
BackdropProps={{ invisible: true }} BackdropProps={{ invisible: true }}
anchor="left" anchor="left"
open={open} open={open}
@ -90,7 +100,7 @@ const AnvilDrawer = ({ open, setOpen }: DrawerProps): JSX.Element => {
)} )}
</List> </List>
</div> </div>
</Drawer> </StyledDrawer>
); );
}; };

Loading…
Cancel
Save