-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathHeadline.js
79 lines (73 loc) · 1.6 KB
/
Headline.js
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
/**
* Component: Headline
*/
import React, { forwardRef } from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import css from './Headline.css';
const Headline = forwardRef((
{
size = 'medium',
margin = '', // If nothing is set it will default to the value of size
tag: Element = 'div',
faded = false,
flex,
block,
children,
className,
weight = 'bold',
...rest },
ref
) => {
const classes = classNames(
// Base styling
css.headline,
// Size
css[`size-${size}`],
// Margin
css[`margin-${margin || size}`],
// Faded
{ [css.isFaded]: faded },
// Define font-weight
{ [css[`font-weight-${weight}`]]: weight },
// Display: flex
{ [css.flex]: flex },
// Display: block
{ [css.block]: block },
// Customize with className
className,
);
return (
<Element
{...rest}
ref={ref}
className={classes}
data-test-headline
>
{children}
</Element>
);
});
Headline.propTypes = {
block: PropTypes.bool,
children: PropTypes.node,
className: PropTypes.string,
faded: PropTypes.bool,
flex: PropTypes.bool,
margin: PropTypes.oneOf([
'xx-small',
'x-small',
'small',
'medium',
'large',
'x-large',
'xx-large',
'none',
''
]),
size: PropTypes.oneOf(['small', 'medium', 'large', 'x-large', 'xx-large']),
tag: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'div', 'legend']),
weight: PropTypes.oneOf(['regular', 'medium', 'bold', 'black']),
};
Headline.displayName = 'Headline';
export default Headline;