vunor 0.4.4 → 0.4.6
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 +17 -0
- package/README.md +25 -3
- package/dist/theme.d.mts +7 -0
- package/dist/theme.mjs +15 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.6
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
|
|
9
|
+
## 0.4.5
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `presetVunor({ borderOpacity })`, default `0.25`: the opacity of the default border colour (`--un-border-opacity` on `:root`), which a `border` with no colour class is drawn with; `ring-current-border` and `shadow-current-border` without `/N` read the same value. Before, it was fixed at `0.25` and an app changed it by overriding the variable in its own CSS.
|
|
14
|
+
- The README ("Clickable Styles (`c8`)") and the skill show how to bring back the `c8-filled` fills of 0.4.1 and earlier by appending three shortcut entries, no `replaceShortcut` needed. The 0.4.2 fills stay the default.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- A `scope-…` token that names no palette colour no longer fails the UnoCSS build with `Not supported color`. UnoCSS picks up such a string anywhere in a scanned file, comments included: a shade (`scope-primary-500`), `scope-white`, `scope-dark` or a Wind colour name (`scope-red`). It now compiles to nothing. `scope-<name>` is still a scope for the seven palette colours: `primary`, `secondary`, `grey`, `neutral`, `good`, `warn` and `error`.
|
|
19
|
+
|
|
3
20
|
## 0.4.4
|
|
4
21
|
|
|
5
22
|
### Added
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A **UnoCSS theme engine** that turns a handful of design decisions into a complete, perceptually consistent design system -- plus an optional set of 30+ Vue 3 components that use it.
|
|
4
4
|
|
|
5
|
-
The core value is the theme: a golden-ratio-based type and spacing scale, an Oklab-graded color palette where every hue looks equally bright at the same step, and a
|
|
5
|
+
The core value is the theme: a golden-ratio-based type and spacing scale, an Oklab-graded color palette where every hue looks equally bright at the same step, and a shortcut object system that merges your classes into any built-in style by name, so you customize a visual detail without rewriting the style. The Vue components are a bonus -- you can use the theme engine on its own with any markup.
|
|
6
6
|
|
|
7
7
|
## Design Philosophy
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ Most design systems hard-code dozens of magic numbers for font sizes, spacing, c
|
|
|
10
10
|
|
|
11
11
|
- **Golden ratio (1.618)** drives the typography scale, spacing tokens, and default border radius
|
|
12
12
|
- **Oklab color model** ensures perceptual uniformity -- `primary-500` and `error-500` look equally bright to the human eye, regardless of hue
|
|
13
|
-
- **Object-driven shortcuts**
|
|
13
|
+
- **Object-driven shortcuts** let you add classes to one variant of any built-in style: same-name shortcuts are merged, not replaced
|
|
14
14
|
|
|
15
15
|
The result: change one seed color or one scale factor, and the entire system recalculates consistently.
|
|
16
16
|
|
|
@@ -142,6 +142,7 @@ Used as `p-$m`, `m-$l`, `gap-$s`, etc. Text-aware margin utilities (`text-mt-$m`
|
|
|
142
142
|
### Other Derived Values
|
|
143
143
|
|
|
144
144
|
- **Border radius**: defaults to `0.618em` (1/golden-ratio), configurable via `baseRadius`
|
|
145
|
+
- **Default border**: a `border` with no colour class is a translucent grey at opacity `0.25`, configurable via `borderOpacity`
|
|
145
146
|
- **Touch targets** (`fingertip-xs` through `fingertip-xl`): sized using `sqrt(k)` progressions
|
|
146
147
|
- **Card spacing**: `card-{typography}` sets `--card-spacing` proportional to the heading's corrected size; `card-dense` switches to 0.6x
|
|
147
148
|
|
|
@@ -149,7 +150,7 @@ Used as `p-$m`, `m-$l`, `gap-$s`, etc. Text-aware margin utilities (`text-mt-$m`
|
|
|
149
150
|
|
|
150
151
|
## Object-Driven Shortcuts
|
|
151
152
|
|
|
152
|
-
This is Vunor's approach to component styling. Instead of flat UnoCSS shortcut strings, Vunor uses **structured nested objects** where keys are variant prefixes and values are the classes to apply. This makes styles readable,
|
|
153
|
+
This is Vunor's approach to component styling. Instead of flat UnoCSS shortcut strings, Vunor uses **structured nested objects** where keys are variant prefixes and values are the classes to apply. This makes styles readable, and lets a later definition of the same shortcut add classes to one variant without restating the rest.
|
|
153
154
|
|
|
154
155
|
### How It Works
|
|
155
156
|
|
|
@@ -247,6 +248,8 @@ export default defineConfig({
|
|
|
247
248
|
|
|
248
249
|
Your `'c8-filled'.'':` classes are added to the base classes of `c8-filled`, while all its `hover:`, `dark:`, `active:` variants remain intact from the defaults. Everything flows through a single merge pipeline, producing consistent CSS passed to UnoCSS.
|
|
249
250
|
|
|
251
|
+
Appending is not always overriding. UnoCSS writes the utilities of a shortcut in the order of its own rules, not in the order of the class string. An appended class wins over an earlier class of the same utility (`rounded-full` over `rounded-base`, one `bg-*` over another). Between different utilities the UnoCSS rule order decides: `px-4` wins over `p-2` and `flex` over `block`, whichever is written last. When an appended class has no effect, append the utility that wins (`px-2` to change a `px-4`), mark your class important (`!p-2`), or [replace the shortcut](#replacing-a-built-in-shortcut).
|
|
252
|
+
|
|
250
253
|
`vunorShortcuts()` returns the merged default shortcuts for all built-in styles (c8, i8, card, dialog, etc.). Pass your overrides as the first argument -- they take priority.
|
|
251
254
|
|
|
252
255
|
### Replacing a Built-in Shortcut
|
|
@@ -341,6 +344,22 @@ Each includes hover, active, and focus states. Hover paints only on devices whos
|
|
|
341
344
|
|
|
342
345
|
`c8-filled` rests on shade 600 and goes to 700 on hover and 800 on press, in light and dark mode. With the default palette white text reaches WCAG AA (4.5:1) on all three fills for every palette colour. In dark mode a 1px inset rim in shade 500 keeps the button's edge at 3:1 or more against every dark layer. If you tune the palette, check your colours' 600 shades: with `mainPalette.preserveInputColor: true` and `good: '#22c55e'`, for example, `good-600` gives white text only 4.18:1.
|
|
343
346
|
|
|
347
|
+
These fills are the default since 0.4.2. To bring back the fills of 0.4.1 and earlier (500 at rest; 600 on hover and 700 on press, 400 and 300 in dark mode), append three entries. Each class you append is a `current-bg-*` like vunor's own, and an appended class wins over an earlier class of the same utility, so no `replaceShortcut` is needed:
|
|
348
|
+
|
|
349
|
+
```ts
|
|
350
|
+
import { defineShortcuts, vunorShortcuts } from 'vunor/theme'
|
|
351
|
+
|
|
352
|
+
vunorShortcuts(
|
|
353
|
+
defineShortcuts({
|
|
354
|
+
'c8-filled': { '': 'current-bg-scope-color-500' },
|
|
355
|
+
'c8-filled-hover': { '': 'current-bg-scope-color-600', 'dark:': 'current-bg-scope-color-400' },
|
|
356
|
+
'c8-filled-active': { '': 'current-bg-scope-color-700', 'dark:': 'current-bg-scope-color-300' },
|
|
357
|
+
})
|
|
358
|
+
)
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Add `'dark:': 'ring-0'` to the `c8-filled` entry to drop the dark-mode rim too. With the default palette, white text on these fills measures 3.4–4.1:1 at rest and 2.1–3.0:1 on the dark-mode hover and press fills, below WCAG AA.
|
|
362
|
+
|
|
344
363
|
To change a c8 hover colour, override the same key vunor uses, so your class merges into vunor's rule and wins:
|
|
345
364
|
|
|
346
365
|
```ts
|
|
@@ -405,6 +424,9 @@ export default defineConfig({
|
|
|
405
424
|
// -- Global border radius --
|
|
406
425
|
baseRadius: '0.5em', // default: 0.618em (1/golden-ratio)
|
|
407
426
|
|
|
427
|
+
// -- Opacity of the default border colour (`border` with no colour class) --
|
|
428
|
+
borderOpacity: 0.25,
|
|
429
|
+
|
|
408
430
|
// -- Typography overrides --
|
|
409
431
|
typography: {
|
|
410
432
|
h1: { size: 4, weight: 300, boldWeight: 700 },
|
package/dist/theme.d.mts
CHANGED
|
@@ -29,6 +29,13 @@ interface TVunorUnoPresetOpts {
|
|
|
29
29
|
xl?: string;
|
|
30
30
|
};
|
|
31
31
|
baseRadius?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Opacity of the default border colour, from `0` to `1`: the
|
|
34
|
+
* `--un-border-opacity` set on `:root`, which a `border` with no colour class
|
|
35
|
+
* is drawn with. `ring-current-border` and `shadow-current-border` without
|
|
36
|
+
* `/N` read the same value. Default `0.25`.
|
|
37
|
+
*/
|
|
38
|
+
borderOpacity?: number;
|
|
32
39
|
/**
|
|
33
40
|
* Page-level element styles: the body, figcaption and h1–h6 typography rules
|
|
34
41
|
* (size, weight, line-height, letter-spacing, plus a level's `font` and `css`
|
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, 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;
|
|
@@ -1914,7 +1914,7 @@ const currentSlotRe = new RegExp(`^current-(${slotAlt})-(.+)$`);
|
|
|
1914
1914
|
const currentPaintRe = new RegExp(`^(text|bg|icon|border|outline|caret|fill|shadow|ring)-current(${sourceAlt})?(\\/\\d{1,3})?$`);
|
|
1915
1915
|
function getScopeCssVars(c, theme) {
|
|
1916
1916
|
const col = theme.colors[c];
|
|
1917
|
-
if (!col) return;
|
|
1917
|
+
if (!col || !theme.colors[`${c}-500`]) return;
|
|
1918
1918
|
const vars = { "--scope-color": colorToRgbWithOpacity(col) };
|
|
1919
1919
|
for (const shade of SCOPE_SHADES) vars[`--scope-color-${shade}`] = colorToRgbWithOpacity(theme.colors[`${c}-${shade}`]) || "";
|
|
1920
1920
|
for (const layer of SCOPE_LAYERS) {
|
|
@@ -2022,12 +2022,12 @@ function unitBy(input, factor, roundTo = 3) {
|
|
|
2022
2022
|
* `:root` theme variables always; page-level element styles only with `baseStyles`.
|
|
2023
2023
|
* Off, `body` keeps the body level's `--font-*` variables for `text-mt-*` / `font-$bold`.
|
|
2024
2024
|
*/
|
|
2025
|
-
function vunorPreflights(baseStyles) {
|
|
2026
|
-
return { getCSS: ({ theme }) => baseStyles ? renderBaseStyles(theme) : renderRootVars(theme) + renderFontVarsCss("body", theme.fontSize.body) };
|
|
2025
|
+
function vunorPreflights(baseStyles, borderOpacity) {
|
|
2026
|
+
return { getCSS: ({ theme }) => baseStyles ? renderBaseStyles(theme, borderOpacity) : renderRootVars(theme, borderOpacity) + renderFontVarsCss("body", theme.fontSize.body) };
|
|
2027
2027
|
}
|
|
2028
|
-
function renderBaseStyles(theme) {
|
|
2028
|
+
function renderBaseStyles(theme, borderOpacity) {
|
|
2029
2029
|
return `${renderFontCss("body", theme.fontSize.body) + renderFontCss("figcaption", theme.fontSize.caption) + renderFontCss("h1", theme.fontSize.h1) + renderFontCss("h2", theme.fontSize.h2) + renderFontCss("h3", theme.fontSize.h3) + renderFontCss("h4", theme.fontSize.h4) + renderFontCss("h5", theme.fontSize.h5) + renderFontCss("h6", theme.fontSize.h6)}
|
|
2030
|
-
${renderRootVars(theme)}
|
|
2030
|
+
${renderRootVars(theme, borderOpacity)}
|
|
2031
2031
|
|
|
2032
2032
|
::-webkit-scrollbar {
|
|
2033
2033
|
width: 10px;
|
|
@@ -2064,9 +2064,9 @@ ${renderRootVars(theme)}
|
|
|
2064
2064
|
}
|
|
2065
2065
|
`;
|
|
2066
2066
|
}
|
|
2067
|
-
function renderRootVars(theme) {
|
|
2067
|
+
function renderRootVars(theme, borderOpacity) {
|
|
2068
2068
|
return `:root {
|
|
2069
|
-
--un-border-opacity:
|
|
2069
|
+
--un-border-opacity: ${borderOpacity};
|
|
2070
2070
|
--un-default-border-color: rgb(150 150 150 / var(--un-border-opacity));
|
|
2071
2071
|
--scope-black: 0 0 0;
|
|
2072
2072
|
--scope-white: 255 255 255;
|
|
@@ -2468,6 +2468,7 @@ const defaultOptions = {
|
|
|
2468
2468
|
xl: `4em`
|
|
2469
2469
|
},
|
|
2470
2470
|
baseRadius: `${round(1 / 1.618, 3)}em`,
|
|
2471
|
+
borderOpacity: .25,
|
|
2471
2472
|
baseStyles: true,
|
|
2472
2473
|
animation: {
|
|
2473
2474
|
durations: {
|
|
@@ -2536,11 +2537,15 @@ const disabledSoftLiteral = {
|
|
|
2536
2537
|
order: -1e3,
|
|
2537
2538
|
match: (matcher, { generator }) => matcher === DISABLED_SOFT && generator.config.shortcuts.some((sc) => sc[0] === DISABLED_SOFT) ? { matcher: DISABLED_SOFT_LITERAL } : void 0
|
|
2538
2539
|
};
|
|
2540
|
+
const REPEATED_IMPORTANT = /!important(?:\s*!important)+\s*$/i;
|
|
2541
|
+
const singleImportant = (util) => {
|
|
2542
|
+
for (const entry of util.entries) if (typeof entry[1] === "string" && entry[1].includes("!")) entry[1] = entry[1].replace(REPEATED_IMPORTANT, "!important");
|
|
2543
|
+
};
|
|
2539
2544
|
const presetVunor = (_opts) => {
|
|
2540
2545
|
const opts = defu(_opts, defaultOptions);
|
|
2541
2546
|
const wind = getFixedWind();
|
|
2542
2547
|
if (!wind.preflights) wind.preflights = [];
|
|
2543
|
-
wind.preflights.push(vunorPreflights(opts.baseStyles));
|
|
2548
|
+
wind.preflights.push(vunorPreflights(opts.baseStyles, opts.borderOpacity));
|
|
2544
2549
|
if (!wind.rules) wind.rules = [];
|
|
2545
2550
|
wind.rules.push(...rules);
|
|
2546
2551
|
const paletteShortcuts = getPaletteShortcuts();
|
|
@@ -2555,6 +2560,7 @@ const presetVunor = (_opts) => {
|
|
|
2555
2560
|
name: "vunor",
|
|
2556
2561
|
theme: defu(theme.theme, wind.theme),
|
|
2557
2562
|
variants: [disabledSoftLiteral, ...wind.variants ?? []],
|
|
2563
|
+
postprocess: [...toArray(wind.postprocess), singleImportant],
|
|
2558
2564
|
shortcuts: [...paletteShortcuts, [DISABLED_SOFT_LITERAL, DISABLED_SOFT]],
|
|
2559
2565
|
extractors: [createVunorExtractor()],
|
|
2560
2566
|
layers: {
|