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

main
Tsu-ba-me 3 years ago
parent 4a268c4b57
commit ca5c0becf7
  1. 33
      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,10 +23,19 @@ const classes = {
off: `${PREFIX}-off`, off: `${PREFIX}-off`,
}; };
const StyledDiv = styled('div')(() => ({ const Decorator: FC<DecoratorProps> = ({
width: '1.4em', colour,
height: '100%', sx,
...restDecoratorProps
}): JSX.Element => (
<MUIBox
{...{
...restDecoratorProps,
className: classes[colour],
sx: {
borderRadius: BORDER_RADIUS, borderRadius: BORDER_RADIUS,
height: '100%',
width: '1.4em',
[`&.${classes.ok}`]: { [`&.${classes.ok}`]: {
backgroundColor: BLUE, backgroundColor: BLUE,
@ -36,12 +52,11 @@ const StyledDiv = styled('div')(() => ({
[`&.${classes.off}`]: { [`&.${classes.off}`]: {
backgroundColor: GREY, backgroundColor: GREY,
}, },
}));
export type Colours = 'ok' | 'off' | 'error' | 'warning'; ...sx,
},
const Decorator = ({ colour }: { colour: Colours }): JSX.Element => ( }}
<StyledDiv className={classes[colour]} /> />
); );
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