-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathText.tsx
207 lines (187 loc) · 4.16 KB
/
Text.tsx
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import { css } from "@emotion/react";
import styled from "@emotion/styled";
/*
Fonts:
JetBrains Mono 500 = assets/fonts/JetBrainsMono-Medium.ttf
JetBrains Mono 400 = assets/fonts/JetBrainsMono-Regular.ttf
Space Grotesk 500 = assets/fonts/SpaceGrotesk-Medium.ttf
Space Grotesk 400 = assets/fonts/SpaceGrotesk-Regular.ttf
*/
// Desktop (base)
const H = `
font-family: "JetBrains Mono";
font-size: 18px;
font-style: normal;
font-weight: 500;
line-height: 18px;
`;
const BODY = `
font-family: "JetBrains Mono";
font-size: 12px;
font-style: normal;
font-weight: 400;
line-height: 14px;
letter-spacing: 0.24px;
`;
const BUTTON = `
font-family: "Space Grotesk";
font-size: 14px;
font-style: normal;
font-weight: 500;
line-height: 16px;
`;
const BUTTON_SECONDARY = `
font-family: "Space Grotesk";
font-size: 12px;
font-style: normal;
font-weight: 500;
line-height: 16px;
text-transform: uppercase;
`;
const SUPPORTING = `
font-family: "Space Grotesk";
font-size: 12px;
font-style: normal;
font-weight: 400;
line-height: 12px;
letter-spacing: 0.24px;
`;
const SUPPORTING_NUMBERS = `
font-family: "JetBrains Mono";
font-size: 11px;
font-style: normal;
font-weight: 400;
line-height: 11px;
letter-spacing: 0.22px;
`;
// Desktop (+added)
const H_NUMBERS = `
font-family: "JetBrains Mono";
font-size: 24px;
font-style: normal;
font-weight: 400;
line-height: 32px;
letter-spacing: 0.48px;
`;
const H_TEXT = `
font-family: "Space Grotesk";
font-size: 24px;
font-style: normal;
font-weight: 400;
line-height: 32px;
`;
const BUTTON_BIG = `
font-family: "Space Grotesk";
font-size: 16px;
font-style: normal;
font-weight: 500;
line-height: 24px;
`;
const TEXT_BIG = `
font-family: "Space Grotesk";
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 24px;
`;
const TEXT = `
font-family: "Space Grotesk";
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 16px;
`;
const CP_Header_18_Medium = `
font-family: Chakra Petch;
font-weight: 500;
font-size: 18px;
line-height: 24px;
letter-spacing: 3%;
`;
const CP_Button_14_Medium = `
font-family: Chakra Petch;
font-weight: 500;
font-size: 14px;
line-height: 16px;
letter-spacing: 2%;
`;
const CP_Body_16_Medium = `
font-family: Chakra Petch;
font-weight: 500;
font-size: 14px;
line-height: 16px;
letter-spacing: 2%;
`;
const CP_Support_10 = `
font-family: Chakra Petch;
font-weight: 500;
font-size: 10px;
line-height: 14px;
letter-spacing: 4%;
`;
export const TEXT_TYPES_MAP = {
H,
BODY,
BUTTON,
BUTTON_SECONDARY,
SUPPORTING,
SUPPORTING_NUMBERS,
H_NUMBERS,
H_TEXT,
BUTTON_BIG,
TEXT_BIG,
TEXT,
CP_Header_18_Medium,
CP_Button_14_Medium,
CP_Body_16_Medium,
CP_Support_10,
};
type TEXT_TYPES = keyof typeof TEXT_TYPES_MAP;
interface TextProps {
type?: TEXT_TYPES;
uppercase?: boolean;
primary?: boolean;
secondary?: boolean;
disabled?: boolean;
color?: string;
nowrap?: boolean;
pointer?: boolean;
greenLight?: boolean;
attention?: boolean;
}
const Text = styled.div<TextProps>`
white-space: ${({ nowrap }) => (nowrap ? "nowrap" : "normal")};
${({ attention, primary, secondary, greenLight, disabled, theme, color }) =>
(() => {
switch (true) {
case attention:
return css`
color: ${theme.colors?.attention};
`;
case greenLight:
return css`
color: ${theme.colors?.greenLight};
`;
case primary:
return css`
color: ${theme.colors?.textPrimary};
`;
case secondary:
return css`
color: ${theme.colors?.textSecondary};
`;
case disabled:
return css`
color: ${theme.colors?.textDisabled};
`;
default:
return css`
color: ${color ?? theme.colors?.textSecondary};
`;
}
})()}
${({ type }) => (type ? TEXT_TYPES_MAP[type] : TEXT_TYPES_MAP.BODY)}
${({ uppercase }) => uppercase && "text-transform: uppercase;"}
cursor: ${({ pointer }) => (pointer ? "pointer" : "inherit")}
`;
export default Text;