vunor 0.4.5 → 0.5.0

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 CHANGED
@@ -1,5 +1,45 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ A minor release: the first three items below change how every app looks, with no code change on its side. Each says how to get the 0.4.x look back.
6
+
7
+ ### Changed (visual)
8
+
9
+ - **Accent text reaches WCAG AA.** `text-current-hl` paints the scope's shade 700 on light and 300 in dark mode, the way the `c8-*` text colours pick a shade per mode. It painted 500 in both modes, which measured 3.4–4.1:1 against white with the default palette (4.1:1 for a strong brand colour such as `#471aec`), below the 4.5:1 that WCAG AA asks of text. Now, with the default palette, it measures at least 5.8:1 on `layer-0` and `layer-1` in both modes and at least 4.9:1 on any layer; with `#471aec`, 6.7:1 or more on `layer-0` and `layer-1` and 5.5:1 or more on any layer. The focused input's floating label (`i8-label`) uses it too. An accent set explicitly with `current-hl-*` (`current-hl-error-500`) is still painted as given, in both modes. Borders, rings, the input underline and icons (`border-current-hl`, `current-outline-hl`, `bg-current-hl`, `icon-current-hl`) keep 500: they need 3:1, not 4.5:1. To keep 500 on an element, write `text-scope-color-500` instead of `text-current-hl`. There is no switch that brings 500 back everywhere.
10
+ - **The ends of the layer ramp keep the palette's tint.** `palette.layerPalette.saturate` now defaults to `{ dark: 0, light: 0 }`. Its old default, `-0.2`, took all colour out of `dark-0`, `dark-4`, `light-0` and `light-4`, so dark-mode `layer-0` (with every `surface-0` panel, `popup-card` and `c8-chrome` on it) was neutral grey whatever the palette. A tinted palette now tints those too; to tint surfaces, tune `layerPalette` (`desaturate` sets how strong the tint is), not only `colors`. With the default palette the page scope (`neutral`, a light blue) tints them slightly: dark-mode `layer-0` goes from `#1f1f1f` to `#1c2022` and `layer-4` from `#333333` to `#2e3437`, light-mode `layer-4` from `#e4e4e4` to `#e2e5e7` (the steps next to the ends shift a little too; `light-0` stays white). A `grey` scope looks the same, within one level per colour channel. To restore the grey ends: `presetVunor({ palette: { layerPalette: { saturate: { dark: -0.2, light: -0.2 } } } })`.
11
+ - **The default border colour comes from the palette.** A `border` with no colour class is drawn in the palette's `grey-500` at `borderOpacity`, instead of a fixed `rgb(150 150 150)`. With the default palette that is `rgb(131 134 144)`: at the default 25% opacity the line is up to 5 levels (of 255) darker, on light and dark layers alike, and very slightly cool. A tinted `palette.colors.grey` tints every colourless border. To restore: `html:root { --un-default-border-color: rgb(150 150 150 / var(--un-border-opacity)) }` in your CSS (`html:root` outranks vunor's `:root` whatever order the stylesheets load in).
12
+
13
+ ### Changed (visual, only with `layers.reverseDark` or `layers.reverseLight`)
14
+
15
+ - `surface-0` … `surface-4` and `c8-chrome` follow the layer orientation, as `layer-N` always did. `surface-N` has the background of `layer-N`, and `c8-chrome` (a `surface-0` button) steps to the `layer-1` background on hover, focus and selection and to `layer-2` on press. They named fixed steps (`scope-dark-0`, hover `scope-dark-1`), so with `reverseDark: true` a chrome button or a `popup-card` was darker than the `layer-0` dialog it sat in. Now, in that orientation, dark mode counts from `dark-4`: the button has the dialog's background and hovers one step darker. In a custom `palette.surfaces` entry, a background of `scope-light-N` (first slot) or `scope-dark-N` (fourth slot) follows the orientation the same way; text and border entries are used as written. Nothing changes in the default orientation.
16
+
17
+ ### Added
18
+
19
+ - Every sized touch target is a runtime variable. `h-fingertip-s`, `min-h-fingertip-m`, `size-fingertip-xs` and the other sized utilities (`w-`, `lh-`, `rounded-`, …, sizes `xs` to `xl`) read `--v-fingertip-xs` … `--v-fingertip-xl`, which `:root` sets from the `fingertip` preset option; they compiled to the literal size (`height: 2.358em`). The defaults are the same sizes, so nothing changes on its own. An app can now raise every touch target in one rule, the way `--v-fingertip` already raised `h-fingertip`, for example to 44 px on a touch screen with one `@media (pointer: coarse) { html:root { … } }` rule: the README ("Touch targets on touch screens") and the skill (`references/theme.md`) have the recipe. Use `html:root`, not `:root`: vunor's own `:root` declares the same variables, and `html:root` outranks it whatever order the stylesheets load in. `fingertip-s` (and the other sizes) makes the variable the active size: `--v-fingertip: var(--v-fingertip-s)` with `--v-fingertip-half: calc(var(--v-fingertip-s) / 2)`.
20
+
21
+ - `current-<slot>-layer-light-N` and `current-<slot>-layer-dark-N` (for example `current-bg-layer-light-1`): one mode's background of `layer-N`, in the `layers.reverse*` orientation, as a single utility. Pair them with `dark:` (`'current-bg-layer-light-1 dark:current-bg-layer-dark-1'`); `c8-chrome` uses them for hover, selection and press, so it follows the orientation without nesting deeper than in 0.4.x.
22
+ - `--current-hl-text`, the colour `text-current-hl` paints, set by every `scope-*` (in both modes) and by `current-hl-*`; a new preflight rule, `.dark { --current-hl-text: var(--scope-color-300) }`, gives a dark subtree the dark shade of the scope it is in. A variable rather than a `dark:` rule, so `text-current-hl` stays one rule and works in dark mode under parent variants too (`group-hover:text-current-hl`, the focused input label).
23
+
24
+ ### Changed
25
+
26
+ - The theme's `spacing` and `lineHeight` entries `fingertip-xs` … `fingertip-xl` are `var(--v-fingertip-<size>)` instead of the sizes. Code that reads them from the UnoCSS theme to compute with them gets the variable; read the `fingertip` preset option instead.
27
+
28
+ ### Fixed
29
+
30
+ - Three classes in vunor's shortcuts matched no UnoCSS rule, so each build logged an `unmatched utility` warning and the shortcut lost that piece. They now do what they were written for:
31
+ - `toast-root`: a toast released before the swipe distance slides back over 200 ms instead of jumping back (`[transition:transform_200ms_ease-out]` under `data-[swipe=cancel]`).
32
+ - `btn-label`: in a button with a bounded width (`w-full` in a narrow column, `max-w-*`), a label longer than the button is cut with an ellipsis; before, it ran out of the button. A label that fits is unchanged. To let labels overflow again, append `min-w-auto`: `vunorShortcuts(defineShortcuts({ 'btn-label': 'min-w-auto' }))`.
33
+ - `i8`: the class `content-box` is removed. It never compiled to anything, so inputs keep their height (`box-sizing: border-box`, border inside the fingertip height).
34
+ - A `fingertip` size that is not a plain length (`fingertip: { m: 'max(3em, 44px)' }`) no longer gives `--v-fingertip-half: NaN`: it is halved with `calc(… / 2)`, in `:root` and in `fingertip-*`. Plain lengths are still halved to a plain length (`3em` → `1.5em`).
35
+ - `border-layer-N` and `outline-layer-N` compile. The skill documents `bg-layer-2 text-layer-1 border-layer-3`, but the per-target layer utilities had no `border` or `outline`, so those classes produced no CSS. They now set the border / outline colour of layer step N in light and dark mode, and follow `layers.reverseLight` / `reverseDark` like `bg-layer-N`.
36
+
37
+ ## 0.4.6
38
+
39
+ ### Fixed
40
+
41
+ - The important variant of a shortcut (`!card`, `card!`) no longer writes `!important !important` on a declaration the shortcut already marks important (`card` makes its dense spacing important). That CSS is invalid: browsers drop the declaration and lightningcss, the CSS minifier of Vite 8, fails the production build. The token `!card` anywhere in a scanned file was enough, `v-if="!card"` included. Every declaration now carries `!important` once, in vunor's shortcuts and in yours; without the `!` nothing changes.
42
+
3
43
  ## 0.4.5
