@wrikka/theme 0.0.0-stage → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -2
- package/dist/brand-DIJLf6Xs.d.mts +68 -0
- package/dist/css-vars-WEUFBMjy.mjs +850 -0
- package/dist/index.d.mts +80 -0
- package/dist/index.mjs +96 -0
- package/dist/preset.d.mts +23 -0
- package/dist/preset.mjs +189 -0
- package/dist/vite.d.mts +58 -0
- package/dist/vite.mjs +100 -0
- package/package.json +58 -3
- package/src/styles/markdown.css +87 -0
- package/src/styles/theme.css +247 -0
- package/src/styles/tokens.css +311 -0
- package/src/styles/tokens.dtcg.json +3656 -0
- package/tokens.json +535 -0
- package/uno.config.ts +246 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { _ as ThemeState, a as brandRamp, c as readableForeground, d as ThemeColor, f as ThemeFont, g as ThemeSpace, h as ThemeRadius, i as brandForMode, l as ColorScheme, m as ThemePreset, n as BrandPair, o as brandVars, p as ThemeMode, r as BrandRamp, s as normalizeBrand, t as BrandInput, u as ColorSet } from "./brand-DIJLf6Xs.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Color math shared by the brand ramp and the token health audit.
|
|
4
|
+
*
|
|
5
|
+
* Colors travel through the theme as CSS "h s% l%" triplets, so every helper
|
|
6
|
+
* accepts that form (or hex) and returns plain sRGB components.
|
|
7
|
+
*/
|
|
8
|
+
export type Rgb = [number, number, number];
|
|
9
|
+
export declare const isHslTriplet: (value: string) => boolean;
|
|
10
|
+
/** Parse an "h s% l%" triplet into sRGB components in the 0–1 range. */
|
|
11
|
+
export declare function hslTripletToRgb(triplet: string): Rgb | undefined;
|
|
12
|
+
/** Parse a six-digit hex color into sRGB components in the 0–1 range. */
|
|
13
|
+
export declare function hexToRgb(hex: string): Rgb | undefined;
|
|
14
|
+
/** Convert a six-digit hex color into the "h s% l%" triplet theme.css uses. */
|
|
15
|
+
export declare function hexToHslTriplet(hex: string): string | undefined;
|
|
16
|
+
export declare function rgbToHslTriplet(rgb: Rgb): string;
|
|
17
|
+
/** WCAG 2.1 relative luminance. */
|
|
18
|
+
export declare function relativeLuminance([r, g, b]: Rgb): number;
|
|
19
|
+
/** WCAG 2.1 contrast ratio between two sRGB colors (1–21). */
|
|
20
|
+
export declare function contrastRatio(a: Rgb, b: Rgb): number;
|
|
21
|
+
/** Contrast between two "h s% l%" triplets; undefined when either fails to parse. */
|
|
22
|
+
export declare function tripletContrast(a: string, b: string): number | undefined;
|
|
23
|
+
export declare const colorSchemes: Record<Exclude<ThemeColor, "auto">, ColorScheme>;
|
|
24
|
+
/** Soft/ink/deep surfaces for the families that carry them; neutral accent has no family. */
|
|
25
|
+
export declare function softVars(colorSet: ColorSet, mode: ThemeMode): Record<string, string>;
|
|
26
|
+
/** Same lightness adjustments applyThemeState uses at runtime. */
|
|
27
|
+
export declare function varsForMode(colorSet: ColorSet, mode: ThemeMode): Record<string, string>;
|
|
28
|
+
export declare function varsForState(state: Pick<ThemeState, "font" | "space" | "radius">): Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Emit a complete theme.css for a ThemeState — light vars on :root, dark vars
|
|
31
|
+
* under [data-theme="dark"], plus the font/space/radius tokens on :root.
|
|
32
|
+
*/
|
|
33
|
+
export declare function cssVarsForTheme(state: ThemeState, color?: Exclude<ThemeColor, "auto">): string;
|
|
34
|
+
/**
|
|
35
|
+
* Brand override layer: the full primary ramp for both modes, meant to be
|
|
36
|
+
* emitted after cssVarsForTheme so it wins on cascade order.
|
|
37
|
+
*/
|
|
38
|
+
export declare function brandCssVars(brand: BrandInput): string;
|
|
39
|
+
export declare function hsl(h: number, s: number, l: number): string;
|
|
40
|
+
/** Shift the lightness channel of an "h s% l%" string, clamped to 0–100. */
|
|
41
|
+
export declare function adjustLightness(hslValue: string, delta: number): string;
|
|
42
|
+
/** Low-emphasis surface of a family color, tuned per mode. */
|
|
43
|
+
export declare function softTriplet(value: string, mode: ThemeMode): string;
|
|
44
|
+
/** Readable text color for a family, for use on its `soft` surface. */
|
|
45
|
+
export declare function inkTriplet(value: string, mode: ThemeMode): string;
|
|
46
|
+
/** Emphasised fill of a family color (darker in both modes). */
|
|
47
|
+
export declare function deepTriplet(value: string): string;
|
|
48
|
+
/** Translucent brand levels applied over any surface: `hsl(var(--color-primary) / var(--su-alpha-<level>))`. */
|
|
49
|
+
export declare function alphaVars(mode: ThemeMode): Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* Weekday themes ΓÇö Thai weekday colors: Sunday red, Monday yellow,
|
|
52
|
+
* Tuesday pink, Wednesday green, Thursday orange, Friday blue,
|
|
53
|
+
* Saturday violet. Matches `weekdayColors` in store.ts.
|
|
54
|
+
*/
|
|
55
|
+
export declare const presets: ThemePreset[];
|
|
56
|
+
export declare const fontStacks: Record<ThemeFont, string>;
|
|
57
|
+
/**
|
|
58
|
+
* Line heights per font. Thai stacks carry stacked vowels and tone marks above
|
|
59
|
+
* and below the baseline, so they need more air than a Latin-only face at the
|
|
60
|
+
* same size.
|
|
61
|
+
*/
|
|
62
|
+
export declare const leadingScales: Record<ThemeFont, Record<"none" | "tight" | "normal" | "relaxed", string>>;
|
|
63
|
+
export declare const spaceScales: Record<ThemeSpace, Record<string, string>>;
|
|
64
|
+
/** Control metrics that follow the space scale, exposed as --su-control-h-*, --su-row-h and --su-gutter. */
|
|
65
|
+
export interface DensityMetrics {
|
|
66
|
+
controlSm: string;
|
|
67
|
+
controlMd: string;
|
|
68
|
+
controlLg: string;
|
|
69
|
+
row: string;
|
|
70
|
+
gutter: string;
|
|
71
|
+
}
|
|
72
|
+
export declare const densityScales: Record<ThemeSpace, DensityMetrics>;
|
|
73
|
+
export declare const radiusScales: Record<ThemeRadius, {
|
|
74
|
+
DEFAULT: string;
|
|
75
|
+
sm: string;
|
|
76
|
+
md: string;
|
|
77
|
+
lg: string;
|
|
78
|
+
xl: string;
|
|
79
|
+
}>;
|
|
80
|
+
export { BrandInput, BrandPair, BrandRamp, ColorScheme, ColorSet, ThemeColor, ThemeFont, ThemeMode, ThemePreset, ThemeRadius, ThemeSpace, ThemeState, brandForMode, brandRamp, brandVars, normalizeBrand, readableForeground };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { A as tripletContrast, C as contrastRatio, D as isHslTriplet, E as hslTripletToRgb, O as relativeLuminance, S as softTriplet, T as hexToRgb, _ as adjustLightness, a as varsForState, b as hsl, c as leadingScales, d as colorSchemes, f as brandForMode, g as readableForeground, h as normalizeBrand, i as varsForMode, k as rgbToHslTriplet, l as radiusScales, m as brandVars, n as cssVarsForTheme, o as densityScales, p as brandRamp, r as softVars, s as fontStacks, t as brandCssVars, u as spaceScales, v as alphaVars, w as hexToHslTriplet, x as inkTriplet, y as deepTriplet } from "./css-vars-WEUFBMjy.mjs";
|
|
2
|
+
|
|
3
|
+
// src/theme/presets.ts
|
|
4
|
+
/**
|
|
5
|
+
* Weekday themes ΓÇö Thai weekday colors: Sunday red, Monday yellow,
|
|
6
|
+
* Tuesday pink, Wednesday green, Thursday orange, Friday blue,
|
|
7
|
+
* Saturday violet. Matches `weekdayColors` in store.ts.
|
|
8
|
+
*/
|
|
9
|
+
const presets = [
|
|
10
|
+
{
|
|
11
|
+
name: "sunday",
|
|
12
|
+
label: "Sunday",
|
|
13
|
+
state: {
|
|
14
|
+
name: "Sunday",
|
|
15
|
+
mode: "dark",
|
|
16
|
+
color: "red",
|
|
17
|
+
font: "sans",
|
|
18
|
+
space: "normal",
|
|
19
|
+
radius: "medium"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "monday",
|
|
24
|
+
label: "Monday",
|
|
25
|
+
state: {
|
|
26
|
+
name: "Monday",
|
|
27
|
+
mode: "dark",
|
|
28
|
+
color: "yellow",
|
|
29
|
+
font: "sans",
|
|
30
|
+
space: "normal",
|
|
31
|
+
radius: "medium"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "tuesday",
|
|
36
|
+
label: "Tuesday",
|
|
37
|
+
state: {
|
|
38
|
+
name: "Tuesday",
|
|
39
|
+
mode: "dark",
|
|
40
|
+
color: "pink",
|
|
41
|
+
font: "serif",
|
|
42
|
+
space: "normal",
|
|
43
|
+
radius: "large"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "wednesday",
|
|
48
|
+
label: "Wednesday",
|
|
49
|
+
state: {
|
|
50
|
+
name: "Wednesday",
|
|
51
|
+
mode: "dark",
|
|
52
|
+
color: "green",
|
|
53
|
+
font: "sans",
|
|
54
|
+
space: "spacious",
|
|
55
|
+
radius: "small"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "thursday",
|
|
60
|
+
label: "Thursday",
|
|
61
|
+
state: {
|
|
62
|
+
name: "Thursday",
|
|
63
|
+
mode: "dark",
|
|
64
|
+
color: "orange",
|
|
65
|
+
font: "sans",
|
|
66
|
+
space: "normal",
|
|
67
|
+
radius: "medium"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "friday",
|
|
72
|
+
label: "Friday",
|
|
73
|
+
state: {
|
|
74
|
+
name: "Friday",
|
|
75
|
+
mode: "dark",
|
|
76
|
+
color: "blue",
|
|
77
|
+
font: "sans",
|
|
78
|
+
space: "normal",
|
|
79
|
+
radius: "medium"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "saturday",
|
|
84
|
+
label: "Saturday",
|
|
85
|
+
state: {
|
|
86
|
+
name: "Saturday",
|
|
87
|
+
mode: "dark",
|
|
88
|
+
color: "violet",
|
|
89
|
+
font: "sans",
|
|
90
|
+
space: "compact",
|
|
91
|
+
radius: "large"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
export { adjustLightness, alphaVars, brandCssVars, brandForMode, brandRamp, brandVars, colorSchemes, contrastRatio, cssVarsForTheme, deepTriplet, densityScales, fontStacks, hexToHslTriplet, hexToRgb, hsl, hslTripletToRgb, inkTriplet, isHslTriplet, leadingScales, normalizeBrand, presets, radiusScales, readableForeground, relativeLuminance, rgbToHslTriplet, softTriplet, softVars, spaceScales, tripletContrast, varsForMode, varsForState };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { _ as ThemeState, t as BrandInput } from "./brand-DIJLf6Xs.mjs";
|
|
2
|
+
import { Preset } from "unocss";
|
|
3
|
+
export interface PresetSolidUIOptions {
|
|
4
|
+
color?: ThemeState["color"];
|
|
5
|
+
font?: ThemeState["font"];
|
|
6
|
+
space?: ThemeState["space"];
|
|
7
|
+
radius?: ThemeState["radius"];
|
|
8
|
+
mode?: ThemeState["mode"];
|
|
9
|
+
/**
|
|
10
|
+
* Brand color (hex or "h s% l%" triplet) that derives the whole primary ramp;
|
|
11
|
+
* pass `{ light, dark }` when dark mode needs a brighter fill.
|
|
12
|
+
*/
|
|
13
|
+
brand?: BrandInput;
|
|
14
|
+
/** Emit a preflight that sets every --color-* and --su-* token on :root/[data-theme]. Default true. */
|
|
15
|
+
preflight?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* UnoCSS preset that maps the solid-ui design tokens to CSS variables.
|
|
19
|
+
* Utilities like `bg-primary`, `text-muted-foreground`, `rounded-lg` resolve to
|
|
20
|
+
* `var(--color-*)` / `var(--su-*)` so themes can be swapped at runtime.
|
|
21
|
+
*/
|
|
22
|
+
export declare function presetSolidUI(options?: PresetSolidUIOptions): Preset;
|
|
23
|
+
export { presetSolidUI as default };
|
package/dist/preset.mjs
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { n as cssVarsForTheme, t as brandCssVars } from "./css-vars-WEUFBMjy.mjs";
|
|
2
|
+
|
|
3
|
+
// src/preset.ts
|
|
4
|
+
/**
|
|
5
|
+
* UnoCSS preset that maps the solid-ui design tokens to CSS variables.
|
|
6
|
+
* Utilities like `bg-primary`, `text-muted-foreground`, `rounded-lg` resolve to
|
|
7
|
+
* `var(--color-*)` / `var(--su-*)` so themes can be swapped at runtime.
|
|
8
|
+
*/
|
|
9
|
+
function presetSolidUI(options = {}) {
|
|
10
|
+
const state = {
|
|
11
|
+
name: "custom",
|
|
12
|
+
mode: options.mode ?? "light",
|
|
13
|
+
color: options.color ?? "blue",
|
|
14
|
+
font: options.font ?? "sans",
|
|
15
|
+
space: options.space ?? "normal",
|
|
16
|
+
radius: options.radius ?? "medium"
|
|
17
|
+
};
|
|
18
|
+
const brandCss = options.brand ? brandCssVars(options.brand) : "";
|
|
19
|
+
return {
|
|
20
|
+
name: "@wrikka/theme/preset",
|
|
21
|
+
theme: {
|
|
22
|
+
colors: {
|
|
23
|
+
background: "hsl(var(--color-background))",
|
|
24
|
+
foreground: "hsl(var(--color-foreground))",
|
|
25
|
+
primary: {
|
|
26
|
+
DEFAULT: "hsl(var(--color-primary))",
|
|
27
|
+
hover: "hsl(var(--color-primary-hover))",
|
|
28
|
+
active: "hsl(var(--color-primary-active))",
|
|
29
|
+
foreground: "hsl(var(--color-primary-foreground))",
|
|
30
|
+
soft: {
|
|
31
|
+
DEFAULT: "hsl(var(--color-primary-soft))",
|
|
32
|
+
foreground: "hsl(var(--color-primary-soft-foreground))"
|
|
33
|
+
},
|
|
34
|
+
ink: "hsl(var(--color-primary-ink))",
|
|
35
|
+
deep: "hsl(var(--color-primary-deep))",
|
|
36
|
+
tint: "hsl(var(--color-primary) / var(--su-alpha-tint))",
|
|
37
|
+
"tint-strong": "hsl(var(--color-primary) / var(--su-alpha-tint-strong))",
|
|
38
|
+
faint: "hsl(var(--color-primary) / var(--su-alpha-faint))",
|
|
39
|
+
wash: "hsl(var(--color-primary) / var(--su-alpha-wash))"
|
|
40
|
+
},
|
|
41
|
+
secondary: {
|
|
42
|
+
DEFAULT: "hsl(var(--color-secondary))",
|
|
43
|
+
hover: "hsl(var(--color-secondary-hover))",
|
|
44
|
+
active: "hsl(var(--color-secondary-active))",
|
|
45
|
+
foreground: "hsl(var(--color-secondary-foreground))"
|
|
46
|
+
},
|
|
47
|
+
accent: {
|
|
48
|
+
DEFAULT: "hsl(var(--color-accent))",
|
|
49
|
+
hover: "hsl(var(--color-accent-hover))",
|
|
50
|
+
active: "hsl(var(--color-accent-active))",
|
|
51
|
+
foreground: "hsl(var(--color-accent-foreground))"
|
|
52
|
+
},
|
|
53
|
+
muted: {
|
|
54
|
+
DEFAULT: "hsl(var(--color-muted))",
|
|
55
|
+
foreground: "hsl(var(--color-muted-foreground))"
|
|
56
|
+
},
|
|
57
|
+
destructive: {
|
|
58
|
+
DEFAULT: "hsl(var(--color-destructive))",
|
|
59
|
+
hover: "hsl(var(--color-destructive-hover))",
|
|
60
|
+
active: "hsl(var(--color-destructive-active))",
|
|
61
|
+
foreground: "hsl(var(--color-destructive-foreground))",
|
|
62
|
+
soft: {
|
|
63
|
+
DEFAULT: "hsl(var(--color-destructive-soft))",
|
|
64
|
+
foreground: "hsl(var(--color-destructive-soft-foreground))"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
success: {
|
|
68
|
+
DEFAULT: "hsl(var(--color-success))",
|
|
69
|
+
foreground: "hsl(var(--color-success-foreground))",
|
|
70
|
+
soft: {
|
|
71
|
+
DEFAULT: "hsl(var(--color-success-soft))",
|
|
72
|
+
foreground: "hsl(var(--color-success-soft-foreground))"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
warning: {
|
|
76
|
+
DEFAULT: "hsl(var(--color-warning))",
|
|
77
|
+
foreground: "hsl(var(--color-warning-foreground))",
|
|
78
|
+
soft: {
|
|
79
|
+
DEFAULT: "hsl(var(--color-warning-soft))",
|
|
80
|
+
foreground: "hsl(var(--color-warning-soft-foreground))"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
info: {
|
|
84
|
+
DEFAULT: "hsl(var(--color-info))",
|
|
85
|
+
foreground: "hsl(var(--color-info-foreground))",
|
|
86
|
+
soft: {
|
|
87
|
+
DEFAULT: "hsl(var(--color-info-soft))",
|
|
88
|
+
foreground: "hsl(var(--color-info-soft-foreground))"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
border: {
|
|
92
|
+
DEFAULT: "hsl(var(--color-border))",
|
|
93
|
+
hover: "hsl(var(--color-border-hover))"
|
|
94
|
+
},
|
|
95
|
+
input: "hsl(var(--color-input))",
|
|
96
|
+
ring: "hsl(var(--color-ring))",
|
|
97
|
+
surface: {
|
|
98
|
+
DEFAULT: "hsl(var(--color-surface))",
|
|
99
|
+
foreground: "hsl(var(--color-surface-foreground))",
|
|
100
|
+
elevated: "hsl(var(--color-surface-elevated))"
|
|
101
|
+
},
|
|
102
|
+
card: {
|
|
103
|
+
DEFAULT: "hsl(var(--color-surface))",
|
|
104
|
+
foreground: "hsl(var(--color-surface-foreground))"
|
|
105
|
+
},
|
|
106
|
+
focus: "hsl(var(--color-focus))",
|
|
107
|
+
overlay: "hsl(var(--color-overlay))",
|
|
108
|
+
scrim: "hsl(var(--color-scrim))",
|
|
109
|
+
skeleton: {
|
|
110
|
+
DEFAULT: "hsl(var(--color-skeleton))",
|
|
111
|
+
shine: "hsl(var(--color-skeleton-shine))"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
fontFamily: {
|
|
115
|
+
sans: "var(--su-font-sans)",
|
|
116
|
+
mono: "var(--su-font-mono)"
|
|
117
|
+
},
|
|
118
|
+
fontSize: {
|
|
119
|
+
"3xs": "var(--su-text-3xs)",
|
|
120
|
+
"2xs": "var(--su-text-2xs)",
|
|
121
|
+
xs: "var(--su-text-xs)",
|
|
122
|
+
sm: "var(--su-text-sm)",
|
|
123
|
+
base: "var(--su-text-base)",
|
|
124
|
+
lg: "var(--su-text-lg)",
|
|
125
|
+
xl: "var(--su-text-xl)",
|
|
126
|
+
"2xl": "var(--su-text-2xl)",
|
|
127
|
+
"3xl": "var(--su-text-3xl)",
|
|
128
|
+
"4xl": "var(--su-text-4xl)",
|
|
129
|
+
"5xl": "var(--su-text-5xl)",
|
|
130
|
+
"6xl": "var(--su-text-6xl)",
|
|
131
|
+
"7xl": "var(--su-text-7xl)",
|
|
132
|
+
"8xl": "var(--su-text-8xl)",
|
|
133
|
+
"9xl": "var(--su-text-9xl)"
|
|
134
|
+
},
|
|
135
|
+
lineHeight: {
|
|
136
|
+
none: "var(--su-leading-none)",
|
|
137
|
+
tight: "var(--su-leading-tight)",
|
|
138
|
+
normal: "var(--su-leading-normal)",
|
|
139
|
+
relaxed: "var(--su-leading-relaxed)"
|
|
140
|
+
},
|
|
141
|
+
spacing: { gutter: "var(--su-gutter)" },
|
|
142
|
+
transitionDuration: {
|
|
143
|
+
fast: "var(--su-duration-fast)",
|
|
144
|
+
normal: "var(--su-duration-normal)",
|
|
145
|
+
slow: "var(--su-duration-slow)",
|
|
146
|
+
slower: "var(--su-duration-slower)"
|
|
147
|
+
},
|
|
148
|
+
transitionTimingFunction: {
|
|
149
|
+
standard: "var(--su-ease-standard)",
|
|
150
|
+
decelerate: "var(--su-ease-decelerate)",
|
|
151
|
+
accelerate: "var(--su-ease-accelerate)"
|
|
152
|
+
},
|
|
153
|
+
radius: {
|
|
154
|
+
DEFAULT: "var(--su-radius-sm)",
|
|
155
|
+
sm: "var(--su-radius-sm)",
|
|
156
|
+
md: "var(--su-radius-md)",
|
|
157
|
+
lg: "var(--su-radius-lg)",
|
|
158
|
+
xl: "var(--su-radius-xl)",
|
|
159
|
+
full: "var(--su-radius-full)"
|
|
160
|
+
},
|
|
161
|
+
boxShadow: {
|
|
162
|
+
sm: "var(--su-shadow-sm)",
|
|
163
|
+
md: "var(--su-shadow-md)",
|
|
164
|
+
lg: "var(--su-shadow-lg)",
|
|
165
|
+
xl: "var(--su-shadow-xl)",
|
|
166
|
+
glow: "var(--su-shadow-glow)"
|
|
167
|
+
},
|
|
168
|
+
zIndex: {
|
|
169
|
+
base: "var(--su-z-base)",
|
|
170
|
+
dropdown: "var(--su-z-dropdown)",
|
|
171
|
+
sticky: "var(--su-z-sticky)",
|
|
172
|
+
fixed: "var(--su-z-fixed)",
|
|
173
|
+
modalBackdrop: "var(--su-z-modal-backdrop)",
|
|
174
|
+
modal: "var(--su-z-modal)",
|
|
175
|
+
popover: "var(--su-z-popover)",
|
|
176
|
+
tooltip: "var(--su-z-tooltip)",
|
|
177
|
+
toast: "var(--su-z-toast)"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
rules: [
|
|
181
|
+
[/^z-(base|dropdown|sticky|fixed|modal-backdrop|modal|popover|tooltip|toast)$/, (m) => ({ "z-index": `var(--su-z-${m[1]})` })],
|
|
182
|
+
[/^h-control-(sm|md|lg)$/, (m) => ({ height: `var(--su-control-h-${m[1]})` })],
|
|
183
|
+
[/^h-row$/, () => ({ height: "var(--su-row-h)" })]
|
|
184
|
+
],
|
|
185
|
+
preflights: options.preflight === false ? [] : [{ getCSS: () => `${cssVarsForTheme(state)}${brandCss}` }]
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export { presetSolidUI as default, presetSolidUI };
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drop-in Vite plugin for Solid UI apps.
|
|
3
|
+
*
|
|
4
|
+
* Wires UnoCSS with the Wrikka stack — presetWind4 (dark-mode selectors),
|
|
5
|
+
* presetSolidUI (design tokens → utilities) and presetIcons (mdi, lucide and
|
|
6
|
+
* simple-icons bundled) — so a consumer only needs:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* // vite.config.ts
|
|
10
|
+
* import { wrikka } from "@wrikka/theme/vite";
|
|
11
|
+
* export default defineConfig({ plugins: [solid(), wrikka()] });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* // app entry (once)
|
|
16
|
+
* import "@wrikka/theme/uno.css";
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* `uno.css`, `virtual:uno.css` and `@wrikka/theme/uno.css` all resolve to the
|
|
20
|
+
* same generated stylesheet.
|
|
21
|
+
*/
|
|
22
|
+
import { PresetSolidUIOptions } from "./preset.mjs";
|
|
23
|
+
import { UserConfig, presetIcons } from "unocss";
|
|
24
|
+
import { Plugin } from "vite";
|
|
25
|
+
/** Specifier consumers import once to pull in the generated stylesheet. */
|
|
26
|
+
export declare const UNO_CSS_ENTRY = "@wrikka/theme/uno.css";
|
|
27
|
+
type PresetIconsOptions = NonNullable<Parameters<typeof presetIcons>[0]>;
|
|
28
|
+
type IconCollection = NonNullable<NonNullable<PresetIconsOptions["collections"]>>[string];
|
|
29
|
+
export interface WrikkaViteOptions {
|
|
30
|
+
/** Forwarded to `presetSolidUI` — brand, mode, color, font, space, radius, preflight. */
|
|
31
|
+
preset?: PresetSolidUIOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Extra UnoCSS icon collections merged over the bundled defaults
|
|
34
|
+
* (`mdi`, `lucide`, `simple-icons`). Same signature presetIcons expects.
|
|
35
|
+
*/
|
|
36
|
+
icons?: Record<string, IconCollection>;
|
|
37
|
+
/**
|
|
38
|
+
* Raw UnoCSS config merged into the generated one — `safelist`,
|
|
39
|
+
* `content`, extra `presets`/`rules`/`theme` keys, etc. Presets, rules and
|
|
40
|
+
* transformers are appended after the Wrikka defaults.
|
|
41
|
+
*/
|
|
42
|
+
uno?: UserConfig;
|
|
43
|
+
/**
|
|
44
|
+
* UnoCSS vite-plugin options that are not part of the UnoCSS config —
|
|
45
|
+
* `mode`, `inspector`, `checkImport`, `postcss`, `transformCSS`, …
|
|
46
|
+
*/
|
|
47
|
+
vite?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the Vite plugins a Solid UI consumer needs. Place it alongside the
|
|
51
|
+
* Solid plugin — order does not matter:
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* plugins: [tanstackStart(), solid({ ssr: true }), wrikka()]
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function wrikka(options?: WrikkaViteOptions): Plugin[];
|
|
58
|
+
export { wrikka as default };
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import presetSolidUI from "./preset.mjs";
|
|
2
|
+
import { presetIcons, presetWind4, transformerDirectives, transformerVariantGroup } from "unocss";
|
|
3
|
+
import UnoCSS from "unocss/vite";
|
|
4
|
+
|
|
5
|
+
// src/vite.ts
|
|
6
|
+
/**
|
|
7
|
+
* Drop-in Vite plugin for Solid UI apps.
|
|
8
|
+
*
|
|
9
|
+
* Wires UnoCSS with the Wrikka stack — presetWind4 (dark-mode selectors),
|
|
10
|
+
* presetSolidUI (design tokens → utilities) and presetIcons (mdi, lucide and
|
|
11
|
+
* simple-icons bundled) — so a consumer only needs:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* // vite.config.ts
|
|
15
|
+
* import { wrikka } from "@wrikka/theme/vite";
|
|
16
|
+
* export default defineConfig({ plugins: [solid(), wrikka()] });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // app entry (once)
|
|
21
|
+
* import "@wrikka/theme/uno.css";
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* `uno.css`, `virtual:uno.css` and `@wrikka/theme/uno.css` all resolve to the
|
|
25
|
+
* same generated stylesheet.
|
|
26
|
+
*/
|
|
27
|
+
/** Specifier consumers import once to pull in the generated stylesheet. */
|
|
28
|
+
const UNO_CSS_ENTRY = "@wrikka/theme/uno.css";
|
|
29
|
+
const VIRTUALUnoEntry = "\0wrikka:uno-entry";
|
|
30
|
+
const DEFAULT_ICON_COLLECTIONS = {
|
|
31
|
+
mdi: () => import("@iconify-json/mdi/icons.json").then((i) => i.default),
|
|
32
|
+
lucide: () => import("@iconify-json/lucide/icons.json").then((i) => i.default),
|
|
33
|
+
"simple-icons": () => import("@iconify-json/simple-icons/icons.json").then((i) => i.default)
|
|
34
|
+
};
|
|
35
|
+
/** Named z-index/duration/density utilities the Wrikka token scale needs. */
|
|
36
|
+
const BASE_RULES = [
|
|
37
|
+
[/^z-(base|dropdown|sticky|fixed|modal-backdrop|modal|popover|tooltip|toast)$/, (m) => ({ "z-index": `var(--su-z-${m[1]})` })],
|
|
38
|
+
[/^duration-(fast|normal|slow|slower)$/, (m) => ({
|
|
39
|
+
"--un-duration": `var(--su-duration-${m[1]})`,
|
|
40
|
+
"transition-duration": `var(--su-duration-${m[1]})`
|
|
41
|
+
})],
|
|
42
|
+
[/^h-control-(sm|md|lg)$/, (m) => ({ height: `var(--su-control-h-${m[1]})` })],
|
|
43
|
+
[/^h-row$/, () => ({ height: "var(--su-row-h)" })]
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* Returns the Vite plugins a Solid UI consumer needs. Place it alongside the
|
|
47
|
+
* Solid plugin — order does not matter:
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* plugins: [tanstackStart(), solid({ ssr: true }), wrikka()]
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
function wrikka(options = {}) {
|
|
54
|
+
const { preset = {}, icons = {}, uno = {}, vite = {} } = options;
|
|
55
|
+
const { presets: extraPresets = [], rules: extraRules = [], transformers: extraTransformers = [], ...unoRest } = uno;
|
|
56
|
+
const unocssConfig = {
|
|
57
|
+
...unoRest,
|
|
58
|
+
presets: [
|
|
59
|
+
presetWind4({
|
|
60
|
+
dark: {
|
|
61
|
+
dark: "html[data-theme=\"dark\"]",
|
|
62
|
+
light: "html[data-theme=\"light\"]"
|
|
63
|
+
},
|
|
64
|
+
preflights: { reset: true }
|
|
65
|
+
}),
|
|
66
|
+
presetSolidUI(preset),
|
|
67
|
+
presetIcons({
|
|
68
|
+
collections: {
|
|
69
|
+
...DEFAULT_ICON_COLLECTIONS,
|
|
70
|
+
...icons
|
|
71
|
+
},
|
|
72
|
+
extraProperties: {
|
|
73
|
+
display: "inline-block",
|
|
74
|
+
"vertical-align": "middle",
|
|
75
|
+
"flex-shrink": "0"
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
...extraPresets
|
|
79
|
+
],
|
|
80
|
+
rules: [...BASE_RULES ?? [], ...extraRules],
|
|
81
|
+
transformers: [
|
|
82
|
+
transformerVariantGroup(),
|
|
83
|
+
transformerDirectives(),
|
|
84
|
+
...extraTransformers
|
|
85
|
+
],
|
|
86
|
+
...vite
|
|
87
|
+
};
|
|
88
|
+
return [{
|
|
89
|
+
name: "wrikka:uno-entry",
|
|
90
|
+
enforce: "pre",
|
|
91
|
+
resolveId(id) {
|
|
92
|
+
if (id === "@wrikka/theme/uno.css") return VIRTUALUnoEntry;
|
|
93
|
+
},
|
|
94
|
+
load(id) {
|
|
95
|
+
if (id === VIRTUALUnoEntry) return `import "virtual:uno.css";`;
|
|
96
|
+
}
|
|
97
|
+
}, ...UnoCSS(unocssConfig)];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { UNO_CSS_ENTRY, wrikka as default, wrikka };
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrikka/theme",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"description": "Design tokens, theme presets, and the UnoCSS configuration behind @wrikka/ui",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"src/styles/tokens.css",
|
|
14
|
+
"src/styles/theme.css",
|
|
15
|
+
"src/styles/markdown.css",
|
|
16
|
+
"src/styles/tokens.dtcg.json",
|
|
17
|
+
"uno.config.ts",
|
|
18
|
+
"tokens.json",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.mjs",
|
|
24
|
+
"types": "./dist/index.d.mts"
|
|
25
|
+
},
|
|
26
|
+
"./preset": {
|
|
27
|
+
"import": "./dist/preset.mjs",
|
|
28
|
+
"types": "./dist/preset.d.mts"
|
|
29
|
+
},
|
|
30
|
+
"./vite": {
|
|
31
|
+
"types": "./dist/vite.d.mts",
|
|
32
|
+
"import": "./dist/vite.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./uno": "./uno.config.ts",
|
|
35
|
+
"./styles/*": "./src/styles/*"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsdown",
|
|
39
|
+
"dev": "tsdown --watch",
|
|
40
|
+
"typecheck": "bun check -p . --no-script",
|
|
41
|
+
"lint": "biome check src",
|
|
42
|
+
"format": "biome format --write src",
|
|
43
|
+
"test": "vitest run --passWithNoTests",
|
|
44
|
+
"gen:tokens": "bun scripts/export-tokens-dtcg.ts",
|
|
45
|
+
"check:tokens": "bun scripts/check-tokens.ts"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"vite": ">=5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"vite": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@iconify-json/lucide": "^1.2.157",
|
|
57
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
58
|
+
"@iconify-json/simple-icons": "^1.2.103",
|
|
59
|
+
"unocss": "^66.10.4"
|
|
60
|
+
}
|
|
6
61
|
}
|