vunor 0.4.1 → 0.4.2
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 +42 -2
- package/dist/theme.d.mts +20 -1
- package/dist/theme.mjs +38 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -177,6 +177,30 @@ h-fingertip flex items-center hover:bg-current/05 dark:text-white [&.btn-round]:
|
|
|
177
177
|
|
|
178
178
|
Wherever you use `class="btn"`, UnoCSS applies all those classes. The nesting is purely for readability and mergeability.
|
|
179
179
|
|
|
180
|
+
### Breakpoints and Hover
|
|
181
|
+
|
|
182
|
+
Breakpoints are variant prefixes like any other, so a breakpoint key works at any depth:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
defineShortcuts({
|
|
186
|
+
'my-panel': {
|
|
187
|
+
'': 'flex flex-col gap-$s',
|
|
188
|
+
'md:': { '': 'flex-row gap-$m', 'dark:': 'bg-black' }, // → "md:flex-row md:gap-$m md:dark:bg-black"
|
|
189
|
+
},
|
|
190
|
+
})
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Vunor's own shortcuts paint hover only on devices whose primary input can hover. Use the same prefixes in yours:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { defineShortcuts, whenHover, whenHoverIdle } from 'vunor/theme'
|
|
197
|
+
|
|
198
|
+
defineShortcuts({
|
|
199
|
+
'my-row': { '': 'p-$s', [whenHover]: 'bg-current/05' }, // @media (hover: hover) { .my-row:hover }
|
|
200
|
+
'my-tile': { [whenHoverIdle]: 'bg-current/10', 'active:': 'bg-current/20' }, // hover stands aside while pressed
|
|
201
|
+
})
|
|
202
|
+
```
|
|
203
|
+
|
|
180
204
|
### Compound Variants
|
|
181
205
|
|
|
182
206
|
Nesting can go deeper for compound variants:
|
|
@@ -275,18 +299,34 @@ Button and clickable element design variants:
|
|
|
275
299
|
|
|
276
300
|
| Class | Description |
|
|
277
301
|
| ------------- | --------------------------------------- |
|
|
278
|
-
| `c8-filled` | Solid background, white text
|
|
302
|
+
| `c8-filled` | Solid background, white text (WCAG AA) |
|
|
279
303
|
| `c8-flat` | Transparent background, colored text |
|
|
280
304
|
| `c8-outlined` | Border + colored text, transparent fill |
|
|
281
305
|
| `c8-light` | Light tinted background, colored text |
|
|
282
306
|
|
|
283
|
-
Each includes hover, active, and focus states. Hover and press do not paint on a disabled element: `disabled`, `aria-disabled="true"` or `data-disabled` (the same definition the `disabled-soft` shortcut uses to fade a disabled element). Keyboard focus still paints, so an `aria-disabled` control stays visibly focusable. Apply on any element alongside `scope-{color}`:
|
|
307
|
+
Each includes hover, active, and focus states. Hover paints only on devices whose primary input can hover (`@media (hover: hover)`), so a tap on a touch screen does not leave it stuck on; press (`:active`) paints everywhere. Hover and press do not paint on a disabled element: `disabled`, `aria-disabled="true"` or `data-disabled` (the same definition the `disabled-soft` shortcut uses to fade a disabled element). Keyboard focus still paints, so an `aria-disabled` control stays visibly focusable. Apply on any element alongside `scope-{color}`:
|
|
284
308
|
|
|
285
309
|
```html
|
|
286
310
|
<button class="scope-primary c8-filled">Save</button>
|
|
287
311
|
<button class="scope-error c8-flat">Cancel</button>
|
|
288
312
|
```
|
|
289
313
|
|
|
314
|
+
`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.
|
|
315
|
+
|
|
316
|
+
To change a c8 hover colour, override the same key vunor uses, so your class merges into vunor's rule and wins:
|
|
317
|
+
|
|
318
|
+
```ts
|
|
319
|
+
import { defineShortcuts, vunorShortcuts, whenEnabled, whenHoverIdle } from 'vunor/theme'
|
|
320
|
+
|
|
321
|
+
vunorShortcuts(
|
|
322
|
+
defineShortcuts({
|
|
323
|
+
'c8-filled': { [whenEnabled]: { [whenHoverIdle]: 'current-bg-scope-color-900' } },
|
|
324
|
+
})
|
|
325
|
+
)
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
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-[scale]` to ease it). It ignores `data-active`, which Reka UI and vunor use for "current" (selected tab, pressed toggle, open popover trigger).
|
|
329
|
+
|
|
290
330
|
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'`).
|
|
291
331
|
|
|
292
332
|
### Inputable Styles (`i8`)
|
package/dist/theme.d.mts
CHANGED
|
@@ -341,6 +341,25 @@ declare const presetVunor: PresetFactory<TVunorTheme, TVunorUnoPresetOpts & {
|
|
|
341
341
|
palette?: TVunorPaletteOptions;
|
|
342
342
|
}>;
|
|
343
343
|
//#endregion
|
|
344
|
+
//#region src/theme/utils/disabled.d.ts
|
|
345
|
+
/** Variant prefix that matches while the element is disabled. */
|
|
346
|
+
declare const whenDisabled = "[&:is(:disabled,[disabled],[aria-disabled=true],[data-disabled])]:";
|
|
347
|
+
/** Variant prefix that matches only while the element is not disabled. */
|
|
348
|
+
declare const whenEnabled = "[&:not(:disabled,[disabled],[aria-disabled=true],[data-disabled])]:";
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/theme/utils/hover.d.ts
|
|
351
|
+
/** Variant prefix for any rule that should only apply on hover-capable devices. */
|
|
352
|
+
declare const whenCanHover = "[@media(hover:hover)]:";
|
|
353
|
+
/** Variant prefix: `hover:` gated behind `@media (hover: hover)`. */
|
|
354
|
+
declare const whenHover = "[@media(hover:hover)]:hover:";
|
|
355
|
+
/**
|
|
356
|
+
* Variant prefix: `hover:` gated behind `@media (hover: hover)` that also stands
|
|
357
|
+
* aside while the element is `:active`. Use it next to an `active:` paint: the
|
|
358
|
+
* gated block is emitted after the plain rules, so a plain gated `hover:` would
|
|
359
|
+
* beat the press paint on a mouse.
|
|
360
|
+
*/
|
|
361
|
+
declare const whenHoverIdle = "[@media(hover:hover)]:[&:hover:not(:active)]:";
|
|
362
|
+
//#endregion
|
|
344
363
|
//#region src/theme/shortcuts/raw.d.ts
|
|
345
364
|
declare const rawVunorShortcuts: TVunorShortcut[];
|
|
346
365
|
//#endregion
|
|
@@ -378,4 +397,4 @@ declare const mergedVunorShortcuts: TVunorShortcut;
|
|
|
378
397
|
*/
|
|
379
398
|
declare function vunorShortcuts(customShortcuts?: TVunorShortcut, baseShortcuts?: TVunorShortcut): Record<string, string>;
|
|
380
399
|
//#endregion
|
|
381
|
-
export { type TVunorLayerPaletteAdvanced, type TVunorMainPaletteAdvanced, type TVunorPaletteColor, type TVunorPaletteOptions, type TVunorShortcut, type TVunorSurfaceConfig, type TVunorTheme, componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, toUnoShortcut, vunorShortcuts };
|
|
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 };
|
package/dist/theme.mjs
CHANGED
|
@@ -41,6 +41,19 @@ const whenDisabledDefault = `[&:where(${disabledSelectors})]:`;
|
|
|
41
41
|
/** Variant prefix that matches only while the element is not disabled. */
|
|
42
42
|
const whenEnabled = `[&:not(${disabledSelectors})]:`;
|
|
43
43
|
//#endregion
|
|
44
|
+
//#region src/theme/utils/hover.ts
|
|
45
|
+
/** Variant prefix for any rule that should only apply on hover-capable devices. */
|
|
46
|
+
const whenCanHover = "[@media(hover:hover)]:";
|
|
47
|
+
/** Variant prefix: `hover:` gated behind `@media (hover: hover)`. */
|
|
48
|
+
const whenHover = `${whenCanHover}hover:`;
|
|
49
|
+
/**
|
|
50
|
+
* Variant prefix: `hover:` gated behind `@media (hover: hover)` that also stands
|
|
51
|
+
* aside while the element is `:active`. Use it next to an `active:` paint: the
|
|
52
|
+
* gated block is emitted after the plain rules, so a plain gated `hover:` would
|
|
53
|
+
* beat the press paint on a mouse.
|
|
54
|
+
*/
|
|
55
|
+
const whenHoverIdle = `${whenCanHover}[&:hover:not(:active)]:`;
|
|
56
|
+
//#endregion
|
|
44
57
|
//#region src/components/Calendar/shortcuts.ts
|
|
45
58
|
const calendarShortcuts = defineShortcuts({
|
|
46
59
|
"calendar-root": "inline-block",
|
|
@@ -54,7 +67,7 @@ const calendarShortcuts = defineShortcuts({
|
|
|
54
67
|
"before:": "absolute bottom-[0.6em] w-[1.5em] h-[2px] bg-scope-color-500/75 block",
|
|
55
68
|
"[&[data-today]::before]:": "content-['']",
|
|
56
69
|
"[&[data-today][data-selected]::before]:": "bg-white",
|
|
57
|
-
[`${whenEnabled}
|
|
70
|
+
[`${whenEnabled}${whenHoverIdle}`]: {
|
|
58
71
|
"": "bg-scope-color-200",
|
|
59
72
|
"dark:": "bg-scope-color-700"
|
|
60
73
|
},
|
|
@@ -110,7 +123,8 @@ const comboboxShortcuts = defineShortcuts({
|
|
|
110
123
|
"combobox-multi-items": "text-ellipsis overflow-hidden whitespace-nowrap absolute max-w-full pr-$m lh-1em",
|
|
111
124
|
"combobox-embedded-input": "text-left outline-0 outline-offset-0",
|
|
112
125
|
"combobox-c8-icon": {
|
|
113
|
-
"": "
|
|
126
|
+
"": "cursor-pointer",
|
|
127
|
+
[whenHover]: "current-icon-scope-color-500 icon-current",
|
|
114
128
|
"group-[[aria-expanded=true]]/i8:": "-scale-100"
|
|
115
129
|
}
|
|
116
130
|
});
|
|
@@ -127,7 +141,10 @@ const dialogShortcuts = defineShortcuts({
|
|
|
127
141
|
},
|
|
128
142
|
"dialog-header": "flex-shrink-0 border-b pb-$m px-$card-spacing pt-$card-spacing",
|
|
129
143
|
"dialog-title": "text-mb-0",
|
|
130
|
-
"dialog-close":
|
|
144
|
+
"dialog-close": {
|
|
145
|
+
"": "absolute right-$card-spacing top-$card-spacing rounded p-$xxs",
|
|
146
|
+
[whenHover]: "bg-grey-500/10"
|
|
147
|
+
},
|
|
131
148
|
"dialog-footer": "flex-shrink-0 flex gap-$s justify-end border-t px-$card-spacing py-$m"
|
|
132
149
|
});
|
|
133
150
|
//#endregion
|
|
@@ -223,7 +240,7 @@ const shortcuts = [
|
|
|
223
240
|
"dark:": "border-scope-dark-0",
|
|
224
241
|
[whenEnabled]: {
|
|
225
242
|
"": "cursor-grab",
|
|
226
|
-
|
|
243
|
+
[whenHover]: "shadow-md",
|
|
227
244
|
"active:": "cursor-grabbing",
|
|
228
245
|
"focus:": "outline-[0.5em]"
|
|
229
246
|
}
|
|
@@ -266,29 +283,24 @@ const btn = defineShortcuts({
|
|
|
266
283
|
//#region src/theme/shortcuts/c8.ts
|
|
267
284
|
const c8 = defineShortcuts({
|
|
268
285
|
"c8-filled": {
|
|
269
|
-
"": "current-bg-scope-color-
|
|
286
|
+
"": "current-bg-scope-color-600 rounded-r1 current-text-white current-icon-white icon-current/100 bg-current text-current",
|
|
287
|
+
"dark:": "ring-1 ring-inset [--un-ring-color:rgb(var(--scope-color-500))]",
|
|
270
288
|
"focus-visible:": "c8-filled-hover",
|
|
271
289
|
[whenEnabled]: {
|
|
272
|
-
|
|
290
|
+
[whenHoverIdle]: "c8-filled-hover",
|
|
273
291
|
"data-[highlighted]:": "c8-filled-hover",
|
|
274
292
|
"active:": "c8-filled-active",
|
|
275
293
|
"data-[active]:": "c8-filled-active"
|
|
276
294
|
}
|
|
277
295
|
},
|
|
278
|
-
"c8-filled-hover":
|
|
279
|
-
|
|
280
|
-
"dark:": "current-bg-scope-color-400"
|
|
281
|
-
},
|
|
282
|
-
"c8-filled-active": {
|
|
283
|
-
"": "current-bg-scope-color-700",
|
|
284
|
-
"dark:": "current-bg-scope-color-300"
|
|
285
|
-
},
|
|
296
|
+
"c8-filled-hover": "current-bg-scope-color-700",
|
|
297
|
+
"c8-filled-active": "current-bg-scope-color-800",
|
|
286
298
|
"c8-flat": {
|
|
287
299
|
"": "current-bg-scope-color-500 rounded-r1 current-text-black current-icon-black bg-current/0 text-current/80 icon-current/50",
|
|
288
300
|
"dark:": "current-text-white current-icon-white",
|
|
289
301
|
"focus-visible:": "c8-flat-hover",
|
|
290
302
|
[whenEnabled]: {
|
|
291
|
-
|
|
303
|
+
[whenHoverIdle]: "c8-flat-hover",
|
|
292
304
|
"data-[highlighted]:": "c8-flat-hover",
|
|
293
305
|
"active:": "c8-flat-active",
|
|
294
306
|
"data-[active]:": "c8-flat-active"
|
|
@@ -309,7 +321,7 @@ const c8 = defineShortcuts({
|
|
|
309
321
|
"dark:": "current-text-scope-color-400 current-icon-scope-color-400",
|
|
310
322
|
"focus-visible:": "c8-outlined-hover",
|
|
311
323
|
[whenEnabled]: {
|
|
312
|
-
|
|
324
|
+
[whenHoverIdle]: "c8-outlined-hover",
|
|
313
325
|
"data-[highlighted]:": "c8-outlined-hover",
|
|
314
326
|
"active:": "c8-outlined-active",
|
|
315
327
|
"data-[active]:": "c8-outlined-active"
|
|
@@ -321,7 +333,7 @@ const c8 = defineShortcuts({
|
|
|
321
333
|
"": "surface-0 rounded-r1 border",
|
|
322
334
|
"focus-visible:": "c8-chrome-hover",
|
|
323
335
|
[whenEnabled]: {
|
|
324
|
-
|
|
336
|
+
[whenHoverIdle]: "c8-chrome-hover",
|
|
325
337
|
"data-[highlighted]:": "c8-chrome-hover",
|
|
326
338
|
"active:": "c8-chrome-active",
|
|
327
339
|
"data-[active]:": "c8-chrome-active"
|
|
@@ -348,7 +360,7 @@ const c8 = defineShortcuts({
|
|
|
348
360
|
"dark:": "current-text-scope-color-400 current-icon-scope-color-400",
|
|
349
361
|
"focus-visible:": "c8-light-hover",
|
|
350
362
|
[whenEnabled]: {
|
|
351
|
-
|
|
363
|
+
[whenHoverIdle]: "c8-light-hover",
|
|
352
364
|
"data-[highlighted]:": "c8-light-hover",
|
|
353
365
|
"active:": "c8-light-active",
|
|
354
366
|
"data-[active]:": "c8-light-active"
|
|
@@ -368,6 +380,10 @@ const popupCard = defineShortcuts({
|
|
|
368
380
|
"popup-card": { "": "surface-0 bg-current rounded-r2 overflow-hidden shadow-popup z-[100] border current-border-grey-400 border-current/20" }
|
|
369
381
|
});
|
|
370
382
|
const disabledSoft = defineShortcuts({ "disabled-soft": { [whenDisabled]: "opacity-40 cursor-not-allowed" } });
|
|
383
|
+
const press = defineShortcuts({ press: {
|
|
384
|
+
"": "[-webkit-tap-highlight-color:transparent]",
|
|
385
|
+
[`${whenEnabled}active:`]: "[scale:var(--press-scale,0.97)]"
|
|
386
|
+
} });
|
|
371
387
|
//#endregion
|
|
372
388
|
//#region src/theme/shortcuts/i8.ts
|
|
373
389
|
const M = "1em";
|
|
@@ -404,7 +420,7 @@ const rawVunorShortcuts = [
|
|
|
404
420
|
"i8-transparent": "bg-transparent!",
|
|
405
421
|
"i8-bare": {
|
|
406
422
|
"": "i8-apply-bg i8-apply-border current-outline-hl rounded-r1 outline-none text-current placeholder:text-current/50 disabled-soft",
|
|
407
|
-
[`${whenEnabled}
|
|
423
|
+
[`${whenEnabled}${whenHover}`]: "border-current-hover",
|
|
408
424
|
"focus:": "current-border-hl outline i8-apply-outline",
|
|
409
425
|
"data-[error=true]:": "current-border-error-500 current-outline-error-500 border-current"
|
|
410
426
|
},
|
|
@@ -480,7 +496,7 @@ const rawVunorShortcuts = [
|
|
|
480
496
|
},
|
|
481
497
|
"i8-icon-clickable": {
|
|
482
498
|
"[&>.i8-icon-wrap]:": "cursor-pointer",
|
|
483
|
-
|
|
499
|
+
[`${whenCanHover}[&>.i8-icon-wrap:hover]:`]: "current-icon-hl icon-current"
|
|
484
500
|
}
|
|
485
501
|
}),
|
|
486
502
|
c8,
|
|
@@ -491,6 +507,7 @@ const rawVunorShortcuts = [
|
|
|
491
507
|
}),
|
|
492
508
|
popupCard,
|
|
493
509
|
disabledSoft,
|
|
510
|
+
press,
|
|
494
511
|
...shortcuts
|
|
495
512
|
];
|
|
496
513
|
//#endregion
|
|
@@ -2556,4 +2573,4 @@ function vunorShortcuts(customShortcuts, baseShortcuts = mergedVunorShortcuts) {
|
|
|
2556
2573
|
return merged;
|
|
2557
2574
|
}
|
|
2558
2575
|
//#endregion
|
|
2559
|
-
export { componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, toUnoShortcut, vunorShortcuts };
|
|
2576
|
+
export { componentClasses, defineShortcuts, getComponentClasses, mergeVunorShortcuts, mergedVunorShortcuts, presetVunor, rawVunorShortcuts, toUnoShortcut, vunorShortcuts, whenCanHover, whenDisabled, whenEnabled, whenHover, whenHoverIdle };
|