fix(striker-ui): revise Decorator to allow props override

main
Tsu-ba-me 3 years ago
parent 4a268c4b57
commit ca5c0becf7
  1. 69
      striker-ui/components/Decorator.tsx
  2. 3
      striker-ui/components/Hosts/AnvilHost.tsx
  3. 2
      striker-ui/components/SharedStorage/SharedStorageHost.tsx

@ -1,4 +1,5 @@
import { styled } from '@mui/material/styles'; import { Box as MUIBox, BoxProps as MUIBoxProps } from '@mui/material';
import { FC } from 'react';
import { import {
BLUE, BLUE,
GREY, GREY,
@ -7,6 +8,12 @@ import {
BORDER_RADIUS, BORDER_RADIUS,
} from '../lib/consts/DEFAULT_THEME'; } from '../lib/consts/DEFAULT_THEME';
export type Colours = 'ok' | 'off' | 'error' | 'warning';
type DecoratorProps = MUIBoxProps & {
colour: Colours;
};
const PREFIX = 'Decorator'; const PREFIX = 'Decorator';
const classes = { const classes = {
@ -16,32 +23,40 @@ const classes = {
off: `${PREFIX}-off`, off: `${PREFIX}-off`,
}; };
const StyledDiv = styled('div')(() => ({ const Decorator: FC<DecoratorProps> = ({
width: '1.4em', colour,
height: '100%', sx,
borderRadius: BORDER_RADIUS, ...restDecoratorProps
}): JSX.Element => (
[`&.${classes.ok}`]: { <MUIBox
backgroundColor: BLUE, {...{
}, ...restDecoratorProps,
className: classes[colour],
[`&.${classes.warning}`]: { sx: {
backgroundColor: PURPLE, borderRadius: BORDER_RADIUS,
}, height: '100%',
width: '1.4em',
[`&.${classes.error}`]: {
backgroundColor: RED, [`&.${classes.ok}`]: {
}, backgroundColor: BLUE,
},
[`&.${classes.off}`]: {
backgroundColor: GREY, [`&.${classes.warning}`]: {
}, backgroundColor: PURPLE,
})); },
export type Colours = 'ok' | 'off' | 'error' | 'warning'; [`&.${classes.error}`]: {
backgroundColor: RED,
const Decorator = ({ colour }: { colour: Colours }): JSX.Element => ( },
<StyledDiv className={classes[colour]} />
[`&.${classes.off}`]: {
backgroundColor: GREY,
},
...sx,
},
}}
/>
); );
export default Decorator; export default Decorator;

@ -31,7 +31,7 @@ const StyledBox = styled(Box)(({ theme }) => ({
[`& .${classes.state}`]: { [`& .${classes.state}`]: {
paddingLeft: '.7em', paddingLeft: '.7em',
paddingRight: '.7em', paddingRight: '.7em',
paddingTop: '1em', paddingTop: '2.2em',
}, },
[`& .${classes.bar}`]: { [`& .${classes.bar}`]: {
@ -44,6 +44,7 @@ const StyledBox = styled(Box)(({ theme }) => ({
}, },
[`& .${classes.decoratorBox}`]: { [`& .${classes.decoratorBox}`]: {
alignSelf: 'stretch',
paddingRight: '.3em', paddingRight: '.3em',
}, },
})); }));

@ -16,7 +16,7 @@ const StyledDiv = styled('div')(() => ({
[`& .${classes.fs}`]: { [`& .${classes.fs}`]: {
paddingLeft: '.7em', paddingLeft: '.7em',
paddingRight: '.7em', paddingRight: '.7em',
paddingTop: '1em', paddingTop: '2.2em',
}, },
[`& .${classes.bar}`]: { [`& .${classes.bar}`]: {

Loading…
Cancel
Save