refactor: change text component to allow unselected option

main
Josue 4 years ago committed by Tsu-ba-me
parent 93d10e0528
commit 427588df0f
  1. 35
      striker-ui/components/Text/BodyText.tsx
  2. 1
      striker-ui/lib/consts/DEFAULT_THEME.ts

@ -1,15 +1,36 @@
import { Typography } from '@material-ui/core'; import { Typography } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import { TEXT } from '../../lib/consts/DEFAULT_THEME'; import { TEXT, UNSELECTED } from '../../lib/consts/DEFAULT_THEME';
const WhiteTypography = withStyles({ interface TextProps {
root: { text: string;
selected?: boolean;
}
const useStyles = makeStyles(() => ({
selected: {
color: TEXT, color: TEXT,
}, },
})(Typography); unselected: {
color: UNSELECTED,
},
}));
const BodyText = ({ text, selected }: TextProps): JSX.Element => {
const classes = useStyles();
return (
<Typography
variant="subtitle1"
className={selected ? classes.selected : classes.unselected}
>
{text}
</Typography>
);
};
const BodyText = ({ text }: { text: string }): JSX.Element => { BodyText.defaultProps = {
return <WhiteTypography variant="subtitle1">{text}</WhiteTypography>; selected: true,
}; };
export default BodyText; export default BodyText;

@ -9,3 +9,4 @@ export const PURPLE_OFF = '#7353BA';
export const BLUE = '#4785FF'; export const BLUE = '#4785FF';
export const GREY = '#E5E5E5'; export const GREY = '#E5E5E5';
export const HOVER = '#444'; export const HOVER = '#444';
export const UNSELECTED = '#888';

Loading…
Cancel
Save