4
44
 
5
45
  ### Added
package/README.md CHANGED
@@ -84,10 +84,13 @@ palette: {
84
84
  layerPalette: {
85
85
  desaturate: 0.2, // pre-desaturate before generating layers
86
86
  luminance: { dark: 0.24, light: 0.32 },
87
+ saturate: { dark: 0, light: 0 }, // added at the ends of the layer ramp
87
88
  },
88
89
  }
89
90
  ```
90
91
 
92
+ To tint surfaces, tune `layerPalette`, not only `colors`: the layers (`layer-*`, `surface-0..4`, `c8-chrome`, popups) come from each seed colour through `layerPalette` alone, while a colour's own `saturate` / `vivid` shape its 50–900 scale. Raise `desaturate` (e.g. `0.5`) for a stronger tint, lower it toward `0` for grey layers. Since 0.5.0 the ends of the layer ramp keep the palette's tint; `layerPalette: { saturate: { dark: -0.2, light: -0.2 } }` brings back the grey ends of 0.4.x (dark-mode `layer-0` neutral grey whatever the palette).
93
+
91
94
  ---
92
95
 
93
96
  ## Golden-Ratio Typography & Spacing
@@ -142,10 +145,27 @@ Used as `p-$m`, `m-$l`, `gap-$s`, etc. Text-aware margin utilities (`text-mt-$m`
142
145
  ### Other Derived Values
143
146
 
144
147
  - **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`
148
+ - **Default border**: a `border` with no colour class is the palette's `grey-500` at opacity `0.25`, configurable via `borderOpacity`
146
149
  - **Touch targets** (`fingertip-xs` through `fingertip-xl`): sized using `sqrt(k)` progressions
147
150
  - **Card spacing**: `card-{typography}` sets `--card-spacing` proportional to the heading's corrected size; `card-dense` switches to 0.6x
148
151
 
152
+ #### Touch targets on touch screens
153
+
154
+ Every touch-target size is a runtime variable on `:root`: `--v-fingertip` (read by `h-fingertip`, which every vunor button and input uses), `--v-fingertip-half` (`px-` / `rounded-fingertip-half`) and `--v-fingertip-xs` … `--v-fingertip-xl` (read by `h-fingertip-s`, `size-fingertip-xs`, `min-h-fingertip-m`, `fingertip-s` and the other sized utilities). Their defaults come from the `fingertip` preset option. One CSS rule gives every control a 44 px tap target on a touch screen and changes nothing on a mouse:
155
+
156
+ ```css
157
+ @media (pointer: coarse) {
158
+ html:root {
159
+ --v-fingertip: 44px;
160
+ --v-fingertip-half: 22px;
161
+ --v-fingertip-s: 44px;
162
+ --v-fingertip-m: 44px;
163
+ }
164
+ }
165
+ ```
166
+
167
+ `html:root` outranks vunor's own `:root`, which declares the same variables, whatever order the stylesheets load in. Write `max(3em, 44px)` to never go below the em size on a large font. `--v-fingertip-xs` is the visible size of small icon buttons (a chip's remove button); raise it only if those are tap targets too.
168
+
149
169
  ---
150
170
 
151
171
  ## Object-Driven Shortcuts
@@ -297,9 +317,9 @@ Layers provide full background + text + icon styling that automatically adapts t
297
317
  </div>
298
318
  ```
299
319
 
300
- - `layer-0` is the outermost (lightest in light mode, darkest in dark)
320
+ - `layer-0` is the outermost (lightest in light mode, darkest in dark); `layers: { reverseLight, reverseDark }` flips either mode
301
321
  - Each subsequent layer steps progressively toward the opposite extreme
302
- - Apply `scope-{color}` to set which palette the layers use
322
+ - Apply `scope-{color}` to set which palette the layers use; they carry a hint of its colour (how much is `palette.layerPalette`)
303
323
 
304
324
  ### Surfaces
305
325
 
@@ -310,7 +330,7 @@ Surfaces apply specific palette stops as background + text + icon:
310
330
  <div class="scope-error surface-500">Bold error banner</div>
311
331
  ```
312
332
 
313
- `surface-0` through `surface-4` map to the layer scale. `surface-50` through `surface-900` map to the main 10-step palette. Custom surfaces can be defined in `palette.surfaces`.
333
+ `surface-0` through `surface-4` map to the layer scale: `surface-N` has the background of `layer-N`, also with `layers.reverse*`. `surface-50` through `surface-900` map to the main 10-step palette. Custom surfaces can be defined in `palette.surfaces`.
314
334
 
315
335
  ### Current-Color System
316
336
 
@@ -323,6 +343,7 @@ Fine-grained color control via CSS custom properties:
323
343
  - `scope-{color}` sets `--scope-color-*` vars for a palette
324
344
  - `current-bg-{color}-{step}` sets `--current-bg`
325
345
  - `bg-current` / `text-current` / `icon-current` apply the current-scoped colors
