-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtailwind.config.js
164 lines (147 loc) · 5.19 KB
/
tailwind.config.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
import plugin from 'tailwindcss/plugin'
function withOpacityValue(variable) {
return ({ opacityValue }) => {
if (opacityValue === undefined) {
return `hsl(var(${variable}) / 1)`
}
return `hsl(var(${variable}) / ${opacityValue})`
}
}
function hexToHSL(hex) {
let r = parseInt(hex.slice(1, 3), 16) / 255;
let g = parseInt(hex.slice(3, 5), 16) / 255;
let b = parseInt(hex.slice(5, 7), 16) / 255;
let max = Math.max(r, g, b), min = Math.min(r, g, b);
let h, s, l = (max + min) / 2;
if (max === min) {
h = s = 0; // achromatic
} else {
let d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
case g: h = (b - r) / d + 2; break;
case b: h = (r - g) / d + 4; break;
}
h /= 6;
}
return `${Math.round(h * 360)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%`;
}
export default {
content: ['./src/**/*.{html,js,svelte,ts}'],
darkMode: 'class',
theme: {
extend: {
fontFamily: {
// Sets the font-display, font-content, and font-handwriting
'display': ['var(--font-display)', 'serif'],
'content': ['var(--font-content)', 'sans-serif'],
'handwriting': ['var(--font-handwriting)', 'cursive'],
},
fontWeight: {
// Sets the weights for the fonts
'display': ['var(--font-display-weight)',],
'content': ['var(--font-content-weight)',],
'handwriting': ['var(--font-handwriting-weight)',],
},
fontSize: {
// Defines extra font sizes
'xs': '0.56rem',
'sm': '0.75rem',
'base': '1rem',
'lg': '1.33rem',
'xl': '1.78rem',
'2xl': '2.37rem',
'3xl': '3.16rem',
'4xl': '4.21rem',
'5xl': '5.61rem',
'6xl': '7.48rem',
'7xl': '9.97rem',
},
colors: {
// Enables the use of text-primary, bg-primary, etc.
primary: withOpacityValue('--primary'),
secondary: withOpacityValue('--secondary'),
background: withOpacityValue('--background'),
text: withOpacityValue('--text'),
},
textColor: {
primary: withOpacityValue('--primary'),
secondary: withOpacityValue('--secondary'),
background: withOpacityValue('--background'),
text: withOpacityValue('--text'),
},
backgroundColor: {
primary: withOpacityValue('--primary'),
secondary: withOpacityValue('--secondary'),
background: withOpacityValue('--background'),
text: withOpacityValue('--text'),
},
borderColor: {
primary: withOpacityValue('--primary'),
secondary: withOpacityValue('--secondary'),
background: withOpacityValue('--background'),
text: withOpacityValue('--text'),
},
// Add theme-specific variables
themeVariables: {
default: {
// Defines the fonts in use by font-display, font-content, and font-handwriting
'font-display': 'Lexend',
'font-content': 'Lexend',
'font-handwriting': 'Dawning of a New Day',
light: {
// Defines the variables in use by text-primary, bg-primary, etc.
'primary': '#145362',
'secondary': '#ffebd0',
'background': '#fefcfb',
'text': '#333333',
// Defines the weights in use by font-display, font-content, and font-handwriting
'font-display-weight': '500',
'font-content-weight': '400',
'font-handwriting-weight': '400',
},
dark: {
'primary': '#84a98c',
'secondary': '#34D399',
'background': '#2f3e46',
'text': '#fefcfb',
'font-display-weight': '500',
'font-content-weight': '400',
'font-handwriting-weight': '400',
},
},
}
}
},
plugins: [
plugin(function ({ addBase, theme }) {
addBase({
':root': {
'--primary': hexToHSL(theme('themeVariables.default.light.primary')),
'--secondary': hexToHSL(theme('themeVariables.default.light.secondary')),
'--background': hexToHSL(theme('themeVariables.default.light.background')),
'--text': hexToHSL(theme('themeVariables.default.light.text')),
'--font-display': theme('themeVariables.default.font-display'),
'--font-content': theme('themeVariables.default.font-content'),
'--font-handwriting': theme('themeVariables.default.font-handwriting'),
'--font-display-weight': theme('themeVariables.default.light.font-display-weight'),
'--font-content-weight': theme('themeVariables.default.light.font-content-weight'),
'--font-handwriting-weight': theme('themeVariables.default.light.font-handwriting-weight'),
},
'.dark': {
'--primary': hexToHSL(theme('themeVariables.default.dark.primary')),
'--secondary': hexToHSL(theme('themeVariables.default.dark.secondary')),
'--background': hexToHSL(theme('themeVariables.default.dark.background')),
'--text': hexToHSL(theme('themeVariables.default.dark.text')),
'--font-display': theme('themeVariables.default.font-display'),
'--font-content': theme('themeVariables.default.font-content'),
'--font-handwriting': theme('themeVariables.default.font-handwriting'),
'--font-display-weight': theme('themeVariables.default.dark.font-display-weight'),
'--font-content-weight': theme('themeVariables.default.dark.font-content-weight'),
'--font-handwriting-weight': theme('themeVariables.default.dark.font-handwriting-weight'),
},
})
})
]
};