-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathglobal-css.ts
More file actions
126 lines (118 loc) · 4.07 KB
/
global-css.ts
File metadata and controls
126 lines (118 loc) · 4.07 KB
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
/* eslint-disable prettier/prettier */
// Prettier has been disabled due to a weird bug with the code on line 44
import { reset, debug } from 'styled-components-style-utils';
import { css, createGlobalStyle } from 'styled-components';
import theme, {Typography} from './theme';
import textScaler from './textScaler';
const typographyElements = [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'p',
'li',
'ul',
'body',
];
const typographyClasses = [
'introduction',
'caption',
'subtitle',
'button',
'menuitem',
'form',
];
const addStylingExceptions = (element: string) => {
switch (element) {
case 'subtitle':
return 'text-transform: uppercase;';
case 'button':
return 'text-decoration: none;';
default:
return '';
}
};
const typographyElementStyling = typographyElements.map(
(element) => css`
${element} {
font-size: ${theme.typography[element as keyof Typography].size};
line-height: ${theme.typography[element as keyof Typography].height};
letter-spacing: ${theme.typography[element as keyof Typography].spacing};
font-family: ${theme.typography[element as keyof Typography].font};
font-weight: ${theme.typography[element as keyof Typography].weight};
color: ${theme.typography[element as keyof Typography].color};
margin-top: ${theme.typography[element as keyof Typography].marginTop};
margin-bottom: ${theme.typography[element as keyof Typography].marginBottom};
margin-left: ${theme.typography[element as keyof Typography].marginLeft};
margin-right: ${theme.typography[element as keyof Typography].marginRight};
${addStylingExceptions(element)};
}
`,
);
export const TypographyClassStyling = createGlobalStyle`
${typographyClasses
.map(
(element) => `.${element} {
font-size: ${theme.typography[element as keyof Typography].size};
line-height: ${theme.typography[element as keyof Typography].height};
letter-spacing: ${theme.typography[element as keyof Typography].spacing};
font-family: ${theme.typography[element as keyof Typography].font};
font-weight: ${theme.typography[element as keyof Typography].weight};
color: ${theme.typography[element as keyof Typography].color};
margin:
${theme.typography[element as keyof Typography].marginTop};
${theme.typography[element as keyof Typography].marginRight};
${theme.typography[element as keyof Typography].marginBottom};
${theme.typography[element as keyof Typography].marginLeft};
${addStylingExceptions(element)};
}`,
)
.join('\n')}
`;
const enableCssReset = false;
const GlobalStyles = createGlobalStyle`
${reset()}
${enableCssReset ? debug() : ''}
html { font-size: 1em; background: ${theme.colors.background} }
a { color: ${theme.colors.primary}; text-decoration: none }
img { width: 100%; height: auto; margin:0; padding: 0}
${typographyElementStyling}
body { overflow-x: hidden; }
textarea { resize: vertical; }
::selection {
background: ${theme.colors.tertiary};
color: ${theme.colors.white}
}
strong { font-weight: 700; }
em { font-style: italic; }
${textScaler}
ul { list-style: circle};
ol {
list-style: decimal;
padding-left: 1rem;
};
blockquote {
margin-left: 10%;
font-style: italic;
position: relative;
::before {
content: '‘‘';
color: ${theme.colors.primary};
font-size: 60px;
position: absolute;
top: 10px;
left: -30px;
letter-spacing: -4px;
font-family: "Times New Roman", Times, serif;
}
}
code { font-family: monospace; }
pre {
white-space: pre-wrap;
font-size: 80%;
}
hr { margin: 42px 0; }
`;
export { GlobalStyles };