aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Markdown/Heading.tsx
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2021-01-14 19:27:47 +0200
committerGitHub <noreply@github.com>2021-01-14 19:27:47 +0200
commite1d1bb966cca5e1541d5703505cfa83e6ae12ec0 (patch)
treed803e0e891fc6c14ff2a390beeabbe59d0ad8485 /src/lib/Markdown/Heading.tsx
parentd23df805ed5d0e78c604d5c9f81f21bbc6a06288 (diff)
parentef9dfdacf17c62254331140a40a508549aa725b4 (diff)
downloadreact-benzin-4.1.0.tar.gz
Merge pull request #22 from eug-vs/develop4.1.0master
Release 4.1.0
Diffstat (limited to 'src/lib/Markdown/Heading.tsx')
-rw-r--r--src/lib/Markdown/Heading.tsx33
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;
+