|
|
@ -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; |
|
|
|