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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
import classnames from 'classnames';
import {
Component,
createElement,
MouseEventHandler,
ReactElement,
ReactNode,
} from 'react';
import injectStyle, { WithStylesProps } from 'react-jss';
import { Theme } from '../../../themes';
import { Omit } from '../typings/generic';
interface IProps extends WithStylesProps<typeof styles> {
children: ReactNode;
level?: number;
className?: string;
id?: string;
onClick?: MouseEventHandler<HTMLButtonElement>;
}
const styles = (theme: Theme) => ({
headline: {
fontWeight: 'lighter',
color: theme.colorText,
marginTop: 0,
marginBottom: 10,
textAlign: 'left',
},
h1: {
fontSize: theme.uiFontSize + 3,
marginTop: 0,
},
h2: {
fontSize: theme.uiFontSize + 2,
},
h3: {
fontSize: theme.uiFontSize + 1,
},
h4: {
fontSize: theme.uiFontSize,
},
h5: {
fontSize: theme.uiFontSize - 1,
},
});
class HeadlineComponent extends Component<IProps> {
render(): ReactElement {
const { classes, level, className, children, id, onClick } = this.props;
return createElement(
`h${level}`,
{
id,
className: classnames({
[classes.headline]: true,
[classes[level ? `h${level}` : 'h1']]: true,
[`${className}`]: className,
}),
'data-type': 'franz-headline',
onClick,
},
children,
);
}
}
const Headline = injectStyle(styles, { injectTheme: true })(HeadlineComponent);
const createH = (level: number) => (props: Omit<IProps, 'classes'>) =>
(
<Headline level={level} {...props}>
{props.children}
</Headline>
);
export const H1 = createH(1);
export const H2 = createH(2);
export const H3 = createH(3);
export const H4 = createH(4);
export const H5 = createH(5);
|