refactor(striker-ui): migrate MUI v4->5 on Panels/Panel

main
Tsu-ba-me 3 years ago
parent 9f3a987e3e
commit 6b1cb44c70
  1. 54
      striker-ui/components/Panels/Panel.tsx

@ -1,27 +1,33 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { makeStyles } from '@material-ui/core/styles'; import { GlobalStyles } from '@mui/material';
import { styled } from '@mui/material/styles';
import { import {
BORDER_RADIUS, BORDER_RADIUS,
PANEL_BACKGROUND, PANEL_BACKGROUND,
TEXT, TEXT,
} from '../../lib/consts/DEFAULT_THEME'; } from '../../lib/consts/DEFAULT_THEME';
type Props = { const PREFIX = 'Panel';
children: ReactNode;
const classes = {
paper: `${PREFIX}-paper`,
square: `${PREFIX}-square`,
topSquare: `${PREFIX}-topSquare`,
bottomSquare: `${PREFIX}-bottomSquare`,
}; };
const useStyles = makeStyles(() => ({ const StyledDiv = styled('div')(() => ({
paper: { margin: '1em',
position: 'relative',
[`& .${classes.paper}`]: {
padding: '2.1em', padding: '2.1em',
backgroundColor: PANEL_BACKGROUND, backgroundColor: PANEL_BACKGROUND,
opacity: 0.8, opacity: 0.8,
zIndex: 999, zIndex: 999,
}, },
container: {
margin: '1em', [`& .${classes.square}`]: {
position: 'relative',
},
square: {
content: '""', content: '""',
position: 'absolute', position: 'absolute',
width: '2.1em', width: '2.1em',
@ -34,15 +40,25 @@ const useStyles = makeStyles(() => ({
padding: 0, padding: 0,
margin: 0, margin: 0,
}, },
topSquare: {
[`& .${classes.topSquare}`]: {
top: '-.3em', top: '-.3em',
left: '-.3em', left: '-.3em',
}, },
bottomSquare: {
[`& .${classes.bottomSquare}`]: {
bottom: '-.3em', bottom: '-.3em',
right: '-.3em', right: '-.3em',
}, },
'@global': { }));
type Props = {
children: ReactNode;
};
const styledScrollbars = (
<GlobalStyles
styles={{
'*::-webkit-scrollbar': { '*::-webkit-scrollbar': {
width: '.6em', width: '.6em',
}, },
@ -54,18 +70,18 @@ const useStyles = makeStyles(() => ({
outline: '1px solid transparent', outline: '1px solid transparent',
borderRadius: BORDER_RADIUS, borderRadius: BORDER_RADIUS,
}, },
}, }}
})); />
);
const Panel = ({ children }: Props): JSX.Element => { const Panel = ({ children }: Props): JSX.Element => {
const classes = useStyles();
return ( return (
<div className={classes.container}> <StyledDiv>
{styledScrollbars}
<div className={`${classes.square} ${classes.topSquare}`} /> <div className={`${classes.square} ${classes.topSquare}`} />
<div className={`${classes.square} ${classes.bottomSquare}`} /> <div className={`${classes.square} ${classes.bottomSquare}`} />
<div className={classes.paper}>{children}</div> <div className={classes.paper}>{children}</div>
</div> </StyledDiv>
); );
}; };

Loading…
Cancel
Save