refactor(striker-ui): migrate MUI v4->5 on Display/Preview

main
Tsu-ba-me 3 years ago
parent 465894eb81
commit a887a03b33
  1. 57
      striker-ui/components/Display/Preview.tsx

@ -1,55 +1,72 @@
import { Dispatch, SetStateAction, useEffect, useState } from 'react'; import { Dispatch, SetStateAction, useEffect, useState } from 'react';
import { Box } from '@material-ui/core'; import { Box, IconButton, styled } from '@mui/material';
import { makeStyles } from '@material-ui/core/styles'; import {
import IconButton from '@material-ui/core/IconButton'; DesktopWindows as DesktopWindowsIcon,
import DesktopWindowsIcon from '@material-ui/icons/DesktopWindows'; PowerOffOutlined as PowerOffOutlinedIcon,
import PowerOffOutlinedIcon from '@material-ui/icons/PowerOffOutlined'; } from '@mui/icons-material';
import { Panel } from '../Panels';
import { BLACK, GREY, TEXT } from '../../lib/consts/DEFAULT_THEME'; import { BLACK, GREY, TEXT } from '../../lib/consts/DEFAULT_THEME';
import { Panel } from '../Panels';
import { HeaderText } from '../Text'; import { HeaderText } from '../Text';
interface PreviewProps { const PREFIX = 'Preview';
setMode: Dispatch<SetStateAction<boolean>>;
uuid: string; const classes = {
serverName: string | string[] | undefined; displayBox: `${PREFIX}-displayBox`,
} fullScreenButton: `${PREFIX}-fullScreenButton`,
fullScreenBox: `${PREFIX}-fullScreenBox`,
imageButton: `${PREFIX}-imageButton`,
powerOffIcon: `${PREFIX}-powerOffIcon`,
previewImage: `${PREFIX}-previewImage`,
};
const useStyles = makeStyles(() => ({ const StyledDiv = styled('div')(() => ({
displayBox: { [`& .${classes.displayBox}`]: {
padding: 0, padding: 0,
paddingTop: '.7em', paddingTop: '.7em',
width: '100%', width: '100%',
}, },
fullScreenButton: {
[`& .${classes.fullScreenButton}`]: {
borderRadius: 8, borderRadius: 8,
backgroundColor: TEXT, backgroundColor: TEXT,
'&:hover': { '&:hover': {
backgroundColor: TEXT, backgroundColor: TEXT,
}, },
}, },
fullScreenBox: {
[`& .${classes.fullScreenBox}`]: {
paddingLeft: '1em', paddingLeft: '1em',
padding: 0, padding: 0,
}, },
imageButton: {
[`& .${classes.imageButton}`]: {
padding: 0, padding: 0,
color: TEXT, color: TEXT,
}, },
powerOffIcon: {
[`& .${classes.powerOffIcon}`]: {
borderRadius: 8, borderRadius: 8,
padding: 0, padding: 0,
color: GREY, color: GREY,
width: '100%', width: '100%',
height: '100%', height: '100%',
}, },
previewImage: {
[`& .${classes.previewImage}`]: {
width: '100%', width: '100%',
height: '100%', height: '100%',
}, },
})); }));
interface PreviewProps {
setMode: Dispatch<SetStateAction<boolean>>;
uuid: string;
serverName: string | string[] | undefined;
}
const Preview = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => { const Preview = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => {
const classes = useStyles();
const [preview, setPreview] = useState<string>(); const [preview, setPreview] = useState<string>();
useEffect(() => { useEffect(() => {
@ -74,6 +91,7 @@ const Preview = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => {
return ( return (
<Panel> <Panel>
<StyledDiv>
<Box flexGrow={1}> <Box flexGrow={1}>
<HeaderText text={`Server: ${serverName}`} /> <HeaderText text={`Server: ${serverName}`} />
</Box> </Box>
@ -108,6 +126,7 @@ const Preview = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => {
</IconButton> </IconButton>
</Box> </Box>
</Box> </Box>
</StyledDiv>
</Panel> </Panel>
); );
}; };

Loading…
Cancel
Save