blob: cc0b709ada509a4946b0d7f39c83c7e6ca6b2056 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
|