vunor 0.4.6 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Changed (visual)
6
+
7
+ - **Popups sit one layer above the panels.** `popup-card` (and with it `<VuSelect>`'s dropdown, `select-content`) paints `layer-1` instead of `surface-0`, and so does `<VuDatePicker>`'s popup (`date-picker-root`, `layer-0` before). `surface-0` has the `layer-0` background, which is what an app normally gives its panels (cards, side sheets), so a menu over a panel had exactly the panel's colour. The popup's text is `layer-1`'s (`scope-dark-0` on light, `scope-light-0` in dark mode, one step stronger than before) and its border is `grey-400` at 20% in both modes (dark mode drew `scope-color-800` at 20%, which hardly showed). With `layers.reverseDark` / `reverseLight` it follows the orientation, as `layer-1` does.
8
+ - **`shadow-popup` can be seen in dark mode.** Dark mode draws `0 2px 8px rgba(0,0,0,0.5), 0 12px 36px rgba(0,0,0,0.7)`; the light shadow (black at 10–15%) was invisible on a dark layer. Everything that uses it gets the dark shadow: `popup-card`, `dialog-card` and `date-picker-root`. Light mode is unchanged.
9
+
10
+ To get the 0.5.0 look back, replace the three shortcuts:
11
+
12
+ ```ts
13
+ vunorShortcuts(
14
+ defineShortcuts({
15
+ 'popup-card': replaceShortcut(
16
+ 'surface-0 bg-current rounded-r2 overflow-hidden shadow-popup z-[100] border current-border-grey-400 border-current/20'
17
+ ),
18
+ 'date-picker-root': replaceShortcut('inline-block layer-0 shadow-popup animate-easy-zoom-in'),
19
+ 'shadow-popup': replaceShortcut(
20
+ 'shadow-[0_0_10px_rgba(0,0,0,0.1),0_4px_20px_rgba(0,0,0,0.15)]'
21
+ ),
22
+ })
23
+ )
24
+ ```
25
+
26
+ ## 0.5.0
27
+
28
+ 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.
29
+
30
+ ### Changed (visual)
31
+
32
+ - **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.
33
+ - **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 } } } })`.
34
+ - **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).
35
+
36
+ ### Changed (visual, only with `layers.reverseDark` or `layers.reverseLight`)
37
+
38
+ - `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.
39
+
40
+ ### Added
41
+
42
+ - 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)`.
43
+
44
+ - `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.
45
+ - `--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).
46
+
47
+ ### Changed
48
+
49
+ - 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.
50
+
51
+ ### Fixed
52
+
53
+ - 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:
54
+ - `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]`).
55
+ - `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' }))`.
56
+ - `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).
57
+ - 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`).
58
+ - `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`.
59
+
3
60
  ## 0.4.6
4
61
 
5
62
  ### Fixed
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, toArray } 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
  }
@@ -73,7 +73,7 @@ const calendarShortcuts = defineShortcuts({
73
73
  },
74
74
  "data-[selected]:": "c8-filled!"
75
75
  },
76
- "date-picker-root": "inline-block layer-0 shadow-popup animate-easy-zoom-in",
76
+ "date-picker-root": "inline-block layer-1 shadow-popup animate-easy-zoom-in",
77
77
  "date-picker-literal": "opacity-75 cursor-text",
