@wordpress/theme 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.md +788 -0
- package/README.md +67 -0
- package/bin/build-tokens.js +83 -0
- package/bin/generate-primitive-tokens/index.ts +115 -0
- package/bin/terrazzo-plugin-ds-tokens-docs/index.ts +103 -0
- package/bin/terrazzo-plugin-figma-ds-token-manager/index.ts +210 -0
- package/bin/terrazzo-plugin-figma-ds-token-manager/lib.ts +1 -0
- package/bin/terrazzo-plugin-known-wpds-css-variables/index.ts +72 -0
- package/build/color-ramps/index.js +132 -0
- package/build/color-ramps/index.js.map +7 -0
- package/build/color-ramps/lib/cache-utils.js +57 -0
- package/build/color-ramps/lib/cache-utils.js.map +7 -0
- package/build/color-ramps/lib/constants.js +105 -0
- package/build/color-ramps/lib/constants.js.map +7 -0
- package/build/color-ramps/lib/find-color-with-constraints.js +141 -0
- package/build/color-ramps/lib/find-color-with-constraints.js.map +7 -0
- package/build/color-ramps/lib/index.js +264 -0
- package/build/color-ramps/lib/index.js.map +7 -0
- package/build/color-ramps/lib/ramp-configs.js +315 -0
- package/build/color-ramps/lib/ramp-configs.js.map +7 -0
- package/build/color-ramps/lib/taper-chroma.js +159 -0
- package/build/color-ramps/lib/taper-chroma.js.map +7 -0
- package/build/color-ramps/lib/types.js +17 -0
- package/build/color-ramps/lib/types.js.map +7 -0
- package/build/color-ramps/lib/utils.js +106 -0
- package/build/color-ramps/lib/utils.js.map +7 -0
- package/build/context.js +34 -0
- package/build/context.js.map +7 -0
- package/build/index.js +29 -0
- package/build/index.js.map +7 -0
- package/build/lock-unlock.js +35 -0
- package/build/lock-unlock.js.map +7 -0
- package/build/prebuilt/js/design-tokens.js +135 -0
- package/build/prebuilt/js/design-tokens.js.map +7 -0
- package/build/prebuilt/json/figma.json +1317 -0
- package/build/prebuilt/ts/design-tokens.js +354 -0
- package/build/prebuilt/ts/design-tokens.js.map +7 -0
- package/build/private-apis.js +36 -0
- package/build/private-apis.js.map +7 -0
- package/build/style.module.css.js +2 -0
- package/build/theme-provider.js +92 -0
- package/build/theme-provider.js.map +7 -0
- package/build/types/css-modules.d.js +2 -0
- package/build/types/css-modules.d.js.map +7 -0
- package/build/types.js +17 -0
- package/build/types.js.map +7 -0
- package/build/use-theme-provider-styles.js +230 -0
- package/build/use-theme-provider-styles.js.map +7 -0
- package/build-module/color-ramps/index.js +95 -0
- package/build-module/color-ramps/index.js.map +7 -0
- package/build-module/color-ramps/lib/cache-utils.js +31 -0
- package/build-module/color-ramps/lib/cache-utils.js.map +7 -0
- package/build-module/color-ramps/lib/constants.js +63 -0
- package/build-module/color-ramps/lib/constants.js.map +7 -0
- package/build-module/color-ramps/lib/find-color-with-constraints.js +112 -0
- package/build-module/color-ramps/lib/find-color-with-constraints.js.map +7 -0
- package/build-module/color-ramps/lib/index.js +235 -0
- package/build-module/color-ramps/lib/index.js.map +7 -0
- package/build-module/color-ramps/lib/ramp-configs.js +290 -0
- package/build-module/color-ramps/lib/ramp-configs.js.map +7 -0
- package/build-module/color-ramps/lib/taper-chroma.js +125 -0
- package/build-module/color-ramps/lib/taper-chroma.js.map +7 -0
- package/build-module/color-ramps/lib/types.js +1 -0
- package/build-module/color-ramps/lib/types.js.map +7 -0
- package/build-module/color-ramps/lib/utils.js +84 -0
- package/build-module/color-ramps/lib/utils.js.map +7 -0
- package/build-module/context.js +10 -0
- package/build-module/context.js.map +7 -0
- package/build-module/index.js +5 -0
- package/build-module/index.js.map +7 -0
- package/build-module/lock-unlock.js +10 -0
- package/build-module/lock-unlock.js.map +7 -0
- package/build-module/prebuilt/js/design-tokens.js +115 -0
- package/build-module/prebuilt/js/design-tokens.js.map +7 -0
- package/build-module/prebuilt/json/figma.json +1317 -0
- package/build-module/prebuilt/ts/design-tokens.js +334 -0
- package/build-module/prebuilt/ts/design-tokens.js.map +7 -0
- package/build-module/private-apis.js +12 -0
- package/build-module/private-apis.js.map +7 -0
- package/build-module/style.module.css.js +1 -0
- package/build-module/theme-provider.js +58 -0
- package/build-module/theme-provider.js.map +7 -0
- package/build-module/types/css-modules.d.js +1 -0
- package/build-module/types/css-modules.d.js.map +7 -0
- package/build-module/types.js +1 -0
- package/build-module/types.js.map +7 -0
- package/build-module/use-theme-provider-styles.js +200 -0
- package/build-module/use-theme-provider-styles.js.map +7 -0
- package/build-style/style.css +3 -0
- package/build-types/color-ramps/index.d.ts +44 -0
- package/build-types/color-ramps/index.d.ts.map +1 -0
- package/build-types/color-ramps/lib/cache-utils.d.ts +22 -0
- package/build-types/color-ramps/lib/cache-utils.d.ts.map +1 -0
- package/build-types/color-ramps/lib/constants.d.ts +38 -0
- package/build-types/color-ramps/lib/constants.d.ts.map +1 -0
- package/build-types/color-ramps/lib/find-color-with-constraints.d.ts +37 -0
- package/build-types/color-ramps/lib/find-color-with-constraints.d.ts.map +1 -0
- package/build-types/color-ramps/lib/index.d.ts +11 -0
- package/build-types/color-ramps/lib/index.d.ts.map +1 -0
- package/build-types/color-ramps/lib/ramp-configs.d.ts +7 -0
- package/build-types/color-ramps/lib/ramp-configs.d.ts.map +1 -0
- package/build-types/color-ramps/lib/taper-chroma.d.ts +32 -0
- package/build-types/color-ramps/lib/taper-chroma.d.ts.map +1 -0
- package/build-types/color-ramps/lib/types.d.ts +78 -0
- package/build-types/color-ramps/lib/types.d.ts.map +1 -0
- package/build-types/color-ramps/lib/utils.d.ts +38 -0
- package/build-types/color-ramps/lib/utils.d.ts.map +1 -0
- package/build-types/color-ramps/stories/index.story.d.ts +14 -0
- package/build-types/color-ramps/stories/index.story.d.ts.map +1 -0
- package/build-types/color-ramps/stories/ramp-table.d.ts +19 -0
- package/build-types/color-ramps/stories/ramp-table.d.ts.map +1 -0
- package/build-types/context.d.ts +10 -0
- package/build-types/context.d.ts.map +1 -0
- package/build-types/index.d.ts +2 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/prebuilt/js/design-tokens.d.ts +3 -0
- package/build-types/prebuilt/js/design-tokens.d.ts.map +1 -0
- package/build-types/prebuilt/ts/design-tokens.d.ts +7 -0
- package/build-types/prebuilt/ts/design-tokens.d.ts.map +1 -0
- package/build-types/private-apis.d.ts +2 -0
- package/build-types/private-apis.d.ts.map +1 -0
- package/build-types/stories/index.story.d.ts +15 -0
- package/build-types/stories/index.story.d.ts.map +1 -0
- package/build-types/theme-provider.d.ts +3 -0
- package/build-types/theme-provider.d.ts.map +1 -0
- package/build-types/types.d.ts +42 -0
- package/build-types/types.d.ts.map +1 -0
- package/build-types/use-theme-provider-styles.d.ts +17 -0
- package/build-types/use-theme-provider-styles.d.ts.map +1 -0
- package/docs/ds-tokens.md +283 -0
- package/package.json +58 -0
- package/src/color-ramps/index.ts +155 -0
- package/src/color-ramps/lib/cache-utils.ts +56 -0
- package/src/color-ramps/lib/constants.ts +85 -0
- package/src/color-ramps/lib/find-color-with-constraints.ts +190 -0
- package/src/color-ramps/lib/index.ts +369 -0
- package/src/color-ramps/lib/ramp-configs.ts +309 -0
- package/src/color-ramps/lib/taper-chroma.ts +226 -0
- package/src/color-ramps/lib/types.ts +90 -0
- package/src/color-ramps/lib/utils.ts +161 -0
- package/src/color-ramps/stories/index.story.tsx +264 -0
- package/src/color-ramps/stories/ramp-table.tsx +212 -0
- package/src/color-ramps/test/__snapshots__/index.test.ts.snap +1280 -0
- package/src/color-ramps/test/index.test.ts +94 -0
- package/src/context.ts +19 -0
- package/src/index.ts +2 -0
- package/src/lock-unlock.ts +10 -0
- package/src/prebuilt/css/design-tokens.css +401 -0
- package/src/prebuilt/js/design-tokens.js +116 -0
- package/src/prebuilt/json/figma.json +1317 -0
- package/src/prebuilt/ts/design-tokens.ts +335 -0
- package/src/private-apis.ts +12 -0
- package/src/stories/index.story.tsx +426 -0
- package/src/style.module.css +3 -0
- package/src/theme-provider.tsx +87 -0
- package/src/types/css-modules.d.ts +4 -0
- package/src/types.ts +44 -0
- package/src/use-theme-provider-styles.ts +247 -0
- package/terrazzo.config.ts +102 -0
- package/tokens/border.json +34 -0
- package/tokens/color.json +877 -0
- package/tokens/elevation.json +201 -0
- package/tokens/spacing.json +45 -0
- package/tokens/typography.json +93 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import Color from "colorjs.io";
|
|
2
|
+
function taperChroma(seed, lTarget, options = {}) {
|
|
3
|
+
const gamut = options.gamut ?? "p3";
|
|
4
|
+
const alpha = options.alpha ?? 0.65;
|
|
5
|
+
const carry = options.carry ?? 0.5;
|
|
6
|
+
const cUpperBound = options.cUpperBound ?? 0.45;
|
|
7
|
+
const radiusLight = options.radiusLight ?? 0.2;
|
|
8
|
+
const radiusDark = options.radiusDark ?? 0.2;
|
|
9
|
+
const kLight = options.kLight ?? 0.85;
|
|
10
|
+
const kDark = options.kDark ?? 0.85;
|
|
11
|
+
const achromaEpsilon = options.achromaEpsilon ?? 5e-3;
|
|
12
|
+
const cSeed = Math.max(0, seed.oklch.c);
|
|
13
|
+
let hSeed = Number(seed.oklch.h);
|
|
14
|
+
const chromaIsTiny = cSeed < achromaEpsilon;
|
|
15
|
+
const hueIsInvalid = !Number.isFinite(hSeed);
|
|
16
|
+
if (chromaIsTiny || hueIsInvalid) {
|
|
17
|
+
if (typeof options.hueFallback === "number") {
|
|
18
|
+
hSeed = normalizeHue(options.hueFallback);
|
|
19
|
+
} else {
|
|
20
|
+
return new Color("oklch", [clamp01(lTarget), 0, 0]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const lSeed = clamp01(seed.oklch.l);
|
|
24
|
+
const cmaxSeed = getCachedMaxChromaAtLH(lSeed, hSeed, gamut, cUpperBound);
|
|
25
|
+
const cmaxTarget = getCachedMaxChromaAtLH(
|
|
26
|
+
clamp01(lTarget),
|
|
27
|
+
hSeed,
|
|
28
|
+
gamut,
|
|
29
|
+
cUpperBound
|
|
30
|
+
);
|
|
31
|
+
let seedRelative = 0;
|
|
32
|
+
const denom = cmaxSeed > 0 ? cmaxSeed : 1e-6;
|
|
33
|
+
seedRelative = clamp01(cSeed / denom);
|
|
34
|
+
const cIntendedBase = alpha * cmaxTarget;
|
|
35
|
+
const cWithCarry = cIntendedBase * Math.pow(seedRelative, clamp01(carry));
|
|
36
|
+
const t = continuousTaper(lSeed, lTarget, {
|
|
37
|
+
radiusLight,
|
|
38
|
+
radiusDark,
|
|
39
|
+
kLight,
|
|
40
|
+
kDark
|
|
41
|
+
});
|
|
42
|
+
let cPlanned = cWithCarry * t;
|
|
43
|
+
const lOut = clamp01(lTarget);
|
|
44
|
+
const candidate = new Color("oklch", [lOut, cPlanned, hSeed]);
|
|
45
|
+
if (!candidate.inGamut(gamut)) {
|
|
46
|
+
const cap = Math.min(cPlanned, cUpperBound);
|
|
47
|
+
cPlanned = getCachedMaxChromaAtLH(lOut, hSeed, gamut, cap);
|
|
48
|
+
}
|
|
49
|
+
cPlanned = Math.min(cPlanned, cSeed);
|
|
50
|
+
return { l: lOut, c: cPlanned };
|
|
51
|
+
}
|
|
52
|
+
function clamp01(x) {
|
|
53
|
+
if (x < 0) {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
if (x > 1) {
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
return x;
|
|
60
|
+
}
|
|
61
|
+
function normalizeHue(h) {
|
|
62
|
+
let hue = h % 360;
|
|
63
|
+
if (hue < 0) {
|
|
64
|
+
hue += 360;
|
|
65
|
+
}
|
|
66
|
+
return hue;
|
|
67
|
+
}
|
|
68
|
+
function raisedCosine(u) {
|
|
69
|
+
const x = clamp01(u);
|
|
70
|
+
return 0.5 - 0.5 * Math.cos(Math.PI * x);
|
|
71
|
+
}
|
|
72
|
+
function continuousTaper(seedL, targetL, opts) {
|
|
73
|
+
const d = targetL - seedL;
|
|
74
|
+
if (d >= 0) {
|
|
75
|
+
const u2 = opts.radiusLight > 0 ? Math.abs(d) / opts.radiusLight : 1;
|
|
76
|
+
const w2 = raisedCosine(u2 > 1 ? 1 : u2);
|
|
77
|
+
return 1 - (1 - opts.kLight) * w2;
|
|
78
|
+
}
|
|
79
|
+
const u = opts.radiusDark > 0 ? Math.abs(d) / opts.radiusDark : 1;
|
|
80
|
+
const w = raisedCosine(u > 1 ? 1 : u);
|
|
81
|
+
return 1 - (1 - opts.kDark) * w;
|
|
82
|
+
}
|
|
83
|
+
const maxChromaCache = /* @__PURE__ */ new Map();
|
|
84
|
+
function keyMax(l, h, gamut, cap) {
|
|
85
|
+
const lq = quantize(l, 1e-3);
|
|
86
|
+
const hq = quantize(normalizeHue(h), 0.1);
|
|
87
|
+
const cq = quantize(cap, 1e-3);
|
|
88
|
+
return `${gamut}|L:${lq}|H:${hq}|cap:${cq}`;
|
|
89
|
+
}
|
|
90
|
+
function quantize(x, step) {
|
|
91
|
+
const k = Math.round(x / step);
|
|
92
|
+
return k * step;
|
|
93
|
+
}
|
|
94
|
+
function getCachedMaxChromaAtLH(l, h, gamut, cap) {
|
|
95
|
+
const key = keyMax(l, h, gamut, cap);
|
|
96
|
+
const hit = maxChromaCache.get(key);
|
|
97
|
+
if (typeof hit === "number") {
|
|
98
|
+
return hit;
|
|
99
|
+
}
|
|
100
|
+
const computed = maxInGamutChromaAtLH(l, h, gamut, cap);
|
|
101
|
+
maxChromaCache.set(key, computed);
|
|
102
|
+
return computed;
|
|
103
|
+
}
|
|
104
|
+
function maxInGamutChromaAtLH(l, h, gamut, cap) {
|
|
105
|
+
let lo = 0;
|
|
106
|
+
let hi = cap;
|
|
107
|
+
let ok = 0;
|
|
108
|
+
const lFixed = clamp01(l);
|
|
109
|
+
const hFixed = normalizeHue(h);
|
|
110
|
+
for (let i = 0; i < 18; i++) {
|
|
111
|
+
const mid = (lo + hi) / 2;
|
|
112
|
+
const probe = new Color("oklch", [lFixed, mid, hFixed]);
|
|
113
|
+
if (probe.inGamut(gamut)) {
|
|
114
|
+
ok = mid;
|
|
115
|
+
lo = mid;
|
|
116
|
+
} else {
|
|
117
|
+
hi = mid;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return ok;
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
taperChroma
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=taper-chroma.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/color-ramps/lib/taper-chroma.ts"],
|
|
4
|
+
"sourcesContent": ["// npm i colorjs.io\n/**\n * External dependencies\n */\nimport Color from 'colorjs.io';\n\nexport interface TaperChromaOptions {\n\tgamut?: 'p3' | 'srgb'; // target gamut (default \"p3\")\n\talpha?: number; // base fraction of Cmax at target (default 0.62)\n\tcarry?: number; // seed vividness carry exponent \u03B2 in [0..1] (default 0.5)\n\tcUpperBound?: number; // hard search cap for C (default 0.45)\n\t// Continuous taper around the seed (desaturate both sides slightly)\n\tradiusLight?: number; // distance in L where kLight is reached (default 0.20)\n\tradiusDark?: number; // distance in L where kDark is reached (default 0.20)\n\tkLight?: number; // floor multiplier near lighter side (default 0.85)\n\tkDark?: number; // floor multiplier near darker side (default 0.85)\n\t// Achromatic handling\n\thueFallback?: number; // degrees: if seed is achromatic and you still want color\n\tachromaEpsilon?: number; // \u2264 this chroma \u2192 treat as achromatic (default 0.005)\n}\n\n/**\n * Given the seed and the target lightness, tapers the chroma smoothly.\n * - C_intended = Cmax(Lt,H0) * alpha * (seedRelative^carry)\n * - Continuous taper vs |Lt - Ls| to softly reduce chroma for neighbors\n * - Downward-only clamp on C (preserve L & H)\n * @param seed\n * @param lTarget\n * @param options\n */\nexport function taperChroma(\n\tseed: Color, // already OKLCH\n\tlTarget: number, // [0..1]\n\toptions: TaperChromaOptions = {}\n): { l: number; c: number } {\n\tconst gamut = options.gamut ?? 'p3';\n\tconst alpha = options.alpha ?? 0.65; // 0.7-0.8 works well for accent surface\n\tconst carry = options.carry ?? 0.5;\n\tconst cUpperBound = options.cUpperBound ?? 0.45;\n\tconst radiusLight = options.radiusLight ?? 0.2;\n\tconst radiusDark = options.radiusDark ?? 0.2;\n\tconst kLight = options.kLight ?? 0.85;\n\tconst kDark = options.kDark ?? 0.85;\n\tconst achromaEpsilon = options.achromaEpsilon ?? 0.005;\n\n\tconst cSeed = Math.max( 0, seed.oklch.c );\n\tlet hSeed = Number( seed.oklch.h );\n\n\tconst chromaIsTiny = cSeed < achromaEpsilon;\n\tconst hueIsInvalid = ! Number.isFinite( hSeed );\n\n\tif ( chromaIsTiny || hueIsInvalid ) {\n\t\tif ( typeof options.hueFallback === 'number' ) {\n\t\t\thSeed = normalizeHue( options.hueFallback );\n\t\t} else {\n\t\t\t// Respect achromatic intent: grayscale at target L\n\t\t\treturn new Color( 'oklch', [ clamp01( lTarget ), 0, 0 ] );\n\t\t}\n\t}\n\n\t// Capacity at seed and target\n\tconst lSeed = clamp01( seed.oklch.l );\n\tconst cmaxSeed = getCachedMaxChromaAtLH( lSeed, hSeed, gamut, cUpperBound );\n\tconst cmaxTarget = getCachedMaxChromaAtLH(\n\t\tclamp01( lTarget ),\n\t\thSeed,\n\t\tgamut,\n\t\tcUpperBound\n\t);\n\n\t// Seed vividness ratio (hue-fair normalization)\n\tlet seedRelative = 0;\n\tconst denom = cmaxSeed > 0 ? cmaxSeed : 1e-6;\n\tseedRelative = clamp01( cSeed / denom );\n\n\t// Intended chroma from local capacity, tempered by seed vividness\n\tconst cIntendedBase = alpha * cmaxTarget;\n\tconst cWithCarry =\n\t\tcIntendedBase * Math.pow( seedRelative, clamp01( carry ) );\n\n\t// Gentle, symmetric desaturation vs distance in L\n\tconst t = continuousTaper( lSeed, lTarget, {\n\t\tradiusLight,\n\t\tradiusDark,\n\t\tkLight,\n\t\tkDark,\n\t} );\n\tlet cPlanned = cWithCarry * t;\n\n\t// Downward-only clamp (preserve L & H)\n\tconst lOut = clamp01( lTarget );\n\tconst candidate = new Color( 'oklch', [ lOut, cPlanned, hSeed ] );\n\tif ( ! candidate.inGamut( gamut ) ) {\n\t\tconst cap = Math.min( cPlanned, cUpperBound );\n\t\tcPlanned = getCachedMaxChromaAtLH( lOut, hSeed, gamut, cap );\n\t}\n\n\tcPlanned = Math.min( cPlanned, cSeed );\n\n\treturn { l: lOut, c: cPlanned };\n}\n\n/* ---------------- helpers & caches ---------------- */\n\nfunction clamp01( x: number ): number {\n\tif ( x < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( x > 1 ) {\n\t\treturn 1;\n\t}\n\treturn x;\n}\nfunction normalizeHue( h: number ): number {\n\tlet hue = h % 360;\n\tif ( hue < 0 ) {\n\t\thue += 360;\n\t}\n\treturn hue;\n}\nfunction raisedCosine( u: number ): number {\n\tconst x = clamp01( u );\n\treturn 0.5 - 0.5 * Math.cos( Math.PI * x );\n}\n\n/**\n * smooth, distance-from-seed chroma taper (raised-cosine per side)\n * @param seedL\n * @param targetL\n * @param opts\n * @param opts.radiusLight\n * @param opts.radiusDark\n * @param opts.kLight\n * @param opts.kDark\n */\nfunction continuousTaper(\n\tseedL: number,\n\ttargetL: number,\n\topts: {\n\t\tradiusLight: number;\n\t\tradiusDark: number;\n\t\tkLight: number;\n\t\tkDark: number;\n\t}\n): number {\n\tconst d = targetL - seedL;\n\tif ( d >= 0 ) {\n\t\tconst u = opts.radiusLight > 0 ? Math.abs( d ) / opts.radiusLight : 1;\n\t\tconst w = raisedCosine( u > 1 ? 1 : u );\n\t\treturn 1 - ( 1 - opts.kLight ) * w;\n\t}\n\tconst u = opts.radiusDark > 0 ? Math.abs( d ) / opts.radiusDark : 1;\n\tconst w = raisedCosine( u > 1 ? 1 : u );\n\treturn 1 - ( 1 - opts.kDark ) * w;\n}\n\n/* ---- chroma-capacity queries with small caches ---- */\n\nconst maxChromaCache = new Map< string, number >();\n\nfunction keyMax(\n\tl: number,\n\th: number,\n\tgamut: 'p3' | 'srgb',\n\tcap: number\n): string {\n\t// Quantize to keep cache compact\n\tconst lq = quantize( l, 1e-3 );\n\tconst hq = quantize( normalizeHue( h ), 1e-1 );\n\tconst cq = quantize( cap, 1e-3 );\n\treturn `${ gamut }|L:${ lq }|H:${ hq }|cap:${ cq }`;\n}\nfunction quantize( x: number, step: number ): number {\n\tconst k = Math.round( x / step );\n\treturn k * step;\n}\n\nfunction getCachedMaxChromaAtLH(\n\tl: number,\n\th: number,\n\tgamut: 'p3' | 'srgb',\n\tcap: number\n): number {\n\tconst key = keyMax( l, h, gamut, cap );\n\tconst hit = maxChromaCache.get( key );\n\tif ( typeof hit === 'number' ) {\n\t\treturn hit;\n\t}\n\n\tconst computed = maxInGamutChromaAtLH( l, h, gamut, cap );\n\tmaxChromaCache.set( key, computed );\n\treturn computed;\n}\n\n/**\n * Binary-search the max in-gamut chroma at fixed (L,H) in the target gamut\n * @param l\n * @param h\n * @param gamut\n * @param cap\n */\nfunction maxInGamutChromaAtLH(\n\tl: number,\n\th: number,\n\tgamut: 'p3' | 'srgb',\n\tcap: number\n): number {\n\tlet lo = 0;\n\tlet hi = cap;\n\tlet ok = 0;\n\n\tconst lFixed = clamp01( l );\n\tconst hFixed = normalizeHue( h );\n\n\tfor ( let i = 0; i < 18; i++ ) {\n\t\tconst mid = ( lo + hi ) / 2;\n\t\tconst probe = new Color( 'oklch', [ lFixed, mid, hFixed ] );\n\t\tif ( probe.inGamut( gamut ) ) {\n\t\t\tok = mid;\n\t\t\tlo = mid;\n\t\t} else {\n\t\t\thi = mid;\n\t\t}\n\t}\n\treturn ok;\n}\n"],
|
|
5
|
+
"mappings": "AAIA,OAAO,WAAW;AA0BX,SAAS,YACf,MACA,SACA,UAA8B,CAAC,GACJ;AAC3B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,SAAS,QAAQ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AAM,OAAQ,GAAG,GAAG,OAAO,GAAI;AACrC,QAAM,MAAM,eAAe,IAAK,GAAI;AACpC,MAAK,OAAO,QAAQ,UAAW;AAC9B,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,qBAAsB,GAAG,GAAG,OAAO,GAAI;AACxD,iBAAe,IAAK,KAAK,QAAS;AAClC,SAAO;AACR;AASA,SAAS,qBACR,GACA,GACA,OACA,KACS;AACT,MAAI,KAAK;AACT,MAAI,KAAK;AACT,MAAI,KAAK;AAET,QAAM,SAAS,QAAS,CAAE;AAC1B,QAAM,SAAS,aAAc,CAAE;AAE/B,WAAU,IAAI,GAAG,IAAI,IAAI,KAAM;AAC9B,UAAM,OAAQ,KAAK,MAAO;AAC1B,UAAM,QAAQ,IAAI,MAAO,SAAS,CAAE,QAAQ,KAAK,MAAO,CAAE;AAC1D,QAAK,MAAM,QAAS,KAAM,GAAI;AAC7B,WAAK;AACL,WAAK;AAAA,IACN,OAAO;AACN,WAAK;AAAA,IACN;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
|
+
"names": ["u", "w"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WHITE,
|
|
3
|
+
BLACK,
|
|
4
|
+
UNIVERSAL_CONTRAST_TOPUP,
|
|
5
|
+
WHITE_TEXT_CONTRAST_MARGIN,
|
|
6
|
+
ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS
|
|
7
|
+
} from "./constants";
|
|
8
|
+
import { getCachedContrast } from "./cache-utils";
|
|
9
|
+
const clampToGamut = (c) => c.toGamut({ space: "p3", method: "css" }).to("oklch");
|
|
10
|
+
function buildDependencyGraph(config) {
|
|
11
|
+
const dependencies = /* @__PURE__ */ new Map();
|
|
12
|
+
const dependents = /* @__PURE__ */ new Map();
|
|
13
|
+
Object.keys(config).forEach((step) => {
|
|
14
|
+
dependencies.set(step, []);
|
|
15
|
+
});
|
|
16
|
+
dependents.set("seed", []);
|
|
17
|
+
Object.keys(config).forEach((step) => {
|
|
18
|
+
dependents.set(step, []);
|
|
19
|
+
});
|
|
20
|
+
Object.entries(config).forEach(([stepName, stepConfig]) => {
|
|
21
|
+
const step = stepName;
|
|
22
|
+
const reference = stepConfig.contrast.reference;
|
|
23
|
+
dependencies.get(step).push(reference);
|
|
24
|
+
dependents.get(reference).push(step);
|
|
25
|
+
if (stepConfig.sameAsIfPossible) {
|
|
26
|
+
dependencies.get(step).push(stepConfig.sameAsIfPossible);
|
|
27
|
+
dependents.get(stepConfig.sameAsIfPossible).push(step);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return { dependencies, dependents };
|
|
31
|
+
}
|
|
32
|
+
function sortByDependency(config) {
|
|
33
|
+
const { dependents } = buildDependencyGraph(config);
|
|
34
|
+
const result = [];
|
|
35
|
+
const visited = /* @__PURE__ */ new Set();
|
|
36
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
37
|
+
function visit(node) {
|
|
38
|
+
if (visiting.has(node)) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Circular dependency detected involving step: ${String(
|
|
41
|
+
node
|
|
42
|
+
)}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (visited.has(node)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
visiting.add(node);
|
|
49
|
+
const nodeDependents = dependents.get(node) || [];
|
|
50
|
+
nodeDependents.forEach((dependent) => {
|
|
51
|
+
visit(dependent);
|
|
52
|
+
});
|
|
53
|
+
visiting.delete(node);
|
|
54
|
+
visited.add(node);
|
|
55
|
+
if (node !== "seed") {
|
|
56
|
+
result.unshift(node);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
visit("seed");
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
function computeBetterFgColorDirection(seed, preferLighter) {
|
|
63
|
+
const contrastAgainstBlack = getCachedContrast(seed, BLACK);
|
|
64
|
+
const contrastAgainstWhite = getCachedContrast(seed, WHITE);
|
|
65
|
+
return contrastAgainstBlack > contrastAgainstWhite + (preferLighter ? WHITE_TEXT_CONTRAST_MARGIN : 0) ? { better: "darker", worse: "lighter" } : { better: "lighter", worse: "darker" };
|
|
66
|
+
}
|
|
67
|
+
function adjustContrastTarget(target) {
|
|
68
|
+
if (target === 1) {
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
return target + UNIVERSAL_CONTRAST_TOPUP;
|
|
72
|
+
}
|
|
73
|
+
function clampAccentScaleReferenceLightness(rawLightness, direction) {
|
|
74
|
+
const thresholds = ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS[direction];
|
|
75
|
+
return Math.max(thresholds.min, Math.min(thresholds.max, rawLightness));
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
adjustContrastTarget,
|
|
79
|
+
clampAccentScaleReferenceLightness,
|
|
80
|
+
clampToGamut,
|
|
81
|
+
computeBetterFgColorDirection,
|
|
82
|
+
sortByDependency
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/color-ramps/lib/utils.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type Color from 'colorjs.io';\n\n/**\n * Internal dependencies\n */\nimport {\n\tWHITE,\n\tBLACK,\n\tUNIVERSAL_CONTRAST_TOPUP,\n\tWHITE_TEXT_CONTRAST_MARGIN,\n\tACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS,\n} from './constants';\nimport type { Ramp, RampStepConfig, RampDirection } from './types';\nimport { getCachedContrast } from './cache-utils';\n\n/**\n * Make sure that a color is valid in the p3 gamut, and converts it to oklch.\n * @param c\n */\nexport const clampToGamut = ( c: Color ) =>\n\tc\n\t\t.toGamut( { space: 'p3', method: 'css' } ) // map into Display-P3 using CSS OKLCH method\n\t\t.to( 'oklch' );\n\n/**\n * Build a dependency graph from the steps configuration\n * @param config - The steps configuration object\n */\nfunction buildDependencyGraph( config: Record< keyof Ramp, RampStepConfig > ): {\n\tdependencies: Map< keyof Ramp, ( keyof Ramp | 'seed' )[] >;\n\tdependents: Map< keyof Ramp | 'seed', ( keyof Ramp )[] >;\n} {\n\tconst dependencies = new Map< keyof Ramp, ( keyof Ramp | 'seed' )[] >();\n\tconst dependents = new Map< keyof Ramp | 'seed', ( keyof Ramp )[] >();\n\n\t// Initialize maps\n\tObject.keys( config ).forEach( ( step ) => {\n\t\tdependencies.set( step as keyof Ramp, [] );\n\t} );\n\tdependents.set( 'seed', [] );\n\tObject.keys( config ).forEach( ( step ) => {\n\t\tdependents.set( step as keyof Ramp, [] );\n\t} );\n\n\t// Build the graph\n\tObject.entries( config ).forEach( ( [ stepName, stepConfig ] ) => {\n\t\tconst step = stepName as keyof Ramp;\n\t\tconst reference = stepConfig.contrast.reference;\n\n\t\tdependencies.get( step )!.push( reference );\n\t\tdependents.get( reference )!.push( step );\n\n\t\t// Add dependency for sameAsIfPossible\n\t\tif ( stepConfig.sameAsIfPossible ) {\n\t\t\tdependencies.get( step )!.push( stepConfig.sameAsIfPossible );\n\t\t\tdependents.get( stepConfig.sameAsIfPossible )!.push( step );\n\t\t}\n\t} );\n\n\treturn { dependencies, dependents };\n}\n\n/**\n * Topologically sort steps based on their dependencies\n * @param config - The steps configuration object\n */\nexport function sortByDependency(\n\tconfig: Record< keyof Ramp, RampStepConfig >\n): ( keyof Ramp )[] {\n\tconst { dependents } = buildDependencyGraph( config );\n\tconst result: ( keyof Ramp )[] = [];\n\tconst visited = new Set< keyof Ramp | 'seed' >();\n\tconst visiting = new Set< keyof Ramp | 'seed' >();\n\n\tfunction visit( node: keyof Ramp | 'seed' ): void {\n\t\tif ( visiting.has( node ) ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Circular dependency detected involving step: ${ String(\n\t\t\t\t\tnode\n\t\t\t\t) }`\n\t\t\t);\n\t\t}\n\t\tif ( visited.has( node ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvisiting.add( node );\n\n\t\t// Visit all dependents (steps that depend on this node)\n\t\tconst nodeDependents = dependents.get( node ) || [];\n\t\tnodeDependents.forEach( ( dependent ) => {\n\t\t\tvisit( dependent );\n\t\t} );\n\n\t\tvisiting.delete( node );\n\t\tvisited.add( node );\n\n\t\t// Add to result only if it's a step (not 'seed')\n\t\tif ( node !== 'seed' ) {\n\t\t\tresult.unshift( node ); // Add to front for correct topological order\n\t\t}\n\t}\n\n\t// Start with seed - this will recursively visit all reachable nodes\n\tvisit( 'seed' );\n\n\treturn result;\n}\n\n/**\n * Finds out whether a lighter or a darker foreground color achieves a better\n * contrast against the seed\n * @param seed\n * @param preferLighter Whether the check should favor white foreground color\n * @return An object with \"better\" and \"worse\" properties, each holding a\n * ramp direction value.\n */\nexport function computeBetterFgColorDirection(\n\tseed: Color,\n\tpreferLighter?: boolean\n): {\n\tbetter: RampDirection;\n\tworse: RampDirection;\n} {\n\tconst contrastAgainstBlack = getCachedContrast( seed, BLACK );\n\tconst contrastAgainstWhite = getCachedContrast( seed, WHITE );\n\n\treturn contrastAgainstBlack >\n\t\tcontrastAgainstWhite +\n\t\t\t( preferLighter ? WHITE_TEXT_CONTRAST_MARGIN : 0 )\n\t\t? { better: 'darker', worse: 'lighter' }\n\t\t: { better: 'lighter', worse: 'darker' };\n}\n\nexport function adjustContrastTarget( target: number ) {\n\tif ( target === 1 ) {\n\t\treturn 1;\n\t}\n\n\t// Add a little top up to take into account any rounding error and algo imprecisions.\n\treturn target + UNIVERSAL_CONTRAST_TOPUP;\n}\n\n/**\n * Prevent the accent scale from referencing a lightness value that\n * would prevent the algorithm from complying with the requirements\n * and cause it to generate unexpected results.\n * @param rawLightness\n * @param direction\n * @return The clamped lightness value\n */\nexport function clampAccentScaleReferenceLightness(\n\trawLightness: number,\n\tdirection: RampDirection\n) {\n\tconst thresholds = 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AAkC;AACjD,QAAK,SAAS,IAAK,IAAK,GAAI;AAC3B,YAAM,IAAI;AAAA,QACT,gDAAiD;AAAA,UAChD;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AACA,QAAK,QAAQ,IAAK,IAAK,GAAI;AAC1B;AAAA,IACD;AAEA,aAAS,IAAK,IAAK;AAGnB,UAAM,iBAAiB,WAAW,IAAK,IAAK,KAAK,CAAC;AAClD,mBAAe,QAAS,CAAE,cAAe;AACxC,YAAO,SAAU;AAAA,IAClB,CAAE;AAEF,aAAS,OAAQ,IAAK;AACtB,YAAQ,IAAK,IAAK;AAGlB,QAAK,SAAS,QAAS;AACtB,aAAO,QAAS,IAAK;AAAA,IACtB;AAAA,EACD;AAGA,QAAO,MAAO;AAEd,SAAO;AACR;AAUO,SAAS,8BACf,MACA,eAIC;AACD,QAAM,uBAAuB,kBAAmB,MAAM,KAAM;AAC5D,QAAM,uBAAuB,kBAAmB,MAAM,KAAM;AAE5D,SAAO,uBACN,wBACG,gBAAgB,6BAA6B,KAC9C,EAAE,QAAQ,UAAU,OAAO,UAAU,IACrC,EAAE,QAAQ,WAAW,OAAO,SAAS;AACzC;AAEO,SAAS,qBAAsB,QAAiB;AACtD,MAAK,WAAW,GAAI;AACnB,WAAO;AAAA,EACR;AAGA,SAAO,SAAS;AACjB;AAUO,SAAS,mCACf,cACA,WACC;AACD,QAAM,aAAa,uCAAwC,SAAU;AACrE,SAAO,KAAK,IAAK,WAAW,KAAK,KAAK,IAAK,WAAW,KAAK,YAAa,CAAE;AAC3E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/context.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeProviderSettings } from './types';\n\ninterface ThemeContextType {\n\tresolvedSettings: ThemeProviderSettings;\n}\n\nexport const ThemeContext = createContext< ThemeContextType >( {\n\tresolvedSettings: {\n\t\tcolor: {},\n\t},\n} );\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,qBAAqB;AAWvB,MAAM,eAAe,cAAmC;AAAA,EAC9D,kBAAkB;AAAA,IACjB,OAAO,CAAC;AAAA,EACT;AACD,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
|
|
2
|
+
const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
3
|
+
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
4
|
+
"@wordpress/theme"
|
|
5
|
+
);
|
|
6
|
+
export {
|
|
7
|
+
lock,
|
|
8
|
+
unlock
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lock-unlock.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/theme'\n\t);\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,wDAAwD;AAE1D,MAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var design_tokens_default = [
|
|
2
|
+
"--wpds-border-radius-x-small",
|
|
3
|
+
"--wpds-border-radius-small",
|
|
4
|
+
"--wpds-border-radius-medium",
|
|
5
|
+
"--wpds-border-radius-large",
|
|
6
|
+
"--wpds-border-width-focus",
|
|
7
|
+
"--wpds-color-bg-surface-neutral",
|
|
8
|
+
"--wpds-color-bg-surface-neutral-strong",
|
|
9
|
+
"--wpds-color-bg-surface-neutral-weak",
|
|
10
|
+
"--wpds-color-bg-surface-brand",
|
|
11
|
+
"--wpds-color-bg-surface-success",
|
|
12
|
+
"--wpds-color-bg-surface-success-weak",
|
|
13
|
+
"--wpds-color-bg-surface-info",
|
|
14
|
+
"--wpds-color-bg-surface-info-weak",
|
|
15
|
+
"--wpds-color-bg-surface-warning",
|
|
16
|
+
"--wpds-color-bg-surface-warning-weak",
|
|
17
|
+
"--wpds-color-bg-surface-error",
|
|
18
|
+
"--wpds-color-bg-surface-error-weak",
|
|
19
|
+
"--wpds-color-bg-interactive-neutral",
|
|
20
|
+
"--wpds-color-bg-interactive-neutral-active",
|
|
21
|
+
"--wpds-color-bg-interactive-neutral-disabled",
|
|
22
|
+
"--wpds-color-bg-interactive-neutral-strong",
|
|
23
|
+
"--wpds-color-bg-interactive-neutral-strong-active",
|
|
24
|
+
"--wpds-color-bg-interactive-neutral-strong-disabled",
|
|
25
|
+
"--wpds-color-bg-interactive-neutral-weak",
|
|
26
|
+
"--wpds-color-bg-interactive-neutral-weak-active",
|
|
27
|
+
"--wpds-color-bg-interactive-neutral-weak-disabled",
|
|
28
|
+
"--wpds-color-bg-interactive-brand",
|
|
29
|
+
"--wpds-color-bg-interactive-brand-active",
|
|
30
|
+
"--wpds-color-bg-interactive-brand-disabled",
|
|
31
|
+
"--wpds-color-bg-interactive-brand-strong",
|
|
32
|
+
"--wpds-color-bg-interactive-brand-strong-active",
|
|
33
|
+
"--wpds-color-bg-interactive-brand-strong-disabled",
|
|
34
|
+
"--wpds-color-bg-interactive-brand-weak",
|
|
35
|
+
"--wpds-color-bg-interactive-brand-weak-active",
|
|
36
|
+
"--wpds-color-bg-interactive-brand-weak-disabled",
|
|
37
|
+
"--wpds-color-bg-track-neutral-weak",
|
|
38
|
+
"--wpds-color-bg-track-neutral",
|
|
39
|
+
"--wpds-color-bg-thumb-neutral-weak",
|
|
40
|
+
"--wpds-color-bg-thumb-neutral-weak-active",
|
|
41
|
+
"--wpds-color-bg-thumb-brand",
|
|
42
|
+
"--wpds-color-bg-thumb-brand-active",
|
|
43
|
+
"--wpds-color-bg-thumb-brand-disabled",
|
|
44
|
+
"--wpds-color-fg-content-neutral",
|
|
45
|
+
"--wpds-color-fg-content-neutral-weak",
|
|
46
|
+
"--wpds-color-fg-interactive-neutral",
|
|
47
|
+
"--wpds-color-fg-interactive-neutral-active",
|
|
48
|
+
"--wpds-color-fg-interactive-neutral-disabled",
|
|
49
|
+
"--wpds-color-fg-interactive-neutral-strong",
|
|
50
|
+
"--wpds-color-fg-interactive-neutral-strong-active",
|
|
51
|
+
"--wpds-color-fg-interactive-neutral-strong-disabled",
|
|
52
|
+
"--wpds-color-fg-interactive-neutral-weak",
|
|
53
|
+
"--wpds-color-fg-interactive-neutral-weak-disabled",
|
|
54
|
+
"--wpds-color-fg-interactive-brand",
|
|
55
|
+
"--wpds-color-fg-interactive-brand-active",
|
|
56
|
+
"--wpds-color-fg-interactive-brand-disabled",
|
|
57
|
+
"--wpds-color-fg-interactive-brand-strong",
|
|
58
|
+
"--wpds-color-fg-interactive-brand-strong-active",
|
|
59
|
+
"--wpds-color-fg-interactive-brand-strong-disabled",
|
|
60
|
+
"--wpds-color-stroke-surface-neutral",
|
|
61
|
+
"--wpds-color-stroke-surface-neutral-weak",
|
|
62
|
+
"--wpds-color-stroke-surface-neutral-strong",
|
|
63
|
+
"--wpds-color-stroke-surface-brand",
|
|
64
|
+
"--wpds-color-stroke-surface-brand-strong",
|
|
65
|
+
"--wpds-color-stroke-surface-success",
|
|
66
|
+
"--wpds-color-stroke-surface-success-strong",
|
|
67
|
+
"--wpds-color-stroke-surface-info",
|
|
68
|
+
"--wpds-color-stroke-surface-info-strong",
|
|
69
|
+
"--wpds-color-stroke-surface-warning",
|
|
70
|
+
"--wpds-color-stroke-surface-warning-strong",
|
|
71
|
+
"--wpds-color-stroke-surface-error",
|
|
72
|
+
"--wpds-color-stroke-surface-error-strong",
|
|
73
|
+
"--wpds-color-stroke-interactive-neutral",
|
|
74
|
+
"--wpds-color-stroke-interactive-neutral-active",
|
|
75
|
+
"--wpds-color-stroke-interactive-neutral-disabled",
|
|
76
|
+
"--wpds-color-stroke-interactive-neutral-strong",
|
|
77
|
+
"--wpds-color-stroke-interactive-brand",
|
|
78
|
+
"--wpds-color-stroke-interactive-brand-active",
|
|
79
|
+
"--wpds-color-stroke-interactive-brand-disabled",
|
|
80
|
+
"--wpds-color-stroke-interactive-error-strong",
|
|
81
|
+
"--wpds-color-stroke-focus-brand",
|
|
82
|
+
"--wpds-elevation-x-small",
|
|
83
|
+
"--wpds-elevation-small",
|
|
84
|
+
"--wpds-elevation-medium",
|
|
85
|
+
"--wpds-elevation-large",
|
|
86
|
+
"--wpds-spacing-05",
|
|
87
|
+
"--wpds-spacing-10",
|
|
88
|
+
"--wpds-spacing-15",
|
|
89
|
+
"--wpds-spacing-20",
|
|
90
|
+
"--wpds-spacing-30",
|
|
91
|
+
"--wpds-spacing-40",
|
|
92
|
+
"--wpds-spacing-50",
|
|
93
|
+
"--wpds-spacing-60",
|
|
94
|
+
"--wpds-spacing-70",
|
|
95
|
+
"--wpds-spacing-80",
|
|
96
|
+
"--wpds-font-family-heading",
|
|
97
|
+
"--wpds-font-family-body",
|
|
98
|
+
"--wpds-font-family-mono",
|
|
99
|
+
"--wpds-font-size-x-small",
|
|
100
|
+
"--wpds-font-size-small",
|
|
101
|
+
"--wpds-font-size-medium",
|
|
102
|
+
"--wpds-font-size-large",
|
|
103
|
+
"--wpds-font-size-x-large",
|
|
104
|
+
"--wpds-font-size-2x-large",
|
|
105
|
+
"--wpds-font-line-height-x-small",
|
|
106
|
+
"--wpds-font-line-height-small",
|
|
107
|
+
"--wpds-font-line-height-medium",
|
|
108
|
+
"--wpds-font-line-height-large",
|
|
109
|
+
"--wpds-font-line-height-x-large",
|
|
110
|
+
"--wpds-font-line-height-2x-large"
|
|
111
|
+
];
|
|
112
|
+
export {
|
|
113
|
+
design_tokens_default as default
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=design-tokens.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/prebuilt/js/design-tokens.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * This file is generated by the @terrazzo/plugin-known-wpds-css-variables plugin.\n * Do not edit this file directly.\n */\n\nexport default [\n\t'--wpds-border-radius-x-small',\n\t'--wpds-border-radius-small',\n\t'--wpds-border-radius-medium',\n\t'--wpds-border-radius-large',\n\t'--wpds-border-width-focus',\n\t'--wpds-color-bg-surface-neutral',\n\t'--wpds-color-bg-surface-neutral-strong',\n\t'--wpds-color-bg-surface-neutral-weak',\n\t'--wpds-color-bg-surface-brand',\n\t'--wpds-color-bg-surface-success',\n\t'--wpds-color-bg-surface-success-weak',\n\t'--wpds-color-bg-surface-info',\n\t'--wpds-color-bg-surface-info-weak',\n\t'--wpds-color-bg-surface-warning',\n\t'--wpds-color-bg-surface-warning-weak',\n\t'--wpds-color-bg-surface-error',\n\t'--wpds-color-bg-surface-error-weak',\n\t'--wpds-color-bg-interactive-neutral',\n\t'--wpds-color-bg-interactive-neutral-active',\n\t'--wpds-color-bg-interactive-neutral-disabled',\n\t'--wpds-color-bg-interactive-neutral-strong',\n\t'--wpds-color-bg-interactive-neutral-strong-active',\n\t'--wpds-color-bg-interactive-neutral-strong-disabled',\n\t'--wpds-color-bg-interactive-neutral-weak',\n\t'--wpds-color-bg-interactive-neutral-weak-active',\n\t'--wpds-color-bg-interactive-neutral-weak-disabled',\n\t'--wpds-color-bg-interactive-brand',\n\t'--wpds-color-bg-interactive-brand-active',\n\t'--wpds-color-bg-interactive-brand-disabled',\n\t'--wpds-color-bg-interactive-brand-strong',\n\t'--wpds-color-bg-interactive-brand-strong-active',\n\t'--wpds-color-bg-interactive-brand-strong-disabled',\n\t'--wpds-color-bg-interactive-brand-weak',\n\t'--wpds-color-bg-interactive-brand-weak-active',\n\t'--wpds-color-bg-interactive-brand-weak-disabled',\n\t'--wpds-color-bg-track-neutral-weak',\n\t'--wpds-color-bg-track-neutral',\n\t'--wpds-color-bg-thumb-neutral-weak',\n\t'--wpds-color-bg-thumb-neutral-weak-active',\n\t'--wpds-color-bg-thumb-brand',\n\t'--wpds-color-bg-thumb-brand-active',\n\t'--wpds-color-bg-thumb-brand-disabled',\n\t'--wpds-color-fg-content-neutral',\n\t'--wpds-color-fg-content-neutral-weak',\n\t'--wpds-color-fg-interactive-neutral',\n\t'--wpds-color-fg-interactive-neutral-active',\n\t'--wpds-color-fg-interactive-neutral-disabled',\n\t'--wpds-color-fg-interactive-neutral-strong',\n\t'--wpds-color-fg-interactive-neutral-strong-active',\n\t'--wpds-color-fg-interactive-neutral-strong-disabled',\n\t'--wpds-color-fg-interactive-neutral-weak',\n\t'--wpds-color-fg-interactive-neutral-weak-disabled',\n\t'--wpds-color-fg-interactive-brand',\n\t'--wpds-color-fg-interactive-brand-active',\n\t'--wpds-color-fg-interactive-brand-disabled',\n\t'--wpds-color-fg-interactive-brand-strong',\n\t'--wpds-color-fg-interactive-brand-strong-active',\n\t'--wpds-color-fg-interactive-brand-strong-disabled',\n\t'--wpds-color-stroke-surface-neutral',\n\t'--wpds-color-stroke-surface-neutral-weak',\n\t'--wpds-color-stroke-surface-neutral-strong',\n\t'--wpds-color-stroke-surface-brand',\n\t'--wpds-color-stroke-surface-brand-strong',\n\t'--wpds-color-stroke-surface-success',\n\t'--wpds-color-stroke-surface-success-strong',\n\t'--wpds-color-stroke-surface-info',\n\t'--wpds-color-stroke-surface-info-strong',\n\t'--wpds-color-stroke-surface-warning',\n\t'--wpds-color-stroke-surface-warning-strong',\n\t'--wpds-color-stroke-surface-error',\n\t'--wpds-color-stroke-surface-error-strong',\n\t'--wpds-color-stroke-interactive-neutral',\n\t'--wpds-color-stroke-interactive-neutral-active',\n\t'--wpds-color-stroke-interactive-neutral-disabled',\n\t'--wpds-color-stroke-interactive-neutral-strong',\n\t'--wpds-color-stroke-interactive-brand',\n\t'--wpds-color-stroke-interactive-brand-active',\n\t'--wpds-color-stroke-interactive-brand-disabled',\n\t'--wpds-color-stroke-interactive-error-strong',\n\t'--wpds-color-stroke-focus-brand',\n\t'--wpds-elevation-x-small',\n\t'--wpds-elevation-small',\n\t'--wpds-elevation-medium',\n\t'--wpds-elevation-large',\n\t'--wpds-spacing-05',\n\t'--wpds-spacing-10',\n\t'--wpds-spacing-15',\n\t'--wpds-spacing-20',\n\t'--wpds-spacing-30',\n\t'--wpds-spacing-40',\n\t'--wpds-spacing-50',\n\t'--wpds-spacing-60',\n\t'--wpds-spacing-70',\n\t'--wpds-spacing-80',\n\t'--wpds-font-family-heading',\n\t'--wpds-font-family-body',\n\t'--wpds-font-family-mono',\n\t'--wpds-font-size-x-small',\n\t'--wpds-font-size-small',\n\t'--wpds-font-size-medium',\n\t'--wpds-font-size-large',\n\t'--wpds-font-size-x-large',\n\t'--wpds-font-size-2x-large',\n\t'--wpds-font-line-height-x-small',\n\t'--wpds-font-line-height-small',\n\t'--wpds-font-line-height-medium',\n\t'--wpds-font-line-height-large',\n\t'--wpds-font-line-height-x-large',\n\t'--wpds-font-line-height-2x-large',\n];\n"],
|
|
5
|
+
"mappings": "AAKA,IAAO,wBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|