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