78
78
  "date-picker-input": {
79
79
  "": "cursor-text rounded-r1 p-0.5 text-current",
@@ -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",
@@ -376,8 +376,11 @@ const c8 = defineShortcuts({
376
376
  //#endregion
377
377
  //#region src/theme/shortcuts/extras.ts
378
378
  const popupCard = defineShortcuts({
379
- "shadow-popup": "shadow-[0_0_10px_rgba(0,0,0,0.1),0_4px_20px_rgba(0,0,0,0.15)]",
380
- "popup-card": { "": "surface-0 bg-current rounded-r2 overflow-hidden shadow-popup z-[100] border current-border-grey-400 border-current/20" }
379
+ "shadow-popup": {
380
+ "": "shadow-[0_0_10px_rgba(0,0,0,0.1),0_4px_20px_rgba(0,0,0,0.15)]",
381
+ "dark:": "shadow-[0_2px_8px_rgba(0,0,0,0.5),0_12px_36px_rgba(0,0,0,0.7)]"
382
+ },
383
+ "popup-card": { "": "layer-1 rounded-r2 overflow-hidden shadow-popup z-[100] border current-border-grey-400 border-current/20" }
381
384
  });
382
385
  const disabledSoft = defineShortcuts({ "disabled-soft": { [whenDisabled]: "opacity-40 cursor-not-allowed" } });
383
386
  const press = defineShortcuts({ press: {
@@ -396,7 +399,7 @@ const roundSignal = pad(FINGERTIP_HALF);
396
399
  const rawVunorShortcuts = [
397
400
  defineShortcuts({
398
401
  "i8": {
399
- "": "h-fingertip min-w-3em flex items-center select-none relative icon-current content-box disabled-soft",
402
+ "": "h-fingertip min-w-3em flex items-center select-none relative icon-current disabled-soft",
400
403
  "data-[type=textarea]:": "min-h-fingertip h-auto items-start",
401
404
  "data-[active=true]:": "icon-current-hl",
402
405
  "focus-within:": "icon-current-hl",
@@ -1517,6 +1520,171 @@ function getComponentClasses(...components) {
1517
1520
  return [...set];
1518
1521
  }
1519
1522
  //#endregion
1523
+ //#region src/theme/rules/palette.ts
1524
+ function colorToRgbWithOpacity(c) {
1525
+ const [r, g, b, _a] = color(c).rgba();
1526
+ return `${r} ${g} ${b}`;
1527
+ }
1528
+ /**
1529
+ * What `text-current-hl` paints (`--current-hl-text`) per mode: accent text needs
1530
+ * WCAG AA (4.5:1) on the layers, which 500 misses, so it takes the scope's 700 on
1531
+ * light and its 300 on dark, as the c8 text colours do. Borders, rings and icons
1532
+ * stay on `--current-hl` (500): they need 3:1.
1533
+ */
1534
+ const HL_TEXT = {
1535
+ light: "var(--scope-color-700)",
1536
+ dark: "var(--scope-color-300)"
1537
+ };
1538
+ /** Layer step N in the orientation `layers.reverseLight` / `reverseDark` sets. */
1539
+ const layerN = (n, reverse) => reverse ? 4 - n : n;
1540
+ function getOpacityVar(key) {
1541
+ return {
1542
+ bg: "--un-bg-opacity",
1543
+ text: "--un-text-opacity",
1544
+ fill: "--un-text-opacity",
1545
+ stroke: "--un-text-opacity",
1546
+ icon: "--un-icon-opacity",
1547
+ border: "--un-border-opacity",
1548
+ outline: "--un-outline-opacity",
1549
+ caret: "--un-caret-opacity",
1550
+ shadow: "--un-shadow-opacity",
1551
+ ring: "--un-ring-opacity"
1552
+ }[key];
1553
+ }
1554
+ function getCssTarget(key) {
1555
+ return {
1556
+ bg: "background-color",
1557
+ text: "color",
1558
+ fill: "fill",
1559
+ stroke: "stroke",
1560
+ icon: "color",
1561
+ border: "border-color",
1562
+ outline: "outline-color",
1563
+ caret: "caret-color",
1564
+ shadow: "--un-shadow-color",
1565
+ ring: "--un-ring-color"
1566
+ }[key];
1567
+ }
1568
+ const SCOPE_SHADES = [
1569
+ "50",
1570
+ "100",
1571
+ "200",
1572
+ "300",
1573
+ "400",
1574
+ "500",
1575
+ "600",
1576
+ "700",
1577
+ "800",
1578
+ "900"
1579
+ ];
1580
+ const SCOPE_LAYERS = [
1581
+ "0",
1582
+ "1",
1583
+ "2",
1584
+ "3",
1585
+ "4"
1586
+ ];
1587
+ const CURRENT_SLOTS = [
1588
+ "text-muted",
1589
+ "icon-muted",
1590
+ "text-hover",
1591
+ "bg-hover",
1592
+ "border-hover",
1593
+ "text",
1594
+ "bg",
1595
+ "icon",
1596
+ "border",
1597
+ "outline",
1598
+ "caret",
1599
+ "hl"
1600
+ ];
1601
+ const slotAlt = CURRENT_SLOTS.join("|");
1602
+ const sourceAlt = [
1603
+ ...CURRENT_SLOTS,
1604
+ "muted",
1605
+ "hover"
1606
+ ].map((s) => `-${s}`).join("|");
1607
+ const currentSlotRe = new RegExp(`^current-(${slotAlt})-(.+)$`);
1608
+ const currentPaintRe = new RegExp(`^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(${sourceAlt})?(\\/\\d{1,3})?$`);
1609
+ function getScopeCssVars(c, theme) {
1610
+ const col = theme.colors[c];
1611
+ if (!col || !theme.colors[`${c}-500`]) return;
1612
+ const vars = { "--scope-color": colorToRgbWithOpacity(col) };
1613
+ for (const shade of SCOPE_SHADES) vars[`--scope-color-${shade}`] = colorToRgbWithOpacity(theme.colors[`${c}-${shade}`]) || "";
1614
+ for (const layer of SCOPE_LAYERS) {
1615
+ vars[`--scope-light-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-light-${layer}`]) || "";
1616
+ vars[`--scope-dark-${layer}`] = colorToRgbWithOpacity(theme.colors[`${c}-dark-${layer}`]) || "";
1617
+ }
1618
+ vars["--current-hl"] = colorToRgbWithOpacity(theme.colors[`${c}-500`]) || "";
1619
+ vars["--current-hl-text"] = HL_TEXT.light;
1620
+ const greyMuted = colorToRgbWithOpacity(theme.colors[`grey-500`]) || "";
1621
+ vars["--current-text-muted"] = greyMuted;
1622
+ vars["--current-icon-muted"] = greyMuted;
1623
+ vars["--current-text-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-dark-0`]) || "";
1624
+ vars["--current-bg-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-light-1`]) || "";
1625
+ vars["--current-border-hover"] = colorToRgbWithOpacity(theme.colors[`${c}-light-3`]) || "";
1626
+ return vars;
1627
+ }
1628
+ const paletteRules = [
1629
+ [currentPaintRe, (match, { theme: _theme }) => {
1630
+ const target = match[1];
1631
+ let source = match[2] || `-${target}`;
1632
+ if (source === "-muted" || source === "-hover") source = `-${target}${source}`;
1633
+ if (target === "text" && source === "-hl") source = "-hl-text";
1634
+ const opacityVar = getOpacityVar(target);
1635
+ const cssVar = getCssTarget(target);
1636
+ const o = match[3];
1637
+ const opacity = o ? Number(o.slice(1)) / 100 : 1;
1638
+ const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
1639
+ if (target === "icon") {
1640
+ const indirect = [
1641
+ "-hl",
1642
+ "-icon-muted",
1643
+ "-icon-hover"
1644
+ ].includes(source);
1645
+ return {
1646
+ [opacityVar]: opacity,
1647
+ "--current-icon": indirect ? `var(--current${source})` : void 0
1648
+ };
1649
+ }
1650
+ if (["shadow", "ring"].includes(target) && source === "-border") return {
1651
+ [opacityVar]: opacity === 1 ? `var(--un-border-opacity)` : opacity,
1652
+ [`--un-${target}-color`]: `rgb(var(--current-border) / ${opacityVal})`
1653
+ };
1654
+ return {
1655
+ [opacityVar]: opacity,
1656
+ [cssVar]: `rgb(var(--current${source}) / ${opacityVal})`
1657
+ };
1658
+ }],
1659
+ [/^(bg|text|fill|stroke|border|outline|icon|caret)-scope-((?:color|dark|light|text|bg|white|black|icon)(?:-\d+)?)(\/\d{1,3})?$/, (match, { theme }) => {
1660
+ const cssVar = getCssTarget(match[1]);
1661
+ const opacityVar = getOpacityVar(match[1]);
1662
+ const source = match[2];
1663
+ const o = match[3];
1664
+ const opacity = o ? Number(o.slice(1)) / 100 : 1;
1665
+ const fallback = source.startsWith("color") ? `grey-${source.slice(6)}` : `grey-${source}`;
1666
+ const opacityVal = opacity === 1 ? `var(${opacityVar})` : opacity;
1667
+ return {
1668
+ [opacityVar]: opacity,
1669
+ [cssVar]: `rgb(var(--scope-${source}, ${theme.colors[fallback] || ""}) / ${opacityVal})`
1670
+ };
1671
+ }],
1672
+ [/^icon-opacity-(\d{1,3})$/, (match, { theme: _theme }) => {
1673
+ const o = match[1];
1674
+ return { "--un-icon-opacity": Number(o) / 100 };
1675
+ }],
1676
+ [/^icon-color$/, () => ({ color: `rgb(var(--current-icon) / var(--un-icon-opacity, 1))` })],
1677
+ [/^icon-size-(.*)$/, (match, { theme }) => {
1678
+ const name = match[1];
1679
+ if (name.startsWith("[") && name.endsWith("]")) return { "--icon-size": name.slice(1, -1) };
1680
+ if (theme.spacing[name]) return { "--icon-size": theme.spacing[name] };
1681
+ }],
1682
+ [/^icon-size$/, () => ({
1683
+ width: `var(--icon-size, 1em)`,
1684
+ height: `var(--icon-size, 1em)`
1685
+ })]
1686
+ ];
1687
+ //#endregion
1520
1688
  //#region src/theme/palitra.ts
1521
1689
  const defaultOpts = {
1522
1690
  colors: {
@@ -1587,8 +1755,8 @@ const defaultOpts = {
1587
1755
  layerPalette: {
1588
1756
  desaturate: .2,
1589
1757
  saturate: {
1590
- dark: -.2,
1591
- light: -.2
1758
+ dark: 0,
1759
+ light: 0
1592
1760
  },
1593
1761
  vivid: {
1594
1762
  dark: 0,
@@ -1804,7 +1972,22 @@ function multiplySaturation(colors, m = .5) {
1804
1972
  }
1805
1973
  return newObj;
1806
1974
  }
1807
- const layerN = (n, reverse) => reverse ? 4 - n : n;
1975
+ /** What `{target}-layer-N` paints from layer step N: each `current-*` slot, plus direct paints. */
1976
+ const LAYER_TARGETS = [
1977
+ ...CURRENT_SLOTS.map((slot) => `current-${slot}`),
1978
+ "bg",
1979
+ "text",
1980
+ "border",
1981
+ "outline",
1982
+ "i8-bg",
1983
+ "i8-border",
1984
+ "i8-outline"
1985
+ ];
1986
+ const layerTargetRe = new RegExp(`^(${LAYER_TARGETS.join("|")})-layer-([0-4])$`);
1987
+ const orientBg = (token, side, reverse) => {
1988
+ const m = /^scope-(light|dark)-([0-4])$/.exec(token);
1989
+ return m?.[1] === side ? `scope-${side}-${layerN(Number(m[2]), reverse)}` : token;
1990
+ };
1808
1991
  const sideTemplate = (bg, n) => {
1809
1992
  const fg = bg === "light" ? "dark" : "light";
1810
1993
  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 +2004,7 @@ function getPaletteShortcuts() {
1821
2004
  "[&.dark]:": dark
1822
2005
  });
1823
2006
  }],
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 }) => {
2007
+ [layerTargetRe, ([, target, a], { theme }) => {
1825
2008
  const d = layerN(Number(a), theme.reverseDarkLayers);
1826
2009
  return toUnoShortcut({
1827
2010
  "": `${target}-scope-light-${layerN(Number(a), theme.reverseLightLayers)}`,
@@ -1829,180 +2012,33 @@ function getPaletteShortcuts() {
1829
2012
  "[&.dark]:": `${target}-scope-dark-${d}`
1830
2013
  });
1831
2014
  }],
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
- }) : ""],
2015
+ [/^surface-(.+)$/, ([, s], { theme }) => {
2016
+ if (!theme.surfaces[s]) return "";
2017
+ const [bg, text, border, darkBg, darkText, darkBorder] = theme.surfaces[s];
2018
+ const lightBg = orientBg(bg, "light", theme.reverseLightLayers);
2019
+ const dark = `current-bg-${orientBg(darkBg, "dark", theme.reverseDarkLayers)} current-text-${darkText} current-icon-${darkText} current-border-${darkBorder} shadow-black/30`;
2020
+ return toUnoShortcut({
2021
+ "": `current-bg-${lightBg} current-text-${text} current-icon-${text} current-border-${border} bg-current text-current border-current icon-current`,
2022
+ "dark:": dark,
2023
+ "[&.dark]:": dark
2024
+ });
2025
+ }],
1837
2026
  { surface: "surface-100" }
1838
2027
  ];
1839
2028
  }
1840
2029
  //#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"
2030
+ //#region src/theme/types.ts
2031
+ /** The sized fingertips: `fingertip-xs` … `fingertip-xl`, each read from `--v-fingertip-<size>`. */
2032
+ const FINGERTIP_SIZES = [
2033
+ "xs",
2034
+ "s",
2035
+ "m",
2036
+ "l",
2037
+ "xl"
1906
2038
  ];
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;
2039
+ function k$1(n, base = 1) {
2040
+ return base * 1.618 ** n;
1932
2041
  }
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
2042
  //#endregion
2007
2043
  //#region src/theme/utils/round.ts
2008
2044
  function round(v, decimals = 0) {
@@ -2016,18 +2052,25 @@ function unitBy(input, factor, roundTo = 3) {
2016
2052
  const units = /(px|em|rem|%)$/.exec(input)?.[1] || "";
2017
2053
  return `${round(v * factor, roundTo)}${units}`;
2018
2054
  }
2055
+ /**
2056
+ * Half of a size: a literal length is halved here (`3em` → `1.5em`); anything
2057
+ * else (`var(--v-fingertip-s)`, `max(3em, 44px)`) by the browser, with `calc()`.
2058
+ */
2059
+ function half(size) {
2060
+ return /^-?[\d.]+(?:px|em|rem|%)?$/.test(size) ? unitBy(size, .5) : `calc(${size} / 2)`;
2061
+ }
2019
2062
  //#endregion
2020
2063
  //#region src/theme/preflights.ts
2021
2064
  /**
2022
2065
  * `:root` theme variables always; page-level element styles only with `baseStyles`.
2023
2066
  * Off, `body` keeps the body level's `--font-*` variables for `text-mt-*` / `font-$bold`.
2024
2067
  */
2025
- function vunorPreflights(baseStyles, borderOpacity) {
2026
- return { getCSS: ({ theme }) => baseStyles ? renderBaseStyles(theme, borderOpacity) : renderRootVars(theme, borderOpacity) + renderFontVarsCss("body", theme.fontSize.body) };
2068
+ function vunorPreflights(opts) {
2069
+ return { getCSS: ({ theme }) => opts.baseStyles ? renderBaseStyles(theme, opts) : renderRootVars(theme, opts) + renderFontVarsCss("body", theme.fontSize.body) };
2027
2070
  }
2028
- function renderBaseStyles(theme, borderOpacity) {
2071
+ function renderBaseStyles(theme, opts) {
2029
2072
  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)}
2073
+ ${renderRootVars(theme, opts)}
2031
2074
 
2032
2075
  ::-webkit-scrollbar {
2033
2076
  width: 10px;
@@ -2064,16 +2107,22 @@ ${renderRootVars(theme, borderOpacity)}
2064
2107
  }
2065
2108
  `;
2066
2109
  }
2067
- function renderRootVars(theme, borderOpacity) {
2110
+ function renderRootVars(theme, opts) {
2111
+ const fingertipM = opts.fingertip.m || "3em";
2112
+ const sizedFingertips = FINGERTIP_SIZES.map((size) => ` --v-fingertip-${size}: ${opts.fingertip[size]};\n`).join("");
2113
+ const borderRgb = colorToRgbWithOpacity(theme.colors["grey-500"]);
2068
2114
  return `:root {
2069
- --un-border-opacity: ${borderOpacity};
2070
- --un-default-border-color: rgb(150 150 150 / var(--un-border-opacity));
2115
+ --un-border-opacity: ${opts.borderOpacity};
2116
+ --un-default-border-color: rgb(${borderRgb} / var(--un-border-opacity));
2071
2117
  --scope-black: 0 0 0;
2072
2118
  --scope-white: 255 255 255;
2073
2119
  --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)};
2120
+ ${sizedFingertips} --v-fingertip: ${fingertipM};
2121
+ --v-fingertip-half: ${half(fingertipM)};
2076
2122
  ${renderDefaultScope(theme)}}
2123
+ .dark {
2124
+ --current-hl-text: ${HL_TEXT.dark};
2125
+ }
2077
2126
  `;
2078
2127
  }
2079
2128
  function renderDefaultScope(theme) {
@@ -2137,92 +2186,130 @@ const i8Rules = [
2137
2186
  }]
2138
2187
  ];
2139
2188
  //#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
- };
2189
+ //#region src/theme/rules/spacing.ts
2190
+ const spacingRules = [
2191
+ [
2192
+ /^text-m([bty])?-(.*)$/,
2193
+ (match, { theme }) => {
2194
+ const dir = match[1];
2195
+ const size = match[2];
2196
+ const d = dir ? {
2197
+ y: ["top", "bottom"],
2198
+ t: ["top"],
2199
+ b: ["bottom"]
2200
+ }[dir] : [
2201
+ "top",
2202
+ "bottom",
2203
+ "left",
2204
+ "right"
2205
+ ];
2206
+ const result = {};
2207
+ if (theme.spacing[size]) {
2208
+ 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"}))`;
2209
+ return result;
2210
+ } else if (/^\d+(em|rem|px)?$/.test(size)) {
2211
+ let s = size;
2212
+ if (/^[\d.]+$/.test(size)) s = `${Number(size) * .25}rem`;
2213
+ for (const prop of d) result[`margin-${prop}`] = ["left", "right"].includes(prop) ? s : `calc(${s} + var(--font-${prop === "top" ? "tc" : "bc"}))`;
2214
+ return result;
2194
2215
  }
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
- }]
2216
+ },
2217
+ { layer: "utilities" }
2217
2218
  ],
2218
- ...paletteRules,
2219
- ...i8Rules
2219
+ [
2220
+ /^card-dense$/,
2221
+ (_match, { theme: _theme }) => ({ "--card-spacing": "var(--card-spacing-dense)" }),
2222
+ { layer: "utilities" }
2223
+ ],
2224
+ [/^card-(.*)$/, (match, { theme }) => {
2225
+ const name = match[1];
2226
+ if (theme.fontSize[name]) {
2227
+ const props = theme.fontSize[name][1];
2228
+ return {
2229
+ "--card-spacing": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.regular)}`,
2230
+ "--card-spacing-dense": `${unitBy(props["--font-corrected"], theme.cardSpacingFactor.dense)}`,
2231
+ "--card-heading-size": props["--font-size"],
2232
+ "--card-heading-bold": props["--font-bold"],
2233
+ "--card-heading-corrected": props["--font-corrected"],
2234
+ "--card-heading-weight": props["font-weight"],
2235
+ "--card-heading-lh": props["line-height"],
2236
+ "--card-heading-ls": props["letter-spacing"],
2237
+ "--card-heading-bc": props["--font-bc"],
2238
+ "--card-heading-tc": props["--font-tc"],
2239
+ "--card-heading-font": props["font-family"] || "inherit",
2240
+ "padding": "var(--card-spacing)"
2241
+ };
2242
+ }
2243
+ }],
2244
+ [/^fingertip-(.*)/, (match, { theme }) => {
2245
+ const name = match[1];
2246
+ const size = name.startsWith("[") && name.endsWith("]") ? name.slice(1, -1) : FINGERTIP_SIZES.includes(name) ? theme.spacing[`fingertip-${name}`] : theme.spacing[name];
2247
+ return size ? {
2248
+ "--v-fingertip": size,
2249
+ "--v-fingertip-half": half(size)
2250
+ } : void 0;
2251
+ }]
2220
2252
  ];
2221
2253
  //#endregion
2222
- //#region src/theme/types.ts
2223
- function k$1(n, base = 1) {
2224
- return base * 1.618 ** n;
2254
+ //#region src/theme/rules/variables.ts
2255
+ /**
2256
+ * `css` for dark mode: under a `.dark` ancestor and on a `.dark` element, for the
2257
+ * accent text (`--current-hl-text`). A selector suffix rather than a `dark:`
2258
+ * variant, so `text-current-hl` keeps working under parent variants
2259
+ * (`group-hover:`, where a nested `dark:` would land inside the group). Variants
2260
+ * on the class itself (`hover:`, `md:`, `dark:`) compose with the suffix; a
2261
+ * `dark:scope-*` or `dark:current-hl-*` override gets the suffix too, so it still
2262
+ * outweighs the light-mode class's dark part.
2263
+ */
2264
+ const inDark = (css) => [":is(.dark *)", ".dark"].map((suffix) => ({
2265
+ [symbols.selector]: (selector) => selector + suffix,
2266
+ ...css
2267
+ }));
2268
+ /** `--current-{slot}`; an accent (`hl`) is the accent text colour too. */
2269
+ const slotCss = (slot, value) => slot === "hl" ? {
2270
+ "--current-hl": value,
2271
+ "--current-hl-text": value
2272
+ } : { [`--current-${slot}`]: value };
2273
+ /**
2274
+ * A `current-{slot}-{source}` colour: `scope-*` and `hl` by reference, a theme
2275
+ * colour as `r g b`. `layer-light-N` / `layer-dark-N` is one mode's background of
2276
+ * `layer-N`, in the `layers.reverse*` orientation: a single leaf, so `c8-chrome`
2277
+ * pairs it with `dark:` and nests no deeper than with fixed `scope-*-N` steps.
2278
+ */
2279
+ function slotValue(source, theme) {
2280
+ if (source.startsWith("scope-")) return `var(--${source})`;
2281
+ const layer = /^layer-(light|dark)-([0-4])$/.exec(source);
2282
+ if (layer) {
2283
+ const reverse = layer[1] === "light" ? theme.reverseLightLayers : theme.reverseDarkLayers;
2284
+ return `var(--scope-${layer[1]}-${layerN(Number(layer[2]), reverse)})`;
2285
+ }
2286
+ if (source === "hl") return `var(--current-hl)`;
2287
+ const themeCol = theme.colors[source];
2288
+ const colStr = typeof themeCol === "string" ? themeCol : themeCol?.DEFAULT;
2289
+ if (!colStr) return;
2290
+ try {
2291
+ return colorToRgbWithOpacity(colStr);
2292
+ } catch {
2293
+ return;
2294
+ }
2225
2295
  }
2296
+ const variableRules = [[currentSlotRe, (match, { theme }) => {
2297
+ const slot = match[1];
2298
+ const value = slotValue(match[2], theme);
2299
+ if (!value) return;
2300
+ return slot === "hl" ? [slotCss(slot, value), ...inDark({ "--current-hl-text": value })] : slotCss(slot, value);
2301
+ }], [/^scope-(.*)$/, (match, { theme }) => {
2302
+ const vars = getScopeCssVars(match[1], theme);
2303
+ return vars && [vars, ...inDark({ "--current-hl-text": HL_TEXT.dark })];
2304
+ }]];
2305
+ //#endregion
2306
+ //#region src/theme/rules/index.ts
2307
+ const rules = [
2308
+ ...spacingRules,
2309
+ ...variableRules,
2310
+ ...paletteRules,
2311
+ ...i8Rules
2312
+ ];
2226
2313
  //#endregion
2227
2314
  //#region src/theme/typography.ts
2228
2315
  function font(weight, boldWeight, size, height, spacing) {
@@ -2336,6 +2423,7 @@ function computeRadiusScale(baseRadius) {
2336
2423
  //#endregion
2337
2424
  //#region src/theme/theme.ts
2338
2425
  const themeFactory = (opts) => {
2426
+ const fingertipSizes = Object.fromEntries(FINGERTIP_SIZES.map((size) => [`fingertip-${size}`, `var(--v-fingertip-${size})`]));
2339
2427
  /**
2340
2428
  * Spacing
2341
2429
  */
@@ -2349,11 +2437,7 @@ const themeFactory = (opts) => {
2349
2437
  "$xxl": `${round(opts.spacingFactor ** 3, 3)}em`,
2350
2438
  "fingertip": "var(--v-fingertip)",
2351
2439
  "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,
2440
+ ...fingertipSizes,
2357
2441
  "$font-tc": "var(--font-bc)",
2358
2442
  "$font-bc": "var(--font-tc)",
2359
2443
  "$font-size": "var(--font-size)",
@@ -2367,11 +2451,7 @@ const themeFactory = (opts) => {
2367
2451
  const lineHeight = {
2368
2452
  "fingertip": "var(--v-fingertip)",
2369
2453
  "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
2454
+ ...fingertipSizes
2375
2455
  };
2376
2456
  const borderRadius = {
2377
2457
  ...spacing,
@@ -2545,7 +2625,7 @@ const presetVunor = (_opts) => {
2545
2625
  const opts = defu(_opts, defaultOptions);
2546
2626
  const wind = getFixedWind();
2547
2627
  if (!wind.preflights) wind.preflights = [];
2548
- wind.preflights.push(vunorPreflights(opts.baseStyles, opts.borderOpacity));
2628
+ wind.preflights.push(vunorPreflights(opts));
2549
2629
  if (!wind.rules) wind.rules = [];
2550
2630
  wind.rules.push(...rules);
2551
2631
  const paletteShortcuts = getPaletteShortcuts();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vunor",
3
- "version": "0.4.6",
3
+ "version": "0.5.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "CHANGELOG.md"