diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2021-01-11 22:15:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 22:15:33 +0200 |
commit | 5f72950c56ea8853b41b64a092a2e98dbf53cf3f (patch) | |
tree | 240101bb69aea59c72e1e6fa328b9c5e1729f367 /src/lib/Markdown/Heading.tsx | |
parent | bc288a43c90ab830019bf077d72081fade76c06e (diff) | |
parent | aa4493b08baae2d41a4c4346b9a5c63b08df471e (diff) | |
download | react-benzin-5f72950c56ea8853b41b64a092a2e98dbf53cf3f.tar.gz |
Merge pull request #20 from eug-vs/feat/react-markdown
Feat: use react-markdown library and support context
Diffstat (limited to 'src/lib/Markdown/Heading.tsx')
-rw-r--r-- | src/lib/Markdown/Heading.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib/Markdown/Heading.tsx b/src/lib/Markdown/Heading.tsx new file mode 100644 index 0000000..cc0b709 --- /dev/null +++ b/src/lib/Markdown/Heading.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { Typography, Divider, makeStyles } from '@material-ui/core'; + +interface PropTypes { + level: number; +} + +type Variant = 'h3' | 'h4' | 'h5' | 'h6'; + +const useStyles = makeStyles(theme => ({ + root: { + padding: theme.spacing(2, 0, 1, 0), + }, +})); + +const Heading: React.FC<PropTypes> = ({ children, level }) => { + const classes = useStyles(); + + let adjustedLevel = level + 2; // Make everything smaller + if (adjustedLevel > 6) adjustedLevel = 6; + + const variant: Variant = `h${adjustedLevel}` as Variant; + + return ( + <div className={classes.root}> + <Typography variant={variant}>{children}</Typography> + <Divider variant="middle" /> + </div> + ); +}; + +export default Heading; + |