-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
uno.config.ts
277 lines (266 loc) · 8.68 KB
/
uno.config.ts
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
import { globSync } from 'fast-glob';
import fs from 'node:fs/promises';
import { basename } from 'node:path';
import { defineConfig, presetIcons, presetUno, transformerDirectives } from 'unocss';
const iconPaths = globSync('./icons/*.svg');
const collectionName = 'bolt';
const customIconCollection = iconPaths.reduce(
(acc, iconPath) => {
const [iconName] = basename(iconPath).split('.');
acc[collectionName] ??= {};
acc[collectionName][iconName] = async () => fs.readFile(iconPath, 'utf8');
return acc;
},
{} as Record<string, Record<string, () => Promise<string>>>,
);
const BASE_COLORS = {
white: '#FFFFFF',
gray: {
50: '#FAFAFA',
100: '#F5F5F5',
200: '#E5E5E5',
300: '#D4D4D4',
400: '#A3A3A3',
500: '#737373',
600: '#525252',
700: '#404040',
800: '#262626',
900: '#171717',
950: '#0A0A0A',
},
accent: {
50: '#EEF9FF',
100: '#D8F1FF',
200: '#BAE7FF',
300: '#8ADAFF',
400: '#53C4FF',
500: '#2BA6FF',
600: '#1488FC',
700: '#0D6FE8',
800: '#1259BB',
900: '#154E93',
950: '#122F59',
},
green: {
50: '#F0FDF4',
100: '#DCFCE7',
200: '#BBF7D0',
300: '#86EFAC',
400: '#4ADE80',
500: '#22C55E',
600: '#16A34A',
700: '#15803D',
800: '#166534',
900: '#14532D',
950: '#052E16',
},
orange: {
50: '#FFFAEB',
100: '#FEEFC7',
200: '#FEDF89',
300: '#FEC84B',
400: '#FDB022',
500: '#F79009',
600: '#DC6803',
700: '#B54708',
800: '#93370D',
900: '#792E0D',
},
red: {
50: '#FEF2F2',
100: '#FEE2E2',
200: '#FECACA',
300: '#FCA5A5',
400: '#F87171',
500: '#EF4444',
600: '#DC2626',
700: '#B91C1C',
800: '#991B1B',
900: '#7F1D1D',
950: '#450A0A',
},
};
const COLOR_PRIMITIVES = {
...BASE_COLORS,
alpha: {
white: generateAlphaPalette(BASE_COLORS.white),
gray: generateAlphaPalette(BASE_COLORS.gray[900]),
red: generateAlphaPalette(BASE_COLORS.red[500]),
accent: generateAlphaPalette(BASE_COLORS.accent[500]),
},
};
export default defineConfig({
shortcuts: {
'bolt-ease-cubic-bezier': 'ease-[cubic-bezier(0.4,0,0.2,1)]',
'transition-theme': 'transition-[background-color,border-color,color] duration-150 bolt-ease-cubic-bezier',
kdb: 'bg-bolt-elements-code-background text-bolt-elements-code-text py-1 px-1.5 rounded-md',
'max-w-chat': 'max-w-[var(--chat-max-width)]',
},
rules: [
/**
* This shorthand doesn't exist in Tailwind and we overwrite it to avoid
* any conflicts with minified CSS classes.
*/
['b', {}],
],
theme: {
colors: {
...COLOR_PRIMITIVES,
bolt: {
elements: {
borderColor: 'var(--bolt-elements-borderColor)',
borderColorActive: 'var(--bolt-elements-borderColorActive)',
background: {
depth: {
1: 'var(--bolt-elements-bg-depth-1)',
2: 'var(--bolt-elements-bg-depth-2)',
3: 'var(--bolt-elements-bg-depth-3)',
4: 'var(--bolt-elements-bg-depth-4)',
},
},
textPrimary: 'var(--bolt-elements-textPrimary)',
textSecondary: 'var(--bolt-elements-textSecondary)',
textTertiary: 'var(--bolt-elements-textTertiary)',
code: {
background: 'var(--bolt-elements-code-background)',
text: 'var(--bolt-elements-code-text)',
},
button: {
primary: {
background: 'var(--bolt-elements-button-primary-background)',
backgroundHover: 'var(--bolt-elements-button-primary-backgroundHover)',
text: 'var(--bolt-elements-button-primary-text)',
},
secondary: {
background: 'var(--bolt-elements-button-secondary-background)',
backgroundHover: 'var(--bolt-elements-button-secondary-backgroundHover)',
text: 'var(--bolt-elements-button-secondary-text)',
},
danger: {
background: 'var(--bolt-elements-button-danger-background)',
backgroundHover: 'var(--bolt-elements-button-danger-backgroundHover)',
text: 'var(--bolt-elements-button-danger-text)',
},
},
item: {
contentDefault: 'var(--bolt-elements-item-contentDefault)',
contentActive: 'var(--bolt-elements-item-contentActive)',
contentAccent: 'var(--bolt-elements-item-contentAccent)',
contentDanger: 'var(--bolt-elements-item-contentDanger)',
backgroundDefault: 'var(--bolt-elements-item-backgroundDefault)',
backgroundActive: 'var(--bolt-elements-item-backgroundActive)',
backgroundAccent: 'var(--bolt-elements-item-backgroundAccent)',
backgroundDanger: 'var(--bolt-elements-item-backgroundDanger)',
},
actions: {
background: 'var(--bolt-elements-actions-background)',
code: {
background: 'var(--bolt-elements-actions-code-background)',
},
},
artifacts: {
background: 'var(--bolt-elements-artifacts-background)',
backgroundHover: 'var(--bolt-elements-artifacts-backgroundHover)',
borderColor: 'var(--bolt-elements-artifacts-borderColor)',
inlineCode: {
background: 'var(--bolt-elements-artifacts-inlineCode-background)',
text: 'var(--bolt-elements-artifacts-inlineCode-text)',
},
},
messages: {
background: 'var(--bolt-elements-messages-background)',
linkColor: 'var(--bolt-elements-messages-linkColor)',
code: {
background: 'var(--bolt-elements-messages-code-background)',
},
inlineCode: {
background: 'var(--bolt-elements-messages-inlineCode-background)',
text: 'var(--bolt-elements-messages-inlineCode-text)',
},
},
icon: {
success: 'var(--bolt-elements-icon-success)',
error: 'var(--bolt-elements-icon-error)',
primary: 'var(--bolt-elements-icon-primary)',
secondary: 'var(--bolt-elements-icon-secondary)',
tertiary: 'var(--bolt-elements-icon-tertiary)',
},
preview: {
addressBar: {
background: 'var(--bolt-elements-preview-addressBar-background)',
backgroundHover: 'var(--bolt-elements-preview-addressBar-backgroundHover)',
backgroundActive: 'var(--bolt-elements-preview-addressBar-backgroundActive)',
text: 'var(--bolt-elements-preview-addressBar-text)',
textActive: 'var(--bolt-elements-preview-addressBar-textActive)',
},
},
terminals: {
background: 'var(--bolt-elements-terminals-background)',
buttonBackground: 'var(--bolt-elements-terminals-buttonBackground)',
},
dividerColor: 'var(--bolt-elements-dividerColor)',
loader: {
background: 'var(--bolt-elements-loader-background)',
progress: 'var(--bolt-elements-loader-progress)',
},
prompt: {
background: 'var(--bolt-elements-prompt-background)',
},
sidebar: {
dropdownShadow: 'var(--bolt-elements-sidebar-dropdownShadow)',
buttonBackgroundDefault: 'var(--bolt-elements-sidebar-buttonBackgroundDefault)',
buttonBackgroundHover: 'var(--bolt-elements-sidebar-buttonBackgroundHover)',
buttonText: 'var(--bolt-elements-sidebar-buttonText)',
},
cta: {
background: 'var(--bolt-elements-cta-background)',
text: 'var(--bolt-elements-cta-text)',
},
},
},
},
},
transformers: [transformerDirectives()],
presets: [
presetUno({
dark: {
light: '[data-theme="light"]',
dark: '[data-theme="dark"]',
},
}),
presetIcons({
warn: true,
collections: {
...customIconCollection,
},
}),
],
});
/**
* Generates an alpha palette for a given hex color.
*
* @param hex - The hex color code (without alpha) to generate the palette from.
* @returns An object where keys are opacity percentages and values are hex colors with alpha.
*
* Example:
*
* ```
* {
* '1': '#FFFFFF03',
* '2': '#FFFFFF05',
* '3': '#FFFFFF08',
* }
* ```
*/
function generateAlphaPalette(hex: string) {
return [1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100].reduce(
(acc, opacity) => {
const alpha = Math.round((opacity / 100) * 255)
.toString(16)
.padStart(2, '0');
acc[opacity] = `${hex}${alpha}`;
return acc;
},
{} as Record<number, string>,
);
}