@wirecore/wirelayer-tokens 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WireCore GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ export interface Rgba {
2
+ r: number;
3
+ g: number;
4
+ b: number;
5
+ a: number;
6
+ }
7
+ export declare function parse(color: string): Rgba;
8
+ /** Paints `top` (optionally with extra opacity, like Tailwind's `/14`) over an opaque `bottom`. */
9
+ export declare function over(top: Rgba, bottom: Rgba, opacity?: number): Rgba;
10
+ export declare function luminance({ r, g, b }: Rgba): number;
11
+ export declare function contrast(a: Rgba, b: Rgba): number;
12
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,IAAI;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb;AAqBD,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAiBzC;AAED,mGAAmG;AACnG,wBAAgB,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,SAAI,GAAG,IAAI,CAI/D;AAED,wBAAgB,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,GAAG,MAAM,CAEnD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAGjD"}
package/dist/color.js ADDED
@@ -0,0 +1,51 @@
1
+ // Colour maths for WCAG contrast checks: parses the token formats (hex, rgba, oklch),
2
+ // composites translucent colours like the browser (in gamma-encoded sRGB) and computes
3
+ // relative luminance / contrast ratios as defined by WCAG 2.2.
4
+ const clamp = (value) => Math.min(1, Math.max(0, value));
5
+ const encode = (linear) => clamp(linear <= 0.0031308 ? 12.92 * linear : 1.055 * Math.pow(linear, 1 / 2.4) - 0.055);
6
+ const decode = (channel) => (channel <= 0.04045 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4));
7
+ function oklchToRgb(l, c, h) {
8
+ const a = c * Math.cos((h * Math.PI) / 180);
9
+ const b = c * Math.sin((h * Math.PI) / 180);
10
+ const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
11
+ const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
12
+ const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
13
+ return {
14
+ r: encode(4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_),
15
+ g: encode(-1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_),
16
+ b: encode(-0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_),
17
+ a: 1,
18
+ };
19
+ }
20
+ export function parse(color) {
21
+ const hex = color.match(/^#([0-9a-f]{6})$/i)?.[1];
22
+ if (hex) {
23
+ const [r, g, b] = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255);
24
+ return { r, g, b, a: 1 };
25
+ }
26
+ const rgba = color.match(/^rgba?\(([^)]+)\)$/)?.[1];
27
+ if (rgba) {
28
+ const [r = 0, g = 0, b = 0, a = 1] = rgba.split(',').map(Number);
29
+ return { r: r / 255, g: g / 255, b: b / 255, a };
30
+ }
31
+ const oklch = color.match(/^oklch\(([^)]+)\)$/)?.[1];
32
+ if (oklch) {
33
+ const [l = 0, c = 0, h = 0] = oklch.trim().split(/\s+/).map(Number);
34
+ return oklchToRgb(l, c, h);
35
+ }
36
+ throw new Error(`Unsupported colour: ${color}`);
37
+ }
38
+ /** Paints `top` (optionally with extra opacity, like Tailwind's `/14`) over an opaque `bottom`. */
39
+ export function over(top, bottom, opacity = 1) {
40
+ const alpha = top.a * opacity;
41
+ const mix = (t, b) => t * alpha + b * (1 - alpha);
42
+ return { r: mix(top.r, bottom.r), g: mix(top.g, bottom.g), b: mix(top.b, bottom.b), a: 1 };
43
+ }
44
+ export function luminance({ r, g, b }) {
45
+ return 0.2126 * decode(r) + 0.7152 * decode(g) + 0.0722 * decode(b);
46
+ }
47
+ export function contrast(a, b) {
48
+ const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x);
49
+ return (light + 0.05) / (dark + 0.05);
50
+ }
51
+ //# sourceMappingURL=color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.js","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,uFAAuF;AACvF,+DAA+D;AAS/D,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,C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G,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAO,EAAE,CAAO;IACrC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAqB,CAAC;IAC7F,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type ColorSet, type Mode, type Theme } from './tokens.js';
2
+ export interface ContrastResult {
3
+ name: string;
4
+ ratio: number;
5
+ min: number;
6
+ }
7
+ /** Every foreground/background combination the components use, with its required ratio. */
8
+ export declare function contrastPairs(colors: ColorSet): ContrastResult[];
9
+ /** All pairs of a theme (in both modes) that miss their required contrast – empty when the theme passes. */
10
+ export declare function checkTheme(theme: Theme): (ContrastResult & {
11
+ mode: Mode;
12
+ })[];
13
+ //# sourceMappingURL=contrast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrast.d.ts","sourceRoot":"","sources":["../src/contrast.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,KAAK,QAAQ,EAAmB,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAsB1G,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACf;AASD,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,EAAE,CA6IhE;AAED,4GAA4G;AAC5G,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,cAAc,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,EAAE,CAM5E"}
@@ -0,0 +1,109 @@
1
+ // WCAG 2.2 AA contrast checks for a full colour set – used by the token tests for every built-in theme
2
+ // and exported so projects can test their own themes:
3
+ // expect(checkTheme(myTheme)).toEqual([])
4
+ import { contrast, over, parse } from './color.js';
5
+ import { modes, resolveColors } from './tokens.js';
6
+ /** 4.5:1 for text (1.4.3), 3:1 for UI component boundaries, selected states and icons (1.4.11). */
7
+ const TEXT = 4.5;
8
+ const NON_TEXT = 3;
9
+ /** Must match the `hover:opacity-*` of the solid button variants in @wirecore/wirelayer-recipes. */
10
+ const HOVER_OPACITY = 0.85;
11
+ /** Info and warn buttons fade less on hover (`hover:opacity-90`) – at 85 % white text would drop below 4.5:1. */
12
+ const HOVER_OPACITY_LIGHT_FILL = 0.9;
13
+ /** Tinted ("soft") buttons: `bg-<colour>/10`, on hover `/14` (the tint of badges and alert icons). */
14
+ const SOFT_HOVER_TINT = 0.14;
15
+ /**
16
+ * Editor colours – must match `editorColorTokens`/`editorColorValue` in @wirecore/wirelayer-recipes: text moved 25 % towards
17
+ * `fg` (`color-mix(in srgb …)`), backgrounds as a 20 % tint.
18
+ */
19
+ const EDITOR_TOKENS = ['primary', 'info', 'success', 'warn', 'danger', 'muted'];
20
+ const EDITOR_TEXT_MIX = 0.25;
21
+ const EDITOR_BACKGROUND_TINT = 0.2;
22
+ const statuses = ['success', 'info', 'warn', 'danger'];
23
+ const surfaces = ['bg', 'bg-2', 'card'];
24
+ /** Every foreground/background combination the components use, with its required ratio. */
25
+ export function contrastPairs(colors) {
26
+ const color = (token) => parse(colors[token]);
27
+ /** A token painted onto an opaque surface, optionally with Tailwind opacity (`bg-success/14`). */
28
+ const on = (token, surface, opacity = 1) => over(color(token), color(surface), opacity);
29
+ const pair = (name, foreground, background, min) => ({
30
+ name,
31
+ foreground,
32
+ background,
33
+ min,
34
+ });
35
+ const pairs = [
36
+ // Body text, labels, helper text, placeholders, input addons
37
+ ...surfaces.flatMap((surface) => [
38
+ pair(`text-fg on ${surface}`, color('fg'), color(surface), TEXT),
39
+ pair(`text-muted on ${surface}`, color('muted'), color(surface), TEXT),
40
+ ]),
41
+ // Error text, badges and alert icons in status colours
42
+ ...statuses.flatMap((status) => [
43
+ pair(`text-${status} on bg`, color(status), color('bg'), TEXT),
44
+ pair(`text-${status} on card`, color(status), color('card'), TEXT),
45
+ ...surfaces.map((surface) => pair(`text-${status} on bg-${status}/14 (${surface})`, color(status), on(status, surface, 0.14), TEXT)),
46
+ ]),
47
+ // Buttons, selected chips/segments/pages (primary), inverted surfaces (badge, tooltip, toast)
48
+ pair('primary: text-on-primary on bg-primary', color('on-primary'), color('primary'), TEXT),
49
+ pair('inverted: text-bg on bg-fg', color('bg'), color('fg'), TEXT),
50
+ pair('secondary: text-fg on bg-line (bg)', color('fg'), on('line', 'bg'), TEXT),
51
+ pair('secondary: text-fg on bg-line (card)', color('fg'), on('line', 'card'), TEXT),
52
+ pair('secondary hover: text-fg on bg-line-2', color('fg'), on('line-2', 'bg'), TEXT),
53
+ pair('success: text-on-success on bg-success', color('on-success'), color('success'), TEXT),
54
+ pair('danger: text-on-danger on bg-danger', color('on-danger'), color('danger'), TEXT),
55
+ pair('info: text-on-info on bg-info', color('on-info'), color('info'), TEXT),
56
+ pair('warn: text-on-warn on bg-warn', color('on-warn'), color('warn'), TEXT),
57
+ // Hover of solid buttons (`hover:opacity-85` fades text and background onto the page)
58
+ ...[
59
+ ['primary', 'on-primary', 'primary'],
60
+ ['success', 'on-success', 'success'],
61
+ ['danger', 'on-danger', 'danger'],
62
+ ].flatMap(([variant, text, fill]) => surfaces.map((surface) => pair(`${variant} hover on ${surface}`, on(text, surface, HOVER_OPACITY), on(fill, surface, HOVER_OPACITY), TEXT))),
63
+ ...[
64
+ ['info', 'on-info', 'info'],
65
+ ['warn', 'on-warn', 'warn'],
66
+ ].flatMap(([variant, text, fill]) => surfaces.map((surface) => pair(`${variant} hover on ${surface}`, on(text, surface, HOVER_OPACITY_LIGHT_FILL), on(fill, surface, HOVER_OPACITY_LIGHT_FILL), TEXT))),
67
+ // Button colour "contrast" (bg-fg text-bg), faded on hover
68
+ ...surfaces.map((surface) => pair(`contrast hover on ${surface}`, on('bg', surface, HOVER_OPACITY), on('fg', surface, HOVER_OPACITY), TEXT)),
69
+ // Coloured outline/text/soft buttons: text in the colour on the page and on its tint (hover); primary as
70
+ // text colour (status colours are covered above)
71
+ ...surfaces.map((surface) => pair(`text-primary on ${surface}`, color('primary'), color(surface), TEXT)),
72
+ ...surfaces.flatMap((surface) => ['primary', ...statuses].map((tone) => pair(`soft ${tone} hover: text-${tone} on bg-${tone}/14 (${surface})`, color(tone), on(tone, surface, SOFT_HOVER_TINT), TEXT))),
73
+ // Outline/text buttons in a colour: hover tint /8 on every surface
74
+ ...surfaces.flatMap((surface) => ['primary', ...statuses].map((tone) => pair(`${tone} outline hover: text on bg-${tone}/8 (${surface})`, color(tone), on(tone, surface, 0.08), TEXT))),
75
+ // Highlight: marked text on the tint of its search term
76
+ ...['bg', 'card'].flatMap((surface) => ['primary', ...statuses].map((tone) => pair(`highlight: text-fg on bg-${tone}/25 (${surface})`, color('fg'), on(tone, surface, 0.25), TEXT))),
77
+ // Editor: every text colour on the surfaces and on every background colour (default text included)
78
+ ...surfaces.flatMap((surface) => ['fg', ...EDITOR_TOKENS].flatMap((text) => {
79
+ const foreground = text === 'fg' ? color('fg') : over(color('fg'), color(text), EDITOR_TEXT_MIX);
80
+ return [
81
+ pair(`editor: text ${text} on ${surface}`, foreground, color(surface), TEXT),
82
+ ...EDITOR_TOKENS.map((background) => pair(`editor: text ${text} on background ${background} (${surface})`, foreground, on(background, surface, EDITOR_BACKGROUND_TINT), TEXT)),
83
+ ];
84
+ })),
85
+ // Menu: shortcut and danger item on a highlighted item; toast: meta line on the inverted surface
86
+ pair('menu shortcut: text-muted on bg-line (card)', color('muted'), on('line', 'card'), TEXT),
87
+ pair('menu danger item: text-danger on bg-line (card)', color('danger'), on('line', 'card'), TEXT),
88
+ pair('toast: text-bg/65 on bg-fg', on('bg', 'fg', 0.65), color('fg'), TEXT),
89
+ // Form control boundaries, selected states, invalid state, focus ring and focused field border
90
+ ...surfaces.flatMap((surface) => [
91
+ pair(`input border line-strong on ${surface}`, on('line-strong', surface), color(surface), NON_TEXT),
92
+ pair(`selected/focus primary on ${surface}`, color('primary'), color(surface), NON_TEXT),
93
+ pair(`invalid border danger on ${surface}`, color('danger'), color(surface), NON_TEXT),
94
+ pair(`focus ring fg on ${surface}`, color('fg'), color(surface), NON_TEXT),
95
+ ]),
96
+ ];
97
+ return pairs.map(({ name, foreground, background, min }) => ({
98
+ name,
99
+ ratio: contrast(foreground, background),
100
+ min,
101
+ }));
102
+ }
103
+ /** All pairs of a theme (in both modes) that miss their required contrast – empty when the theme passes. */
104
+ export function checkTheme(theme) {
105
+ return modes.flatMap((mode) => contrastPairs(resolveColors(theme, mode))
106
+ .filter((result) => result.ratio < result.min)
107
+ .map((result) => ({ ...result, mode })));
108
+ }
109
+ //# sourceMappingURL=contrast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrast.js","sourceRoot":"","sources":["../src/contrast.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,sDAAsD;AACtD,4CAA4C;AAC5C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAa,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,aAAa,EAAyD,MAAM,aAAa,CAAC;AAE1G,mGAAmG;AACnG,MAAM,IAAI,GAAG,GAAG,CAAC;AACjB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,oGAAoG;AACpG,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,iHAAiH;AACjH,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,sGAAsG;AACtG,MAAM,eAAe,GAAG,IAAI,CAAC;AAC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AAG,CAAC;SAC7C,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAC9C,CAAC;AACN,CAAC"}
package/dist/css.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { ColorSet, Theme } from './tokens.js';
2
+ /** `--wc-*` declarations for a (partial) colour set. */
3
+ export declare const colorDeclarations: (set: Partial<ColorSet>) => string;
4
+ /**
5
+ * CSS for a theme: its overrides apply with `data-theme="<name>"`, combined with `data-mode` on the same
6
+ * element or nested in either direction. Dark rules are more specific, so they win over the light ones.
7
+ * Use it to generate CSS for a custom theme, e.g. in a build script.
8
+ */
9
+ export declare function themeToCss(theme: Theme): string;
10
+ //# sourceMappingURL=css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEnD,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,GAAI,KAAK,OAAO,CAAC,QAAQ,CAAC,WAGrC,CAAC;AAEpB;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAY/C"}
package/dist/css.js ADDED
@@ -0,0 +1,23 @@
1
+ /** `--wc-*` declarations for a (partial) colour set. */
2
+ export const colorDeclarations = (set) => Object.entries(set)
3
+ .map(([token, value]) => ` --wc-${token}: ${value};`)
4
+ .join('\n');
5
+ /**
6
+ * CSS for a theme: its overrides apply with `data-theme="<name>"`, combined with `data-mode` on the same
7
+ * element or nested in either direction. Dark rules are more specific, so they win over the light ones.
8
+ * Use it to generate CSS for a custom theme, e.g. in a build script.
9
+ */
10
+ export function themeToCss(theme) {
11
+ const t = `[data-theme=${theme.name}]`;
12
+ return `${t},
13
+ ${t} [data-mode=light] {
14
+ ${colorDeclarations(theme.colors.light)}
15
+ }
16
+
17
+ ${t}[data-mode=dark],
18
+ ${t} [data-mode=dark],
19
+ [data-mode=dark] ${t} {
20
+ ${colorDeclarations(theme.colors.dark)}
21
+ }`;
22
+ }
23
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.js","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAsB,EAAE,EAAE,CACxD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;KACd,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,YAAY,KAAK,KAAK,KAAK,GAAG,CAAC;KACvD,IAAI,CAAC,IAAI,CAAC,CAAC;AAEpB;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAY;IACnC,MAAM,CAAC,GAAG,eAAe,KAAK,CAAC,IAAI,GAAG,CAAC;IACvC,OAAO,GAAG,CAAC;EACb,CAAC;EACD,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;;;EAGrC,CAAC;EACD,CAAC;mBACgB,CAAC;EAClB,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;EACpC,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './tokens.js';
2
+ export { checkTheme, contrastPairs, type ContrastResult } from './contrast.js';
3
+ export { colorDeclarations, themeToCss } from './css.js';
4
+ export { nativeExtraThemes, nativeFonts, nativeThemeName, themeToNativeCss } from './native.js';
5
+ export { contrast, luminance, over, parse, type Rgba } from './color.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // Design tokens (tokens.ts) and the helpers built on them – they import tokens.ts, not this file (no cycles)
2
+ export * from './tokens.js';
3
+ export { checkTheme, contrastPairs } from './contrast.js';
4
+ export { colorDeclarations, themeToCss } from './css.js';
5
+ export { nativeExtraThemes, nativeFonts, nativeThemeName, themeToNativeCss } from './native.js';
6
+ export { contrast, luminance, over, parse } from './color.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAa,MAAM,YAAY,CAAC"}
@@ -0,0 +1,190 @@
1
+ /* Generated by @wirecore/wirelayer-tokens – do not edit */
2
+ @custom-variant ocean-light (&:where(.ocean-light, .ocean-light *));
3
+ @custom-variant ocean-dark (&:where(.ocean-dark, .ocean-dark *));
4
+ @custom-variant violet-light (&:where(.violet-light, .violet-light *));
5
+ @custom-variant violet-dark (&:where(.violet-dark, .violet-dark *));
6
+ @custom-variant teal-light (&:where(.teal-light, .teal-light *));
7
+ @custom-variant teal-dark (&:where(.teal-dark, .teal-dark *));
8
+
9
+ @layer theme {
10
+ :root {
11
+ @variant light {
12
+ --color-bg: #FFFFFF;
13
+ --color-bg-2: #F6F6F6;
14
+ --color-card: #FFFFFF;
15
+ --color-fg: #0A0A0A;
16
+ --color-muted: #666666;
17
+ --color-line: rgba(0, 0, 0, 0.08);
18
+ --color-line-2: rgba(0, 0, 0, 0.16);
19
+ --color-line-strong: rgba(0, 0, 0, 0.43);
20
+ --color-glow: rgba(0, 0, 0, 0.045);
21
+ --color-success: oklch(0.47 0.13 155);
22
+ --color-warn: oklch(0.505 0.14 70);
23
+ --color-danger: oklch(0.515 0.19 25);
24
+ --color-info: oklch(0.50 0.12 245);
25
+ --color-on-success: #FFFFFF;
26
+ --color-on-danger: #FFFFFF;
27
+ --color-on-info: #FFFFFF;
28
+ --color-on-warn: #FFFFFF;
29
+ --color-primary: #0A0A0A;
30
+ --color-on-primary: #FFFFFF;
31
+ }
32
+ @variant dark {
33
+ --color-bg: #050505;
34
+ --color-bg-2: #0A0A0A;
35
+ --color-card: #0C0C0C;
36
+ --color-fg: #F4F4F4;
37
+ --color-muted: #8F8F8F;
38
+ --color-line: rgba(255, 255, 255, 0.09);
39
+ --color-line-2: rgba(255, 255, 255, 0.18);
40
+ --color-line-strong: rgba(255, 255, 255, 0.35);
41
+ --color-glow: rgba(255, 255, 255, 0.07);
42
+ --color-success: oklch(0.78 0.14 155);
43
+ --color-warn: oklch(0.84 0.14 80);
44
+ --color-danger: oklch(0.70 0.18 25);
45
+ --color-info: oklch(0.76 0.11 245);
46
+ --color-on-success: #050505;
47
+ --color-on-danger: #050505;
48
+ --color-on-info: #050505;
49
+ --color-on-warn: #050505;
50
+ --color-primary: #F4F4F4;
51
+ --color-on-primary: #050505;
52
+ }
53
+ @variant ocean-light {
54
+ --color-bg: #FFFFFF;
55
+ --color-bg-2: #F6F6F6;
56
+ --color-card: #FFFFFF;
57
+ --color-fg: #0A0A0A;
58
+ --color-muted: #666666;
59
+ --color-line: rgba(0, 0, 0, 0.08);
60
+ --color-line-2: rgba(0, 0, 0, 0.16);
61
+ --color-line-strong: rgba(0, 0, 0, 0.43);
62
+ --color-glow: rgba(0, 0, 0, 0.045);
63
+ --color-success: oklch(0.47 0.13 155);
64
+ --color-warn: oklch(0.505 0.14 70);
65
+ --color-danger: oklch(0.515 0.19 25);
66
+ --color-info: oklch(0.50 0.12 245);
67
+ --color-on-success: #FFFFFF;
68
+ --color-on-danger: #FFFFFF;
69
+ --color-on-info: #FFFFFF;
70
+ --color-on-warn: #FFFFFF;
71
+ --color-primary: oklch(0.48 0.17 255);
72
+ --color-on-primary: #FFFFFF;
73
+ }
74
+ @variant ocean-dark {
75
+ --color-bg: #050505;
76
+ --color-bg-2: #0A0A0A;
77
+ --color-card: #0C0C0C;
78
+ --color-fg: #F4F4F4;
79
+ --color-muted: #8F8F8F;
80
+ --color-line: rgba(255, 255, 255, 0.09);
81
+ --color-line-2: rgba(255, 255, 255, 0.18);
82
+ --color-line-strong: rgba(255, 255, 255, 0.35);
83
+ --color-glow: rgba(255, 255, 255, 0.07);
84
+ --color-success: oklch(0.78 0.14 155);
85
+ --color-warn: oklch(0.84 0.14 80);
86
+ --color-danger: oklch(0.70 0.18 25);
87
+ --color-info: oklch(0.76 0.11 245);
88
+ --color-on-success: #050505;
89
+ --color-on-danger: #050505;
90
+ --color-on-info: #050505;
91
+ --color-on-warn: #050505;
92
+ --color-primary: oklch(0.72 0.13 250);
93
+ --color-on-primary: #050505;
94
+ }
95
+ @variant violet-light {
96
+ --color-bg: #FFFFFF;
97
+ --color-bg-2: #F6F6F6;
98
+ --color-card: #FFFFFF;
99
+ --color-fg: #0A0A0A;
100
+ --color-muted: #666666;
101
+ --color-line: rgba(0, 0, 0, 0.08);
102
+ --color-line-2: rgba(0, 0, 0, 0.16);
103
+ --color-line-strong: rgba(0, 0, 0, 0.43);
104
+ --color-glow: rgba(0, 0, 0, 0.045);
105
+ --color-success: oklch(0.47 0.13 155);
106
+ --color-warn: oklch(0.505 0.14 70);
107
+ --color-danger: oklch(0.515 0.19 25);
108
+ --color-info: oklch(0.50 0.12 245);
109
+ --color-on-success: #FFFFFF;
110
+ --color-on-danger: #FFFFFF;
111
+ --color-on-info: #FFFFFF;
112
+ --color-on-warn: #FFFFFF;
113
+ --color-primary: oklch(0.49 0.2 295);
114
+ --color-on-primary: #FFFFFF;
115
+ }
116
+ @variant violet-dark {
117
+ --color-bg: #050505;
118
+ --color-bg-2: #0A0A0A;
119
+ --color-card: #0C0C0C;
120
+ --color-fg: #F4F4F4;
121
+ --color-muted: #8F8F8F;
122
+ --color-line: rgba(255, 255, 255, 0.09);
123
+ --color-line-2: rgba(255, 255, 255, 0.18);
124
+ --color-line-strong: rgba(255, 255, 255, 0.35);
125
+ --color-glow: rgba(255, 255, 255, 0.07);
126
+ --color-success: oklch(0.78 0.14 155);
127
+ --color-warn: oklch(0.84 0.14 80);
128
+ --color-danger: oklch(0.70 0.18 25);
129
+ --color-info: oklch(0.76 0.11 245);
130
+ --color-on-success: #050505;
131
+ --color-on-danger: #050505;
132
+ --color-on-info: #050505;
133
+ --color-on-warn: #050505;
134
+ --color-primary: oklch(0.74 0.15 295);
135
+ --color-on-primary: #050505;
136
+ }
137
+ @variant teal-light {
138
+ --color-bg: #FFFFFF;
139
+ --color-bg-2: #F6F6F6;
140
+ --color-card: #FFFFFF;
141
+ --color-fg: #0A0A0A;
142
+ --color-muted: #666666;
143
+ --color-line: rgba(0, 0, 0, 0.08);
144
+ --color-line-2: rgba(0, 0, 0, 0.16);
145
+ --color-line-strong: rgba(0, 0, 0, 0.43);
146
+ --color-glow: rgba(0, 0, 0, 0.045);
147
+ --color-success: oklch(0.47 0.13 155);
148
+ --color-warn: oklch(0.505 0.14 70);
149
+ --color-danger: oklch(0.515 0.19 25);
150
+ --color-info: oklch(0.50 0.12 245);
151
+ --color-on-success: #FFFFFF;
152
+ --color-on-danger: #FFFFFF;
153
+ --color-on-info: #FFFFFF;
154
+ --color-on-warn: #FFFFFF;
155
+ --color-primary: oklch(0.45 0.1 190);
156
+ --color-on-primary: #FFFFFF;
157
+ }
158
+ @variant teal-dark {
159
+ --color-bg: #050505;
160
+ --color-bg-2: #0A0A0A;
161
+ --color-card: #0C0C0C;
162
+ --color-fg: #F4F4F4;
163
+ --color-muted: #8F8F8F;
164
+ --color-line: rgba(255, 255, 255, 0.09);
165
+ --color-line-2: rgba(255, 255, 255, 0.18);
166
+ --color-line-strong: rgba(255, 255, 255, 0.35);
167
+ --color-glow: rgba(255, 255, 255, 0.07);
168
+ --color-success: oklch(0.78 0.14 155);
169
+ --color-warn: oklch(0.84 0.14 80);
170
+ --color-danger: oklch(0.70 0.18 25);
171
+ --color-info: oklch(0.76 0.11 245);
172
+ --color-on-success: #050505;
173
+ --color-on-danger: #050505;
174
+ --color-on-info: #050505;
175
+ --color-on-warn: #050505;
176
+ --color-primary: oklch(0.76 0.11 190);
177
+ --color-on-primary: #050505;
178
+ }
179
+ }
180
+ }
181
+
182
+ @theme {
183
+ --font-sans: 'SchibstedGrotesk_400Regular';
184
+ --font-sans-medium: 'SchibstedGrotesk_500Medium';
185
+ --font-sans-semibold: 'SchibstedGrotesk_600SemiBold';
186
+ --font-sans-bold: 'SchibstedGrotesk_700Bold';
187
+ --font-mono: 'JetBrainsMono_400Regular';
188
+ --radius-card: 20px;
189
+ --radius-panel: 28px;
190
+ }
@@ -0,0 +1,19 @@
1
+ import { type Mode, type Theme } from './tokens.js';
2
+ /** Uniwind theme name of a theme in a mode, e.g. `dark` or `ocean-dark`. */
3
+ export declare const nativeThemeName: (theme: string, mode: Mode) => string;
4
+ /** Themes to register in the Metro/Vite config (`extraThemes`) – everything except `light`/`dark`. */
5
+ export declare const nativeExtraThemes: (list?: Theme[]) => string[];
6
+ /**
7
+ * Font families in React Native: one family per weight, named like the font files of
8
+ * `@expo-google-fonts/*` (RN cannot pick the weight of a custom font by itself).
9
+ */
10
+ export declare const nativeFonts: {
11
+ readonly sans: "SchibstedGrotesk_400Regular";
12
+ readonly 'sans-medium': "SchibstedGrotesk_500Medium";
13
+ readonly 'sans-semibold': "SchibstedGrotesk_600SemiBold";
14
+ readonly 'sans-bold': "SchibstedGrotesk_700Bold";
15
+ readonly mono: "JetBrainsMono_400Regular";
16
+ };
17
+ /** `@variant` blocks with all colours of a theme, for `@layer theme { :root { … } }` in a Uniwind CSS file. */
18
+ export declare const themeToNativeCss: (theme: Theme) => string;
19
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAKlF,4EAA4E;AAC5E,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,MAAM,IAAI,WAAuD,CAAC;AAEjH,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,GAAI,OAAM,KAAK,EAAW,aAGA,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC;AAEX,+GAA+G;AAC/G,eAAO,MAAM,gBAAgB,GAAI,OAAO,KAAK,WAQ1B,CAAC"}
package/dist/native.js ADDED
@@ -0,0 +1,30 @@
1
+ import { modes, resolveColors, themes } from './tokens.js';
2
+ // React Native (Uniwind) knows only flat themes, so every theme × mode pair becomes one Uniwind theme.
3
+ // The default theme keeps Uniwind's built-in `light`/`dark` (and with it the system setting).
4
+ /** Uniwind theme name of a theme in a mode, e.g. `dark` or `ocean-dark`. */
5
+ export const nativeThemeName = (theme, mode) => (theme === 'wirecore' ? mode : `${theme}-${mode}`);
6
+ /** Themes to register in the Metro/Vite config (`extraThemes`) – everything except `light`/`dark`. */
7
+ export const nativeExtraThemes = (list = themes) => list
8
+ .flatMap((theme) => modes.map((mode) => nativeThemeName(theme.name, mode)))
9
+ .filter((name) => !modes.includes(name));
10
+ /**
11
+ * Font families in React Native: one family per weight, named like the font files of
12
+ * `@expo-google-fonts/*` (RN cannot pick the weight of a custom font by itself).
13
+ */
14
+ export const nativeFonts = {
15
+ sans: 'SchibstedGrotesk_400Regular',
16
+ 'sans-medium': 'SchibstedGrotesk_500Medium',
17
+ 'sans-semibold': 'SchibstedGrotesk_600SemiBold',
18
+ 'sans-bold': 'SchibstedGrotesk_700Bold',
19
+ mono: 'JetBrainsMono_400Regular',
20
+ };
21
+ /** `@variant` blocks with all colours of a theme, for `@layer theme { :root { … } }` in a Uniwind CSS file. */
22
+ export const themeToNativeCss = (theme) => modes
23
+ .map((mode) => {
24
+ const declarations = Object.entries(resolveColors(theme, mode))
25
+ .map(([token, value]) => ` --color-${token}: ${value};`)
26
+ .join('\n');
27
+ return ` @variant ${nativeThemeName(theme.name, mode)} {\n${declarations}\n }`;
28
+ })
29
+ .join('\n');
30
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAyB,MAAM,aAAa,CAAC;AAElF,uGAAuG;AACvG,8FAA8F;AAE9F,4EAA4E;AAC5E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,IAAU,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC,CAAC;AAEjH,sGAAsG;AACtG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAgB,MAAM,EAAE,EAAE,CACxD,IAAI;KACC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;KAC1E,MAAM,CAAC,CAAC,IAAI,EA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