vunor 0.1.6 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -86
- package/dist/AppToasts.d.mts +1 -1
- package/dist/ButtonBase.d.mts +1 -1
- package/dist/ButtonBase.mjs +1 -1
- package/dist/CardHeader.mjs +2 -2
- package/dist/Combobox.d.mts +32 -32
- package/dist/Combobox.mjs +1 -1
- package/dist/DatePicker.d.mts +3 -3
- package/dist/DatePickerBase.d.mts +2 -2
- package/dist/DatePickerBase.mjs +1 -1
- package/dist/DevTools.mjs +30 -6
- package/dist/Input.d.mts +1 -1
- package/dist/InputBase.mjs +1 -1
- package/dist/Pagination.mjs +5 -5
- package/dist/Select.mjs +1 -1
- package/dist/SelectBase.d.mts +2 -2
- package/dist/theme.d.mts +3 -4
- package/dist/theme.mjs +1073 -1013
- package/package.json +1 -1
package/dist/theme.mjs
CHANGED
|
@@ -29,32 +29,6 @@ const toastShortcuts = defineShortcuts({
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
//#endregion
|
|
32
|
-
//#region src/components/Button/shortcuts.ts
|
|
33
|
-
const buttonShortcuts = defineShortcuts({
|
|
34
|
-
"btn": {
|
|
35
|
-
"": "h-fingertip flex items-center justify-center px-$m gap-$xs select-none fw-bold tracking-wide relative",
|
|
36
|
-
"[&.btn-round]:": "px-fingertip-half rounded-fingertip-half",
|
|
37
|
-
"[&.btn-square]:": "size-fingertip px-0",
|
|
38
|
-
"[&.btn-round.btn-square]:": "px-0",
|
|
39
|
-
"disabled:": "opacity-80 cursor-not-allowed",
|
|
40
|
-
"[&>span]:data-[loading]:": "opacity-0 pointer-events-none",
|
|
41
|
-
"[&>div:not(.loading-indicator-wrapper)]:data-[loading]:": "opacity-0 pointer-events-none",
|
|
42
|
-
"[&>.loading-indicator-wrapper]:": "absolute left-0 top-0 right-0 bottom-0 flex items-center justify-center cursor-wait"
|
|
43
|
-
},
|
|
44
|
-
"btn-square": { "": "" },
|
|
45
|
-
"btn-label": {
|
|
46
|
-
"": "lh-1em ellipsis whitespace-nowrap overflow-x-clip overflow-y-visible",
|
|
47
|
-
"group-[.btn-square]/btn:": "hidden"
|
|
48
|
-
},
|
|
49
|
-
"btn-icon": {
|
|
50
|
-
"": "size-1em font-size-1.25em",
|
|
51
|
-
"group-[.btn-round]/btn:[&.btn-icon-left]:": "ml-[-0.5em]",
|
|
52
|
-
"group-[.btn-round]/btn:[&.btn-icon-right]:": "mr-[-0.5em]",
|
|
53
|
-
"group-[.btn-square]/btn:": "font-size-1.5em m-0!",
|
|
54
|
-
"group-[.btn-round.btn-square]/btn:": "m-0!"
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
//#endregion
|
|
58
32
|
//#region src/components/Calendar/shortcuts.ts
|
|
59
33
|
const calendarShortcuts = defineShortcuts({
|
|
60
34
|
"calendar-root": "inline-block",
|
|
@@ -62,9 +36,8 @@ const calendarShortcuts = defineShortcuts({
|
|
|
62
36
|
"calendar-grid-row": "grid grid-cols-7 text-body-s",
|
|
63
37
|
"calendar-month-grid": "flex flex-col gap-$m sm:flex-row flex-wrap sm:gap-$m",
|
|
64
38
|
"calendar-cell": {
|
|
65
|
-
"": "c8-flat relative flex items-center justify-center lh-1em rounded-r0 whitespace-nowrap font-normal size-3em outline-none",
|
|
39
|
+
"": "disabled-soft c8-flat relative flex items-center justify-center lh-1em rounded-r0 whitespace-nowrap font-normal size-3em outline-none",
|
|
66
40
|
"focus-visible:": "shadow-[0_0_0_2px] shadow-black",
|
|
67
|
-
"data-[disabled]:": "opacity-30",
|
|
68
41
|
"data-[unavailable]:": "pointer-events-none opacity-50 line-through",
|
|
69
42
|
"before:": "absolute bottom-[0.6em] w-[1.5em] h-[2px] bg-scope-color-500/75 block",
|
|
70
43
|
"[&[data-today]::before]:": "content-['']",
|
|
@@ -103,9 +76,9 @@ const cardShortcuts = defineShortcuts({ card: `data-[rounded=true]:rounded-$card
|
|
|
103
76
|
//#region src/components/Checkbox/shortcuts.ts
|
|
104
77
|
const checkboxShortcuts = defineShortcuts({
|
|
105
78
|
"checkbox-root": {
|
|
106
|
-
"": "text-body select-none flex gap-$m cursor-default current-bg-scope-color-500 current-border-scope-color-500",
|
|
79
|
+
"": "disabled-soft text-body select-none flex gap-$m cursor-default current-bg-scope-color-500 current-border-scope-color-500",
|
|
107
80
|
"data-[error=true]:": "current-border-error-500",
|
|
108
|
-
"aria-[disabled=true]:": "scope-grey
|
|
81
|
+
"aria-[disabled=true]:": "scope-grey"
|
|
109
82
|
},
|
|
110
83
|
"checkbox": {
|
|
111
84
|
"": "cursor-default shrink-0 select-none rounded-r0 transition-all transition-duration-100 flex size-1.5em appearance-none items-center justify-center bg-current/0 border-current border-[0.16em] current-icon-white",
|
|
@@ -156,12 +129,6 @@ const loadingShortcuts = defineShortcuts({
|
|
|
156
129
|
"inner-loading": "bg-white/50 dark:bg-black/50 flex items-center justify-center absolute left-0 top-0 right-0 bottom-0 z-5 cursor-wait"
|
|
157
130
|
});
|
|
158
131
|
//#endregion
|
|
159
|
-
//#region src/components/Menu/shortcuts.ts
|
|
160
|
-
const menuShortcuts = defineShortcuts({
|
|
161
|
-
"menu-root": "flex flex-col overflow-hidden",
|
|
162
|
-
"menu-item": "justify-start c8-flat gap-$m w-full fw-400"
|
|
163
|
-
});
|
|
164
|
-
//#endregion
|
|
165
132
|
//#region src/components/ProgressBar/shortcuts.ts
|
|
166
133
|
const progressShortcuts = defineShortcuts({
|
|
167
134
|
"progress-track": {
|
|
@@ -190,8 +157,6 @@ const progressShortcuts = defineShortcuts({
|
|
|
190
157
|
//#region src/components/shortcuts.ts
|
|
191
158
|
const shortcuts = [
|
|
192
159
|
cardShortcuts,
|
|
193
|
-
menuShortcuts,
|
|
194
|
-
buttonShortcuts,
|
|
195
160
|
checkboxShortcuts,
|
|
196
161
|
defineShortcuts({
|
|
197
162
|
"rb-container": { "": "flex flex-col gap-$s text-body" },
|
|
@@ -203,22 +168,22 @@ const shortcuts = [
|
|
|
203
168
|
},
|
|
204
169
|
"rb-item-wrapper": { "": "flex" },
|
|
205
170
|
"rb-item": {
|
|
206
|
-
"": "select-none shrink-0 current-bg-scope-color-500 bg-current/0 size-1.25em rounded-full cursor-default current-border-grey-500 border-current/40 border-[0.16em] transition-none",
|
|
171
|
+
"": "disabled-soft select-none shrink-0 current-bg-scope-color-500 bg-current/0 size-1.25em rounded-full cursor-default current-border-grey-500 border-current/40 border-[0.16em] transition-none",
|
|
207
172
|
"data-[state=checked]:not-[[data-error='true']]:": "current-border-scope-color-500 border-current",
|
|
208
173
|
"data-[state=checked]:": "bg-current",
|
|
209
174
|
"active:enabled:": "bg-current/20",
|
|
210
|
-
"aria-[disabled=true]:": "scope-grey
|
|
175
|
+
"aria-[disabled=true]:": "scope-grey",
|
|
211
176
|
"data-[error=true]:": "current-border-error-500 current-bg-error-500"
|
|
212
177
|
},
|
|
213
178
|
"rb-item-indicator": { "": "flex items-center justify-center w-full h-full rounded-full relative after:content-[''] after:block after:size-[0.5em] after:rounded-[50%] after:bg-white animate-zoom-in animate-duration-100" },
|
|
214
179
|
"rb-item-label": {
|
|
215
|
-
"": "select-none px-$s text-body leading-none lh-1.25em",
|
|
216
|
-
"aria-[disabled=true]:": "scope-grey
|
|
180
|
+
"": "disabled-soft select-none px-$s text-body leading-none lh-1.25em",
|
|
181
|
+
"aria-[disabled=true]:": "scope-grey"
|
|
217
182
|
}
|
|
218
183
|
}),
|
|
219
184
|
defineShortcuts({
|
|
220
185
|
"select-content": {
|
|
221
|
-
"": "min-w-[60px]
|
|
186
|
+
"": "popup-card min-w-[60px]",
|
|
222
187
|
"data-[design=round]:": "rounded-fingertip-half",
|
|
223
188
|
"[&>div[data-reka-combobox-viewport]]:": "max-h-[var(--reka-popper-available-height)] [scrollbar-width:auto]",
|
|
224
189
|
"[&>div[data-reka-combobox-viewport]::-webkit-scrollbar]:": "block"
|
|
@@ -230,8 +195,8 @@ const shortcuts = [
|
|
|
230
195
|
"[&>span]:": "text-label text-grey-400"
|
|
231
196
|
},
|
|
232
197
|
"select-item": {
|
|
233
|
-
"": "text-body leading-none flex items-center min-h-fingertip relative select-none relative",
|
|
234
|
-
"data-[disabled]:": "
|
|
198
|
+
"": "disabled-soft text-body leading-none flex items-center min-h-fingertip relative select-none relative",
|
|
199
|
+
"data-[disabled]:": "pointer-events-none",
|
|
235
200
|
"data-[highlighted]:": "outline-none bg-scope-color-500/15",
|
|
236
201
|
"[&>span]:": "px-$m",
|
|
237
202
|
"group-data-[design=round]:[&>span]:": "px-fingertip-half",
|
|
@@ -263,10 +228,35 @@ const shortcuts = [
|
|
|
263
228
|
dialogShortcuts,
|
|
264
229
|
calendarShortcuts,
|
|
265
230
|
progressShortcuts,
|
|
266
|
-
toastShortcuts
|
|
267
|
-
{ "shadow-popup": "shadow-[0_0_10px_rgba(0,0,0,0.1),0_4px_20px_rgba(0,0,0,0.15)]" }
|
|
231
|
+
toastShortcuts
|
|
268
232
|
];
|
|
269
233
|
//#endregion
|
|
234
|
+
//#region src/theme/shortcuts/btn.ts
|
|
235
|
+
const btn = defineShortcuts({
|
|
236
|
+
"btn": {
|
|
237
|
+
"": "h-fingertip flex items-center justify-center px-$m gap-$xs select-none fw-bold tracking-wide relative",
|
|
238
|
+
"[&.btn-round]:": "px-fingertip-half rounded-fingertip-half",
|
|
239
|
+
"[&.btn-square]:": "size-fingertip px-0",
|
|
240
|
+
"[&.btn-round.btn-square]:": "px-0",
|
|
241
|
+
"disabled:": "opacity-80 cursor-not-allowed",
|
|
242
|
+
"[&>span]:data-[loading]:": "opacity-0 pointer-events-none",
|
|
243
|
+
"[&>div:not(.loading-indicator-wrapper)]:data-[loading]:": "opacity-0 pointer-events-none",
|
|
244
|
+
"[&>.loading-indicator-wrapper]:": "absolute left-0 top-0 right-0 bottom-0 flex items-center justify-center cursor-wait"
|
|
245
|
+
},
|
|
246
|
+
"btn-square": { "": "" },
|
|
247
|
+
"btn-label": {
|
|
248
|
+
"": "lh-1em ellipsis whitespace-nowrap overflow-x-clip overflow-y-visible",
|
|
249
|
+
"group-[.btn-square]/btn:": "hidden"
|
|
250
|
+
},
|
|
251
|
+
"btn-icon": {
|
|
252
|
+
"": "size-1em font-size-1.25em",
|
|
253
|
+
"group-[.btn-round]/btn:[&.btn-icon-left]:": "ml-[-0.5em]",
|
|
254
|
+
"group-[.btn-round]/btn:[&.btn-icon-right]:": "mr-[-0.5em]",
|
|
255
|
+
"group-[.btn-square]/btn:": "font-size-1.5em m-0!",
|
|
256
|
+
"group-[.btn-round.btn-square]/btn:": "m-0!"
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
//#endregion
|
|
270
260
|
//#region src/theme/shortcuts/c8.ts
|
|
271
261
|
const c8 = defineShortcuts({
|
|
272
262
|
"c8-filled": {
|
|
@@ -294,6 +284,7 @@ const c8 = defineShortcuts({
|
|
|
294
284
|
"active:": "c8-flat-active",
|
|
295
285
|
"data-[active]:": "c8-flat-active",
|
|
296
286
|
"data-[selected=true]:": "c8-flat-selected",
|
|
287
|
+
"data-[on=true]:": "c8-flat-selected",
|
|
297
288
|
"aria-[selected=true]:": "c8-flat-selected",
|
|
298
289
|
"aria-[pressed=true]:": "c8-flat-selected"
|
|
299
290
|
},
|
|
@@ -322,6 +313,7 @@ const c8 = defineShortcuts({
|
|
|
322
313
|
"active:": "c8-chrome-active",
|
|
323
314
|
"data-[active]:": "c8-chrome-active",
|
|
324
315
|
"data-[selected=true]:": "c8-chrome-selected",
|
|
316
|
+
"data-[on=true]:": "c8-chrome-selected",
|
|
325
317
|
"aria-[selected=true]:": "c8-chrome-selected",
|
|
326
318
|
"aria-[pressed=true]:": "c8-chrome-selected"
|
|
327
319
|
},
|
|
@@ -346,6 +338,7 @@ const c8 = defineShortcuts({
|
|
|
346
338
|
"active:": "c8-light-active",
|
|
347
339
|
"data-[active]:": "c8-light-active",
|
|
348
340
|
"data-[selected=true]:": "c8-light-hover",
|
|
341
|
+
"data-[on=true]:": "c8-light-hover",
|
|
349
342
|
"aria-[selected=true]:": "c8-light-hover",
|
|
350
343
|
"aria-[pressed=true]:": "c8-light-hover"
|
|
351
344
|
},
|
|
@@ -353,121 +346,149 @@ const c8 = defineShortcuts({
|
|
|
353
346
|
"c8-light-active": { "not-([disabled]):": "bg-current/30" }
|
|
354
347
|
});
|
|
355
348
|
//#endregion
|
|
356
|
-
//#region src/theme/shortcuts/
|
|
357
|
-
const
|
|
358
|
-
"
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
349
|
+
//#region src/theme/shortcuts/extras.ts
|
|
350
|
+
const popupCard = defineShortcuts({
|
|
351
|
+
"shadow-popup": "shadow-[0_0_10px_rgba(0,0,0,0.1),0_4px_20px_rgba(0,0,0,0.15)]",
|
|
352
|
+
"popup-card": { "": "surface-0 bg-current rounded-r2 overflow-hidden shadow-popup z-[100] border current-border-grey-400 border-current/20" }
|
|
353
|
+
});
|
|
354
|
+
const disabledPaint = "opacity-40 cursor-not-allowed";
|
|
355
|
+
const disabledSoft = defineShortcuts({ "disabled-soft": {
|
|
356
|
+
"disabled:": disabledPaint,
|
|
357
|
+
"aria-[disabled=true]:": disabledPaint,
|
|
358
|
+
"data-[disabled]:": disabledPaint
|
|
359
|
+
} });
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/theme/shortcuts/raw.ts
|
|
362
|
+
const rawVunorShortcuts = [
|
|
363
|
+
defineShortcuts({
|
|
364
|
+
"i8": {
|
|
365
|
+
"": "h-fingertip min-w-3em flex items-center select-none relative icon-current content-box disabled-soft",
|
|
366
|
+
"data-[type=textarea]:": "min-h-fingertip h-auto items-start",
|
|
367
|
+
"data-[active=true]:": "icon-current-hl",
|
|
368
|
+
"focus-within:": "icon-current-hl",
|
|
369
|
+
"[&.i8-flat]:": { "": "border-b-width-[var(--i8-border-width,1px)]" },
|
|
370
|
+
"[&.i8-filled]:": {
|
|
371
|
+
"": "i8-apply-bg current-outline-hl i8-apply-border rounded-r1 i8-apply-border",
|
|
372
|
+
"data-[active=true]:": "current-border-hl outline i8-apply-outline",
|
|
373
|
+
"focus-within:": "current-border-hl outline i8-apply-outline"
|
|
374
|
+
},
|
|
375
|
+
"[&.i8-transparent]:": "bg-transparent!",
|
|
376
|
+
"[&.i8-round]:": {
|
|
377
|
+
"": "i8-apply-bg current-outline-hl rounded-fingertip-half i8-apply-border",
|
|
378
|
+
"data-[active=true]:": "current-border-hl outline i8-apply-outline",
|
|
379
|
+
"focus-within:": "current-border-hl outline i8-apply-outline"
|
|
380
|
+
},
|
|
381
|
+
"group-[[data-error=true]]/i8:": { "": "current-border-error-500 current-outline-error-500 border-opacity-100 border-current" }
|
|
368
382
|
},
|
|
369
|
-
"
|
|
370
|
-
|
|
371
|
-
"": "
|
|
372
|
-
"
|
|
373
|
-
"
|
|
383
|
+
"i8-bare": {
|
|
384
|
+
"": "i8-apply-bg i8-apply-border current-outline-hl rounded-r1 outline-none text-current placeholder:text-current/50 disabled-soft",
|
|
385
|
+
"hover:": "border-current-hover",
|
|
386
|
+
"focus:": "current-border-hl outline i8-apply-outline",
|
|
387
|
+
"data-[error=true]:": "current-border-error-500 current-outline-error-500 border-current"
|
|
374
388
|
},
|
|
375
|
-
"
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
"i8-loading": {
|
|
379
|
-
"": "text-current-icon pl-$m",
|
|
380
|
-
"last:": "pr-$m"
|
|
381
|
-
},
|
|
382
|
-
"i8-icon-wrap": "size-fingertip flex items-center justify-center",
|
|
383
|
-
"i8-underline": {
|
|
384
|
-
"group-[.i8-filled]/i8:": "hidden",
|
|
385
|
-
"": "absolute left-50% h-2px right-50% bottom-[-1px] pointer-events-none transition-all transition-duration-300 will-change-left will-change-right bg-current-hl",
|
|
386
|
-
"group-[[data-active=true]]/i8:": "left-0 right-0"
|
|
387
|
-
},
|
|
388
|
-
"segmented": {
|
|
389
|
-
"": {
|
|
390
|
-
"first-of-type:": "rounded-r-0!",
|
|
391
|
-
"last-of-type:": "rounded-lt-0! rounded-lb-0!",
|
|
392
|
-
"not-last-of-type:not-first-of-type:": "rounded-0!",
|
|
393
|
-
"not-first-of-type:": "border-l-0! border-l-grey-500/20",
|
|
394
|
-
"data-[active=true]:": "z-2"
|
|
389
|
+
"i8-loading": {
|
|
390
|
+
"": "text-current-icon pl-$m",
|
|
391
|
+
"last:": "pr-$m"
|
|
395
392
|
},
|
|
396
|
-
"
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
"
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
"
|
|
413
|
-
"
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
"
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
"
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
"
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
"": "
|
|
456
|
-
"
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
"": "
|
|
464
|
-
"
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
"
|
|
469
|
-
|
|
470
|
-
|
|
393
|
+
"i8-icon-wrap": "size-fingertip flex items-center justify-center",
|
|
394
|
+
"i8-underline": {
|
|
395
|
+
"group-[.i8-filled]/i8:": "hidden",
|
|
396
|
+
"": "absolute left-50% h-2px right-50% bottom-[-1px] pointer-events-none transition-all transition-duration-300 will-change-left will-change-right bg-current-hl",
|
|
397
|
+
"group-[[data-active=true]]/i8:": "left-0 right-0"
|
|
398
|
+
},
|
|
399
|
+
"segmented": {
|
|
400
|
+
"": {
|
|
401
|
+
"first-of-type:": "rounded-r-0!",
|
|
402
|
+
"last-of-type:": "rounded-lt-0! rounded-lb-0!",
|
|
403
|
+
"not-last-of-type:not-first-of-type:": "rounded-0!",
|
|
404
|
+
"not-first-of-type:": "border-l-0! border-l-grey-500/20",
|
|
405
|
+
"data-[active=true]:": "z-2"
|
|
406
|
+
},
|
|
407
|
+
"[&.i8-flat]:": { "not-first-of-type:": "ml-$xs" }
|
|
408
|
+
},
|
|
409
|
+
"i8-input-wrapper": { "": "relative w-full h-full" },
|
|
410
|
+
"i8-input": {
|
|
411
|
+
"": "w-full outline-none h-full bg-transparent",
|
|
412
|
+
"group-[.i8-filled]/i8:[&:not([data-has-prepend=true])]:": "pl-$m",
|
|
413
|
+
"group-[.i8-filled]/i8:[&:not([data-has-append=true])]:": "pr-$m",
|
|
414
|
+
"selection:": "bg-scope-color-500 text-white",
|
|
415
|
+
"group-[.i8-round]/i8:[&:not([data-has-prepend=true])]:": "pl-fingertip-half",
|
|
416
|
+
"group-[.i8-round]/i8:[&:not([data-has-append=true])]:": "pr-fingertip-half",
|
|
417
|
+
"group-[[data-has-label]]/i8:": "pt-$m",
|
|
418
|
+
"group-[.segmented.i8-round:not(:first-child)]/i8:[&:not([data-has-prepend=true])]:": "pl-$m",
|
|
419
|
+
"group-[.segmented.i8-round:not(:last-child)]/i8:[&:not([data-has-append=true])]:": "pr-$m"
|
|
420
|
+
},
|
|
421
|
+
"i8-textarea": {
|
|
422
|
+
"": "w-full outline-none h-full bg-transparent text-body",
|
|
423
|
+
"group-[.i8-filled]/i8:[&:not([data-has-prepend=true])]:": "pl-$m",
|
|
424
|
+
"group-[.i8-filled]/i8:[&:not([data-has-append=true])]:": "pr-$m",
|
|
425
|
+
"selection:": "bg-scope-color-500 text-white",
|
|
426
|
+
"group-[.i8-round]/i8:[&:not([data-has-prepend=true])]:": "pl-fingertip-half",
|
|
427
|
+
"group-[.i8-round]/i8:[&:not([data-has-append=true])]:": "pr-fingertip-half",
|
|
428
|
+
"group-[.segmented.i8-round:not(:first-child)]/i8:[&:not([data-has-prepend=true])]:": "pl-$m",
|
|
429
|
+
"group-[.segmented.i8-round:not(:last-child)]/i8:[&:not([data-has-append=true])]:": "pr-$m"
|
|
430
|
+
},
|
|
431
|
+
"i8-ta-wrapper": {
|
|
432
|
+
"": "w-full pt-0.75em",
|
|
433
|
+
"group-[[data-has-label]]/i8:": "mt-$m"
|
|
434
|
+
},
|
|
435
|
+
"i8-label": {
|
|
436
|
+
"": "absolute top-0 h-fingertip text-body text-grey-400 lh-fingertip transition-all transition-duration-300 truncate text-ellipsis overflow-hidden max-w-70%",
|
|
437
|
+
"group-[:focus-within]/i8:": "h-[2em] lh-2em text-label font-size-[0.7em] text-current-hl",
|
|
438
|
+
"group-[[data-active=true]]/i8:": "h-[2em] lh-2em text-label font-size-[0.7em] text-current-hl",
|
|
439
|
+
"group-[[data-has-placeholder]]/i8:": "h-[2em] lh-2em text-label font-size-[0.7em]",
|
|
440
|
+
"group-[[data-has-value]]/i8:": "h-[2em] lh-2em text-label font-size-[0.7em]"
|
|
441
|
+
},
|
|
442
|
+
"i8-label-wrapper": {
|
|
443
|
+
"": "pointer-events-none absolute left-0 right-0 bottom-0 top-0",
|
|
444
|
+
"group-[.i8-filled]/i8:data-[has-prepend=true]": "pl-0",
|
|
445
|
+
"group-[.i8-filled]/i8:data-[has-append=true]": "pr-0",
|
|
446
|
+
"group-[.i8-filled]/i8:": "px-$m",
|
|
447
|
+
"group-[.i8-round]/i8:[&:not([data-has-prepend=true])]:": "pl-fingertip-half",
|
|
448
|
+
"group-[.i8-round]/i8:[&:not([data-has-append=true])]:": "pr-fingertip-half",
|
|
449
|
+
"group-[.segmented.i8-round:not(:first-child)]/i8:[&:not([data-has-prepend=true])]:": "pl-$m",
|
|
450
|
+
"group-[.segmented.i8-round:not(:last-child)]/i8:[&:not([data-has-append=true])]:": "pr-$m"
|
|
451
|
+
},
|
|
452
|
+
"i8-hint": { "": "text-caption pt-$xs text-grey-400 flex-1" },
|
|
453
|
+
"i8-counter": { "": "text-caption pt-$xs text-grey-400" },
|
|
454
|
+
"i8-hint-wrapper": {
|
|
455
|
+
"": "relative flex justify-between",
|
|
456
|
+
"group-[.i8-round]/i8:": "px-fingertip-half",
|
|
457
|
+
"group-[.i8-filled]/i8:": "px-$m"
|
|
458
|
+
},
|
|
459
|
+
"i8-hint-wrapper-stack": { "": "relative flex justify-between" },
|
|
460
|
+
"i8-stack-label": { "": "relative pb-$xxs" },
|
|
461
|
+
"i8-prepend": {
|
|
462
|
+
"": "flex items-center",
|
|
463
|
+
"group-[[data-type=textarea]]/i8:": "my-$m"
|
|
464
|
+
},
|
|
465
|
+
"i8-append": {
|
|
466
|
+
"": "flex items-center",
|
|
467
|
+
"group-[[data-type=textarea]]/i8:": "my-$m"
|
|
468
|
+
},
|
|
469
|
+
"i8-before": {
|
|
470
|
+
"": "h-fingertip flex items-center icon-current",
|
|
471
|
+
"group-[[data-group-active=true]]/i8:": "icon-current-hl"
|
|
472
|
+
},
|
|
473
|
+
"i8-after": {
|
|
474
|
+
"": "h-fingertip flex items-center icon-current",
|
|
475
|
+
"group-[[data-group-active=true]]/i8:": "icon-current-hl"
|
|
476
|
+
},
|
|
477
|
+
"i8-icon-clickable": {
|
|
478
|
+
"[&>.i8-icon-wrap]:": "cursor-pointer",
|
|
479
|
+
"[&>.i8-icon-wrap:hover]:": "current-icon-hl icon-current"
|
|
480
|
+
}
|
|
481
|
+
}),
|
|
482
|
+
c8,
|
|
483
|
+
btn,
|
|
484
|
+
defineShortcuts({
|
|
485
|
+
"menu-root": "flex flex-col overflow-hidden",
|
|
486
|
+
"menu-item": "justify-start c8-flat gap-$m w-full fw-400"
|
|
487
|
+
}),
|
|
488
|
+
popupCard,
|
|
489
|
+
disabledSoft,
|
|
490
|
+
...shortcuts
|
|
491
|
+
];
|
|
471
492
|
//#endregion
|
|
472
493
|
//#region src/theme/utils/shortcut-obj.ts
|
|
473
494
|
/**
|
|
@@ -527,833 +548,6 @@ const mergeTwoVunorShortcuts = (target, source) => {
|
|
|
527
548
|
*/
|
|
528
549
|
const mergeVunorShortcuts = (shortcuts) => shortcuts.reduce((acc, shortcut) => mergeTwoVunorShortcuts(acc, shortcut), {});
|
|
529
550
|
//#endregion
|
|
530
|
-
//#region src/theme/palitra.ts
|
|
531
|
-
const defaultOpts = {
|
|
532
|
-
colors: {
|
|
533
|
-
primary: {
|
|
534
|
-
color: "#004eaf",
|
|
535
|
-
preserveInputColor: true,
|
|
536
|
-
saturate: {
|
|
537
|
-
dark: -.2,
|
|
538
|
-
light: -.2
|
|
539
|
-
}
|
|
540
|
-
},
|
|
541
|
-
grey: {
|
|
542
|
-
color: "#858892",
|
|
543
|
-
saturate: {
|
|
544
|
-
dark: 0,
|
|
545
|
-
light: 0
|
|
546
|
-
}
|
|
547
|
-
},
|
|
548
|
-
secondary: {
|
|
549
|
-
color: "#edd812",
|
|
550
|
-
vivid: {
|
|
551
|
-
dark: .4,
|
|
552
|
-
light: .4
|
|
553
|
-
}
|
|
554
|
-
},
|
|
555
|
-
neutral: {
|
|
556
|
-
color: "#5da0c5",
|
|
557
|
-
vivid: {
|
|
558
|
-
dark: .1,
|
|
559
|
-
light: .1
|
|
560
|
-
}
|
|
561
|
-
},
|
|
562
|
-
good: {
|
|
563
|
-
color: "#7bc76a",
|
|
564
|
-
vivid: {
|
|
565
|
-
dark: .2,
|
|
566
|
-
light: .5
|
|
567
|
-
}
|
|
568
|
-
},
|
|
569
|
-
warn: {
|
|
570
|
-
color: "#ef9421",
|
|
571
|
-
vivid: {
|
|
572
|
-
dark: .2,
|
|
573
|
-
light: .3
|
|
574
|
-
}
|
|
575
|
-
},
|
|
576
|
-
error: { color: "#bf5a5f" }
|
|
577
|
-
},
|
|
578
|
-
lightest: .97,
|
|
579
|
-
darkest: .24,
|
|
580
|
-
layersDepth: .08,
|
|
581
|
-
flatness: 1,
|
|
582
|
-
mainPalette: {
|
|
583
|
-
preserveInputColor: false,
|
|
584
|
-
luminance: {
|
|
585
|
-
useMiddle: true,
|
|
586
|
-
middle: .62
|
|
587
|
-
},
|
|
588
|
-
saturate: {
|
|
589
|
-
dark: -.25,
|
|
590
|
-
light: -.25
|
|
591
|
-
},
|
|
592
|
-
vivid: {
|
|
593
|
-
dark: .1,
|
|
594
|
-
light: .2
|
|
595
|
-
}
|
|
596
|
-
},
|
|
597
|
-
layerPalette: {
|
|
598
|
-
desaturate: .2,
|
|
599
|
-
saturate: {
|
|
600
|
-
dark: -.2,
|
|
601
|
-
light: -.2
|
|
602
|
-
},
|
|
603
|
-
vivid: {
|
|
604
|
-
dark: 0,
|
|
605
|
-
light: 0
|
|
606
|
-
}
|
|
607
|
-
},
|
|
608
|
-
surfaces: {
|
|
609
|
-
"0": [
|
|
610
|
-
"scope-light-0",
|
|
611
|
-
"scope-dark-1",
|
|
612
|
-
"scope-color-100",
|
|
613
|
-
"scope-dark-0",
|
|
614
|
-
"scope-light-1",
|
|
615
|
-
"scope-color-800"
|
|
616
|
-
],
|
|
617
|
-
"1": [
|
|
618
|
-
"scope-light-1",
|
|
619
|
-
"scope-dark-1",
|
|
620
|
-
"scope-color-100",
|
|
621
|
-
"scope-dark-1",
|
|
622
|
-
"scope-light-1",
|
|
623
|
-
"scope-color-800"
|
|
624
|
-
],
|
|
625
|
-
"2": [
|
|
626
|
-
"scope-light-2",
|
|
627
|
-
"scope-dark-1",
|
|
628
|
-
"scope-color-100",
|
|
629
|
-
"scope-dark-2",
|
|
630
|
-
"scope-light-1",
|
|
631
|
-
"scope-color-800"
|
|
632
|
-
],
|
|
633
|
-
"3": [
|
|
634
|
-
"scope-light-3",
|
|
635
|
-
"scope-dark-1",
|
|
636
|
-
"scope-color-100",
|
|
637
|
-
"scope-dark-3",
|
|
638
|
-
"scope-light-1",
|
|
639
|
-
"scope-color-800"
|
|
640
|
-
],
|
|
641
|
-
"4": [
|
|
642
|
-
"scope-light-4",
|
|
643
|
-
"scope-dark-1",
|
|
644
|
-
"scope-color-100",
|
|
645
|
-
"scope-dark-4",
|
|
646
|
-
"scope-light-1",
|
|
647
|
-
"scope-color-800"
|
|
648
|
-
],
|
|
649
|
-
"50": [
|
|
650
|
-
"scope-color-50",
|
|
651
|
-
"scope-color-700",
|
|
652
|
-
"scope-color-200",
|
|
653
|
-
"scope-color-900",
|
|
654
|
-
"scope-color-200",
|
|
655
|
-
"scope-color-500"
|
|
656
|
-
],
|
|
657
|
-
"100": [
|
|
658
|
-
"scope-color-100",
|
|
659
|
-
"scope-color-800",
|
|
660
|
-
"scope-color-200",
|
|
661
|
-
"scope-color-800",
|
|
662
|
-
"scope-color-200",
|
|
663
|
-
"scope-color-500"
|
|
664
|
-
],
|
|
665
|
-
"200": [
|
|
666
|
-
"scope-color-200",
|
|
667
|
-
"scope-color-800",
|
|
668
|
-
"scope-color-400",
|
|
669
|
-
"scope-color-700",
|
|
670
|
-
"scope-color-100",
|
|
671
|
-
"scope-color-400"
|
|
672
|
-
],
|
|
673
|
-
"300": [
|
|
674
|
-
"scope-color-300",
|
|
675
|
-
"scope-color-900",
|
|
676
|
-
"scope-color-500",
|
|
677
|
-
"scope-color-600",
|
|
678
|
-
"scope-color-100",
|
|
679
|
-
"scope-color-300"
|
|
680
|
-
],
|
|
681
|
-
"400": [
|
|
682
|
-
"scope-color-400",
|
|
683
|
-
"scope-color-50",
|
|
684
|
-
"scope-color-200",
|
|
685
|
-
"scope-color-500",
|
|
686
|
-
"scope-color-50",
|
|
687
|
-
"scope-color-200"
|
|
688
|
-
],
|
|
689
|
-
"500": [
|
|
690
|
-
"scope-color-500",
|
|
691
|
-
"scope-color-50",
|
|
692
|
-
"scope-color-200",
|
|
693
|
-
"scope-color-400",
|
|
694
|
-
"scope-color-50",
|
|
695
|
-
"scope-color-100"
|
|
696
|
-
],
|
|
697
|
-
"600": [
|
|
698
|
-
"scope-color-600",
|
|
699
|
-
"scope-color-100",
|
|
700
|
-
"scope-color-300",
|
|
701
|
-
"scope-color-300",
|
|
702
|
-
"scope-color-900",
|
|
703
|
-
"scope-color-700"
|
|
704
|
-
],
|
|
705
|
-
"700": [
|
|
706
|
-
"scope-color-700",
|
|
707
|
-
"scope-color-100",
|
|
708
|
-
"scope-color-300",
|
|
709
|
-
"scope-color-200",
|
|
710
|
-
"scope-color-800",
|
|
711
|
-
"scope-color-600"
|
|
712
|
-
],
|
|
713
|
-
"800": [
|
|
714
|
-
"scope-color-800",
|
|
715
|
-
"scope-color-200",
|
|
716
|
-
"scope-color-400",
|
|
717
|
-
"scope-color-100",
|
|
718
|
-
"scope-color-800",
|
|
719
|
-
"scope-color-500"
|
|
720
|
-
],
|
|
721
|
-
"900": [
|
|
722
|
-
"scope-color-900",
|
|
723
|
-
"scope-color-200",
|
|
724
|
-
"scope-color-400",
|
|
725
|
-
"scope-color-50",
|
|
726
|
-
"scope-color-700",
|
|
727
|
-
"scope-color-500"
|
|
728
|
-
]
|
|
729
|
-
}
|
|
730
|
-
};
|
|
731
|
-
function generatePalette(_opts) {
|
|
732
|
-
const _colors = _opts?.colors || {};
|
|
733
|
-
for (const key of Object.keys(_colors)) {
|
|
734
|
-
const col = _opts?.colors?.[key];
|
|
735
|
-
if (typeof col === "string") _colors[key] = { color: col };
|
|
736
|
-
}
|
|
737
|
-
const opts = defu$1({
|
|
738
|
-
..._opts,
|
|
739
|
-
colors: _colors
|
|
740
|
-
}, defaultOpts);
|
|
741
|
-
const bgOptions = {
|
|
742
|
-
count: 5,
|
|
743
|
-
preserveInputColor: false,
|
|
744
|
-
flatness: opts.layerPalette.flatness ?? opts.flatness,
|
|
745
|
-
luminance: {
|
|
746
|
-
dark: opts.layerPalette.luminance?.dark ?? opts.darkest,
|
|
747
|
-
light: opts.layerPalette.luminance?.light ?? opts.darkest + opts.layersDepth,
|
|
748
|
-
useMiddle: false
|
|
749
|
-
},
|
|
750
|
-
saturate: opts.layerPalette.saturate,
|
|
751
|
-
vivid: opts.layerPalette.vivid,
|
|
752
|
-
suffixes: [
|
|
753
|
-
"dark-0",
|
|
754
|
-
"dark-1",
|
|
755
|
-
"dark-2",
|
|
756
|
-
"dark-3",
|
|
757
|
-
"dark-4"
|
|
758
|
-
]
|
|
759
|
-
};
|
|
760
|
-
const darks = palitra(multiplySaturation(opts.colors, opts.layerPalette.desaturate), bgOptions).toStrings();
|
|
761
|
-
bgOptions.suffixes = [
|
|
762
|
-
"light-0",
|
|
763
|
-
"light-1",
|
|
764
|
-
"light-2",
|
|
765
|
-
"light-3",
|
|
766
|
-
"light-4"
|
|
767
|
-
].toReversed();
|
|
768
|
-
const lumDark = bgOptions.luminance?.dark ?? opts.darkest;
|
|
769
|
-
bgOptions.luminance = {
|
|
770
|
-
dark: 1 - ((bgOptions.luminance?.light ?? opts.darkest + opts.layersDepth) - lumDark),
|
|
771
|
-
light: 1,
|
|
772
|
-
useMiddle: false
|
|
773
|
-
};
|
|
774
|
-
const lights = palitra(multiplySaturation(opts.colors, opts.layerPalette.desaturate), bgOptions).toStrings();
|
|
775
|
-
const colors = palitra({
|
|
776
|
-
primary: opts.colors.primary,
|
|
777
|
-
grey: opts.colors.grey,
|
|
778
|
-
secondary: opts.colors.secondary,
|
|
779
|
-
neutral: opts.colors.neutral,
|
|
780
|
-
good: opts.colors.good,
|
|
781
|
-
warn: opts.colors.warn,
|
|
782
|
-
error: opts.colors.error
|
|
783
|
-
}, {
|
|
784
|
-
count: 10,
|
|
785
|
-
preserveInputColor: opts.mainPalette.preserveInputColor,
|
|
786
|
-
flatness: opts.mainPalette.flatness ?? opts.flatness,
|
|
787
|
-
luminance: {
|
|
788
|
-
dark: opts.mainPalette.luminance?.dark ?? opts.darkest + opts.layersDepth + .02,
|
|
789
|
-
light: opts.mainPalette.luminance?.light ?? opts.lightest,
|
|
790
|
-
useMiddle: opts.mainPalette.luminance?.useMiddle,
|
|
791
|
-
middle: opts.mainPalette.luminance?.middle
|
|
792
|
-
},
|
|
793
|
-
saturate: opts.mainPalette.saturate,
|
|
794
|
-
vivid: opts.mainPalette.vivid
|
|
795
|
-
}).toStrings();
|
|
796
|
-
return {
|
|
797
|
-
opts,
|
|
798
|
-
colors: {
|
|
799
|
-
...darks,
|
|
800
|
-
...lights,
|
|
801
|
-
...colors
|
|
802
|
-
},
|
|
803
|
-
surfaces: opts.surfaces
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
function multiplySaturation(colors, m = .5) {
|
|
807
|
-
const newObj = {};
|
|
808
|
-
for (const [key, val] of Object.entries(colors)) {
|
|
809
|
-
const col = typeof val === "string" ? val : val.color;
|
|
810
|
-
if (col) {
|
|
811
|
-
const [h, s, l] = color(col).hsl();
|
|
812
|
-
newObj[key] = color(h, s * m, l, "hsl").hex();
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
return newObj;
|
|
816
|
-
}
|
|
817
|
-
const layerN = (n, reverse) => reverse ? 4 - n : n;
|
|
818
|
-
function getPaletteShortcuts() {
|
|
819
|
-
return [
|
|
820
|
-
[/^layer-([0-4])$/, ([, a], { theme }) => {
|
|
821
|
-
const d = layerN(Number(a), theme.reverseDarkLayers);
|
|
822
|
-
return toUnoShortcut({
|
|
823
|
-
"": `current-bg-scope-light-${layerN(Number(a), theme.reverseLightLayers)} current-text-scope-dark-2 current-icon-scope-dark-2 current-border-grey-500 bg-current text-current`,
|
|
824
|
-
"dark:": `current-bg-scope-dark-${d} current-text-scope-light-2 current-icon-scope-light-2`,
|
|
825
|
-
"[&.dark]:": `current-bg-scope-dark-${d} current-text-scope-light-2 current-icon-scope-light-2`
|
|
826
|
-
});
|
|
827
|
-
}],
|
|
828
|
-
[/^(bg|text|current-text|current-bg|current-icon|current-border|current-outline|current-caret|current-hl|i8-bg|i8-border|i8-outline)-layer-([0-4])$/, ([, target, a], { theme }) => {
|
|
829
|
-
const d = layerN(Number(a), theme.reverseDarkLayers);
|
|
830
|
-
return toUnoShortcut({
|
|
831
|
-
"": `${target}-scope-light-${layerN(Number(a), theme.reverseLightLayers)}`,
|
|
832
|
-
"dark:": `${target}-scope-dark-${d}`,
|
|
833
|
-
"[&.dark]:": `${target}-scope-dark-${d}`
|
|
834
|
-
});
|
|
835
|
-
}],
|
|
836
|
-
[/^surface-(.+)$/, ([, s], { theme }) => theme.surfaces[s] ? toUnoShortcut({
|
|
837
|
-
"": `current-bg-${theme.surfaces[s][0]} current-text-${theme.surfaces[s][1]} current-icon-${theme.surfaces[s][1]} current-border-${theme.surfaces[s][2]} bg-current text-current border-current icon-current`,
|
|
838
|
-
"dark:": `current-bg-${theme.surfaces[s][3]} current-text-${theme.surfaces[s][4]} current-icon-${theme.surfaces[s][4]} current-border-${theme.surfaces[s][5]} shadow-black/30`,
|
|
839
|
-
"[&.dark]:": `current-bg-${theme.surfaces[s][3]} current-text-${theme.surfaces[s][4]} current-icon-${theme.surfaces[s][4]} current-border-${theme.surfaces[s][5]} shadow-black/30`
|
|
840
|
-
}) : ""],
|
|
841
|
-
{ surface: "surface-100" }
|
|
842
|
-
];
|
|
843
|
-
}
|
|
844
|
-
//#endregion
|
|
845
|
-
//#region src/theme/rules/palette.ts
|
|
846
|
-
function colorToRgbWithOpacity(c) {
|
|
847
|
-
const [r, g, b, _a] = color(c).rgba();
|
|
848
|
-
return `${r} ${g} ${b}`;
|
|
849
|
-
}
|
|
850
|
-
function getOpacityVar(key) {
|
|
851
|
-
return {
|
|
852
|
-
bg: "--un-bg-opacity",
|
|
853
|
-
text: "--un-text-opacity",
|
|
854
|
-
fill: "--un-text-opacity",
|
|
855
|
-
stroke: "--un-text-opacity",
|
|
856
|
-
icon: "--un-icon-opacity",
|
|
857
|
-
border: "--un-border-opacity",
|
|
858
|
-
outline: "--un-outline-opacity",
|
|
859
|
-
caret: "--un-caret-opacity",
|
|
860
|
-
shadow: "--un-shadow-opacity",
|
|
861
|
-
ring: "--un-ring-opacity"
|
|
862
|
-
}[key];
|
|
863
|
-
}
|
|
864
|
-
function getCssTarget(key) {
|
|
865
|
-
return {
|
|
866
|
-
bg: "background-color",
|
|
867
|
-
text: "color",
|
|
868
|
-
fill: "fill",
|
|
869
|
-
stroke: "stroke",
|
|
870
|
-
icon: "color",
|
|
871
|
-
border: "border-color",
|
|
872
|
-
outline: "outline-color",
|
|
873
|
-
caret: "caret-color",
|
|
874
|
-
shadow: "--un-shadow-color",
|
|
875
|
-
ring: "--un-ring-color"
|
|
876
|
-
}[key];
|
|
877
|
-
}
|
|
878
|
-
const SCOPE_SHADES = [
|
|
879
|
-
"50",
|
|
880
|
-
"100",
|
|
881
|
-
"200",
|
|
882
|
-
"300",
|
|
883
|
-
"400",
|
|
884
|
-
"500",
|
|
885
|
-
"600",
|
|
886
|
-
"700",
|
|
887
|
-
"800",
|
|
888
|
-
"900"
|
|
889
|
-
];
|
|
890
|
-
const SCOPE_LAYERS = [
|
|
891
|
-
"0",
|
|
892
|
-
"1",
|
|
893
|
-
"2",
|
|
894
|
-
"3",
|
|
895
|
-
"4"
|
|
896
|
-
];
|
|
897
|
-
function getScopeCssVars(c, theme) {
|
|
898
|
-
const col = theme.colors[c];
|
|
899
|
-
if (!col) return;
|
|
900
|
-
const vars = { "--scope-color": colorToRgbWithOpacity(col) };
|
|
901
|
-
for (const shade of SCOPE_SHADES) vars[`--scope-color-${shade}`] = colorToRgbWithOpacity(theme.colors[`${c}-${shade}`]) || "";
|
|
902
|
-
for (const layer of SCOPE_LAYERS) {
|
|
903
|
-
vars[`--scope-light-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-light-${layer}`]) || "";
|
|
904
|
-
vars[`--scope-dark-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-dark-${layer}`]) || "";
|
|
905
|
-
}
|
|
906
|
-
vars["--current-hl"] = colorToRgbWithOpacity(theme.colors[`${c}-500`]) || "";
|
|
907
|
-
return vars;
|
|
908
|
-
}
|
|
909
|
-
const paletteRules = [
|
|
910
|
-
[/^current-(text|bg|icon|border|outline|caret|hl)-(.+)$/, (match, { theme }) => {
|
|
911
|
-
const t = match[1];
|
|
912
|
-
const c = match[2];
|
|
913
|
-
if (c.startsWith("scope-")) return { [`--current-${t}`]: `var(--${c})` };
|
|
914
|
-
if (c === "hl") return { [`--current-${t}`]: `var(--current-hl)` };
|
|
915
|
-
const col = theme.colors[c] || c;
|
|
916
|
-
if (col) return { [`--current-${t}`]: colorToRgbWithOpacity(col.DEFAULT || col) };
|
|
917
|
-
}],
|
|
918
|
-
[/^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(-text|-bg|-icon|-border|-outline|-caret|-hl)?(\/\d{1,3})?$/, (match, { theme: _theme }) => {
|
|
919
|
-
const target = match[1];
|
|
920
|
-
const source = match[2] || `-${target}`;
|
|
921
|
-
const opacityVar = getOpacityVar(target);
|
|
922
|
-
const cssVar = getCssTarget(target);
|
|
923
|
-
const o = match[3];
|
|
924
|
-
const opacity = o ? Number(o.slice(1)) / 100 : 1;
|
|
925
|
-
const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
|
|
926
|
-
if (target === "icon") return {
|
|
927
|
-
[opacityVar]: opacity,
|
|
928
|
-
"--current-icon": source === "-hl" ? `var(--current${source})` : void 0
|
|
929
|
-
};
|
|
930
|
-
if (["shadow", "ring"].includes(target) && source === "-border") return {
|
|
931
|
-
[opacityVar]: opacity === 1 ? `var(--un-border-opacity)` : opacity,
|
|
932
|
-
[`--un-${target}-color`]: `rgb(var(--current-border) / ${opacityVal})`
|
|
933
|
-
};
|
|
934
|
-
return {
|
|
935
|
-
[opacityVar]: opacity,
|
|
936
|
-
[cssVar]: `rgb(var(--current${source}) / ${opacityVal})`
|
|
937
|
-
};
|
|
938
|
-
}],
|
|
939
|
-
[/^scope-(.*)$/, (match, { theme }) => getScopeCssVars(match[1], theme)],
|
|
940
|
-
[/^(bg|text|fill|stroke|border|outline|icon|caret)-scope-((?:color|dark|light|text|bg|white|black|icon)(?:-\d+)?)(\/\d{1,3})?$/, (match, { theme }) => {
|
|
941
|
-
const cssVar = getCssTarget(match[1]);
|
|
942
|
-
const opacityVar = getOpacityVar(match[1]);
|
|
943
|
-
const source = match[2];
|
|
944
|
-
const o = match[3];
|
|
945
|
-
const opacity = o ? Number(o.slice(1)) / 100 : 1;
|
|
946
|
-
const fallback = source.startsWith("color") ? `grey-${source.slice(6)}` : `grey-${source}`;
|
|
947
|
-
const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
|
|
948
|
-
return {
|
|
949
|
-
[opacityVar]: opacity,
|
|
950
|
-
[cssVar]: `rgb(var(--scope-${source}, ${theme.colors[fallback] || ""}) / ${opacityVal})`
|
|
951
|
-
};
|
|
952
|
-
}],
|
|
953
|
-
[/^icon-opacity-(\d{1,3})$/, (match, { theme: _theme }) => {
|
|
954
|
-
const o = match[1];
|
|
955
|
-
return { "--un-icon-opacity": Number(o) / 100 };
|
|
956
|
-
}],
|
|
957
|
-
[/^icon-color$/, () => ({ color: `rgb(var(--current-icon) / var(--un-icon-opacity, 1))` })],
|
|
958
|
-
[/^icon-size-(.*)$/, (match, { theme }) => {
|
|
959
|
-
const name = match[1];
|
|
960
|
-
if (name.startsWith("[") && name.endsWith("]")) return { "--icon-size": name.slice(1, -1) };
|
|
961
|
-
if (theme.spacing[name]) return { "--icon-size": theme.spacing[name] };
|
|
962
|
-
}],
|
|
963
|
-
[/^icon-size$/, () => ({
|
|
964
|
-
width: `var(--icon-size, 1em)`,
|
|
965
|
-
height: `var(--icon-size, 1em)`
|
|
966
|
-
})]
|
|
967
|
-
];
|
|
968
|
-
//#endregion
|
|
969
|
-
//#region src/theme/utils/round.ts
|
|
970
|
-
function round(v, decimals = 0) {
|
|
971
|
-
const d = 10 ** decimals;
|
|
972
|
-
return Math.round(v * d) / d;
|
|
973
|
-
}
|
|
974
|
-
//#endregion
|
|
975
|
-
//#region src/theme/utils/unit-by.ts
|
|
976
|
-
function unitBy(input, factor, roundTo = 3) {
|
|
977
|
-
const v = Number.parseFloat(input);
|
|
978
|
-
const units = /(px|em|rem|%)$/.exec(input)?.[1] || "";
|
|
979
|
-
return `${round(v * factor, roundTo)}${units}`;
|
|
980
|
-
}
|
|
981
|
-
//#endregion
|
|
982
|
-
//#region src/theme/preflights.ts
|
|
983
|
-
const fontsPreflights = { getCSS: ({ theme }) => `${renderFontCss("body", theme.fontSize.body) + renderFontCss("figcaption", theme.fontSize.caption) + renderFontCss("h1", theme.fontSize.h1) + renderFontCss("h2", theme.fontSize.h2) + renderFontCss("h3", theme.fontSize.h3) + renderFontCss("h4", theme.fontSize.h4) + renderFontCss("h5", theme.fontSize.h5) + renderFontCss("h6", theme.fontSize.h6)}
|
|
984
|
-
:root {
|
|
985
|
-
--un-border-opacity: 0.25;
|
|
986
|
-
--un-default-border-color: rgb(150 150 150 / var(--un-border-opacity));
|
|
987
|
-
--scope-black: 0 0 0;
|
|
988
|
-
--scope-white: 255 255 255;
|
|
989
|
-
--scope-hl: var(--scope-color-500);
|
|
990
|
-
--v-fingertip: ${theme.spacing["fingertip-m"] || "3em"};
|
|
991
|
-
--v-fingertip-half: ${unitBy(theme.spacing["fingertip-m"] || "3em", .5)};
|
|
992
|
-
${renderDefaultScope(theme)}}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
::-webkit-scrollbar {
|
|
996
|
-
width: 10px;
|
|
997
|
-
height: 10px;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
::-webkit-scrollbar-track {
|
|
1001
|
-
background: rgba(0,0,0,0.05);
|
|
1002
|
-
border-radius: 5px;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
::-webkit-scrollbar-thumb {
|
|
1006
|
-
background-color: rgba(0,0,0,0.2);
|
|
1007
|
-
border-radius: 5px;
|
|
1008
|
-
border: 2px solid transparent;
|
|
1009
|
-
background-clip: padding-box;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
::-webkit-scrollbar-thumb:hover {
|
|
1013
|
-
background-color: rgba(0,0,0,0.3);
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
.dark ::-webkit-scrollbar-track {
|
|
1018
|
-
background: rgba(255,255,255,0.05);
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
.dark ::-webkit-scrollbar-thumb {
|
|
1022
|
-
background-color: rgba(255,255,255,0.2);
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
.dark ::-webkit-scrollbar-thumb:hover {
|
|
1026
|
-
background-color: rgba(255,255,255,0.3);
|
|
1027
|
-
}
|
|
1028
|
-
` };
|
|
1029
|
-
function renderDefaultScope(theme) {
|
|
1030
|
-
const vars = getScopeCssVars("neutral", theme);
|
|
1031
|
-
if (!vars) return "";
|
|
1032
|
-
return `${Object.entries(vars).map(([k, v]) => ` ${k}: ${v};`).join("\n")}\n`;
|
|
1033
|
-
}
|
|
1034
|
-
function renderFontCss(selector, font) {
|
|
1035
|
-
return `${selector} { font-size: ${font[0]}; ${Object.entries(font[1]).map((e) => `${e[0]}: ${e[1]};`).join(" ")} }\n`;
|
|
1036
|
-
}
|
|
1037
|
-
//#endregion
|
|
1038
|
-
//#region src/theme/rules/i8-rules.ts
|
|
1039
|
-
const i8Rules = [
|
|
1040
|
-
[/^i8-(border|outline|bg)-(.+)$/, (match, { theme }) => {
|
|
1041
|
-
const target = match[1];
|
|
1042
|
-
const value = match[2];
|
|
1043
|
-
if (value === "none") return { [`--i8-${target}-width`]: "0" };
|
|
1044
|
-
if (value === "transparent") return { [`--i8-${target}-color`]: "0" };
|
|
1045
|
-
if (value.startsWith("scope-")) return { [`--i8-${target}-color`]: `var(--${value})` };
|
|
1046
|
-
const col = theme.colors[value];
|
|
1047
|
-
if (col) return { [`--i8-${target}-color`]: colorToRgbWithOpacity(String(col.DEFAULT || col)) };
|
|
1048
|
-
const width = theme.spacing[value];
|
|
1049
|
-
if (width) return { [`--i8-${target}-width`]: width };
|
|
1050
|
-
if (value.endsWith("px") || value.endsWith("em") || value.endsWith("rem")) return { [`--i8-${target}-width`]: value };
|
|
1051
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1052
|
-
const v = value.slice(1, -1);
|
|
1053
|
-
if (v.endsWith("px") || v.endsWith("em") || v.endsWith("rem")) return { [`--i8-${target}-width`]: v };
|
|
1054
|
-
return { [`--i8-${target}-color`]: v };
|
|
1055
|
-
}
|
|
1056
|
-
}],
|
|
1057
|
-
[/^i8-(border|outline|bg)-opacity-(\d{1,3})$/, (match, { theme: _theme }) => {
|
|
1058
|
-
const target = match[1];
|
|
1059
|
-
const value = match[2];
|
|
1060
|
-
return { [`--i8-${target}-opacity`]: Number(value) / 100 };
|
|
1061
|
-
}],
|
|
1062
|
-
[/^i8-apply-(border|outline|bg)$/, (match, { theme: _theme }) => {
|
|
1063
|
-
const target = match[1];
|
|
1064
|
-
const prop = {
|
|
1065
|
-
border: "border-color",
|
|
1066
|
-
outline: "outline-color",
|
|
1067
|
-
bg: "background-color"
|
|
1068
|
-
}[target];
|
|
1069
|
-
const variable = {
|
|
1070
|
-
border: "--i8-border-color, var(--current-border)",
|
|
1071
|
-
outline: "--i8-outline-color, var(--current-outline)",
|
|
1072
|
-
bg: "--i8-bg-color, var(--current-bg)"
|
|
1073
|
-
}[target];
|
|
1074
|
-
const op = {
|
|
1075
|
-
border: `--i8-border-opacity, 0.2`,
|
|
1076
|
-
outline: `--i8-outline-opacity, 0.5`,
|
|
1077
|
-
bg: "--i8-bg-opacity, 1"
|
|
1078
|
-
}[target];
|
|
1079
|
-
return target === "bg" ? { [prop]: `rgb(var(${variable}) / var(${op}))` } : {
|
|
1080
|
-
[prop]: `rgb(var(${variable}) / var(${op}))`,
|
|
1081
|
-
[`${target}-width`]: `var(--i8-${target}-width, ${target === "border" ? 1 : 2}px)`
|
|
1082
|
-
};
|
|
1083
|
-
}]
|
|
1084
|
-
];
|
|
1085
|
-
//#endregion
|
|
1086
|
-
//#region src/theme/rules/index.ts
|
|
1087
|
-
const rules = [
|
|
1088
|
-
...[
|
|
1089
|
-
[
|
|
1090
|
-
/^text-m([bty])?-(.*)$/,
|
|
1091
|
-
(match, { theme }) => {
|
|
1092
|
-
const dir = match[1];
|
|
1093
|
-
const size = match[2];
|
|
1094
|
-
const d = dir ? {
|
|
1095
|
-
y: ["top", "bottom"],
|
|
1096
|
-
t: ["top"],
|
|
1097
|
-
b: ["bottom"]
|
|
1098
|
-
}[dir] : [
|
|
1099
|
-
"top",
|
|
1100
|
-
"bottom",
|
|
1101
|
-
"left",
|
|
1102
|
-
"right"
|
|
1103
|
-
];
|
|
1104
|
-
const result = {};
|
|
1105
|
-
if (theme.spacing[size]) {
|
|
1106
|
-
for (const prop of d) result[`margin-${prop}`] = ["left", "right"].includes(prop) ? theme.spacing[size] : `calc(${theme.spacing[size]} + var(--font-${prop === "top" ? "tc" : "bc"}))`;
|
|
1107
|
-
return result;
|
|
1108
|
-
} else if (/^\d+(em|rem|px)?$/.test(size)) {
|
|
1109
|
-
let s = size;
|
|
1110
|
-
if (/^[\d.]+$/.test(size)) s = `${Number(size) * .25}rem`;
|
|
1111
|
-
for (const prop of d) result[`margin-${prop}`] = ["left", "right"].includes(prop) ? s : `calc(${s} + var(--font-${prop === "top" ? "tc" : "bc"}))`;
|
|
1112
|
-
return result;
|
|
1113
|
-
}
|
|
1114
|
-
},
|
|
1115
|
-
{ layer: "utilities" }
|
|
1116
|
-
],
|
|
1117
|
-
[
|
|
1118
|
-
/^card-dense$/,
|
|
1119
|
-
(_match, { theme: _theme }) => ({ "--card-spacing": "var(--card-spacing-dense)" }),
|
|
1120
|
-
{ layer: "utilities" }
|
|
1121
|
-
],
|
|
1122
|
-
[/^card-(.*)$/, (match, { theme }) => {
|
|
1123
|
-
const name = match[1];
|
|
1124
|
-
if (theme.fontSize[name]) {
|
|
1125
|
-
const props = theme.fontSize[name][1];
|
|
1126
|
-
return {
|
|
1127
|
-
"--card-spacing": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.regular)}`,
|
|
1128
|
-
"--card-spacing-dense": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.dense)}`,
|
|
1129
|
-
"--card-heading-size": props["--font-size"],
|
|
1130
|
-
"--card-heading-bold": props["--font-bold"],
|
|
1131
|
-
"--card-heading-corrected": props["--font-corrected"],
|
|
1132
|
-
"--card-heading-weight": props["font-weight"],
|
|
1133
|
-
"--card-heading-lh": props["line-height"],
|
|
1134
|
-
"--card-heading-ls": props["letter-spacing"],
|
|
1135
|
-
"--card-heading-bc": props["--font-bc"],
|
|
1136
|
-
"--card-heading-tc": props["--font-tc"],
|
|
1137
|
-
"padding": "var(--card-spacing)"
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1140
|
-
}],
|
|
1141
|
-
[/^fingertip-(.*)/, (match, { theme }) => {
|
|
1142
|
-
const name = match[1];
|
|
1143
|
-
if (name.startsWith("[") && name.endsWith("]")) return {
|
|
1144
|
-
"--v-fingertip": name.slice(1, -1),
|
|
1145
|
-
"--v-fingertip-half": unitBy(name.slice(1, -1), .5)
|
|
1146
|
-
};
|
|
1147
|
-
if ([
|
|
1148
|
-
"xs",
|
|
1149
|
-
"s",
|
|
1150
|
-
"m",
|
|
1151
|
-
"l",
|
|
1152
|
-
"xl"
|
|
1153
|
-
].includes(name)) return {
|
|
1154
|
-
"--v-fingertip": theme.spacing[`fingertip-${name}`],
|
|
1155
|
-
"--v-fingertip-half": unitBy(theme.spacing[`fingertip-${name}`], .5)
|
|
1156
|
-
};
|
|
1157
|
-
if (theme.spacing[name]) return {
|
|
1158
|
-
"--v-fingertip": theme.spacing[name],
|
|
1159
|
-
"--v-fingertip-half": unitBy(theme.spacing[name], .5)
|
|
1160
|
-
};
|
|
1161
|
-
}]
|
|
1162
|
-
],
|
|
1163
|
-
...paletteRules,
|
|
1164
|
-
...i8Rules
|
|
1165
|
-
];
|
|
1166
|
-
//#endregion
|
|
1167
|
-
//#region src/theme/types.ts
|
|
1168
|
-
function k$1(n, base = 1) {
|
|
1169
|
-
return base * 1.618 ** n;
|
|
1170
|
-
}
|
|
1171
|
-
//#endregion
|
|
1172
|
-
//#region src/theme/typography.ts
|
|
1173
|
-
function font(weight, boldWeight, size, height, spacing) {
|
|
1174
|
-
return {
|
|
1175
|
-
weight,
|
|
1176
|
-
boldWeight,
|
|
1177
|
-
size,
|
|
1178
|
-
height,
|
|
1179
|
-
spacing
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
const defaultTypography = {
|
|
1183
|
-
"h1": font(400, 700, k$1(3.5), k$1(.5), -.025),
|
|
1184
|
-
"h2": font(400, 700, k$1(2.5), k$1(.5), -.022),
|
|
1185
|
-
"h3": font(400, 700, k$1(2), k$1(.5), -.022),
|
|
1186
|
-
"h4": font(400, 600, k$1(1), k$1(.5), -.02),
|
|
1187
|
-
"h5": font(400, 600, k$1(.5), k$1(.5), -.017),
|
|
1188
|
-
"h6": font(600, 700, k$1(.25), k$1(.5), -.014),
|
|
1189
|
-
"subheading": font(400, 600, k$1(-.2), k$1(.5), -.007),
|
|
1190
|
-
"body-l": font(400, 600, k$1(.5), k$1(.75), -.014),
|
|
1191
|
-
"body": font(400, 600, k$1(0), k$1(.75), -.011),
|
|
1192
|
-
"body-s": font(400, 600, k$1(-.5), k$1(1), 0),
|
|
1193
|
-
"callout": font(400, 600, k$1(-.25), k$1(.5), -.009),
|
|
1194
|
-
"label": font(500, 700, k$1(-.25), k$1(.5), -.004),
|
|
1195
|
-
"caption": font(400, 600, k$1(-.5), k$1(.5), -.007),
|
|
1196
|
-
"overline": font(400, 600, k$1(-.5), k$1(.5), .0618)
|
|
1197
|
-
};
|
|
1198
|
-
function buildFontTheme(size, w, wBold, lh, ls, actualFontHeightFactor = 1, actualFontHeightTopBottomRatio = .5) {
|
|
1199
|
-
const correctedSize = size * actualFontHeightFactor;
|
|
1200
|
-
const m = (lh * size - correctedSize) / size;
|
|
1201
|
-
const half = correctedSize / 2;
|
|
1202
|
-
const offt = correctedSize * actualFontHeightTopBottomRatio - half + m / 2;
|
|
1203
|
-
const offb = correctedSize * (1 - actualFontHeightTopBottomRatio) - half + m / 2;
|
|
1204
|
-
const mt = round(offt, 4);
|
|
1205
|
-
const mb = round(offb, 4);
|
|
1206
|
-
return {
|
|
1207
|
-
mt,
|
|
1208
|
-
mb,
|
|
1209
|
-
size,
|
|
1210
|
-
correctedSize,
|
|
1211
|
-
theme: [`${size}em`, {
|
|
1212
|
-
"--font-bold": wBold,
|
|
1213
|
-
"--font-size": `${size}em`,
|
|
1214
|
-
"--font-corrected": `${correctedSize}em`,
|
|
1215
|
-
"--font-bc": `${-mb}em`,
|
|
1216
|
-
"--font-tc": `${-mt}em`,
|
|
1217
|
-
"font-weight": w,
|
|
1218
|
-
"line-height": `${lh}em`,
|
|
1219
|
-
"letter-spacing": `${ls}em`
|
|
1220
|
-
}]
|
|
1221
|
-
};
|
|
1222
|
-
}
|
|
1223
|
-
//#endregion
|
|
1224
|
-
//#region src/theme/utils/radius-scale.ts
|
|
1225
|
-
const ROOT_FONT_PX = 16;
|
|
1226
|
-
function parseRadius(input) {
|
|
1227
|
-
const m = input.trim().match(/^(-?\d*\.?\d+)(px|em|rem)?$/);
|
|
1228
|
-
if (!m) return null;
|
|
1229
|
-
const n = Number.parseFloat(m[1]);
|
|
1230
|
-
if (!Number.isFinite(n)) return null;
|
|
1231
|
-
return {
|
|
1232
|
-
n,
|
|
1233
|
-
unit: m[2] ?? ""
|
|
1234
|
-
};
|
|
1235
|
-
}
|
|
1236
|
-
function computeRadiusScale(baseRadius) {
|
|
1237
|
-
const parsed = parseRadius(baseRadius);
|
|
1238
|
-
if (!parsed) return {
|
|
1239
|
-
r0: `min(${baseRadius}, clamp(2px, calc(${baseRadius} / 2), 4px))`,
|
|
1240
|
-
r1: baseRadius,
|
|
1241
|
-
r2: `calc(${baseRadius} * 1.5)`,
|
|
1242
|
-
r3: `calc(${baseRadius} * 2)`,
|
|
1243
|
-
r4: `calc(${baseRadius} * 2.5)`
|
|
1244
|
-
};
|
|
1245
|
-
const { n, unit } = parsed;
|
|
1246
|
-
if (n === 0) return {
|
|
1247
|
-
r0: "0",
|
|
1248
|
-
r1: "0",
|
|
1249
|
-
r2: "0",
|
|
1250
|
-
r3: "0",
|
|
1251
|
-
r4: "0"
|
|
1252
|
-
};
|
|
1253
|
-
const basePx = unit === "em" || unit === "rem" ? n * ROOT_FONT_PX : n;
|
|
1254
|
-
const r0Px = Math.min(basePx, Math.max(2, Math.min(basePx / 2, 4)));
|
|
1255
|
-
const scaled = unit ? baseRadius : `${n}px`;
|
|
1256
|
-
return {
|
|
1257
|
-
r0: `${round(r0Px, 3)}px`,
|
|
1258
|
-
r1: baseRadius,
|
|
1259
|
-
r2: unitBy(scaled, 1.5),
|
|
1260
|
-
r3: unitBy(scaled, 2),
|
|
1261
|
-
r4: unitBy(scaled, 2.5)
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
//#endregion
|
|
1265
|
-
//#region src/theme/theme.ts
|
|
1266
|
-
const themeFactory = (opts) => {
|
|
1267
|
-
/**
|
|
1268
|
-
* Spacing
|
|
1269
|
-
*/
|
|
1270
|
-
const spacing = {
|
|
1271
|
-
"$xxs": `${round(1 / opts.spacingFactor ** 3, 3)}em`,
|
|
1272
|
-
"$xs": `${round(1 / opts.spacingFactor ** 2, 3)}em`,
|
|
1273
|
-
"$s": `${round(1 / opts.spacingFactor, 3)}em`,
|
|
1274
|
-
"$m": "1em",
|
|
1275
|
-
"$l": `${round(opts.spacingFactor, 3)}em`,
|
|
1276
|
-
"$xl": `${round(opts.spacingFactor ** 2, 3)}em`,
|
|
1277
|
-
"$xxl": `${round(opts.spacingFactor ** 3, 3)}em`,
|
|
1278
|
-
"fingertip": "var(--v-fingertip)",
|
|
1279
|
-
"fingertip-half": "var(--v-fingertip-half)",
|
|
1280
|
-
"fingertip-xs": opts.fingertip.xs,
|
|
1281
|
-
"fingertip-s": opts.fingertip.s,
|
|
1282
|
-
"fingertip-m": opts.fingertip.m,
|
|
1283
|
-
"fingertip-l": opts.fingertip.l,
|
|
1284
|
-
"fingertip-xl": opts.fingertip.xl,
|
|
1285
|
-
"$font-tc": "var(--font-bc)",
|
|
1286
|
-
"$font-bc": "var(--font-tc)",
|
|
1287
|
-
"$font-size": "var(--font-size)",
|
|
1288
|
-
"$font-corrected": "var(--font-corrected)",
|
|
1289
|
-
"$card-spacing": "var(--card-spacing)",
|
|
1290
|
-
"$card-spacing-dense": "var(--card-spacing-dense)",
|
|
1291
|
-
"$card-heading-size": "var(--card-heading-size)",
|
|
1292
|
-
"$card-heading-corrected": "var(--card-heading-corrected)",
|
|
1293
|
-
"base-radius": opts.baseRadius
|
|
1294
|
-
};
|
|
1295
|
-
const lineHeight = {
|
|
1296
|
-
"fingertip": "var(--v-fingertip)",
|
|
1297
|
-
"fingertip-half": "var(--v-fingertip-half)",
|
|
1298
|
-
"fingertip-xs": opts.fingertip.xs,
|
|
1299
|
-
"fingertip-s": opts.fingertip.s,
|
|
1300
|
-
"fingertip-m": opts.fingertip.m,
|
|
1301
|
-
"fingertip-l": opts.fingertip.l,
|
|
1302
|
-
"fingertip-xl": opts.fingertip.xl
|
|
1303
|
-
};
|
|
1304
|
-
const borderRadius = {
|
|
1305
|
-
...spacing,
|
|
1306
|
-
base: opts.baseRadius,
|
|
1307
|
-
...computeRadiusScale(opts.baseRadius)
|
|
1308
|
-
};
|
|
1309
|
-
/**
|
|
1310
|
-
* Typography
|
|
1311
|
-
*/
|
|
1312
|
-
const fontWeight = { $bold: "var(--font-bold)" };
|
|
1313
|
-
const fontSize = { "card-header": ["var(--card-heading-size)", {
|
|
1314
|
-
"--font-bold": "var(--card-heading-bold)",
|
|
1315
|
-
"--font-size": "var(--card-heading-size)",
|
|
1316
|
-
"--font-corrected": "var(--card-heading-corrected)",
|
|
1317
|
-
"--font-bc": "var(--card-heading-bc)",
|
|
1318
|
-
"--font-tc": "var(--card-heading-tc)",
|
|
1319
|
-
"font-weight": "var(--card-heading-weight)",
|
|
1320
|
-
"line-height": "var(--card-heading-lh)",
|
|
1321
|
-
"letter-spacing": "var(--card-heading-ls)"
|
|
1322
|
-
}] };
|
|
1323
|
-
for (const [name, val] of Object.entries(opts.typography)) if (val?.size) {
|
|
1324
|
-
const ft = buildFontTheme(val.size || 1, val.weight || 400, val.boldWeight || 700, val.height || 1, val.spacing || 0, val.actualHeightFactor || opts.actualFontHeightFactor, val.actualHeightTopBottomRatio || opts.actualFontHeightTopBottomRatio);
|
|
1325
|
-
fontSize[name] = ft.theme;
|
|
1326
|
-
spacing[name] = `${ft.size}em`;
|
|
1327
|
-
}
|
|
1328
|
-
const palette = generatePalette(opts.palette);
|
|
1329
|
-
/**
|
|
1330
|
-
* Putting all together
|
|
1331
|
-
*/
|
|
1332
|
-
return {
|
|
1333
|
-
paletteOpts: palette.opts,
|
|
1334
|
-
theme: {
|
|
1335
|
-
colors: palette.colors,
|
|
1336
|
-
surfaces: palette.surfaces,
|
|
1337
|
-
reverseLightLayers: opts.layers.reverseLight,
|
|
1338
|
-
reverseDarkLayers: opts.layers.reverseDark,
|
|
1339
|
-
lineHeight,
|
|
1340
|
-
spacing,
|
|
1341
|
-
fontWeight,
|
|
1342
|
-
actualFontHeightFactor: opts.actualFontHeightFactor,
|
|
1343
|
-
cardSpacingFactor: opts.cardSpacingFactor,
|
|
1344
|
-
fontSize,
|
|
1345
|
-
width: spacing,
|
|
1346
|
-
height: spacing,
|
|
1347
|
-
maxWidth: spacing,
|
|
1348
|
-
maxHeight: spacing,
|
|
1349
|
-
minWidth: spacing,
|
|
1350
|
-
minHeight: spacing,
|
|
1351
|
-
borderRadius,
|
|
1352
|
-
animation: opts.animation
|
|
1353
|
-
}
|
|
1354
|
-
};
|
|
1355
|
-
};
|
|
1356
|
-
//#endregion
|
|
1357
551
|
//#region src/theme/generated/component-classes.ts
|
|
1358
552
|
const componentClasses = {
|
|
1359
553
|
AppLayout: [
|
|
@@ -1737,7 +931,6 @@ const componentClasses = {
|
|
|
1737
931
|
DevTools: [
|
|
1738
932
|
"[&>.checkbox]:hover:bg-neutral-100",
|
|
1739
933
|
"absolute",
|
|
1740
|
-
"b",
|
|
1741
934
|
"bg-transparent",
|
|
1742
935
|
"border",
|
|
1743
936
|
"border-0",
|
|
@@ -2059,7 +1252,6 @@ const componentClasses = {
|
|
|
2059
1252
|
"btn",
|
|
2060
1253
|
"btn-icon",
|
|
2061
1254
|
"c8-flat",
|
|
2062
|
-
"disabled:opacity-30",
|
|
2063
1255
|
"flex",
|
|
2064
1256
|
"gap-1",
|
|
2065
1257
|
"icon-color",
|
|
@@ -2195,24 +1387,899 @@ const componentClasses = {
|
|
|
2195
1387
|
"text-label",
|
|
2196
1388
|
"whitespace-nowrap"
|
|
2197
1389
|
],
|
|
2198
|
-
Tabs: [
|
|
2199
|
-
"c8-flat",
|
|
2200
|
-
"flex",
|
|
2201
|
-
"grow",
|
|
2202
|
-
"relative",
|
|
2203
|
-
"tab",
|
|
2204
|
-
"tabs-indicator"
|
|
2205
|
-
]
|
|
1390
|
+
Tabs: [
|
|
1391
|
+
"c8-flat",
|
|
1392
|
+
"flex",
|
|
1393
|
+
"grow",
|
|
1394
|
+
"relative",
|
|
1395
|
+
"tab",
|
|
1396
|
+
"tabs-indicator"
|
|
1397
|
+
]
|
|
1398
|
+
};
|
|
1399
|
+
function getComponentClasses(...components) {
|
|
1400
|
+
const set = /* @__PURE__ */ new Set();
|
|
1401
|
+
for (const name of components) {
|
|
1402
|
+
const key = name.startsWith("Vu") ? name.slice(2) : name;
|
|
1403
|
+
for (const cls of componentClasses[key] ?? []) set.add(cls);
|
|
1404
|
+
}
|
|
1405
|
+
return [...set];
|
|
1406
|
+
}
|
|
1407
|
+
//#endregion
|
|
1408
|
+
//#region src/theme/palitra.ts
|
|
1409
|
+
const defaultOpts = {
|
|
1410
|
+
colors: {
|
|
1411
|
+
primary: {
|
|
1412
|
+
color: "#004eaf",
|
|
1413
|
+
preserveInputColor: true,
|
|
1414
|
+
saturate: {
|
|
1415
|
+
dark: -.2,
|
|
1416
|
+
light: -.2
|
|
1417
|
+
}
|
|
1418
|
+
},
|
|
1419
|
+
grey: {
|
|
1420
|
+
color: "#858892",
|
|
1421
|
+
saturate: {
|
|
1422
|
+
dark: 0,
|
|
1423
|
+
light: 0
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
secondary: {
|
|
1427
|
+
color: "#edd812",
|
|
1428
|
+
vivid: {
|
|
1429
|
+
dark: .4,
|
|
1430
|
+
light: .4
|
|
1431
|
+
}
|
|
1432
|
+
},
|
|
1433
|
+
neutral: {
|
|
1434
|
+
color: "#5da0c5",
|
|
1435
|
+
vivid: {
|
|
1436
|
+
dark: .1,
|
|
1437
|
+
light: .1
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
good: {
|
|
1441
|
+
color: "#7bc76a",
|
|
1442
|
+
vivid: {
|
|
1443
|
+
dark: .2,
|
|
1444
|
+
light: .5
|
|
1445
|
+
}
|
|
1446
|
+
},
|
|
1447
|
+
warn: {
|
|
1448
|
+
color: "#ef9421",
|
|
1449
|
+
vivid: {
|
|
1450
|
+
dark: .2,
|
|
1451
|
+
light: .3
|
|
1452
|
+
}
|
|
1453
|
+
},
|
|
1454
|
+
error: { color: "#bf5a5f" }
|
|
1455
|
+
},
|
|
1456
|
+
lightest: .97,
|
|
1457
|
+
darkest: .24,
|
|
1458
|
+
layersDepth: .08,
|
|
1459
|
+
flatness: 1,
|
|
1460
|
+
mainPalette: {
|
|
1461
|
+
preserveInputColor: false,
|
|
1462
|
+
luminance: {
|
|
1463
|
+
useMiddle: true,
|
|
1464
|
+
middle: .62
|
|
1465
|
+
},
|
|
1466
|
+
saturate: {
|
|
1467
|
+
dark: -.25,
|
|
1468
|
+
light: -.25
|
|
1469
|
+
},
|
|
1470
|
+
vivid: {
|
|
1471
|
+
dark: .1,
|
|
1472
|
+
light: .2
|
|
1473
|
+
}
|
|
1474
|
+
},
|
|
1475
|
+
layerPalette: {
|
|
1476
|
+
desaturate: .2,
|
|
1477
|
+
saturate: {
|
|
1478
|
+
dark: -.2,
|
|
1479
|
+
light: -.2
|
|
1480
|
+
},
|
|
1481
|
+
vivid: {
|
|
1482
|
+
dark: 0,
|
|
1483
|
+
light: 0
|
|
1484
|
+
}
|
|
1485
|
+
},
|
|
1486
|
+
surfaces: {
|
|
1487
|
+
"0": [
|
|
1488
|
+
"scope-light-0",
|
|
1489
|
+
"scope-dark-1",
|
|
1490
|
+
"scope-color-100",
|
|
1491
|
+
"scope-dark-0",
|
|
1492
|
+
"scope-light-1",
|
|
1493
|
+
"scope-color-800"
|
|
1494
|
+
],
|
|
1495
|
+
"1": [
|
|
1496
|
+
"scope-light-1",
|
|
1497
|
+
"scope-dark-1",
|
|
1498
|
+
"scope-color-100",
|
|
1499
|
+
"scope-dark-1",
|
|
1500
|
+
"scope-light-1",
|
|
1501
|
+
"scope-color-800"
|
|
1502
|
+
],
|
|
1503
|
+
"2": [
|
|
1504
|
+
"scope-light-2",
|
|
1505
|
+
"scope-dark-1",
|
|
1506
|
+
"scope-color-100",
|
|
1507
|
+
"scope-dark-2",
|
|
1508
|
+
"scope-light-1",
|
|
1509
|
+
"scope-color-800"
|
|
1510
|
+
],
|
|
1511
|
+
"3": [
|
|
1512
|
+
"scope-light-3",
|
|
1513
|
+
"scope-dark-1",
|
|
1514
|
+
"scope-color-100",
|
|
1515
|
+
"scope-dark-3",
|
|
1516
|
+
"scope-light-1",
|
|
1517
|
+
"scope-color-800"
|
|
1518
|
+
],
|
|
1519
|
+
"4": [
|
|
1520
|
+
"scope-light-4",
|
|
1521
|
+
"scope-dark-1",
|
|
1522
|
+
"scope-color-100",
|
|
1523
|
+
"scope-dark-4",
|
|
1524
|
+
"scope-light-1",
|
|
1525
|
+
"scope-color-800"
|
|
1526
|
+
],
|
|
1527
|
+
"50": [
|
|
1528
|
+
"scope-color-50",
|
|
1529
|
+
"scope-color-700",
|
|
1530
|
+
"scope-color-200",
|
|
1531
|
+
"scope-color-900",
|
|
1532
|
+
"scope-color-200",
|
|
1533
|
+
"scope-color-500"
|
|
1534
|
+
],
|
|
1535
|
+
"100": [
|
|
1536
|
+
"scope-color-100",
|
|
1537
|
+
"scope-color-800",
|
|
1538
|
+
"scope-color-200",
|
|
1539
|
+
"scope-color-800",
|
|
1540
|
+
"scope-color-200",
|
|
1541
|
+
"scope-color-500"
|
|
1542
|
+
],
|
|
1543
|
+
"200": [
|
|
1544
|
+
"scope-color-200",
|
|
1545
|
+
"scope-color-800",
|
|
1546
|
+
"scope-color-400",
|
|
1547
|
+
"scope-color-700",
|
|
1548
|
+
"scope-color-100",
|
|
1549
|
+
"scope-color-400"
|
|
1550
|
+
],
|
|
1551
|
+
"300": [
|
|
1552
|
+
"scope-color-300",
|
|
1553
|
+
"scope-color-900",
|
|
1554
|
+
"scope-color-500",
|
|
1555
|
+
"scope-color-600",
|
|
1556
|
+
"scope-color-100",
|
|
1557
|
+
"scope-color-300"
|
|
1558
|
+
],
|
|
1559
|
+
"400": [
|
|
1560
|
+
"scope-color-400",
|
|
1561
|
+
"scope-color-50",
|
|
1562
|
+
"scope-color-200",
|
|
1563
|
+
"scope-color-500",
|
|
1564
|
+
"scope-color-50",
|
|
1565
|
+
"scope-color-200"
|
|
1566
|
+
],
|
|
1567
|
+
"500": [
|
|
1568
|
+
"scope-color-500",
|
|
1569
|
+
"scope-color-50",
|
|
1570
|
+
"scope-color-200",
|
|
1571
|
+
"scope-color-400",
|
|
1572
|
+
"scope-color-50",
|
|
1573
|
+
"scope-color-100"
|
|
1574
|
+
],
|
|
1575
|
+
"600": [
|
|
1576
|
+
"scope-color-600",
|
|
1577
|
+
"scope-color-100",
|
|
1578
|
+
"scope-color-300",
|
|
1579
|
+
"scope-color-300",
|
|
1580
|
+
"scope-color-900",
|
|
1581
|
+
"scope-color-700"
|
|
1582
|
+
],
|
|
1583
|
+
"700": [
|
|
1584
|
+
"scope-color-700",
|
|
1585
|
+
"scope-color-100",
|
|
1586
|
+
"scope-color-300",
|
|
1587
|
+
"scope-color-200",
|
|
1588
|
+
"scope-color-800",
|
|
1589
|
+
"scope-color-600"
|
|
1590
|
+
],
|
|
1591
|
+
"800": [
|
|
1592
|
+
"scope-color-800",
|
|
1593
|
+
"scope-color-200",
|
|
1594
|
+
"scope-color-400",
|
|
1595
|
+
"scope-color-100",
|
|
1596
|
+
"scope-color-800",
|
|
1597
|
+
"scope-color-500"
|
|
1598
|
+
],
|
|
1599
|
+
"900": [
|
|
1600
|
+
"scope-color-900",
|
|
1601
|
+
"scope-color-200",
|
|
1602
|
+
"scope-color-400",
|
|
1603
|
+
"scope-color-50",
|
|
1604
|
+
"scope-color-700",
|
|
1605
|
+
"scope-color-500"
|
|
1606
|
+
]
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
function generatePalette(_opts) {
|
|
1610
|
+
const _colors = _opts?.colors || {};
|
|
1611
|
+
for (const key of Object.keys(_colors)) {
|
|
1612
|
+
const col = _opts?.colors?.[key];
|
|
1613
|
+
if (typeof col === "string") _colors[key] = { color: col };
|
|
1614
|
+
}
|
|
1615
|
+
const opts = defu$1({
|
|
1616
|
+
..._opts,
|
|
1617
|
+
colors: _colors
|
|
1618
|
+
}, defaultOpts);
|
|
1619
|
+
const bgOptions = {
|
|
1620
|
+
count: 5,
|
|
1621
|
+
preserveInputColor: false,
|
|
1622
|
+
flatness: opts.layerPalette.flatness ?? opts.flatness,
|
|
1623
|
+
luminance: {
|
|
1624
|
+
dark: opts.layerPalette.luminance?.dark ?? opts.darkest,
|
|
1625
|
+
light: opts.layerPalette.luminance?.light ?? opts.darkest + opts.layersDepth,
|
|
1626
|
+
useMiddle: false
|
|
1627
|
+
},
|
|
1628
|
+
saturate: opts.layerPalette.saturate,
|
|
1629
|
+
vivid: opts.layerPalette.vivid,
|
|
1630
|
+
suffixes: [
|
|
1631
|
+
"dark-0",
|
|
1632
|
+
"dark-1",
|
|
1633
|
+
"dark-2",
|
|
1634
|
+
"dark-3",
|
|
1635
|
+
"dark-4"
|
|
1636
|
+
]
|
|
1637
|
+
};
|
|
1638
|
+
const darks = palitra(multiplySaturation(opts.colors, opts.layerPalette.desaturate), bgOptions).toStrings();
|
|
1639
|
+
bgOptions.suffixes = [
|
|
1640
|
+
"light-0",
|
|
1641
|
+
"light-1",
|
|
1642
|
+
"light-2",
|
|
1643
|
+
"light-3",
|
|
1644
|
+
"light-4"
|
|
1645
|
+
].toReversed();
|
|
1646
|
+
const lumDark = bgOptions.luminance?.dark ?? opts.darkest;
|
|
1647
|
+
bgOptions.luminance = {
|
|
1648
|
+
dark: 1 - ((bgOptions.luminance?.light ?? opts.darkest + opts.layersDepth) - lumDark),
|
|
1649
|
+
light: 1,
|
|
1650
|
+
useMiddle: false
|
|
1651
|
+
};
|
|
1652
|
+
const lights = palitra(multiplySaturation(opts.colors, opts.layerPalette.desaturate), bgOptions).toStrings();
|
|
1653
|
+
const colors = palitra({
|
|
1654
|
+
primary: opts.colors.primary,
|
|
1655
|
+
grey: opts.colors.grey,
|
|
1656
|
+
secondary: opts.colors.secondary,
|
|
1657
|
+
neutral: opts.colors.neutral,
|
|
1658
|
+
good: opts.colors.good,
|
|
1659
|
+
warn: opts.colors.warn,
|
|
1660
|
+
error: opts.colors.error
|
|
1661
|
+
}, {
|
|
1662
|
+
count: 10,
|
|
1663
|
+
preserveInputColor: opts.mainPalette.preserveInputColor,
|
|
1664
|
+
flatness: opts.mainPalette.flatness ?? opts.flatness,
|
|
1665
|
+
luminance: {
|
|
1666
|
+
dark: opts.mainPalette.luminance?.dark ?? opts.darkest + opts.layersDepth + .02,
|
|
1667
|
+
light: opts.mainPalette.luminance?.light ?? opts.lightest,
|
|
1668
|
+
useMiddle: opts.mainPalette.luminance?.useMiddle,
|
|
1669
|
+
middle: opts.mainPalette.luminance?.middle
|
|
1670
|
+
},
|
|
1671
|
+
saturate: opts.mainPalette.saturate,
|
|
1672
|
+
vivid: opts.mainPalette.vivid
|
|
1673
|
+
}).toStrings();
|
|
1674
|
+
return {
|
|
1675
|
+
opts,
|
|
1676
|
+
colors: {
|
|
1677
|
+
...darks,
|
|
1678
|
+
...lights,
|
|
1679
|
+
...colors
|
|
1680
|
+
},
|
|
1681
|
+
surfaces: opts.surfaces
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
function multiplySaturation(colors, m = .5) {
|
|
1685
|
+
const newObj = {};
|
|
1686
|
+
for (const [key, val] of Object.entries(colors)) {
|
|
1687
|
+
const col = typeof val === "string" ? val : val.color;
|
|
1688
|
+
if (col) {
|
|
1689
|
+
const [h, s, l] = color(col).hsl();
|
|
1690
|
+
newObj[key] = color(h, s * m, l, "hsl").hex();
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
return newObj;
|
|
1694
|
+
}
|
|
1695
|
+
const layerN = (n, reverse) => reverse ? 4 - n : n;
|
|
1696
|
+
function getPaletteShortcuts() {
|
|
1697
|
+
return [
|
|
1698
|
+
[/^layer-([0-4])$/, ([, a], { theme }) => {
|
|
1699
|
+
const sideTemplate = (bg, n) => {
|
|
1700
|
+
const fg = bg === "light" ? "dark" : "light";
|
|
1701
|
+
return `current-bg-scope-${bg}-${n} current-text-scope-${fg}-0 current-icon-scope-${fg}-0 current-text-muted-scope-${fg}-2 current-icon-muted-scope-${fg}-2 current-bg-hover-scope-${bg}-${Math.min(n + 1, 4)} current-border-hover-scope-${bg}-3 current-text-hover-scope-${fg}-0`;
|
|
1702
|
+
};
|
|
1703
|
+
const d = layerN(Number(a), theme.reverseDarkLayers);
|
|
1704
|
+
const l = layerN(Number(a), theme.reverseLightLayers);
|
|
1705
|
+
const dark = sideTemplate("dark", d);
|
|
1706
|
+
return toUnoShortcut({
|
|
1707
|
+
"": `${sideTemplate("light", l)} current-border-grey-500 bg-current text-current`,
|
|
1708
|
+
"dark:": dark,
|
|
1709
|
+
"[&.dark]:": dark
|
|
1710
|
+
});
|
|
1711
|
+
}],
|
|
1712
|
+
[/^(current-text-muted|current-icon-muted|current-text-hover|current-bg-hover|current-border-hover|bg|text|current-text|current-bg|current-icon|current-border|current-outline|current-caret|current-hl|i8-bg|i8-border|i8-outline)-layer-([0-4])$/, ([, target, a], { theme }) => {
|
|
1713
|
+
const d = layerN(Number(a), theme.reverseDarkLayers);
|
|
1714
|
+
return toUnoShortcut({
|
|
1715
|
+
"": `${target}-scope-light-${layerN(Number(a), theme.reverseLightLayers)}`,
|
|
1716
|
+
"dark:": `${target}-scope-dark-${d}`,
|
|
1717
|
+
"[&.dark]:": `${target}-scope-dark-${d}`
|
|
1718
|
+
});
|
|
1719
|
+
}],
|
|
1720
|
+
[/^surface-(.+)$/, ([, s], { theme }) => theme.surfaces[s] ? toUnoShortcut({
|
|
1721
|
+
"": `current-bg-${theme.surfaces[s][0]} current-text-${theme.surfaces[s][1]} current-icon-${theme.surfaces[s][1]} current-border-${theme.surfaces[s][2]} bg-current text-current border-current icon-current`,
|
|
1722
|
+
"dark:": `current-bg-${theme.surfaces[s][3]} current-text-${theme.surfaces[s][4]} current-icon-${theme.surfaces[s][4]} current-border-${theme.surfaces[s][5]} shadow-black/30`,
|
|
1723
|
+
"[&.dark]:": `current-bg-${theme.surfaces[s][3]} current-text-${theme.surfaces[s][4]} current-icon-${theme.surfaces[s][4]} current-border-${theme.surfaces[s][5]} shadow-black/30`
|
|
1724
|
+
}) : ""],
|
|
1725
|
+
{ surface: "surface-100" }
|
|
1726
|
+
];
|
|
1727
|
+
}
|
|
1728
|
+
//#endregion
|
|
1729
|
+
//#region src/theme/rules/palette.ts
|
|
1730
|
+
function colorToRgbWithOpacity(c) {
|
|
1731
|
+
const [r, g, b, _a] = color(c).rgba();
|
|
1732
|
+
return `${r} ${g} ${b}`;
|
|
1733
|
+
}
|
|
1734
|
+
function getOpacityVar(key) {
|
|
1735
|
+
return {
|
|
1736
|
+
bg: "--un-bg-opacity",
|
|
1737
|
+
text: "--un-text-opacity",
|
|
1738
|
+
fill: "--un-text-opacity",
|
|
1739
|
+
stroke: "--un-text-opacity",
|
|
1740
|
+
icon: "--un-icon-opacity",
|
|
1741
|
+
border: "--un-border-opacity",
|
|
1742
|
+
outline: "--un-outline-opacity",
|
|
1743
|
+
caret: "--un-caret-opacity",
|
|
1744
|
+
shadow: "--un-shadow-opacity",
|
|
1745
|
+
ring: "--un-ring-opacity"
|
|
1746
|
+
}[key];
|
|
1747
|
+
}
|
|
1748
|
+
function getCssTarget(key) {
|
|
1749
|
+
return {
|
|
1750
|
+
bg: "background-color",
|
|
1751
|
+
text: "color",
|
|
1752
|
+
fill: "fill",
|
|
1753
|
+
stroke: "stroke",
|
|
1754
|
+
icon: "color",
|
|
1755
|
+
border: "border-color",
|
|
1756
|
+
outline: "outline-color",
|
|
1757
|
+
caret: "caret-color",
|
|
1758
|
+
shadow: "--un-shadow-color",
|
|
1759
|
+
ring: "--un-ring-color"
|
|
1760
|
+
}[key];
|
|
1761
|
+
}
|
|
1762
|
+
const SCOPE_SHADES = [
|
|
1763
|
+
"50",
|
|
1764
|
+
"100",
|
|
1765
|
+
"200",
|
|
1766
|
+
"300",
|
|
1767
|
+
"400",
|
|
1768
|
+
"500",
|
|
1769
|
+
"600",
|
|
1770
|
+
"700",
|
|
1771
|
+
"800",
|
|
1772
|
+
"900"
|
|
1773
|
+
];
|
|
1774
|
+
const SCOPE_LAYERS = [
|
|
1775
|
+
"0",
|
|
1776
|
+
"1",
|
|
1777
|
+
"2",
|
|
1778
|
+
"3",
|
|
1779
|
+
"4"
|
|
1780
|
+
];
|
|
1781
|
+
const CURRENT_SLOTS = [
|
|
1782
|
+
"text-muted",
|
|
1783
|
+
"icon-muted",
|
|
1784
|
+
"text-hover",
|
|
1785
|
+
"bg-hover",
|
|
1786
|
+
"border-hover",
|
|
1787
|
+
"text",
|
|
1788
|
+
"bg",
|
|
1789
|
+
"icon",
|
|
1790
|
+
"border",
|
|
1791
|
+
"outline",
|
|
1792
|
+
"caret",
|
|
1793
|
+
"hl"
|
|
1794
|
+
];
|
|
1795
|
+
const slotAlt = CURRENT_SLOTS.join("|");
|
|
1796
|
+
const sourceAlt = [
|
|
1797
|
+
...CURRENT_SLOTS,
|
|
1798
|
+
"muted",
|
|
1799
|
+
"hover"
|
|
1800
|
+
].map((s) => `-${s}`).join("|");
|
|
1801
|
+
const currentSlotRe = new RegExp(`^current-(${slotAlt})-(.+)$`);
|
|
1802
|
+
const currentPaintRe = new RegExp(`^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(${sourceAlt})?(\\/\\d{1,3})?$`);
|
|
1803
|
+
function getScopeCssVars(c, theme) {
|
|
1804
|
+
const col = theme.colors[c];
|
|
1805
|
+
if (!col) return;
|
|
1806
|
+
const vars = { "--scope-color": colorToRgbWithOpacity(col) };
|
|
1807
|
+
for (const shade of SCOPE_SHADES) vars[`--scope-color-${shade}`] = colorToRgbWithOpacity(theme.colors[`${c}-${shade}`]) || "";
|
|
1808
|
+
for (const layer of SCOPE_LAYERS) {
|
|
1809
|
+
vars[`--scope-light-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-light-${layer}`]) || "";
|
|
1810
|
+
vars[`--scope-dark-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-dark-${layer}`]) || "";
|
|
1811
|
+
}
|
|
1812
|
+
vars["--current-hl"] = colorToRgbWithOpacity(theme.colors[`${c}-500`]) || "";
|
|
1813
|
+
const greyMuted = colorToRgbWithOpacity(theme.colors[`grey-500`]) || "";
|
|
1814
|
+
vars["--current-text-muted"] = greyMuted;
|
|
1815
|
+
vars["--current-icon-muted"] = greyMuted;
|
|
1816
|
+
vars["--current-text-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-dark-0`]) || "";
|
|
1817
|
+
vars["--current-bg-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-light-1`]) || "";
|
|
1818
|
+
vars["--current-border-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-light-3`]) || "";
|
|
1819
|
+
return vars;
|
|
1820
|
+
}
|
|
1821
|
+
const paletteRules = [
|
|
1822
|
+
[currentSlotRe, (match, { theme }) => {
|
|
1823
|
+
const t = match[1];
|
|
1824
|
+
const c = match[2];
|
|
1825
|
+
if (c.startsWith("scope-")) return { [`--current-${t}`]: `var(--${c})` };
|
|
1826
|
+
if (c === "hl") return { [`--current-${t}`]: `var(--current-hl)` };
|
|
1827
|
+
const themeCol = theme.colors[c];
|
|
1828
|
+
const colStr = typeof themeCol === "string" ? themeCol : themeCol?.DEFAULT;
|
|
1829
|
+
if (!colStr) return;
|
|
1830
|
+
try {
|
|
1831
|
+
return { [`--current-${t}`]: colorToRgbWithOpacity(colStr) };
|
|
1832
|
+
} catch {
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
}],
|
|
1836
|
+
[currentPaintRe, (match, { theme: _theme }) => {
|
|
1837
|
+
const target = match[1];
|
|
1838
|
+
let source = match[2] || `-${target}`;
|
|
1839
|
+
if (source === "-muted" || source === "-hover") source = `-${target}${source}`;
|
|
1840
|
+
const opacityVar = getOpacityVar(target);
|
|
1841
|
+
const cssVar = getCssTarget(target);
|
|
1842
|
+
const o = match[3];
|
|
1843
|
+
const opacity = o ? Number(o.slice(1)) / 100 : 1;
|
|
1844
|
+
const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
|
|
1845
|
+
if (target === "icon") {
|
|
1846
|
+
const indirect = [
|
|
1847
|
+
"-hl",
|
|
1848
|
+
"-icon-muted",
|
|
1849
|
+
"-icon-hover"
|
|
1850
|
+
].includes(source);
|
|
1851
|
+
return {
|
|
1852
|
+
[opacityVar]: opacity,
|
|
1853
|
+
"--current-icon": indirect ? `var(--current${source})` : void 0
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
if (["shadow", "ring"].includes(target) && source === "-border") return {
|
|
1857
|
+
[opacityVar]: opacity === 1 ? `var(--un-border-opacity)` : opacity,
|
|
1858
|
+
[`--un-${target}-color`]: `rgb(var(--current-border) / ${opacityVal})`
|
|
1859
|
+
};
|
|
1860
|
+
return {
|
|
1861
|
+
[opacityVar]: opacity,
|
|
1862
|
+
[cssVar]: `rgb(var(--current${source}) / ${opacityVal})`
|
|
1863
|
+
};
|
|
1864
|
+
}],
|
|
1865
|
+
[/^scope-(.*)$/, (match, { theme }) => getScopeCssVars(match[1], theme)],
|
|
1866
|
+
[/^(bg|text|fill|stroke|border|outline|icon|caret)-scope-((?:color|dark|light|text|bg|white|black|icon)(?:-\d+)?)(\/\d{1,3})?$/, (match, { theme }) => {
|
|
1867
|
+
const cssVar = getCssTarget(match[1]);
|
|
1868
|
+
const opacityVar = getOpacityVar(match[1]);
|
|
1869
|
+
const source = match[2];
|
|
1870
|
+
const o = match[3];
|
|
1871
|
+
const opacity = o ? Number(o.slice(1)) / 100 : 1;
|
|
1872
|
+
const fallback = source.startsWith("color") ? `grey-${source.slice(6)}` : `grey-${source}`;
|
|
1873
|
+
const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
|
|
1874
|
+
return {
|
|
1875
|
+
[opacityVar]: opacity,
|
|
1876
|
+
[cssVar]: `rgb(var(--scope-${source}, ${theme.colors[fallback] || ""}) / ${opacityVal})`
|
|
1877
|
+
};
|
|
1878
|
+
}],
|
|
1879
|
+
[/^icon-opacity-(\d{1,3})$/, (match, { theme: _theme }) => {
|
|
1880
|
+
const o = match[1];
|
|
1881
|
+
return { "--un-icon-opacity": Number(o) / 100 };
|
|
1882
|
+
}],
|
|
1883
|
+
[/^icon-color$/, () => ({ color: `rgb(var(--current-icon) / var(--un-icon-opacity, 1))` })],
|
|
1884
|
+
[/^icon-size-(.*)$/, (match, { theme }) => {
|
|
1885
|
+
const name = match[1];
|
|
1886
|
+
if (name.startsWith("[") && name.endsWith("]")) return { "--icon-size": name.slice(1, -1) };
|
|
1887
|
+
if (theme.spacing[name]) return { "--icon-size": theme.spacing[name] };
|
|
1888
|
+
}],
|
|
1889
|
+
[/^icon-size$/, () => ({
|
|
1890
|
+
width: `var(--icon-size, 1em)`,
|
|
1891
|
+
height: `var(--icon-size, 1em)`
|
|
1892
|
+
})]
|
|
1893
|
+
];
|
|
1894
|
+
//#endregion
|
|
1895
|
+
//#region src/theme/utils/round.ts
|
|
1896
|
+
function round(v, decimals = 0) {
|
|
1897
|
+
const d = 10 ** decimals;
|
|
1898
|
+
return Math.round(v * d) / d;
|
|
1899
|
+
}
|
|
1900
|
+
//#endregion
|
|
1901
|
+
//#region src/theme/utils/unit-by.ts
|
|
1902
|
+
function unitBy(input, factor, roundTo = 3) {
|
|
1903
|
+
const v = Number.parseFloat(input);
|
|
1904
|
+
const units = /(px|em|rem|%)$/.exec(input)?.[1] || "";
|
|
1905
|
+
return `${round(v * factor, roundTo)}${units}`;
|
|
1906
|
+
}
|
|
1907
|
+
//#endregion
|
|
1908
|
+
//#region src/theme/preflights.ts
|
|
1909
|
+
const fontsPreflights = { getCSS: ({ theme }) => `${renderFontCss("body", theme.fontSize.body) + renderFontCss("figcaption", theme.fontSize.caption) + renderFontCss("h1", theme.fontSize.h1) + renderFontCss("h2", theme.fontSize.h2) + renderFontCss("h3", theme.fontSize.h3) + renderFontCss("h4", theme.fontSize.h4) + renderFontCss("h5", theme.fontSize.h5) + renderFontCss("h6", theme.fontSize.h6)}
|
|
1910
|
+
:root {
|
|
1911
|
+
--un-border-opacity: 0.25;
|
|
1912
|
+
--un-default-border-color: rgb(150 150 150 / var(--un-border-opacity));
|
|
1913
|
+
--scope-black: 0 0 0;
|
|
1914
|
+
--scope-white: 255 255 255;
|
|
1915
|
+
--scope-hl: var(--scope-color-500);
|
|
1916
|
+
--v-fingertip: ${theme.spacing["fingertip-m"] || "3em"};
|
|
1917
|
+
--v-fingertip-half: ${unitBy(theme.spacing["fingertip-m"] || "3em", .5)};
|
|
1918
|
+
${renderDefaultScope(theme)}}
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
::-webkit-scrollbar {
|
|
1922
|
+
width: 10px;
|
|
1923
|
+
height: 10px;
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
::-webkit-scrollbar-track {
|
|
1927
|
+
background: rgba(0,0,0,0.05);
|
|
1928
|
+
border-radius: 5px;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
::-webkit-scrollbar-thumb {
|
|
1932
|
+
background-color: rgba(0,0,0,0.2);
|
|
1933
|
+
border-radius: 5px;
|
|
1934
|
+
border: 2px solid transparent;
|
|
1935
|
+
background-clip: padding-box;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
::-webkit-scrollbar-thumb:hover {
|
|
1939
|
+
background-color: rgba(0,0,0,0.3);
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
|
|
1943
|
+
.dark ::-webkit-scrollbar-track {
|
|
1944
|
+
background: rgba(255,255,255,0.05);
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
.dark ::-webkit-scrollbar-thumb {
|
|
1948
|
+
background-color: rgba(255,255,255,0.2);
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
.dark ::-webkit-scrollbar-thumb:hover {
|
|
1952
|
+
background-color: rgba(255,255,255,0.3);
|
|
1953
|
+
}
|
|
1954
|
+
` };
|
|
1955
|
+
function renderDefaultScope(theme) {
|
|
1956
|
+
const vars = getScopeCssVars("neutral", theme);
|
|
1957
|
+
if (!vars) return "";
|
|
1958
|
+
return `${Object.entries(vars).map(([k, v]) => ` ${k}: ${v};`).join("\n")}\n`;
|
|
1959
|
+
}
|
|
1960
|
+
function renderFontCss(selector, font) {
|
|
1961
|
+
return `${selector} { font-size: ${font[0]}; ${Object.entries(font[1]).map((e) => `${e[0]}: ${e[1]};`).join(" ")} }\n`;
|
|
1962
|
+
}
|
|
1963
|
+
//#endregion
|
|
1964
|
+
//#region src/theme/rules/i8-rules.ts
|
|
1965
|
+
const i8Rules = [
|
|
1966
|
+
[/^i8-(border|outline|bg)-(.+)$/, (match, { theme }) => {
|
|
1967
|
+
const target = match[1];
|
|
1968
|
+
const value = match[2];
|
|
1969
|
+
if (value === "none") return { [`--i8-${target}-width`]: "0" };
|
|
1970
|
+
if (value === "transparent") return { [`--i8-${target}-color`]: "0" };
|
|
1971
|
+
if (value.startsWith("scope-")) return { [`--i8-${target}-color`]: `var(--${value})` };
|
|
1972
|
+
const col = theme.colors[value];
|
|
1973
|
+
if (col) return { [`--i8-${target}-color`]: colorToRgbWithOpacity(String(col.DEFAULT || col)) };
|
|
1974
|
+
const width = theme.spacing[value];
|
|
1975
|
+
if (width) return { [`--i8-${target}-width`]: width };
|
|
1976
|
+
if (value.endsWith("px") || value.endsWith("em") || value.endsWith("rem")) return { [`--i8-${target}-width`]: value };
|
|
1977
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1978
|
+
const v = value.slice(1, -1);
|
|
1979
|
+
if (v.endsWith("px") || v.endsWith("em") || v.endsWith("rem")) return { [`--i8-${target}-width`]: v };
|
|
1980
|
+
return { [`--i8-${target}-color`]: v };
|
|
1981
|
+
}
|
|
1982
|
+
}],
|
|
1983
|
+
[/^i8-(border|outline|bg)-opacity-(\d{1,3})$/, (match, { theme: _theme }) => {
|
|
1984
|
+
const target = match[1];
|
|
1985
|
+
const value = match[2];
|
|
1986
|
+
return { [`--i8-${target}-opacity`]: Number(value) / 100 };
|
|
1987
|
+
}],
|
|
1988
|
+
[/^i8-apply-(border|outline|bg)$/, (match, { theme: _theme }) => {
|
|
1989
|
+
const target = match[1];
|
|
1990
|
+
const prop = {
|
|
1991
|
+
border: "border-color",
|
|
1992
|
+
outline: "outline-color",
|
|
1993
|
+
bg: "background-color"
|
|
1994
|
+
}[target];
|
|
1995
|
+
const variable = {
|
|
1996
|
+
border: "--i8-border-color, var(--current-border)",
|
|
1997
|
+
outline: "--i8-outline-color, var(--current-outline)",
|
|
1998
|
+
bg: "--i8-bg-color, var(--current-bg)"
|
|
1999
|
+
}[target];
|
|
2000
|
+
const op = {
|
|
2001
|
+
border: `--i8-border-opacity, 0.2`,
|
|
2002
|
+
outline: `--i8-outline-opacity, 0.5`,
|
|
2003
|
+
bg: "--i8-bg-opacity, 1"
|
|
2004
|
+
}[target];
|
|
2005
|
+
return target === "bg" ? { [prop]: `rgb(var(${variable}) / var(${op}))` } : {
|
|
2006
|
+
[prop]: `rgb(var(${variable}) / var(${op}))`,
|
|
2007
|
+
[`${target}-width`]: `var(--i8-${target}-width, ${target === "border" ? 1 : 2}px)`
|
|
2008
|
+
};
|
|
2009
|
+
}]
|
|
2010
|
+
];
|
|
2011
|
+
//#endregion
|
|
2012
|
+
//#region src/theme/rules/index.ts
|
|
2013
|
+
const rules = [
|
|
2014
|
+
...[
|
|
2015
|
+
[
|
|
2016
|
+
/^text-m([bty])?-(.*)$/,
|
|
2017
|
+
(match, { theme }) => {
|
|
2018
|
+
const dir = match[1];
|
|
2019
|
+
const size = match[2];
|
|
2020
|
+
const d = dir ? {
|
|
2021
|
+
y: ["top", "bottom"],
|
|
2022
|
+
t: ["top"],
|
|
2023
|
+
b: ["bottom"]
|
|
2024
|
+
}[dir] : [
|
|
2025
|
+
"top",
|
|
2026
|
+
"bottom",
|
|
2027
|
+
"left",
|
|
2028
|
+
"right"
|
|
2029
|
+
];
|
|
2030
|
+
const result = {};
|
|
2031
|
+
if (theme.spacing[size]) {
|
|
2032
|
+
for (const prop of d) result[`margin-${prop}`] = ["left", "right"].includes(prop) ? theme.spacing[size] : `calc(${theme.spacing[size]} + var(--font-${prop === "top" ? "tc" : "bc"}))`;
|
|
2033
|
+
return result;
|
|
2034
|
+
} else if (/^\d+(em|rem|px)?$/.test(size)) {
|
|
2035
|
+
let s = size;
|
|
2036
|
+
if (/^[\d.]+$/.test(size)) s = `${Number(size) * .25}rem`;
|
|
2037
|
+
for (const prop of d) result[`margin-${prop}`] = ["left", "right"].includes(prop) ? s : `calc(${s} + var(--font-${prop === "top" ? "tc" : "bc"}))`;
|
|
2038
|
+
return result;
|
|
2039
|
+
}
|
|
2040
|
+
},
|
|
2041
|
+
{ layer: "utilities" }
|
|
2042
|
+
],
|
|
2043
|
+
[
|
|
2044
|
+
/^card-dense$/,
|
|
2045
|
+
(_match, { theme: _theme }) => ({ "--card-spacing": "var(--card-spacing-dense)" }),
|
|
2046
|
+
{ layer: "utilities" }
|
|
2047
|
+
],
|
|
2048
|
+
[/^card-(.*)$/, (match, { theme }) => {
|
|
2049
|
+
const name = match[1];
|
|
2050
|
+
if (theme.fontSize[name]) {
|
|
2051
|
+
const props = theme.fontSize[name][1];
|
|
2052
|
+
return {
|
|
2053
|
+
"--card-spacing": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.regular)}`,
|
|
2054
|
+
"--card-spacing-dense": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.dense)}`,
|
|
2055
|
+
"--card-heading-size": props["--font-size"],
|
|
2056
|
+
"--card-heading-bold": props["--font-bold"],
|
|
2057
|
+
"--card-heading-corrected": props["--font-corrected"],
|
|
2058
|
+
"--card-heading-weight": props["font-weight"],
|
|
2059
|
+
"--card-heading-lh": props["line-height"],
|
|
2060
|
+
"--card-heading-ls": props["letter-spacing"],
|
|
2061
|
+
"--card-heading-bc": props["--font-bc"],
|
|
2062
|
+
"--card-heading-tc": props["--font-tc"],
|
|
2063
|
+
"padding": "var(--card-spacing)"
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
}],
|
|
2067
|
+
[/^fingertip-(.*)/, (match, { theme }) => {
|
|
2068
|
+
const name = match[1];
|
|
2069
|
+
if (name.startsWith("[") && name.endsWith("]")) return {
|
|
2070
|
+
"--v-fingertip": name.slice(1, -1),
|
|
2071
|
+
"--v-fingertip-half": unitBy(name.slice(1, -1), .5)
|
|
2072
|
+
};
|
|
2073
|
+
if ([
|
|
2074
|
+
"xs",
|
|
2075
|
+
"s",
|
|
2076
|
+
"m",
|
|
2077
|
+
"l",
|
|
2078
|
+
"xl"
|
|
2079
|
+
].includes(name)) return {
|
|
2080
|
+
"--v-fingertip": theme.spacing[`fingertip-${name}`],
|
|
2081
|
+
"--v-fingertip-half": unitBy(theme.spacing[`fingertip-${name}`], .5)
|
|
2082
|
+
};
|
|
2083
|
+
if (theme.spacing[name]) return {
|
|
2084
|
+
"--v-fingertip": theme.spacing[name],
|
|
2085
|
+
"--v-fingertip-half": unitBy(theme.spacing[name], .5)
|
|
2086
|
+
};
|
|
2087
|
+
}]
|
|
2088
|
+
],
|
|
2089
|
+
...paletteRules,
|
|
2090
|
+
...i8Rules
|
|
2091
|
+
];
|
|
2092
|
+
//#endregion
|
|
2093
|
+
//#region src/theme/types.ts
|
|
2094
|
+
function k$1(n, base = 1) {
|
|
2095
|
+
return base * 1.618 ** n;
|
|
2096
|
+
}
|
|
2097
|
+
//#endregion
|
|
2098
|
+
//#region src/theme/typography.ts
|
|
2099
|
+
function font(weight, boldWeight, size, height, spacing) {
|
|
2100
|
+
return {
|
|
2101
|
+
weight,
|
|
2102
|
+
boldWeight,
|
|
2103
|
+
size,
|
|
2104
|
+
height,
|
|
2105
|
+
spacing
|
|
2106
|
+
};
|
|
2107
|
+
}
|
|
2108
|
+
const defaultTypography = {
|
|
2109
|
+
"h1": font(400, 700, k$1(3.5), k$1(.5), -.025),
|
|
2110
|
+
"h2": font(400, 700, k$1(2.5), k$1(.5), -.022),
|
|
2111
|
+
"h3": font(400, 700, k$1(2), k$1(.5), -.022),
|
|
2112
|
+
"h4": font(400, 600, k$1(1), k$1(.5), -.02),
|
|
2113
|
+
"h5": font(400, 600, k$1(.5), k$1(.5), -.017),
|
|
2114
|
+
"h6": font(600, 700, k$1(.25), k$1(.5), -.014),
|
|
2115
|
+
"subheading": font(400, 600, k$1(-.2), k$1(.5), -.007),
|
|
2116
|
+
"body-l": font(400, 600, k$1(.5), k$1(.75), -.014),
|
|
2117
|
+
"body": font(400, 600, k$1(0), k$1(.75), -.011),
|
|
2118
|
+
"body-s": font(400, 600, k$1(-.5), k$1(1), 0),
|
|
2119
|
+
"callout": font(400, 600, k$1(-.25), k$1(.5), -.009),
|
|
2120
|
+
"label": font(500, 700, k$1(-.25), k$1(.5), -.004),
|
|
2121
|
+
"caption": font(400, 600, k$1(-.5), k$1(.5), -.007),
|
|
2122
|
+
"overline": font(400, 600, k$1(-.5), k$1(.5), .0618)
|
|
2206
2123
|
};
|
|
2207
|
-
function
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2124
|
+
function buildFontTheme(size, w, wBold, lh, ls, actualFontHeightFactor = 1, actualFontHeightTopBottomRatio = .5) {
|
|
2125
|
+
const correctedSize = size * actualFontHeightFactor;
|
|
2126
|
+
const m = (lh * size - correctedSize) / size;
|
|
2127
|
+
const half = correctedSize / 2;
|
|
2128
|
+
const offt = correctedSize * actualFontHeightTopBottomRatio - half + m / 2;
|
|
2129
|
+
const offb = correctedSize * (1 - actualFontHeightTopBottomRatio) - half + m / 2;
|
|
2130
|
+
const mt = round(offt, 4);
|
|
2131
|
+
const mb = round(offb, 4);
|
|
2132
|
+
return {
|
|
2133
|
+
mt,
|
|
2134
|
+
mb,
|
|
2135
|
+
size,
|
|
2136
|
+
correctedSize,
|
|
2137
|
+
theme: [`${size}em`, {
|
|
2138
|
+
"--font-bold": wBold,
|
|
2139
|
+
"--font-size": `${size}em`,
|
|
2140
|
+
"--font-corrected": `${correctedSize}em`,
|
|
2141
|
+
"--font-bc": `${-mb}em`,
|
|
2142
|
+
"--font-tc": `${-mt}em`,
|
|
2143
|
+
"font-weight": w,
|
|
2144
|
+
"line-height": `${lh}em`,
|
|
2145
|
+
"letter-spacing": `${ls}em`
|
|
2146
|
+
}]
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
//#endregion
|
|
2150
|
+
//#region src/theme/utils/radius-scale.ts
|
|
2151
|
+
const ROOT_FONT_PX = 16;
|
|
2152
|
+
function parseRadius(input) {
|
|
2153
|
+
const m = input.trim().match(/^(-?\d*\.?\d+)(px|em|rem)?$/);
|
|
2154
|
+
if (!m) return null;
|
|
2155
|
+
const n = Number.parseFloat(m[1]);
|
|
2156
|
+
if (!Number.isFinite(n)) return null;
|
|
2157
|
+
return {
|
|
2158
|
+
n,
|
|
2159
|
+
unit: m[2] ?? ""
|
|
2160
|
+
};
|
|
2161
|
+
}
|
|
2162
|
+
function computeRadiusScale(baseRadius) {
|
|
2163
|
+
const parsed = parseRadius(baseRadius);
|
|
2164
|
+
if (!parsed) return {
|
|
2165
|
+
r0: `min(${baseRadius}, clamp(2px, calc(${baseRadius} / 2), 4px))`,
|
|
2166
|
+
r1: baseRadius,
|
|
2167
|
+
r2: `calc(${baseRadius} * 1.5)`,
|
|
2168
|
+
r3: `calc(${baseRadius} * 2)`,
|
|
2169
|
+
r4: `calc(${baseRadius} * 2.5)`
|
|
2170
|
+
};
|
|
2171
|
+
const { n, unit } = parsed;
|
|
2172
|
+
if (n === 0) return {
|
|
2173
|
+
r0: "0",
|
|
2174
|
+
r1: "0",
|
|
2175
|
+
r2: "0",
|
|
2176
|
+
r3: "0",
|
|
2177
|
+
r4: "0"
|
|
2178
|
+
};
|
|
2179
|
+
const basePx = unit === "em" || unit === "rem" ? n * ROOT_FONT_PX : n;
|
|
2180
|
+
const r0Px = Math.min(basePx, Math.max(2, Math.min(basePx / 2, 4)));
|
|
2181
|
+
const scaled = unit ? baseRadius : `${n}px`;
|
|
2182
|
+
return {
|
|
2183
|
+
r0: `${round(r0Px, 3)}px`,
|
|
2184
|
+
r1: baseRadius,
|
|
2185
|
+
r2: unitBy(scaled, 1.5),
|
|
2186
|
+
r3: unitBy(scaled, 2),
|
|
2187
|
+
r4: unitBy(scaled, 2.5)
|
|
2188
|
+
};
|
|
2214
2189
|
}
|
|
2215
2190
|
//#endregion
|
|
2191
|
+
//#region src/theme/theme.ts
|
|
2192
|
+
const themeFactory = (opts) => {
|
|
2193
|
+
/**
|
|
2194
|
+
* Spacing
|
|
2195
|
+
*/
|
|
2196
|
+
const spacing = {
|
|
2197
|
+
"$xxs": `${round(1 / opts.spacingFactor ** 3, 3)}em`,
|
|
2198
|
+
"$xs": `${round(1 / opts.spacingFactor ** 2, 3)}em`,
|
|
2199
|
+
"$s": `${round(1 / opts.spacingFactor, 3)}em`,
|
|
2200
|
+
"$m": "1em",
|
|
2201
|
+
"$l": `${round(opts.spacingFactor, 3)}em`,
|
|
2202
|
+
"$xl": `${round(opts.spacingFactor ** 2, 3)}em`,
|
|
2203
|
+
"$xxl": `${round(opts.spacingFactor ** 3, 3)}em`,
|
|
2204
|
+
"fingertip": "var(--v-fingertip)",
|
|
2205
|
+
"fingertip-half": "var(--v-fingertip-half)",
|
|
2206
|
+
"fingertip-xs": opts.fingertip.xs,
|
|
2207
|
+
"fingertip-s": opts.fingertip.s,
|
|
2208
|
+
"fingertip-m": opts.fingertip.m,
|
|
2209
|
+
"fingertip-l": opts.fingertip.l,
|
|
2210
|
+
"fingertip-xl": opts.fingertip.xl,
|
|
2211
|
+
"$font-tc": "var(--font-bc)",
|
|
2212
|
+
"$font-bc": "var(--font-tc)",
|
|
2213
|
+
"$font-size": "var(--font-size)",
|
|
2214
|
+
"$font-corrected": "var(--font-corrected)",
|
|
2215
|
+
"$card-spacing": "var(--card-spacing)",
|
|
2216
|
+
"$card-spacing-dense": "var(--card-spacing-dense)",
|
|
2217
|
+
"$card-heading-size": "var(--card-heading-size)",
|
|
2218
|
+
"$card-heading-corrected": "var(--card-heading-corrected)",
|
|
2219
|
+
"base-radius": opts.baseRadius
|
|
2220
|
+
};
|
|
2221
|
+
const lineHeight = {
|
|
2222
|
+
"fingertip": "var(--v-fingertip)",
|
|
2223
|
+
"fingertip-half": "var(--v-fingertip-half)",
|
|
2224
|
+
"fingertip-xs": opts.fingertip.xs,
|
|
2225
|
+
"fingertip-s": opts.fingertip.s,
|
|
2226
|
+
"fingertip-m": opts.fingertip.m,
|
|
2227
|
+
"fingertip-l": opts.fingertip.l,
|
|
2228
|
+
"fingertip-xl": opts.fingertip.xl
|
|
2229
|
+
};
|
|
2230
|
+
const borderRadius = {
|
|
2231
|
+
...spacing,
|
|
2232
|
+
base: opts.baseRadius,
|
|
2233
|
+
...computeRadiusScale(opts.baseRadius)
|
|
2234
|
+
};
|
|
2235
|
+
/**
|
|
2236
|
+
* Typography
|
|
2237
|
+
*/
|
|
2238
|
+
const fontWeight = { $bold: "var(--font-bold)" };
|
|
2239
|
+
const fontSize = { "card-header": ["var(--card-heading-size)", {
|
|
2240
|
+
"--font-bold": "var(--card-heading-bold)",
|
|
2241
|
+
"--font-size": "var(--card-heading-size)",
|
|
2242
|
+
"--font-corrected": "var(--card-heading-corrected)",
|
|
2243
|
+
"--font-bc": "var(--card-heading-bc)",
|
|
2244
|
+
"--font-tc": "var(--card-heading-tc)",
|
|
2245
|
+
"font-weight": "var(--card-heading-weight)",
|
|
2246
|
+
"line-height": "var(--card-heading-lh)",
|
|
2247
|
+
"letter-spacing": "var(--card-heading-ls)"
|
|
2248
|
+
}] };
|
|
2249
|
+
for (const [name, val] of Object.entries(opts.typography)) if (val?.size) {
|
|
2250
|
+
const ft = buildFontTheme(val.size || 1, val.weight || 400, val.boldWeight || 700, val.height || 1, val.spacing || 0, val.actualHeightFactor || opts.actualFontHeightFactor, val.actualHeightTopBottomRatio || opts.actualFontHeightTopBottomRatio);
|
|
2251
|
+
fontSize[name] = ft.theme;
|
|
2252
|
+
spacing[name] = `${ft.size}em`;
|
|
2253
|
+
}
|
|
2254
|
+
const palette = generatePalette(opts.palette);
|
|
2255
|
+
/**
|
|
2256
|
+
* Putting all together
|
|
2257
|
+
*/
|
|
2258
|
+
return {
|
|
2259
|
+
paletteOpts: palette.opts,
|
|
2260
|
+
theme: {
|
|
2261
|
+
colors: palette.colors,
|
|
2262
|
+
surfaces: palette.surfaces,
|
|
2263
|
+
reverseLightLayers: opts.layers.reverseLight,
|
|
2264
|
+
reverseDarkLayers: opts.layers.reverseDark,
|
|
2265
|
+
lineHeight,
|
|
2266
|
+
spacing,
|
|
2267
|
+
fontWeight,
|
|
2268
|
+
actualFontHeightFactor: opts.actualFontHeightFactor,
|
|
2269
|
+
cardSpacingFactor: opts.cardSpacingFactor,
|
|
2270
|
+
fontSize,
|
|
2271
|
+
width: spacing,
|
|
2272
|
+
height: spacing,
|
|
2273
|
+
maxWidth: spacing,
|
|
2274
|
+
maxHeight: spacing,
|
|
2275
|
+
minWidth: spacing,
|
|
2276
|
+
minHeight: spacing,
|
|
2277
|
+
borderRadius,
|
|
2278
|
+
animation: opts.animation
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
};
|
|
2282
|
+
//#endregion
|
|
2216
2283
|
//#region src/theme/preset-vunor.ts
|
|
2217
2284
|
function createVunorExtractor() {
|
|
2218
2285
|
return {
|
|
@@ -2319,10 +2386,11 @@ const presetVunor = (_opts) => {
|
|
|
2319
2386
|
wind.rules.push(...rules);
|
|
2320
2387
|
const paletteShortcuts = getPaletteShortcuts();
|
|
2321
2388
|
const theme = themeFactory(opts);
|
|
2322
|
-
|
|
2389
|
+
const paletteOptsCss = `__vunor_palette_options {background-image: url("data:image/gif;base64,${Buffer.from(JSON.stringify({
|
|
2323
2390
|
...theme.paletteOpts,
|
|
2324
2391
|
surfaces: void 0
|
|
2325
|
-
})).toString("base64")}")}
|
|
2392
|
+
})).toString("base64")}")}`;
|
|
2393
|
+
wind.preflights.push({ getCSS: () => paletteOptsCss });
|
|
2326
2394
|
return {
|
|
2327
2395
|
...wind,
|
|
2328
2396
|
name: "vunor",
|
|
@@ -2350,14 +2418,6 @@ function getFixedWind() {
|
|
|
2350
2418
|
//#endregion
|
|
2351
2419
|
//#region src/theme.ts
|
|
2352
2420
|
/**
|
|
2353
|
-
* Array of raw vunor shortcuts (not merged)
|
|
2354
|
-
*/
|
|
2355
|
-
const rawVunorShortcuts = [
|
|
2356
|
-
i8,
|
|
2357
|
-
c8,
|
|
2358
|
-
...shortcuts
|
|
2359
|
-
];
|
|
2360
|
-
/**
|
|
2361
2421
|
* Vunor shortcuts (merged version of rawVunorShortcuts)
|
|
2362
2422
|
*/
|
|
2363
2423
|
const mergedVunorShortcuts = mergeVunorShortcuts(rawVunorShortcuts);
|