-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtailwind.config.ts
More file actions
222 lines (209 loc) · 6.1 KB
/
Copy pathtailwind.config.ts
File metadata and controls
222 lines (209 loc) · 6.1 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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import type { Config } from "tailwindcss"
import plugin from "tailwindcss/plugin"
import drxkicuiConfig from "./drxkicui.config"
import { generateCssColorVars } from "./src/utils/generateCssColorVars"
import { generateRadixColors } from "./src/utils/generateRadixColors"
import { generateCssVarMapping } from "./src/utils/generateAccentCssVarMapping"
const { base, lightBackground, darkBackground, colors } = drxkicuiConfig
interface GeneratedCssColorResults {
default: object
wideGamut: object
}
export const cssColorVars = Object.entries(colors).reduce(
(accumulator, currentValue) => {
const [name, hex] = currentValue
const lightRadixColors = generateRadixColors({
appearance: "light",
accent: hex,
gray: base,
background: lightBackground,
})
const darkRadixColors = generateRadixColors({
appearance: "dark",
accent: hex,
gray: base,
background: darkBackground,
})
return {
...accumulator,
[name]: {
light: generateCssColorVars({
name: name,
scale: lightRadixColors.accentScale,
alphaScale: lightRadixColors.accentScaleAlpha,
scaleWideGamut: lightRadixColors.accentScaleWideGamut,
alphaScaleWideGamut:
lightRadixColors.accentScaleAlphaWideGamut,
contrast: lightRadixColors.accentContrast,
surface: lightRadixColors.accentSurface,
surfaceWideGamut: lightRadixColors.accentSurfaceWideGamut,
}),
dark: generateCssColorVars({
name: name,
scale: darkRadixColors.accentScale,
alphaScale: darkRadixColors.accentScaleAlpha,
scaleWideGamut: darkRadixColors.accentScaleWideGamut,
alphaScaleWideGamut:
darkRadixColors.accentScaleAlphaWideGamut,
contrast: darkRadixColors.accentContrast,
surface: darkRadixColors.accentSurface,
surfaceWideGamut: darkRadixColors.accentSurfaceWideGamut,
}),
accentMapping: generateCssVarMapping("accent", name),
},
}
},
{} as Record<
string,
{
light: GeneratedCssColorResults
dark: GeneratedCssColorResults
accentMapping: object
}
>,
)
const lightRadixColors = generateRadixColors({
appearance: "light",
accent: base,
gray: base,
background: lightBackground,
})
const lightBaseCssColorVars = generateCssColorVars({
name: "base",
scale: lightRadixColors.grayScale,
alphaScale: lightRadixColors.grayScaleAlpha,
scaleWideGamut: lightRadixColors.grayScaleWideGamut,
alphaScaleWideGamut: lightRadixColors.grayScaleAlphaWideGamut,
contrast: "#FFFFFF",
surface: lightRadixColors.graySurface,
surfaceWideGamut: lightRadixColors.graySurfaceWideGamut,
})
const darkRadixColors = generateRadixColors({
appearance: "dark",
accent: base,
gray: base,
background: darkBackground,
})
const darkBaseCssColorVars = generateCssColorVars({
name: "base",
scale: darkRadixColors.grayScale,
alphaScale: darkRadixColors.grayScaleAlpha,
scaleWideGamut: darkRadixColors.grayScaleWideGamut,
alphaScaleWideGamut: darkRadixColors.grayScaleAlphaWideGamut,
contrast: "#FFFFFF",
surface: darkRadixColors.graySurface,
surfaceWideGamut: darkRadixColors.graySurfaceWideGamut,
})
export const cssVarMappings = Object.entries(cssColorVars).reduce(
(accumulator, [name, cssColorVars]) => {
return {
...accumulator,
[`[data-accent-color="${name}"]`]: cssColorVars.accentMapping,
}
},
{},
)
export default {
content: ["./src/**/*.{js,ts,jsx,tsx}"],
darkMode: ["class", '[data-mode="dark"]'],
theme: {
extend: {
spacing: {
"0.25": "0.0625rem",
},
boxShadow: {
"light-1": `inset 0 1.5px 2px 0 var(--black-a2),
inset 0 1.5px 2px 0 var(--black-a2)`,
"light-2": `0 0 0 0.5px var(--black-a1),
0 1px 1px 0 var(--black-a2),
0 2px 1px -1px var(--black-a1),
0 1px 3px 0 var(--black-a1)`,
"light-3": `0 2px 3px -2px var(--black-a3),
0 3px 12px -4px var(--black-a2),
0 4px 16px -8px var(--black-a2)`,
"light-4": `0 8px 40px var(--black-a1),
0 12px 32px -16px var(--black-a3)`,
"light-5": `0 12px 60px var(--black-a3),
0 12px 32px -16px var(--black-a5)`,
"dark-1": `inset 0 -1px 1px 0 var(--black-a3),
inset 0 0 0 1px var(--black-a3),
inset 0 3px 4px 0 var(--black-a5)`,
"dark-2": `
0 0 0 0.5px var(--black-a3),
0 1px 1px 0 var(--black-a6),
0 2px 1px -1px var(--black-a6),
0 1px 3px 0 var(--black-a5)`,
"dark-3": `
0 2px 3px -2px var(--black-a3),
0 4px 8px -2px var(--black-a5),
0 4px 12px -4px var(--black-a7)`,
"dark-4": `
0 8px 40px var(--black-a5),
0 8px 24px -12px var(--black-a7)`,
"dark-5": `
0 12px 60px var(--black-a5),
0 12px 32px -16px var(--black-a7)`,
},
},
},
plugins: [
plugin(function ({ addBase }) {
addBase({
':root[data-mode="light"]': Object.values(cssColorVars).reduce(
(accumulator, cssColorVars) => ({
...accumulator,
...cssColorVars.light.default,
}),
{
...lightBaseCssColorVars.default,
"--color-background": lightRadixColors.background,
},
),
':root[data-mode="dark"]': Object.values(cssColorVars).reduce(
(accumulator, cssColorVars) => ({
...accumulator,
...cssColorVars.dark.default,
}),
{
...darkBaseCssColorVars.default,
"--color-background": darkRadixColors.background,
},
),
"@supports (color: color(display-p3 1 1 1))": {
"@media (color-gamut: p3)": {
':root[data-mode="light"]': Object.values(
cssColorVars,
).reduce(
(accumulator, cssColorVars) => ({
...accumulator,
...cssColorVars.light.wideGamut,
}),
{
...lightBaseCssColorVars.wideGamut,
"--color-background":
lightRadixColors.background,
},
),
':root[data-mode="dark"]': Object.values(
cssColorVars,
).reduce(
(accumulator, cssColorVars) => ({
...accumulator,
...cssColorVars.dark.wideGamut,
}),
{
...darkBaseCssColorVars.wideGamut,
"--color-background":
darkRadixColors.background,
},
),
},
},
...cssVarMappings,
":root": {
...cssVarMappings,
},
})
}),
],
} satisfies Config