346
+ - `text-current-hl` is accent text (links, a focused input's label): the scope's shade 700 on light and 300 in dark mode, which reaches WCAG AA (4.5:1) on every layer with the default palette and with strong brand colours. An accent set with `current-hl-*` is painted as given. Before 0.5.0 it was shade 500 in both modes; `text-scope-color-500` paints that on one element.
326
347
 
327
348
  ### Clickable Styles (`c8`)
328
349
 
package/dist/DevTools.mjs CHANGED
@@ -8,6 +8,34 @@ import VuCardHeader$1 from "vunor/CardHeader";
8
8
  import VuCardInner from "vunor/CardInner";
9
9
  import VuSlider from "vunor/Slider";
10
10
  import VuTabs from "vunor/Tabs";
11
+ //#region src/theme/rules/palette.ts
12
+ function colorToRgbWithOpacity(c) {
13
+ const [r, g, b, _a] = color(c).rgba();
14
+ return `${r} ${g} ${b}`;
15
+ }
16
+ const CURRENT_SLOTS = [
17
+ "text-muted",
18
+ "icon-muted",
19
+ "text-hover",
20
+ "bg-hover",
21
+ "border-hover",
22
+ "text",
23
+ "bg",
24
+ "icon",
25
+ "border",
26
+ "outline",
27
+ "caret",
28
+ "hl"
29
+ ];
30
+ const slotAlt = CURRENT_SLOTS.join("|");
31
+ const sourceAlt = [
32
+ ...CURRENT_SLOTS,
33
+ "muted",
34
+ "hover"
35
+ ].map((s) => `-${s}`).join("|");
36
+ new RegExp(`^current-(${slotAlt})-(.+)$`);
37
+ new RegExp(`^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(${sourceAlt})?(\\/\\d{1,3})?$`);
38
+ //#endregion
11
39
  //#region src/theme/palitra.ts
12
40
  const defaultOpts = {
13
41
  colors: {
@@ -78,8 +106,8 @@ const defaultOpts = {
78
106
  layerPalette: {
79
107
  desaturate: .2,
80
108
  saturate: {
81
- dark: -.2,
82
- light: -.2
109
+ dark: 0,
110
+ light: 0
83
111
  },
84
112
  vivid: {
85
113
  dark: 0,
@@ -295,34 +323,18 @@ function multiplySaturation(colors, m = .5) {
295
323
  }
296
324
  return newObj;
297
325
  }
298
- //#endregion
299
- //#region src/theme/rules/palette.ts
300
- function colorToRgbWithOpacity(c) {
301
- const [r, g, b, _a] = color(c).rgba();
302
- return `${r} ${g} ${b}`;
303
- }
304
- const CURRENT_SLOTS = [
305
- "text-muted",
306
- "icon-muted",
307
- "text-hover",
308
- "bg-hover",
309
- "border-hover",
310
- "text",
326
+ /** What `{target}-layer-N` paints from layer step N: each `current-*` slot, plus direct paints. */
327
+ const LAYER_TARGETS = [
328
+ ...CURRENT_SLOTS.map((slot) => `current-${slot}`),
311
329
  "bg",
312
- "icon",
330
+ "text",
313
331
  "border",
314
332
  "outline",
315
- "caret",
316
- "hl"
333
+ "i8-bg",
334
+ "i8-border",
335
+ "i8-outline"
317
336
  ];
318
- const slotAlt = CURRENT_SLOTS.join("|");
319
- const sourceAlt = [
320
- ...CURRENT_SLOTS,
321
- "muted",
322
- "hover"
323
- ].map((s) => `-${s}`).join("|");
324
- new RegExp(`^current-(${slotAlt})-(.+)$`);
325
- new RegExp(`^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(${sourceAlt})?(\\/\\d{1,3})?$`);
337
+ new RegExp(`^(${LAYER_TARGETS.join("|")})-layer-([0-4])$`);
326
338
  //#endregion
327
339
  //#region src/components/DevTools/DevTools.vue?vue&type=script&setup=true&lang.ts
328
340
  const _hoisted_1 = { key: 0 };
@@ -536,8 +548,8 @@ var DevTools_default = /* @__PURE__ */ defineComponent({
536
548
  flatness: [l.flatness ?? p.flatness ?? 1],
537
549
  lumDark: [l.luminance?.dark ?? p.darkest],
538
550
  lumLight: [l.luminance?.light ?? p.darkest + p.layersDepth],
539
- saturateDark: [l.saturate?.dark ?? -.2],
540
- saturateLight: [l.saturate?.light ?? -.2],
551
+ saturateDark: [l.saturate?.dark ?? 0],
552
+ saturateLight: [l.saturate?.light ?? 0],
541
553
  vividDark: [l.vivid?.dark ?? 0],
542
554
  vividLight: [l.vivid?.light ?? 0]
543
555
  };
package/dist/theme.d.mts CHANGED
@@ -21,6 +21,13 @@ interface TVunorUnoPresetOpts {
21
21
  reverseDark?: boolean;
22
22
  reverseLight?: boolean;
23
23
  };
24
+ /**
25
+ * Touch-target sizes. Each is the default of a runtime variable on `:root`
26
+ * (`--v-fingertip-xs` … `--v-fingertip-xl`), which `h-fingertip-s`,
27
+ * `size-fingertip-xs`, `fingertip-m` and the other sized utilities read, so an
28
+ * app can change them in CSS (for example for a coarse pointer). `m` is also
29
+ * the default of `--v-fingertip`, the size `h-fingertip` reads.
30
+ */
24
31
  fingertip?: {
25
32
  xs?: string;
26
33
  s?: string;
@@ -80,11 +87,6 @@ declare const themeFactory: (opts: Required<TVunorUnoPresetOpts> & {
80
87
  lineHeight: {
81
88
  fingertip: string;
82
89
  'fingertip-half': string;
83
- 'fingertip-xs': string | undefined;
84
- 'fingertip-s': string | undefined;
85
- 'fingertip-m': string | undefined;
86
- 'fingertip-l': string | undefined;
87
- 'fingertip-xl': string | undefined;
88
90
  };
89
91
  spacing: Record<string, string>;
90
92
  fontWeight: Record<string, string>;
@@ -316,15 +318,18 @@ interface TVunorLayerPaletteAdvanced {
316
318
  light?: number;
317
319
  };
318
320
  /**
319
- * Saturation on dark/light ends
321
+ * Saturation added at the dark/light ends of the layer ramp (`dark-0`,
322
+ * `dark-4`, `light-0`, `light-4`), after `desaturate`. `0` keeps the palette's
323
+ * tint on every layer; `-0.2` (the default before 0.5.0) turns the ends grey
324
+ * whatever the palette.
320
325
  */
321
326
  saturate?: {
322
327
  /**
323
- * @default -0.2
328
+ * @default 0
324
329
  */
325
330
  dark?: number;
326
331
  /**
327
- * @default -0.2
332
+ * @default 0
328
333
  */
329
334
  light?: number;
330
335
  };
package/dist/theme.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import defu$1, { defu } from "defu";
2
- import { presetWind } from "unocss";
2
+ import { presetWind, symbols, toArray } from "unocss";
3
3
  import { color, palitra } from "@prostojs/palitra";
4
4
  //#region src/theme/utils/define-sc.ts
5
5
  const defineShortcuts = (sc) => sc;
@@ -23,7 +23,7 @@ const toastShortcuts = defineShortcuts({
23
23
  "data-[state=closed]:": "animate-hide",
24
24
  "data-[swipe=move]:": "translate-x-[var(--reka-toast-swipe-move-x)]",
25
25
  "data-[swipe=end]:": "animate-swipe-out",
26
- "data-[swipe=cancel]:": "translate-x-0 transition-[transform_200ms_ease-out]",
26
+ "data-[swipe=cancel]:": "translate-x-0 [transition:transform_200ms_ease-out]",
27
27
  "data-[swipe=left]:": "[--toast-out-x:calc(-100%-var(--viewport-padding))]",
28
28
  "data-[swipe=right]:": "[--toast-out-x:calc(100%+var(--viewport-padding))]"
29
29
  }
@@ -274,7 +274,7 @@ const btn = defineShortcuts({
274
274
  },
275
275
  "btn-round": { "": btnRound },
276
276
  "btn-square": { "": btnSquare },
277
- "btn-label": { "": "lh-1em ellipsis whitespace-nowrap overflow-x-clip overflow-y-visible display-[var(--btn-label-display,revert)]" },
277
+ "btn-label": { "": "lh-1em text-ellipsis min-w-0 whitespace-nowrap overflow-x-clip overflow-y-visible display-[var(--btn-label-display,revert)]" },
278
278
  "btn-icon": { "": "size-1em font-size-[var(--btn-icon-fs,1.25em)]" },
279
279
  "btn-icon-left": { "": "ml-[var(--btn-icon-pull,0)]" },
280
280
  "btn-icon-right": { "": "mr-[var(--btn-icon-pull,0)]" }
@@ -344,16 +344,16 @@ const c8 = defineShortcuts({
344
344
  "aria-[pressed=true]:": "c8-chrome-selected"
345
345
  },
346
346
  "c8-chrome-hover": {
347
- "": "current-bg-scope-light-1 bg-current",
348
- "dark:": "current-bg-scope-dark-1"
347
+ "": "current-bg-layer-light-1 bg-current",
348
+ "dark:": "current-bg-layer-dark-1"
349
349
  },
350
350
  "c8-chrome-active": {
351
- "": "current-bg-scope-light-2 bg-current",
352
- "dark:": "current-bg-scope-dark-2"
351
+ "": "current-bg-layer-light-2 bg-current",
352
+ "dark:": "current-bg-layer-dark-2"
353
353
  },
354
354
  "c8-chrome-selected": {
355
- "": "current-bg-scope-light-1 bg-current current-text-scope-color-500 text-current current-icon-scope-color-500 icon-current/100",
356
- "dark:": "current-bg-scope-dark-1 current-text-scope-color-400 current-icon-scope-color-400"
355
+ "": "current-bg-layer-light-1 bg-current current-text-scope-color-500 text-current current-icon-scope-color-500 icon-current/100",
356
+ "dark:": "current-bg-layer-dark-1 current-text-scope-color-400 current-icon-scope-color-400"
357
357
  },
358
358
  "c8-light": {
359
359
  "": "current-bg-scope-color-500 rounded-r1 current-text-scope-color-500 current-icon-scope-color-500 bg-current/10 text-current icon-current/80",
@@ -396,7 +396,7 @@ const roundSignal = pad(FINGERTIP_HALF);
396
396
  const rawVunorShortcuts = [
397
397
  defineShortcuts({
398
398
  "i8": {
399
- "": "h-fingertip min-w-3em flex items-center select-none relative icon-current content-box disabled-soft",
399
+ "": "h-fingertip min-w-3em flex items-center select-none relative icon-current disabled-soft",
400
400
  "data-[type=textarea]:": "min-h-fingertip h-auto items-start",
401
401
  "data-[active=true]:": "icon-current-hl",
402
402
  "focus-within:": "icon-current-hl",
@@ -1517,6 +1517,171 @@ function getComponentClasses(...components) {
1517
1517
  return [...set];
1518
1518
  }
1519
1519
  //#endregion
1520
+ //#region src/theme/rules/palette.ts
1521
+ function colorToRgbWithOpacity(c) {
1522
+ const [r, g, b, _a] = color(c).rgba();
1523
+ return `${r} ${g} ${b}`;
1524
+ }
1525
+ /**
1526
+ * What `text-current-hl` paints (`--current-hl-text`) per mode: accent text needs
1527
+ * WCAG AA (4.5:1) on the layers, which 500 misses, so it takes the scope's 700 on
1528
+ * light and its 300 on dark, as the c8 text colours do. Borders, rings and icons
1529
+ * stay on `--current-hl` (500): they need 3:1.
1530
+ */
1531
+ const HL_TEXT = {
1532
+ light: "var(--scope-color-700)",
1533
+ dark: "var(--scope-color-300)"
1534
+ };
1535
+ /** Layer step N in the orientation `layers.reverseLight` / `reverseDark` sets. */
1536
+ const layerN = (n, reverse) => reverse ? 4 - n : n;
1537
+ function getOpacityVar(key) {
1538
+ return {
1539
+ bg: "--un-bg-opacity",
1540
+ text: "--un-text-opacity",
1541
+ fill: "--un-text-opacity",
1542
+ stroke: "--un-text-opacity",
1543
+ icon: "--un-icon-opacity",
1544
+ border: "--un-border-opacity",
1545
+ outline: "--un-outline-opacity",
1546
+ caret: "--un-caret-opacity",
1547
+ shadow: "--un-shadow-opacity",
1548
+ ring: "--un-ring-opacity"
1549
+ }[key];
1550
+ }
1551
+ function getCssTarget(key) {
1552
+ return {
1553
+ bg: "background-color",
1554
+ text: "color",
1555
+ fill: "fill",
1556
+ stroke: "stroke",
1557
+ icon: "color",
1558
+ border: "border-color",
1559
+ outline: "outline-color",
1560
+ caret: "caret-color",
1561
+ shadow: "--un-shadow-color",
1562
+ ring: "--un-ring-color"
1563
+ }[key];
1564
+ }
1565
+ const SCOPE_SHADES = [
1566
+ "50",
1567
+ "100",
1568
+ "200",
1569
+ "300",
1570
+ "400",
1571
+ "500",
1572
+ "600",
1573
+ "700",
1574
+ "800",
1575
+ "900"
1576
+ ];
1577
+ const SCOPE_LAYERS = [
1578
+ "0",
1579
+ "1",
1580
+ "2",
1581
+ "3",
1582
+ "4"
1583
+ ];
1584
+ const CURRENT_SLOTS = [
1585
+ "text-muted",
1586
+ "icon-muted",
1587
+ "text-hover",
1588
+ "bg-hover",
1589
+ "border-hover",
1590
+ "text",
1591
+ "bg",
1592
+ "icon",
1593
+ "border",
1594
+ "outline",
1595
+ "caret",
1596
+ "hl"
1597
+ ];
1598
+ const slotAlt = CURRENT_SLOTS.join("|");
1599
+ const sourceAlt = [
1600
+ ...CURRENT_SLOTS,
1601
+ "muted",
1602
+ "hover"
1603
+ ].map((s) => `-${s}`).join("|");
1604
+ const currentSlotRe = new RegExp(`^current-(${slotAlt})-(.+)$`);
1605
+ const currentPaintRe = new RegExp(`^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(${sourceAlt})?(\\/\\d{1,3})?$`);
1606
+ function getScopeCssVars(c, theme) {
1607
+ const col = theme.colors[c];
1608
+ if (!col || !theme.colors[`${c}-500`]) return;
1609
+ const vars = { "--scope-color": colorToRgbWithOpacity(col) };
1610
+ for (const shade of SCOPE_SHADES) vars[`--scope-color-${shade}`] = colorToRgbWithOpacity(theme.colors[`${c}-${shade}`]) || "";
1611
+ for (const layer of SCOPE_LAYERS) {
1612
+ vars[`--scope-light-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-light-${layer}`]) || "";
1613
+ vars[`--scope-dark-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-dark-${layer}`]) || "";
1614
+ }
1615
+ vars["--current-hl"] = colorToRgbWithOpacity(theme.colors[`${c}-500`]) || "";
1616
+ vars["--current-hl-text"] = HL_TEXT.light;
1617
+ const greyMuted = colorToRgbWithOpacity(theme.colors[`grey-500`]) || "";
1618
+ vars["--current-text-muted"] = greyMuted;
1619
+ vars["--current-icon-muted"] = greyMuted;
1620
+ vars["--current-text-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-dark-0`]) || "";
1621
+ vars["--current-bg-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-light-1`]) || "";
1622
+ vars["--current-border-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-light-3`]) || "";
1623
+ return vars;
1624
+ }
1625
+ const paletteRules = [
1626
+ [currentPaintRe, (match, { theme: _theme }) => {
1627
+ const target = match[1];
1628
+ let source = match[2] || `-${target}`;
1629
+ if (source === "-muted" || source === "-hover") source = `-${target}${source}`;
1630
+ if (target === "text" && source === "-hl") source = "-hl-text";
1631
+ const opacityVar = getOpacityVar(target);
1632
+ const cssVar = getCssTarget(target);
1633
+ const o = match[3];
1634
+ const opacity = o ? Number(o.slice(1)) / 100 : 1;
1635
+ const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
1636
+ if (target === "icon") {
1637
+ const indirect = [
1638
+ "-hl",
1639
+ "-icon-muted",
1640
+ "-icon-hover"
1641
+ ].includes(source);
1642
+ return {
1643
+ [opacityVar]: opacity,
1644
+ "--current-icon": indirect ? `var(--current${source})` : void 0
1645
+ };
1646
+ }
1647
+ if (["shadow", "ring"].includes(target) && source === "-border") return {
1648
+ [opacityVar]: opacity === 1 ? `var(--un-border-opacity)` : opacity,
1649
+ [`--un-${target}-color`]: `rgb(var(--current-border) / ${opacityVal})`
1650
+ };
1651
+ return {
1652
+ [opacityVar]: opacity,
1653
+ [cssVar]: `rgb(var(--current${source}) / ${opacityVal})`
1654
+ };
1655
+ }],
1656
+ [/^(bg|text|fill|stroke|border|outline|icon|caret)-scope-((?:color|dark|light|text|bg|white|black|icon)(?:-\d+)?)(\/\d{1,3})?$/, (match, { theme }) => {
1657
+ const cssVar = getCssTarget(match[1]);
1658
+ const opacityVar = getOpacityVar(match[1]);
1659
+ const source = match[2];
1660
+ const o = match[3];
1661
+ const opacity = o ? Number(o.slice(1)) / 100 : 1;
1662
+ const fallback = source.startsWith("color") ? `grey-${source.slice(6)}` : `grey-${source}`;
1663
+ const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
1664
+ return {
1665
+ [opacityVar]: opacity,
1666
+ [cssVar]: `rgb(var(--scope-${source}, ${theme.colors[fallback] || ""}) / ${opacityVal})`
1667
+ };
1668
+ }],
1669
+ [/^icon-opacity-(\d{1,3})$/, (match, { theme: _theme }) => {
1670
+ const o = match[1];
1671
+ return { "--un-icon-opacity": Number(o) / 100 };
1672
+ }],
1673
+ [/^icon-color$/, () => ({ color: `rgb(var(--current-icon) / var(--un-icon-opacity, 1))` })],
1674
+ [/^icon-size-(.*)$/, (match, { theme }) => {
1675
+ const name = match[1];
1676
+ if (name.startsWith("[") && name.endsWith("]")) return { "--icon-size": name.slice(1, -1) };
1677
+ if (theme.spacing[name]) return { "--icon-size": theme.spacing[name] };
1678
+ }],
1679
+ [/^icon-size$/, () => ({
1680
+ width: `var(--icon-size, 1em)`,
1681
+ height: `var(--icon-size, 1em)`
1682
+ })]
1683
+ ];
1684
+ //#endregion
1520
1685
  //#region src/theme/palitra.ts
1521
1686
  const defaultOpts = {
1522
1687
  colors: {
@@ -1587,8 +1752,8 @@ const defaultOpts = {
1587
1752
  layerPalette: {
1588
1753
  desaturate: .2,
1589
1754
  saturate: {
1590
- dark: -.2,
1591
- light: -.2
1755
+ dark: 0,
1756
+ light: 0
1592
1757
  },
1593
1758
  vivid: {
1594
1759
  dark: 0,
@@ -1804,7 +1969,22 @@ function multiplySaturation(colors, m = .5) {
1804
1969
  }
1805
1970
  return newObj;
1806
1971
  }
1807
- const layerN = (n, reverse) => reverse ? 4 - n : n;
1972
+ /** What `{target}-layer-N` paints from layer step N: each `current-*` slot, plus direct paints. */
1973
+ const LAYER_TARGETS = [
1974
+ ...CURRENT_SLOTS.map((slot) => `current-${slot}`),
1975
+ "bg",
1976
+ "text",
1977
+ "border",
1978
+ "outline",
1979
+ "i8-bg",
1980
+ "i8-border",
1981
+ "i8-outline"
1982
+ ];
1983
+ const layerTargetRe = new RegExp(`^(${LAYER_TARGETS.join("|")})-layer-([0-4])$`);
1984
+ const orientBg = (token, side, reverse) => {
1985
+ const m = /^scope-(light|dark)-([0-4])$/.exec(token);
1986
+ return m?.[1] === side ? `scope-${side}-${layerN(Number(m[2]), reverse)}` : token;
1987
+ };
1808
1988
  const sideTemplate = (bg, n) => {
1809
1989
  const fg = bg === "light" ? "dark" : "light";
1810
1990
  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`;
@@ -1821,7 +2001,7 @@ function getPaletteShortcuts() {
1821
2001
  "[&.dark]:": dark
1822
2002
  });
1823
2003
  }],
1824
- [/^(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 }) => {
2004
+ [layerTargetRe, ([, target, a], { theme }) => {
1825
2005
  const d = layerN(Number(a), theme.reverseDarkLayers);
1826
2006
  return toUnoShortcut({
1827
2007
  "": `${target}-scope-light-${layerN(Number(a), theme.reverseLightLayers)}`,
@@ -1829,180 +2009,33 @@ function getPaletteShortcuts() {
1829
2009
  "[&.dark]:": `${target}-scope-dark-${d}`
1830
2010
  });
1831
2011
  }],
1832
- [/^surface-(.+)$/, ([, s], { theme }) => theme.surfaces[s] ? toUnoShortcut({
1833
- "": `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`,
1834
- "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`,
1835
- "[&.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`
1836
- }) : ""],
2012
+ [/^surface-(.+)$/, ([, s], { theme }) => {
2013
+ if (!theme.surfaces[s]) return "";
2014
+ const [bg, text, border, darkBg, darkText, darkBorder] = theme.surfaces[s];
2015
+ const lightBg = orientBg(bg, "light", theme.reverseLightLayers);
2016
+ const dark = `current-bg-${orientBg(darkBg, "dark", theme.reverseDarkLayers)} current-text-${darkText} current-icon-${darkText} current-border-${darkBorder} shadow-black/30`;
2017
+ return toUnoShortcut({
2018
+ "": `current-bg-${lightBg} current-text-${text} current-icon-${text} current-border-${border} bg-current text-current border-current icon-current`,
2019
+ "dark:": dark,
2020
+ "[&.dark]:": dark
2021
+ });
2022
+ }],
1837
2023
  { surface: "surface-100" }
1838
2024
  ];
1839
2025
  }
1840
2026
  //#endregion
1841
- //#region src/theme/rules/palette.ts
1842
- function colorToRgbWithOpacity(c) {
1843
- const [r, g, b, _a] = color(c).rgba();
1844
- return `${r} ${g} ${b}`;
1845
- }
1846
- function getOpacityVar(key) {
1847
- return {
1848
- bg: "--un-bg-opacity",
1849
- text: "--un-text-opacity",
1850
- fill: "--un-text-opacity",
1851
- stroke: "--un-text-opacity",
1852
- icon: "--un-icon-opacity",
1853
- border: "--un-border-opacity",
1854
- outline: "--un-outline-opacity",
1855
- caret: "--un-caret-opacity",
1856
- shadow: "--un-shadow-opacity",
1857
- ring: "--un-ring-opacity"
1858
- }[key];
1859
- }
1860
- function getCssTarget(key) {
1861
- return {
1862
- bg: "background-color",
1863
- text: "color",
1864
- fill: "fill",
1865
- stroke: "stroke",
1866
- icon: "color",
1867
- border: "border-color",
1868
- outline: "outline-color",
1869
- caret: "caret-color",
1870
- shadow: "--un-shadow-color",
1871
- ring: "--un-ring-color"
1872
- }[key];
1873
- }
1874
- const SCOPE_SHADES = [
1875
- "50",
1876
- "100",
1877
- "200",
1878
- "300",
1879
- "400",
1880
- "500",
1881
- "600",
1882
- "700",
1883
- "800",
1884
- "900"
1885
- ];
1886
- const SCOPE_LAYERS = [
1887
- "0",
1888
- "1",
1889
- "2",
1890
- "3",
1891
- "4"
1892
- ];
1893
- const CURRENT_SLOTS = [
1894
- "text-muted",
1895
- "icon-muted",
1896
- "text-hover",
1897
- "bg-hover",
1898
- "border-hover",
1899
- "text",
1900
- "bg",
1901
- "icon",
1902
- "border",
1903
- "outline",
1904
- "caret",
1905
- "hl"
2027
+ //#region src/theme/types.ts
2028
+ /** The sized fingertips: `fingertip-xs` … `fingertip-xl`, each read from `--v-fingertip-<size>`. */
2029
+ const FINGERTIP_SIZES = [
2030
+ "xs",
2031
+ "s",
2032
+ "m",
2033
+ "l",
2034
+ "xl"
1906
2035
  ];
1907
- const slotAlt = CURRENT_SLOTS.join("|");
1908
- const sourceAlt = [
1909
- ...CURRENT_SLOTS,
1910
- "muted",
1911
- "hover"
1912
- ].map((s) => `-${s}`).join("|");
1913
- const currentSlotRe = new RegExp(`^current-(${slotAlt})-(.+)$`);
1914
- const currentPaintRe = new RegExp(`^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(${sourceAlt})?(\\/\\d{1,3})?$`);
1915
- function getScopeCssVars(c, theme) {
1916
- const col = theme.colors[c];
1917
- if (!col || !theme.colors[`${c}-500`]) return;
1918
- const vars = { "--scope-color": colorToRgbWithOpacity(col) };
1919
- for (const shade of SCOPE_SHADES) vars[`--scope-color-${shade}`] = colorToRgbWithOpacity(theme.colors[`${c}-${shade}`]) || "";
1920
- for (const layer of SCOPE_LAYERS) {
1921
- vars[`--scope-light-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-light-${layer}`]) || "";
1922
- vars[`--scope-dark-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-dark-${layer}`]) || "";
1923
- }
1924
- vars["--current-hl"] = colorToRgbWithOpacity(theme.colors[`${c}-500`]) || "";
1925
- const greyMuted = colorToRgbWithOpacity(theme.colors[`grey-500`]) || "";
1926
- vars["--current-text-muted"] = greyMuted;
1927
- vars["--current-icon-muted"] = greyMuted;
1928
- vars["--current-text-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-dark-0`]) || "";
1929
- vars["--current-bg-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-light-1`]) || "";
1930
- vars["--current-border-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-light-3`]) || "";
1931
- return vars;
2036
+ function k$1(n, base = 1) {
2037
+ return base * 1.618 ** n;
1932
2038
  }
1933
- const paletteRules = [
1934
- [currentSlotRe, (match, { theme }) => {
1935
- const t = match[1];
1936
- const c = match[2];
1937
- if (c.startsWith("scope-")) return { [`--current-${t}`]: `var(--${c})` };
1938
- if (c === "hl") return { [`--current-${t}`]: `var(--current-hl)` };
1939
- const themeCol = theme.colors[c];
1940
- const colStr = typeof themeCol === "string" ? themeCol : themeCol?.DEFAULT;
1941
- if (!colStr) return;
1942
- try {
1943
- return { [`--current-${t}`]: colorToRgbWithOpacity(colStr) };
1944
- } catch {
1945
- return;
1946
- }
1947
- }],
1948
- [currentPaintRe, (match, { theme: _theme }) => {
1949
- const target = match[1];
1950
- let source = match[2] || `-${target}`;
1951
- if (source === "-muted" || source === "-hover") source = `-${target}${source}`;
1952
- const opacityVar = getOpacityVar(target);
1953
- const cssVar = getCssTarget(target);
1954
- const o = match[3];
1955
- const opacity = o ? Number(o.slice(1)) / 100 : 1;
1956
- const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
1957
- if (target === "icon") {
1958
- const indirect = [
1959
- "-hl",
1960
- "-icon-muted",
1961
- "-icon-hover"
1962
- ].includes(source);
1963
- return {
1964
- [opacityVar]: opacity,
1965
- "--current-icon": indirect ? `var(--current${source})` : void 0
1966
- };
1967
- }
1968
- if (["shadow", "ring"].includes(target) && source === "-border") return {
1969
- [opacityVar]: opacity === 1 ? `var(--un-border-opacity)` : opacity,
1970
- [`--un-${target}-color`]: `rgb(var(--current-border) / ${opacityVal})`
1971
- };
1972
- return {
1973
- [opacityVar]: opacity,
1974
- [cssVar]: `rgb(var(--current${source}) / ${opacityVal})`
1975
- };
1976
- }],
1977
- [/^scope-(.*)$/, (match, { theme }) => getScopeCssVars(match[1], theme)],
1978
- [/^(bg|text|fill|stroke|border|outline|icon|caret)-scope-((?:color|dark|light|text|bg|white|black|icon)(?:-\d+)?)(\/\d{1,3})?$/, (match, { theme }) => {
1979
- const cssVar = getCssTarget(match[1]);
1980
- const opacityVar = getOpacityVar(match[1]);
1981
- const source = match[2];
1982
- const o = match[3];
1983
- const opacity = o ? Number(o.slice(1)) / 100 : 1;
1984
- const fallback = source.startsWith("color") ? `grey-${source.slice(6)}` : `grey-${source}`;
1985
- const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
1986
- return {
1987
- [opacityVar]: opacity,
1988
- [cssVar]: `rgb(var(--scope-${source}, ${theme.colors[fallback] || ""}) / ${opacityVal})`
1989
- };
1990
- }],
1991
- [/^icon-opacity-(\d{1,3})$/, (match, { theme: _theme }) => {
1992
- const o = match[1];
1993
- return { "--un-icon-opacity": Number(o) / 100 };
1994
- }],
1995
- [/^icon-color$/, () => ({ color: `rgb(var(--current-icon) / var(--un-icon-opacity, 1))` })],
1996
- [/^icon-size-(.*)$/, (match, { theme }) => {
1997
- const name = match[1];
1998
- if (name.startsWith("[") && name.endsWith("]")) return { "--icon-size": name.slice(1, -1) };
1999
- if (theme.spacing[name]) return { "--icon-size": theme.spacing[name] };
2000
- }],
2001
- [/^icon-size$/, () => ({
2002
- width: `var(--icon-size, 1em)`,
2003
- height: `var(--icon-size, 1em)`
2004
- })]
2005
- ];
2006
2039
  //#endregion
2007
2040
  //#region src/theme/utils/round.ts
2008
2041
  function round(v, decimals = 0) {
@@ -2016,18 +2049,25 @@ function unitBy(input, factor, roundTo = 3) {
2016
2049
  const units = /(px|em|rem|%)$/.exec(input)?.[1] || "";
2017
2050
  return `${round(v * factor, roundTo)}${units}`;
2018
2051
  }
2052
+ /**
2053
+ * Half of a size: a literal length is halved here (`3em` → `1.5em`); anything
2054
+ * else (`var(--v-fingertip-s)`, `max(3em, 44px)`) by the browser, with `calc()`.
2055
+ */
2056
+ function half(size) {
2057
+ return /^-?[\d.]+(?:px|em|rem|%)?$/.test(size) ? unitBy(size, .5) : `calc(${size} / 2)`;
2058
+ }
2019
2059
  //#endregion
2020
2060
  //#region src/theme/preflights.ts
2021
2061
  /**
2022
2062
  * `:root` theme variables always; page-level element styles only with `baseStyles`.
2023
2063
  * Off, `body` keeps the body level's `--font-*` variables for `text-mt-*` / `font-$bold`.
2024
2064
  */
2025
- function vunorPreflights(baseStyles, borderOpacity) {
2026
- return { getCSS: ({ theme }) => baseStyles ? renderBaseStyles(theme, borderOpacity) : renderRootVars(theme, borderOpacity) + renderFontVarsCss("body", theme.fontSize.body) };
2065
+ function vunorPreflights(opts) {
2066
+ return { getCSS: ({ theme }) => opts.baseStyles ? renderBaseStyles(theme, opts) : renderRootVars(theme, opts) + renderFontVarsCss("body", theme.fontSize.body) };
2027
2067
  }
2028
- function renderBaseStyles(theme, borderOpacity) {
2068
+ function renderBaseStyles(theme, opts) {
2029
2069
  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)}
2030
- ${renderRootVars(theme, borderOpacity)}
2070
+ ${renderRootVars(theme, opts)}
2031
2071
 
2032
2072
  ::-webkit-scrollbar {
2033
2073
  width: 10px;
@@ -2064,16 +2104,22 @@ ${renderRootVars(theme, borderOpacity)}
2064
2104
  }
2065
2105
  `;
2066
2106
  }
2067
- function renderRootVars(theme, borderOpacity) {
2107
+ function renderRootVars(theme, opts) {
2108
+ const fingertipM = opts.fingertip.m || "3em";
2109
+ const sizedFingertips = FINGERTIP_SIZES.map((size) => ` --v-fingertip-${size}: ${opts.fingertip[size]};\n`).join("");
2110
+ const borderRgb = colorToRgbWithOpacity(theme.colors["grey-500"]);
2068
2111
  return `:root {
2069
- --un-border-opacity: ${borderOpacity};
2070
- --un-default-border-color: rgb(150 150 150 / var(--un-border-opacity));
2112
+ --un-border-opacity: ${opts.borderOpacity};
2113
+ --un-default-border-color: rgb(${borderRgb} / var(--un-border-opacity));
2071
2114
  --scope-black: 0 0 0;
2072
2115
  --scope-white: 255 255 255;
2073
2116
  --scope-hl: var(--scope-color-500);
2074
- --v-fingertip: ${theme.spacing["fingertip-m"] || "3em"};
2075
- --v-fingertip-half: ${unitBy(theme.spacing["fingertip-m"] || "3em", .5)};
2117
+ ${sizedFingertips} --v-fingertip: ${fingertipM};
2118
+ --v-fingertip-half: ${half(fingertipM)};
2076
2119
  ${renderDefaultScope(theme)}}
2120
+ .dark {
2121
+ --current-hl-text: ${HL_TEXT.dark};
2122
+ }
2077
2123
  `;
2078
2124
  }
2079
2125
  function renderDefaultScope(theme) {
@@ -2137,92 +2183,130 @@ const i8Rules = [
2137
2183
  }]
2138
2184
  ];
2139
2185
  //#endregion
2140
- //#region src/theme/rules/index.ts
2141
- const rules = [
2142
- ...[
2143
- [
2144
- /^text-m([bty])?-(.*)$/,
2145
- (match, { theme }) => {
2146
- const dir = match[1];
2147
- const size = match[2];
2148
- const d = dir ? {
2149
- y: ["top", "bottom"],
2150
- t: ["top"],
2151
- b: ["bottom"]
2152
- }[dir] : [
2153
- "top",
2154
- "bottom",
2155
- "left",
2156
- "right"
2157
- ];
2158
- const result = {};
2159
- if (theme.spacing[size]) {
2160
- 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"}))`;
2161
- return result;
2162
- } else if (/^\d+(em|rem|px)?$/.test(size)) {
2163
- let s = size;
2164
- if (/^[\d.]+$/.test(size)) s = `${Number(size) * .25}rem`;
2165
- for (const prop of d) result[`margin-${prop}`] = ["left", "right"].includes(prop) ? s : `calc(${s} + var(--font-${prop === "top" ? "tc" : "bc"}))`;
2166
- return result;
2167
- }
2168
- },
2169
- { layer: "utilities" }
2170
- ],
2171
- [
2172
- /^card-dense$/,
2173
- (_match, { theme: _theme }) => ({ "--card-spacing": "var(--card-spacing-dense)" }),
2174
- { layer: "utilities" }
2175
- ],
2176
- [/^card-(.*)$/, (match, { theme }) => {
2177
- const name = match[1];
2178
- if (theme.fontSize[name]) {
2179
- const props = theme.fontSize[name][1];
2180
- return {
2181
- "--card-spacing": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.regular)}`,
2182
- "--card-spacing-dense": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.dense)}`,
2183
- "--card-heading-size": props["--font-size"],
2184
- "--card-heading-bold": props["--font-bold"],
2185
- "--card-heading-corrected": props["--font-corrected"],
2186
- "--card-heading-weight": props["font-weight"],
2187
- "--card-heading-lh": props["line-height"],
2188
- "--card-heading-ls": props["letter-spacing"],
2189
- "--card-heading-bc": props["--font-bc"],
2190
- "--card-heading-tc": props["--font-tc"],
2191
- "--card-heading-font": props["font-family"] || "inherit",
2192
- "padding": "var(--card-spacing)"
2193
- };
2186
+ //#region src/theme/rules/spacing.ts
2187
+ const spacingRules = [
2188
+ [
2189
+ /^text-m([bty])?-(.*)$/,
2190
+ (match, { theme }) => {
2191
+ const dir = match[1];
2192
+ const size = match[2];
2193
+ const d = dir ? {
2194
+ y: ["top", "bottom"],
2195
+ t: ["top"],
2196
+ b: ["bottom"]
2197
+ }[dir] : [
2198
+ "top",
2199
+ "bottom",
2200
+ "left",
2201
+ "right"
2202
+ ];
2203
+ const result = {};
2204
+ if (theme.spacing[size]) {
2205
+ 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"}))`;
2206
+ return result;
2207
+ } else if (/^\d+(em|rem|px)?$/.test(size)) {
2208
+ let s = size;
2209
+ if (/^[\d.]+$/.test(size)) s = `${Number(size) * .25}rem`;
2210
+ for (const prop of d) result[`margin-${prop}`] = ["left", "right"].includes(prop) ? s : `calc(${s} + var(--font-${prop === "top" ? "tc" : "bc"}))`;
2211
+ return result;
2194
2212
  }
2195
- }],
2196
- [/^fingertip-(.*)/, (match, { theme }) => {
2197
- const name = match[1];
2198
- if (name.startsWith("[") && name.endsWith("]")) return {
2199
- "--v-fingertip": name.slice(1, -1),
2200
- "--v-fingertip-half": unitBy(name.slice(1, -1), .5)
2201
- };
2202
- if ([
2203
- "xs",
2204
- "s",
2205
- "m",
2206
- "l",
2207
- "xl"
2208
- ].includes(name)) return {
2209
- "--v-fingertip": theme.spacing[`fingertip-${name}`],
2210
- "--v-fingertip-half": unitBy(theme.spacing[`fingertip-${name}`], .5)
2211
- };
2212
- if (theme.spacing[name]) return {
2213
- "--v-fingertip": theme.spacing[name],
2214
- "--v-fingertip-half": unitBy(theme.spacing[name], .5)
2215
- };
2216
- }]
2213
+ },
2214
+ { layer: "utilities" }
2217
2215
  ],
2218
- ...paletteRules,
2219
- ...i8Rules
2216
+ [
2217
+ /^card-dense$/,
2218
+ (_match, { theme: _theme }) => ({ "--card-spacing": "var(--card-spacing-dense)" }),
2219
+ { layer: "utilities" }
2220
+ ],
2221
+ [/^card-(.*)$/, (match, { theme }) => {
2222
+ const name = match[1];
2223
+ if (theme.fontSize[name]) {
2224
+ const props = theme.fontSize[name][1];
2225
+ return {
2226
+ "--card-spacing": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.regular)}`,
2227
+ "--card-spacing-dense": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.dense)}`,
2228
+ "--card-heading-size": props["--font-size"],
2229
+ "--card-heading-bold": props["--font-bold"],
2230
+ "--card-heading-corrected": props["--font-corrected"],
2231
+ "--card-heading-weight": props["font-weight"],
2232
+ "--card-heading-lh": props["line-height"],
2233
+ "--card-heading-ls": props["letter-spacing"],
2234
+ "--card-heading-bc": props["--font-bc"],
2235
+ "--card-heading-tc": props["--font-tc"],
2236
+ "--card-heading-font": props["font-family"] || "inherit",
2237
+ "padding": "var(--card-spacing)"
2238
+ };
2239
+ }
2240
+ }],
2241
+ [/^fingertip-(.*)/, (match, { theme }) => {
2242
+ const name = match[1];
2243
+ const size = name.startsWith("[") && name.endsWith("]") ? name.slice(1, -1) : FINGERTIP_SIZES.includes(name) ? theme.spacing[`fingertip-${name}`] : theme.spacing[name];
2244
+ return size ? {
2245
+ "--v-fingertip": size,
2246
+ "--v-fingertip-half": half(size)
2247
+ } : void 0;
2248
+ }]
2220
2249
  ];
2221
2250
  //#endregion
2222
- //#region src/theme/types.ts
2223
- function k$1(n, base = 1) {
2224
- return base * 1.618 ** n;
2251
+ //#region src/theme/rules/variables.ts
2252
+ /**
2253
+ * `css` for dark mode: under a `.dark` ancestor and on a `.dark` element, for the
2254
+ * accent text (`--current-hl-text`). A selector suffix rather than a `dark:`
2255
+ * variant, so `text-current-hl` keeps working under parent variants
2256
+ * (`group-hover:`, where a nested `dark:` would land inside the group). Variants
2257
+ * on the class itself (`hover:`, `md:`, `dark:`) compose with the suffix; a
2258
+ * `dark:scope-*` or `dark:current-hl-*` override gets the suffix too, so it still
2259
+ * outweighs the light-mode class's dark part.
2260
+ */
2261
+ const inDark = (css) => [":is(.dark *)", ".dark"].map((suffix) => ({
2262
+ [symbols.selector]: (selector) => selector + suffix,
2263
+ ...css
2264
+ }));
2265
+ /** `--current-{slot}`; an accent (`hl`) is the accent text colour too. */
2266
+ const slotCss = (slot, value) => slot === "hl" ? {
2267
+ "--current-hl": value,
2268
+ "--current-hl-text": value
2269
+ } : { [`--current-${slot}`]: value };
2270
+ /**
2271
+ * A `current-{slot}-{source}` colour: `scope-*` and `hl` by reference, a theme
2272
+ * colour as `r g b`. `layer-light-N` / `layer-dark-N` is one mode's background of
2273
+ * `layer-N`, in the `layers.reverse*` orientation: a single leaf, so `c8-chrome`
2274
+ * pairs it with `dark:` and nests no deeper than with fixed `scope-*-N` steps.
2275
+ */
2276
+ function slotValue(source, theme) {
2277
+ if (source.startsWith("scope-")) return `var(--${source})`;
2278
+ const layer = /^layer-(light|dark)-([0-4])$/.exec(source);
2279
+ if (layer) {
2280
+ const reverse = layer[1] === "light" ? theme.reverseLightLayers : theme.reverseDarkLayers;
2281
+ return `var(--scope-${layer[1]}-${layerN(Number(layer[2]), reverse)})`;
2282
+ }
2283
+ if (source === "hl") return `var(--current-hl)`;
2284
+ const themeCol = theme.colors[source];
2285
+ const colStr = typeof themeCol === "string" ? themeCol : themeCol?.DEFAULT;
2286
+ if (!colStr) return;
2287
+ try {
2288
+ return colorToRgbWithOpacity(colStr);
2289
+ } catch {
2290
+ return;
2291
+ }
2225
2292
  }
2293
+ const variableRules = [[currentSlotRe, (match, { theme }) => {
2294
+ const slot = match[1];
2295
+ const value = slotValue(match[2], theme);
2296
+ if (!value) return;
2297
+ return slot === "hl" ? [slotCss(slot, value), ...inDark({ "--current-hl-text": value })] : slotCss(slot, value);
2298
+ }], [/^scope-(.*)$/, (match, { theme }) => {
2299
+ const vars = getScopeCssVars(match[1], theme);
2300
+ return vars && [vars, ...inDark({ "--current-hl-text": HL_TEXT.dark })];
2301
+ }]];
2302
+ //#endregion
2303
+ //#region src/theme/rules/index.ts
2304
+ const rules = [
2305
+ ...spacingRules,
2306
+ ...variableRules,
2307
+ ...paletteRules,
2308
+ ...i8Rules
2309
+ ];
2226
2310
  //#endregion
2227
2311
  //#region src/theme/typography.ts
2228
2312
  function font(weight, boldWeight, size, height, spacing) {
@@ -2336,6 +2420,7 @@ function computeRadiusScale(baseRadius) {
2336
2420
  //#endregion
2337
2421
  //#region src/theme/theme.ts
2338
2422
  const themeFactory = (opts) => {
2423
+ const fingertipSizes = Object.fromEntries(FINGERTIP_SIZES.map((size) => [`fingertip-${size}`, `var(--v-fingertip-${size})`]));
2339
2424
  /**
2340
2425
  * Spacing
2341
2426
  */
@@ -2349,11 +2434,7 @@ const themeFactory = (opts) => {
2349
2434
  "$xxl": `${round(opts.spacingFactor ** 3, 3)}em`,
2350
2435
  "fingertip": "var(--v-fingertip)",
2351
2436
  "fingertip-half": "var(--v-fingertip-half)",
2352
- "fingertip-xs": opts.fingertip.xs,
2353
- "fingertip-s": opts.fingertip.s,
2354
- "fingertip-m": opts.fingertip.m,
2355
- "fingertip-l": opts.fingertip.l,
2356
- "fingertip-xl": opts.fingertip.xl,
2437
+ ...fingertipSizes,
2357
2438
  "$font-tc": "var(--font-bc)",
2358
2439
  "$font-bc": "var(--font-tc)",
2359
2440
  "$font-size": "var(--font-size)",
@@ -2367,11 +2448,7 @@ const themeFactory = (opts) => {
2367
2448
  const lineHeight = {
2368
2449
  "fingertip": "var(--v-fingertip)",
2369
2450
  "fingertip-half": "var(--v-fingertip-half)",
2370
- "fingertip-xs": opts.fingertip.xs,
2371
- "fingertip-s": opts.fingertip.s,
2372
- "fingertip-m": opts.fingertip.m,
2373
- "fingertip-l": opts.fingertip.l,
2374
- "fingertip-xl": opts.fingertip.xl
2451
+ ...fingertipSizes
2375
2452
  };
2376
2453
  const borderRadius = {
2377
2454
  ...spacing,
@@ -2537,11 +2614,15 @@ const disabledSoftLiteral = {
2537
2614
  order: -1e3,
2538
2615
  match: (matcher, { generator }) => matcher === DISABLED_SOFT && generator.config.shortcuts.some((sc) => sc[0] === DISABLED_SOFT) ? { matcher: DISABLED_SOFT_LITERAL } : void 0
2539
2616
  };
2617
+ const REPEATED_IMPORTANT = /!important(?:\s*!important)+\s*$/i;
2618
+ const singleImportant = (util) => {
2619
+ for (const entry of util.entries) if (typeof entry[1] === "string" && entry[1].includes("!")) entry[1] = entry[1].replace(REPEATED_IMPORTANT, "!important");
2620
+ };
2540
2621
  const presetVunor = (_opts) => {
2541
2622
  const opts = defu(_opts, defaultOptions);
2542
2623
  const wind = getFixedWind();
2543
2624
  if (!wind.preflights) wind.preflights = [];
2544
- wind.preflights.push(vunorPreflights(opts.baseStyles, opts.borderOpacity));
2625
+ wind.preflights.push(vunorPreflights(opts));
2545
2626
  if (!wind.rules) wind.rules = [];
2546
2627
  wind.rules.push(...rules);
2547
2628
  const paletteShortcuts = getPaletteShortcuts();
@@ -2556,6 +2637,7 @@ const presetVunor = (_opts) => {
2556
2637
  name: "vunor",
2557
2638
  theme: defu(theme.theme, wind.theme),
2558
2639
  variants: [disabledSoftLiteral, ...wind.variants ?? []],
2640
+ postprocess: [...toArray(wind.postprocess), singleImportant],
2559
2641
  shortcuts: [...paletteShortcuts, [DISABLED_SOFT_LITERAL, DISABLED_SOFT]],
2560
2642
  extractors: [createVunorExtractor()],
2561
2643
  layers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vunor",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "CHANGELOG.md"