vunor 0.4.3 → 0.4.5
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/CHANGELOG.md +24 -1
- package/README.md +56 -8
- package/dist/theme.d.mts +22 -2
- package/dist/theme.mjs +38 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.5
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `presetVunor({ borderOpacity })`, default `0.25`: the opacity of the default border colour (`--un-border-opacity` on `:root`), which a `border` with no colour class is drawn with; `ring-current-border` and `shadow-current-border` without `/N` read the same value. Before, it was fixed at `0.25` and an app changed it by overriding the variable in its own CSS.
|
|
8
|
+
- The README ("Clickable Styles (`c8`)") and the skill show how to bring back the `c8-filled` fills of 0.4.1 and earlier by appending three shortcut entries, no `replaceShortcut` needed. The 0.4.2 fills stay the default.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- A `scope-…` token that names no palette colour no longer fails the UnoCSS build with `Not supported color`. UnoCSS picks up such a string anywhere in a scanned file, comments included: a shade (`scope-primary-500`), `scope-white`, `scope-dark` or a Wind colour name (`scope-red`). It now compiles to nothing. `scope-<name>` is still a scope for the seven palette colours: `primary`, `secondary`, `grey`, `neutral`, `good`, `warn` and `error`.
|
|
13
|
+
|
|
14
|
+
## 0.4.4
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `replaceShortcut` from `vunor/theme`: replaces a built-in shortcut instead of merging into it. A shortcut of yours with the same name as a built-in one is merged with it (its classes are appended); mark your entry to drop vunor's definition and keep only your classes: `vunorShortcuts(defineShortcuts({ press: replaceShortcut({ 'active:': 'scale-95' }) }))`. It takes any form a normal entry takes (a string, an array or a shortcut object) and goes on the shortcut name, not on a variant key. In `mergeVunorShortcuts([a, b, c])` a marked entry drops the definitions of its name from the earlier lists, later lists merge on top of it as usual, and the mark survives the merge, so a map composed with `mergeVunorShortcuts` and passed to `vunorShortcuts()` still replaces the built-in shortcut.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `vunorShortcuts()` no longer changes the exported `mergedVunorShortcuts` object (it turned its shortcut objects into strings in place), and an array entry (`'my-row': ['p-2', 'm-1']`) now becomes `p-2 m-1` (it became `0p-2 1m-1`).
|
|
23
|
+
- In a shortcut object, an array item holding several classes gets the variant prefix on each class: `{ 'hover:': ['p-2 m-1'] }` becomes `hover:p-2 hover:m-1` (it became `hover:p-2 m-1`).
|
|
24
|
+
- The `press` notes for 0.4.2 advised `transition-[scale]` to ease the press, but that class generates no CSS. Use `[transition-property:scale] duration-150`.
|
|
25
|
+
|
|
3
26
|
## 0.4.3
|
|
4
27
|
|
|
5
28
|
### Changed
|
|
@@ -10,7 +33,7 @@
|
|
|
10
33
|
|
|
11
34
|
### Added
|
|
12
35
|
|
|
13
|
-
- `press` shortcut: press feedback for any clickable. An enabled element shrinks to `scale: var(--press-scale, 0.97)` while it is `:active`, on touch and mouse. It ignores `data-active`, which Reka UI and vunor use for "current" (selected tab, pressed toggle, open popover trigger). It uses the `scale` property, so it stacks with translate/rotate utilities, sets no transition (add `transition-
|
|
36
|
+
- `press` shortcut: press feedback for any clickable. An enabled element shrinks to `scale: var(--press-scale, 0.97)` while it is `:active`, on touch and mouse. It ignores `data-active`, which Reka UI and vunor use for "current" (selected tab, pressed toggle, open popover trigger). It uses the `scale` property, so it stacks with translate/rotate utilities, sets no transition (add `[transition-property:scale] duration-150` to ease it) and clears the iOS tap highlight. An app that passes its own `press` shortcut to `vunorShortcuts()` gets vunor's rule merged into it; mark the app's one with `replaceShortcut` (0.4.4) or rename it.
|
|
14
37
|
- `whenHover`, `whenHoverIdle` and `whenCanHover` from `vunor/theme`: variant-prefix keys for your own shortcuts that apply hover only on devices whose primary input can hover. Use `whenHoverIdle` when the shortcut also paints `active:`.
|
|
15
38
|
- `whenEnabled` and `whenDisabled` from `vunor/theme`: the variant-prefix keys for vunor's shared disabled definition, needed to override c8 states (see below).
|
|
16
39
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A **UnoCSS theme engine** that turns a handful of design decisions into a complete, perceptually consistent design system -- plus an optional set of 30+ Vue 3 components that use it.
|
|
4
4
|
|
|
5
|
-
The core value is the theme: a golden-ratio-based type and spacing scale, an Oklab-graded color palette where every hue looks equally bright at the same step, and a
|
|
5
|
+
The core value is the theme: a golden-ratio-based type and spacing scale, an Oklab-graded color palette where every hue looks equally bright at the same step, and a shortcut object system that merges your classes into any built-in style by name, so you customize a visual detail without rewriting the style. The Vue components are a bonus -- you can use the theme engine on its own with any markup.
|
|
6
6
|
|
|
7
7
|
## Design Philosophy
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ Most design systems hard-code dozens of magic numbers for font sizes, spacing, c
|
|
|
10
10
|
|
|
11
11
|
- **Golden ratio (1.618)** drives the typography scale, spacing tokens, and default border radius
|
|
12
12
|
- **Oklab color model** ensures perceptual uniformity -- `primary-500` and `error-500` look equally bright to the human eye, regardless of hue
|
|
13
|
-
- **Object-driven shortcuts**
|
|
13
|
+
- **Object-driven shortcuts** let you add classes to one variant of any built-in style: same-name shortcuts are merged, not replaced
|
|
14
14
|
|
|
15
15
|
The result: change one seed color or one scale factor, and the entire system recalculates consistently.
|
|
16
16
|
|
|
@@ -142,6 +142,7 @@ Used as `p-$m`, `m-$l`, `gap-$s`, etc. Text-aware margin utilities (`text-mt-$m`
|
|
|
142
142
|
### Other Derived Values
|
|
143
143
|
|
|
144
144
|
- **Border radius**: defaults to `0.618em` (1/golden-ratio), configurable via `baseRadius`
|
|
145
|
+
- **Default border**: a `border` with no colour class is a translucent grey at opacity `0.25`, configurable via `borderOpacity`
|
|
145
146
|
- **Touch targets** (`fingertip-xs` through `fingertip-xl`): sized using `sqrt(k)` progressions
|
|
146
147
|
- **Card spacing**: `card-{typography}` sets `--card-spacing` proportional to the heading's corrected size; `card-dense` switches to 0.6x
|
|
147
148
|
|
|
@@ -149,7 +150,7 @@ Used as `p-$m`, `m-$l`, `gap-$s`, etc. Text-aware margin utilities (`text-mt-$m`
|
|
|
149
150
|
|
|
150
151
|
## Object-Driven Shortcuts
|
|
151
152
|
|
|
152
|
-
This is Vunor's approach to component styling. Instead of flat UnoCSS shortcut strings, Vunor uses **structured nested objects** where keys are variant prefixes and values are the classes to apply. This makes styles readable,
|
|
153
|
+
This is Vunor's approach to component styling. Instead of flat UnoCSS shortcut strings, Vunor uses **structured nested objects** where keys are variant prefixes and values are the classes to apply. This makes styles readable, and lets a later definition of the same shortcut add classes to one variant without restating the rest.
|
|
153
154
|
|
|
154
155
|
### How It Works
|
|
155
156
|
|
|
@@ -223,7 +224,7 @@ defineShortcuts({
|
|
|
223
224
|
|
|
224
225
|
### Why Objects Instead of Strings?
|
|
225
226
|
|
|
226
|
-
**Because they merge.** When two shortcut objects define the same key, `mergeVunorShortcuts()`
|
|
227
|
+
**Because they merge.** When two shortcut objects define the same key, `mergeVunorShortcuts()` merges them, appending the later entry's classes. This is the key to Vunor's customization model: you can surgically override a single variant of a built-in style without rewriting the whole shortcut.
|
|
227
228
|
|
|
228
229
|
For example, to make all filled buttons pill-shaped while keeping every other variant (hover, active, dark mode, disabled) intact:
|
|
229
230
|
|
|
@@ -232,10 +233,10 @@ import { vunorShortcuts, defineShortcuts } from 'vunor/theme'
|
|
|
232
233
|
|
|
233
234
|
const myOverrides = defineShortcuts({
|
|
234
235
|
'c8-filled': {
|
|
235
|
-
'': 'rounded-full', //
|
|
236
|
+
'': 'rounded-full', // added to the base classes
|
|
236
237
|
},
|
|
237
238
|
'i8-flat': {
|
|
238
|
-
'': 'border-b-2', //
|
|
239
|
+
'': 'border-b-2', // added to the base classes
|
|
239
240
|
},
|
|
240
241
|
})
|
|
241
242
|
|
|
@@ -245,10 +246,38 @@ export default defineConfig({
|
|
|
245
246
|
})
|
|
246
247
|
```
|
|
247
248
|
|
|
248
|
-
Your `'c8-filled'.'':`
|
|
249
|
+
Your `'c8-filled'.'':` classes are added to the base classes of `c8-filled`, while all its `hover:`, `dark:`, `active:` variants remain intact from the defaults. Everything flows through a single merge pipeline, producing consistent CSS passed to UnoCSS.
|
|
250
|
+
|
|
251
|
+
Appending is not always overriding. UnoCSS writes the utilities of a shortcut in the order of its own rules, not in the order of the class string. An appended class wins over an earlier class of the same utility (`rounded-full` over `rounded-base`, one `bg-*` over another). Between different utilities the UnoCSS rule order decides: `px-4` wins over `p-2` and `flex` over `block`, whichever is written last. When an appended class has no effect, append the utility that wins (`px-2` to change a `px-4`), mark your class important (`!p-2`), or [replace the shortcut](#replacing-a-built-in-shortcut).
|
|
249
252
|
|
|
250
253
|
`vunorShortcuts()` returns the merged default shortcuts for all built-in styles (c8, i8, card, dialog, etc.). Pass your overrides as the first argument -- they take priority.
|
|
251
254
|
|
|
255
|
+
### Replacing a Built-in Shortcut
|
|
256
|
+
|
|
257
|
+
To drop a built-in shortcut and use only your own classes under its name, mark your entry with `replaceShortcut`:
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
import { defineShortcuts, replaceShortcut, vunorShortcuts } from 'vunor/theme'
|
|
261
|
+
|
|
262
|
+
const mine = defineShortcuts({
|
|
263
|
+
// vunor's own `press` is dropped; only these classes remain
|
|
264
|
+
'press': replaceShortcut({ 'active:': 'scale-95' }),
|
|
265
|
+
// a normal entry still merges into vunor's c8-filled
|
|
266
|
+
'c8-filled': { '': 'rounded-full' },
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
export default defineConfig({
|
|
270
|
+
presets: [presetVunor()],
|
|
271
|
+
shortcuts: [vunorShortcuts(mine)],
|
|
272
|
+
})
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
`replaceShortcut` takes any form a normal entry takes (a string, an array or a shortcut object). Put it on the shortcut name, not on a variant key inside a shortcut (there it has no effect). In `mergeVunorShortcuts([a, b, c])` a marked entry drops the definitions of its name from the earlier lists, and entries in later lists merge on top of it as usual. The mark survives the merge, so `vunorShortcuts(mergeVunorShortcuts([x, y]))` still replaces the built-in shortcut when `y` marks it.
|
|
276
|
+
|
|
277
|
+
Without vunor's merge, plain UnoCSS does the same: a shortcut in a later map of the `shortcuts` array replaces an earlier one of the same name, so `shortcuts: [vunorShortcuts(), { press: 'active:scale-95' }]` also drops vunor's `press`.
|
|
278
|
+
|
|
279
|
+
An app shortcut with the same name as a built-in one is merged with it unless it is marked: when a vunor release adds a shortcut whose name your app already uses, mark your app's one with `replaceShortcut` (or rename it).
|
|
280
|
+
|
|
252
281
|
---
|
|
253
282
|
|
|
254
283
|
## Semantic CSS Classes
|
|
@@ -315,6 +344,22 @@ Each includes hover, active, and focus states. Hover paints only on devices whos
|
|
|
315
344
|
|
|
316
345
|
`c8-filled` rests on shade 600 and goes to 700 on hover and 800 on press, in light and dark mode. With the default palette white text reaches WCAG AA (4.5:1) on all three fills for every palette colour. In dark mode a 1px inset rim in shade 500 keeps the button's edge at 3:1 or more against every dark layer. If you tune the palette, check your colours' 600 shades: with `mainPalette.preserveInputColor: true` and `good: '#22c55e'`, for example, `good-600` gives white text only 4.18:1.
|
|
317
346
|
|
|
347
|
+
These fills are the default since 0.4.2. To bring back the fills of 0.4.1 and earlier (500 at rest; 600 on hover and 700 on press, 400 and 300 in dark mode), append three entries. Each class you append is a `current-bg-*` like vunor's own, and an appended class wins over an earlier class of the same utility, so no `replaceShortcut` is needed:
|
|
348
|
+
|
|
349
|
+
```ts
|
|
350
|
+
import { defineShortcuts, vunorShortcuts } from 'vunor/theme'
|
|
351
|
+
|
|
352
|
+
vunorShortcuts(
|
|
353
|
+
defineShortcuts({
|
|
354
|
+
'c8-filled': { '': 'current-bg-scope-color-500' },
|
|
355
|
+
'c8-filled-hover': { '': 'current-bg-scope-color-600', 'dark:': 'current-bg-scope-color-400' },
|
|
356
|
+
'c8-filled-active': { '': 'current-bg-scope-color-700', 'dark:': 'current-bg-scope-color-300' },
|
|
357
|
+
})
|
|
358
|
+
)
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Add `'dark:': 'ring-0'` to the `c8-filled` entry to drop the dark-mode rim too. With the default palette, white text on these fills measures 3.4–4.1:1 at rest and 2.1–3.0:1 on the dark-mode hover and press fills, below WCAG AA.
|
|
362
|
+
|
|
318
363
|
To change a c8 hover colour, override the same key vunor uses, so your class merges into vunor's rule and wins:
|
|
319
364
|
|
|
320
365
|
```ts
|
|
@@ -329,7 +374,7 @@ vunorShortcuts(
|
|
|
329
374
|
|
|
330
375
|
`whenEnabled` and `whenDisabled` are the variant-prefix keys for the shared disabled definition above. Use them in your own shortcuts so a state matches the same elements vunor treats as disabled: `{ [whenEnabled]: { 'active:': 'bg-current/20' }, [whenDisabled]: 'cursor-not-allowed' }`.
|
|
331
376
|
|
|
332
|
-
For press feedback on any clickable, add `press`: it shrinks an enabled element slightly while it is `:active` (`[--press-scale:0.9]` changes the amount; add `transition-
|
|
377
|
+
For press feedback on any clickable, add `press`: it shrinks an enabled element slightly while it is `:active` (`[--press-scale:0.9]` changes the amount; add `[transition-property:scale] duration-150` to ease it). It ignores `data-active`, which Reka UI and vunor use for "current" (selected tab, pressed toggle, open popover trigger).
|
|
333
378
|
|
|
334
379
|
The `btn` layout primitive fades a disabled element to opacity 0.8. That is a default: `disabled-soft` (0.4) or a `disabled:opacity-*` utility replaces it, whether written on the element or composed with `btn` in your own shortcut (`'my-btn': 'btn disabled-soft'`).
|
|
335
380
|
|
|
@@ -379,6 +424,9 @@ export default defineConfig({
|
|
|
379
424
|
// -- Global border radius --
|
|
380
425
|
baseRadius: '0.5em', // default: 0.618em (1/golden-ratio)
|
|
381
426
|
|
|
427
|
+
// -- Opacity of the default border colour (`border` with no colour class) --
|
|
428
|
+
borderOpacity: 0.25,
|
|
429
|
+
|
|
382
430
|
// -- Typography overrides --
|
|
383
431
|
typography: {
|
|
384
432
|
h1: { size: 4, weight: 300, boldWeight: 700 },
|
package/dist/theme.d.mts
CHANGED
|
@@ -29,6 +29,13 @@ interface TVunorUnoPresetOpts {
|
|
|
29
29
|
xl?: string;
|
|
30
30
|
};
|
|
31
31
|
baseRadius?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Opacity of the default border colour, from `0` to `1`: the
|
|
34
|
+
* `--un-border-opacity` set on `:root`, which a `border` with no colour class
|
|
35
|
+
* is drawn with. `ring-current-border` and `shadow-current-border` without
|
|
36
|
+
* `/N` read the same value. Default `0.25`.
|
|
37
|
+
*/
|
|
38
|
+
borderOpacity?: number;
|
|
32
39
|
/**
|
|
33
40
|
* Page-level element styles: the body, figcaption and h1–h6 typography rules
|
|
34
41
|
* (size, weight, line-height, letter-spacing, plus a level's `font` and `css`
|
|
@@ -370,9 +377,22 @@ declare const rawVunorShortcuts: TVunorShortcut[];
|
|
|
370
377
|
* @returns string
|
|
371
378
|
*/
|
|
372
379
|
declare function toUnoShortcut(obj: TVunorShortcut): string;
|
|
380
|
+
/**
|
|
381
|
+
* Marks a top-level shortcut entry as a replacement: when shortcuts are merged
|
|
382
|
+
* (`mergeVunorShortcuts`, `vunorShortcuts`), it drops every earlier definition of
|
|
383
|
+
* the same name instead of merging into it. Later entries still merge on top of it.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* vunorShortcuts(defineShortcuts({ press: replaceShortcut({ 'active:': 'scale-95' }) }))
|
|
387
|
+
*
|
|
388
|
+
* @param value the shortcut, in any form a normal entry accepts
|
|
389
|
+
* @returns the shortcut's class string in a marked array
|
|
390
|
+
*/
|
|
391
|
+
declare const replaceShortcut: (value: string | string[] | TVunorShortcut) => string[];
|
|
373
392
|
/**
|
|
374
393
|
* Merges an array of vunor shortcuts
|
|
375
|
-
* Items from the beginning have less priority
|
|
394
|
+
* Items from the beginning have less priority. An entry marked with
|
|
395
|
+
* `replaceShortcut` drops the earlier entries of its name.
|
|
376
396
|
*
|
|
377
397
|
* @param shortcuts TVunorShortcut[]
|
|
378
398
|
* @returns TVunorShortcut
|
|
@@ -397,4 +417,4 @@ declare const mergedVunorShortcuts: TVunorShortcut;
|
|
|
397
417
|
*/
|
|
398
418
|
declare function vunorShortcuts(customShortcuts?: TVunorShortcut, baseShortcuts?: TVunorShortcut): Record<string, string>;
|
|
399
419
|
//#endregion
|
|
400
|
-
export { type TVunorLayerPaletteAdvanced, type TVunorMainPaletteAdvanced, type TVunorPaletteColor, type TVunorPaletteOptions, type TVunorShortcut, type TVunorSurfaceConfig, type TVunorTheme, componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|
|
420
|
+
export { type TVunorLayerPaletteAdvanced, type TVunorMainPaletteAdvanced, type TVunorPaletteColor, type TVunorPaletteOptions, type TVunorShortcut, type TVunorSurfaceConfig, type TVunorTheme, componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, replaceShortcut, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|
package/dist/theme.mjs
CHANGED
|
@@ -527,11 +527,28 @@ function toUnoShortcut(obj) {
|
|
|
527
527
|
}
|
|
528
528
|
function prepareScArray(input) {
|
|
529
529
|
if (typeof input === "string") return input.split(" ");
|
|
530
|
-
if (Array.isArray(input)) return input;
|
|
530
|
+
if (Array.isArray(input)) return input.flatMap((item) => item.split(" "));
|
|
531
531
|
const a = [];
|
|
532
532
|
for (const [key, val] of Object.entries(input)) a.push(...prepareScArray(val).map((v) => `${key}${v}`));
|
|
533
533
|
return a;
|
|
534
534
|
}
|
|
535
|
+
const REPLACE = Symbol.for("vunor.replaceShortcut");
|
|
536
|
+
/** A shortcut value as one UnoCSS class string */
|
|
537
|
+
const toClassString = (value = "") => typeof value === "string" ? value : Array.isArray(value) ? value.join(" ") : toUnoShortcut(value);
|
|
538
|
+
const markReplacement = (classes) => Object.defineProperty(classes, REPLACE, { value: true });
|
|
539
|
+
const isReplacement = (value) => Array.isArray(value) && REPLACE in value;
|
|
540
|
+
/**
|
|
541
|
+
* Marks a top-level shortcut entry as a replacement: when shortcuts are merged
|
|
542
|
+
* (`mergeVunorShortcuts`, `vunorShortcuts`), it drops every earlier definition of
|
|
543
|
+
* the same name instead of merging into it. Later entries still merge on top of it.
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* vunorShortcuts(defineShortcuts({ press: replaceShortcut({ 'active:': 'scale-95' }) }))
|
|
547
|
+
*
|
|
548
|
+
* @param value the shortcut, in any form a normal entry accepts
|
|
549
|
+
* @returns the shortcut's class string in a marked array
|
|
550
|
+
*/
|
|
551
|
+
const replaceShortcut = (value) => markReplacement([toClassString(value)]);
|
|
535
552
|
/**
|
|
536
553
|
* Merges source vunor shortcut with target vunor shortcut
|
|
537
554
|
* The target vunor shortcut has more power
|
|
@@ -546,9 +563,12 @@ const mergeTwoVunorShortcuts = (target, source) => {
|
|
|
546
563
|
for (const key of Array.from(keys)) {
|
|
547
564
|
const inSource = Object.prototype.hasOwnProperty.call(source, key);
|
|
548
565
|
const inTarget = Object.prototype.hasOwnProperty.call(target, key);
|
|
549
|
-
|
|
566
|
+
const targetEntry = target[key];
|
|
567
|
+
if (inSource && isReplacement(source[key])) result[key] = source[key];
|
|
568
|
+
else if (inSource && inTarget && isReplacement(targetEntry)) result[key] = markReplacement([...targetEntry, toClassString(source[key])]);
|
|
569
|
+
else if (inSource && inTarget) {
|
|
550
570
|
let sourceValue = source[key];
|
|
551
|
-
let targetValue =
|
|
571
|
+
let targetValue = targetEntry;
|
|
552
572
|
if (Array.isArray(sourceValue)) sourceValue = sourceValue.join(" ");
|
|
553
573
|
if (Array.isArray(targetValue)) targetValue = targetValue.join(" ");
|
|
554
574
|
if (typeof sourceValue === "string" && typeof targetValue === "string") result[key] = `${targetValue} ${sourceValue}`;
|
|
@@ -562,7 +582,8 @@ const mergeTwoVunorShortcuts = (target, source) => {
|
|
|
562
582
|
};
|
|
563
583
|
/**
|
|
564
584
|
* Merges an array of vunor shortcuts
|
|
565
|
-
* Items from the beginning have less priority
|
|
585
|
+
* Items from the beginning have less priority. An entry marked with
|
|
586
|
+
* `replaceShortcut` drops the earlier entries of its name.
|
|
566
587
|
*
|
|
567
588
|
* @param shortcuts TVunorShortcut[]
|
|
568
589
|
* @returns TVunorShortcut
|
|
@@ -1893,7 +1914,7 @@ const currentSlotRe = new RegExp(`^current-(${slotAlt})-(.+)$`);
|
|
|
1893
1914
|
const currentPaintRe = new RegExp(`^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(${sourceAlt})?(\\/\\d{1,3})?$`);
|
|
1894
1915
|
function getScopeCssVars(c, theme) {
|
|
1895
1916
|
const col = theme.colors[c];
|
|
1896
|
-
if (!col) return;
|
|
1917
|
+
if (!col || !theme.colors[`${c}-500`]) return;
|
|
1897
1918
|
const vars = { "--scope-color": colorToRgbWithOpacity(col) };
|
|
1898
1919
|
for (const shade of SCOPE_SHADES) vars[`--scope-color-${shade}`] = colorToRgbWithOpacity(theme.colors[`${c}-${shade}`]) || "";
|
|
1899
1920
|
for (const layer of SCOPE_LAYERS) {
|
|
@@ -2001,12 +2022,12 @@ function unitBy(input, factor, roundTo = 3) {
|
|
|
2001
2022
|
* `:root` theme variables always; page-level element styles only with `baseStyles`.
|
|
2002
2023
|
* Off, `body` keeps the body level's `--font-*` variables for `text-mt-*` / `font-$bold`.
|
|
2003
2024
|
*/
|
|
2004
|
-
function vunorPreflights(baseStyles) {
|
|
2005
|
-
return { getCSS: ({ theme }) => baseStyles ? renderBaseStyles(theme) : renderRootVars(theme) + renderFontVarsCss("body", theme.fontSize.body) };
|
|
2025
|
+
function vunorPreflights(baseStyles, borderOpacity) {
|
|
2026
|
+
return { getCSS: ({ theme }) => baseStyles ? renderBaseStyles(theme, borderOpacity) : renderRootVars(theme, borderOpacity) + renderFontVarsCss("body", theme.fontSize.body) };
|
|
2006
2027
|
}
|
|
2007
|
-
function renderBaseStyles(theme) {
|
|
2028
|
+
function renderBaseStyles(theme, borderOpacity) {
|
|
2008
2029
|
return `${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)}
|
|
2009
|
-
${renderRootVars(theme)}
|
|
2030
|
+
${renderRootVars(theme, borderOpacity)}
|
|
2010
2031
|
|
|
2011
2032
|
::-webkit-scrollbar {
|
|
2012
2033
|
width: 10px;
|
|
@@ -2043,9 +2064,9 @@ ${renderRootVars(theme)}
|
|
|
2043
2064
|
}
|
|
2044
2065
|
`;
|
|
2045
2066
|
}
|
|
2046
|
-
function renderRootVars(theme) {
|
|
2067
|
+
function renderRootVars(theme, borderOpacity) {
|
|
2047
2068
|
return `:root {
|
|
2048
|
-
--un-border-opacity:
|
|
2069
|
+
--un-border-opacity: ${borderOpacity};
|
|
2049
2070
|
--un-default-border-color: rgb(150 150 150 / var(--un-border-opacity));
|
|
2050
2071
|
--scope-black: 0 0 0;
|
|
2051
2072
|
--scope-white: 255 255 255;
|
|
@@ -2447,6 +2468,7 @@ const defaultOptions = {
|
|
|
2447
2468
|
xl: `4em`
|
|
2448
2469
|
},
|
|
2449
2470
|
baseRadius: `${round(1 / 1.618, 3)}em`,
|
|
2471
|
+
borderOpacity: .25,
|
|
2450
2472
|
baseStyles: true,
|
|
2451
2473
|
animation: {
|
|
2452
2474
|
durations: {
|
|
@@ -2519,7 +2541,7 @@ const presetVunor = (_opts) => {
|
|
|
2519
2541
|
const opts = defu(_opts, defaultOptions);
|
|
2520
2542
|
const wind = getFixedWind();
|
|
2521
2543
|
if (!wind.preflights) wind.preflights = [];
|
|
2522
|
-
wind.preflights.push(vunorPreflights(opts.baseStyles));
|
|
2544
|
+
wind.preflights.push(vunorPreflights(opts.baseStyles, opts.borderOpacity));
|
|
2523
2545
|
if (!wind.rules) wind.rules = [];
|
|
2524
2546
|
wind.rules.push(...rules);
|
|
2525
2547
|
const paletteShortcuts = getPaletteShortcuts();
|
|
@@ -2569,8 +2591,9 @@ const mergedVunorShortcuts = mergeVunorShortcuts(rawVunorShortcuts);
|
|
|
2569
2591
|
*/
|
|
2570
2592
|
function vunorShortcuts(customShortcuts, baseShortcuts = mergedVunorShortcuts) {
|
|
2571
2593
|
const merged = customShortcuts ? mergeVunorShortcuts([baseShortcuts, customShortcuts]) : baseShortcuts;
|
|
2572
|
-
|
|
2573
|
-
|
|
2594
|
+
const result = {};
|
|
2595
|
+
for (const [key, val] of Object.entries(merged)) result[key] = toClassString(val);
|
|
2596
|
+
return result;
|
|
2574
2597
|
}
|
|
2575
2598
|
//#endregion
|
|
2576
|
-
export { componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|
|
2599
|
+
export { componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, replaceShortcut, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|