Local modifications to ClusterLabs/Anvil by Alteeve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.4 KiB

import { styled, Typography, TypographyProps } from '@mui/material';
import { BLACK, TEXT, UNSELECTED } from '../../lib/consts/DEFAULT_THEME';
const PREFIX = 'BodyText';
const classes = {
inverted: `${PREFIX}-inverted`,
selected: `${PREFIX}-selected`,
unselected: `${PREFIX}-unselected`,
};
const StyledTypography = styled(Typography)(() => ({
[`&.${classes.inverted}`]: {
color: BLACK,
},
[`&.${classes.selected}`]: {
color: TEXT,
},
[`&.${classes.unselected}`]: {
color: UNSELECTED,
},
}));
type BodyTextProps = TypographyProps & {
inverted?: boolean;
selected?: boolean;
text: string;
};
const BodyText = ({
inverted,
selected,
sx,
text,
}: BodyTextProps): JSX.Element => {
const buildBodyTextClasses = ({
isInvert,
isSelect,
}: {
isInvert?: boolean;
isSelect?: boolean;
}) => {
let bodyTextClasses = '';
if (isInvert) {
bodyTextClasses += classes.inverted;
} else if (isSelect) {
bodyTextClasses += classes.selected;
} else {
bodyTextClasses += classes.unselected;
}
return bodyTextClasses;
};
return (
<StyledTypography
{...{ sx }}
className={buildBodyTextClasses({
isInvert: inverted,
isSelect: selected,
})}
variant="subtitle1"
>
{text}
</StyledTypography>
);
};
BodyText.defaultProps = {
inverted: false,
selected: true,
};
export default BodyText;