-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtext.js
186 lines (162 loc) · 3.38 KB
/
text.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import styled, { css } from 'styled-components'
import PropTypes from 'prop-types'
import {
regular as fontRegular,
light as fontLight,
bold as fontBold,
black as fontBlack
} from './fonts'
import { primaryTextColor, gray60 } from './colors'
const bold = props => {
if (props.bold) {
return css`
${fontBlack} letter-spacing: -.025em;
`
}
}
const light = props => {
if (props.light) {
return css`
${fontLight} letter-spacing: -0.01em;
font-weight: regular;
`
}
}
const uppercase = props => {
if (props.uppercase) {
return css`
text-transform: uppercase;
`
}
}
const lowercase = props => {
if (props.lowercase) {
return css`
text-transform: lowercase;
`
}
}
const align = props => {
switch (props.align) {
case 'center': {
return css`
text-align: center;
`
}
case 'right': {
return css`
text-align: right;
`
}
case 'justify': {
return css`
text-align: justify;
`
}
default:
case 'left': {
return css`
text-align: left;
`
}
}
}
const color = ({ theme, color }) => {
return css`
color: ${theme.color[color]};
`
}
export const TextBase = css`
${uppercase}
${lowercase}
${bold}
${light}
${align}
${color}
`
const HBase = css`
line-height: 1;
${fontBlack} letter-spacing: -.025em;
color: ${primaryTextColor};
${TextBase} margin: 0;
`
const basePropTypes = {
/** Boolean to make bold */
bold: PropTypes.bool,
/** Boolean to make light */
light: PropTypes.bool,
/** Boolean to make uppercase */
uppercase: PropTypes.bool,
/** Boolean to make lowercase */
lowercase: PropTypes.bool,
/** Boolean to align the text */
align: PropTypes.oneOf(['left', 'right', 'center', 'justify']),
/** String to change color of letters */
color: PropTypes.string
}
const baseDefaultProps = {
bold: false,
light: false,
uppercase: false,
lowercase: false,
align: 'left'
}
export const Span = styled.span`
font-size: 1.1rem;
${fontLight} ${TextBase};
`
Span.displayName = 'Span'
Span.propTypes = basePropTypes
Span.defaultProps = baseDefaultProps
export const H1 = styled.h1`
${HBase} font-size: 3.125rem;
`
H1.displayName = 'H1'
H1.propTypes = basePropTypes
H1.defaultProps = baseDefaultProps
export const H2 = styled.h2`
${HBase} font-size: 1.563rem;
`
H2.displayName = 'H2'
H2.propTypes = basePropTypes
H2.defaultProps = baseDefaultProps
export const H3 = styled.h3`
${HBase} font-size: 1.031rem;
line-height: 1.5;
`
H3.displayName = 'H3'
H3.propTypes = basePropTypes
H3.defaultProps = baseDefaultProps
export const H4 = styled.h4`
${HBase} font-size: 0.8rem;
`
H4.displayName = 'H4'
H4.propTypes = basePropTypes
H4.defaultProps = baseDefaultProps
export const H5 = styled.h5`
${HBase} font-size: 0.8rem;
`
H5.displayName = 'H5'
H5.propTypes = basePropTypes
H5.defaultProps = baseDefaultProps
export const P = styled.p`
font-size: 1.031rem;
line-height: 1.5;
letter-spacing: -0.01em;
${fontLight} ${TextBase};
`
P.displayName = 'P'
P.propTypes = basePropTypes
P.defaultProps = baseDefaultProps
export const Time = styled.time`
font-size: 0.8rem;
${fontBold} margin-bottom: 1em;
display: inline-block;
${TextBase};
`
Time.displayName = 'Time'
Time.propTypes = basePropTypes
Time.defaultProps = baseDefaultProps
export const Hr = styled.hr`
margin: 20px 0;
`