aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/headline/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/ui/headline/index.tsx')
-rw-r--r--src/components/ui/headline/index.tsx70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/components/ui/headline/index.tsx b/src/components/ui/headline/index.tsx
new file mode 100644
index 000000000..3a3654f02
--- /dev/null
+++ b/src/components/ui/headline/index.tsx
@@ -0,0 +1,70 @@
1import classnames from 'classnames';
2import { Component, createElement, ReactNode } from 'react';
3import injectStyle from 'react-jss';
4
5import { Theme } from '@meetfranz/theme';
6import { IWithStyle, Omit } from '../typings/generic';
7
8interface IProps extends IWithStyle {
9 level?: number;
10 className?: string;
11 children: string | ReactNode;
12 id?: string;
13}
14
15const styles = (theme: Theme) => ({
16 headline: {
17 fontWeight: 'lighter',
18 color: theme.colorText,
19 marginTop: 0,
20 marginBottom: 10,
21 textAlign: 'left',
22 },
23 h1: {
24 fontSize: 30,
25 marginTop: 0,
26 },
27 h2: {
28 fontSize: 20,
29 },
30 h3: {
31 fontSize: 18,
32 },
33 h4: {
34 fontSize: theme.uiFontSize,
35 },
36});
37
38class HeadlineComponent extends Component<IProps> {
39 render() {
40 const { classes, level, className, children, id } = this.props;
41
42 return createElement(
43 `h${level}`,
44 {
45 id,
46 className: classnames({
47 [classes.headline]: true,
48 [classes[level ? `h${level}` : 'h1']]: true,
49 [`${className}`]: className,
50 }),
51 'data-type': 'franz-headline',
52 },
53 children,
54 );
55 }
56}
57
58const Headline = injectStyle(styles)(HeadlineComponent);
59
60const createH = (level: number) => (props: Omit<IProps, 'classes' | 'theme'>) =>
61 (
62 <Headline level={level} {...props}>
63 {props.children}
64 </Headline>
65 );
66
67export const H1 = createH(1);
68export const H2 = createH(2);
69export const H3 = createH(3);
70export const H4 = createH(4);