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

main
Tsu-ba-me 3 years ago
parent a162d04ff0
commit 82a0cc950d
  1. 35
      striker-ui/components/Network/Network.tsx

@ -1,6 +1,6 @@
import { useContext } from 'react';
import { Box, Divider } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { Box, Divider } from '@mui/material';
import { styled } from '@mui/material/styles';
import { Panel } from '../Panels';
import { HeaderText, BodyText } from '../Text';
import PeriodicFetch from '../../lib/fetchers/periodicFetch';
@ -13,8 +13,18 @@ import { AnvilContext } from '../AnvilContext';
import Decorator, { Colours } from '../Decorator';
import Spinner from '../Spinner';
const useStyles = makeStyles((theme) => ({
container: {
const PREFIX = 'Network';
const classes = {
container: `${PREFIX}-container`,
root: `${PREFIX}-root`,
noPaddingLeft: `${PREFIX}-noPaddingLeft`,
divider: `${PREFIX}-divider`,
verticalDivider: `${PREFIX}-verticalDivider`,
};
const StyledDiv = styled('div')(({ theme }) => ({
[`& .${classes.container}`]: {
width: '100%',
overflow: 'auto',
height: '32vh',
@ -24,17 +34,21 @@ const useStyles = makeStyles((theme) => ({
overflow: 'hidden',
},
},
root: {
[`& .${classes.root}`]: {
paddingTop: '.7em',
paddingBottom: '.7em',
},
noPaddingLeft: {
[`& .${classes.noPaddingLeft}`]: {
paddingLeft: 0,
},
divider: {
background: DIVIDER,
[`& .${classes.divider}`]: {
backgroundColor: DIVIDER,
},
verticalDivider: {
[`& .${classes.verticalDivider}`]: {
height: '3.5em',
},
}));
@ -54,7 +68,6 @@ const selectDecorator = (state: string): Colours => {
const Network = (): JSX.Element => {
const { uuid } = useContext(AnvilContext);
const classes = useStyles();
const { data, isLoading } = PeriodicFetch<AnvilNetwork>(
`${process.env.NEXT_PUBLIC_API_URL}/get_networks?anvil_uuid=${uuid}`,
@ -63,6 +76,7 @@ const Network = (): JSX.Element => {
const processed = processNetworkData(data);
return (
<Panel>
<StyledDiv>
<HeaderText text="Network" />
{!isLoading ? (
<Box className={classes.container}>
@ -120,6 +134,7 @@ const Network = (): JSX.Element => {
) : (
<Spinner />
)}
</StyledDiv>
</Panel>
);
};

Loading…
Cancel
Save