@adea-ai/themes 0.11.9 → 0.11.13
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/dist/accents.d.ts +19 -19
- package/dist/accents.d.ts.map +1 -1
- package/dist/accents.js +45 -93
- package/dist/accents.js.map +1 -1
- package/dist/adapters/base24.d.ts +21 -12
- package/dist/adapters/base24.d.ts.map +1 -1
- package/dist/adapters/base24.js +47 -72
- package/dist/adapters/base24.js.map +1 -1
- package/dist/adapters/css-variables.d.ts +29 -0
- package/dist/adapters/css-variables.d.ts.map +1 -0
- package/dist/adapters/css-variables.js +56 -0
- package/dist/adapters/css-variables.js.map +1 -0
- package/dist/adapters/css.d.ts +2 -4
- package/dist/adapters/css.d.ts.map +1 -1
- package/dist/adapters/css.js +7 -39
- package/dist/adapters/css.js.map +1 -1
- package/dist/adapters/shadcn.d.ts +8 -4
- package/dist/adapters/shadcn.d.ts.map +1 -1
- package/dist/adapters/shadcn.js +38 -57
- package/dist/adapters/shadcn.js.map +1 -1
- package/dist/adapters/shiki.d.ts +2 -10
- package/dist/adapters/shiki.d.ts.map +1 -1
- package/dist/adapters/shiki.js +16 -29
- package/dist/adapters/shiki.js.map +1 -1
- package/dist/adapters/tailwind.d.ts +3 -3
- package/dist/adapters/tailwind.d.ts.map +1 -1
- package/dist/adapters/tailwind.js +7 -28
- package/dist/adapters/tailwind.js.map +1 -1
- package/dist/adapters/xterm.d.ts.map +1 -1
- package/dist/adapters/xterm.js +9 -21
- package/dist/adapters/xterm.js.map +1 -1
- package/dist/base24-synthesis.d.ts +31 -0
- package/dist/base24-synthesis.d.ts.map +1 -0
- package/dist/base24-synthesis.js +25 -0
- package/dist/base24-synthesis.js.map +1 -0
- package/dist/derive.d.ts +1 -1
- package/dist/derive.d.ts.map +1 -1
- package/dist/derive.js +11 -26
- package/dist/derive.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/normalize.d.ts +0 -8
- package/dist/normalize.d.ts.map +1 -1
- package/dist/normalize.js +105 -232
- package/dist/normalize.js.map +1 -1
- package/dist/oklch.d.ts +1 -7
- package/dist/oklch.d.ts.map +1 -1
- package/dist/oklch.js +15 -35
- package/dist/oklch.js.map +1 -1
- package/dist/policy.d.ts +14 -4
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +16 -4
- package/dist/policy.js.map +1 -1
- package/dist/render.d.ts +30 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +74 -0
- package/dist/render.js.map +1 -0
- package/dist/sources.d.ts +26 -33
- package/dist/sources.d.ts.map +1 -1
- package/dist/sources.js +136 -305
- package/dist/sources.js.map +1 -1
- package/dist/step-search.d.ts +10 -0
- package/dist/step-search.d.ts.map +1 -0
- package/dist/step-search.js +21 -0
- package/dist/step-search.js.map +1 -0
- package/dist/theme-token-projection-script.js +1 -1
- package/dist/theme-token-projection.d.ts +34 -3
- package/dist/theme-token-projection.d.ts.map +1 -1
- package/dist/theme-token-projection.js +78 -2
- package/dist/theme-token-projection.js.map +1 -1
- package/dist/validate.d.ts +12 -17
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +17 -63
- package/dist/validate.js.map +1 -1
- package/package.json +1 -1
- package/src/accents.ts +57 -96
- package/src/adapters/base24.ts +53 -75
- package/src/adapters/css-variables.ts +67 -0
- package/src/adapters/css.ts +9 -54
- package/src/adapters/shadcn.ts +34 -60
- package/src/adapters/shiki.ts +17 -30
- package/src/adapters/tailwind.ts +7 -37
- package/src/adapters/xterm.ts +9 -21
- package/src/base24-synthesis.ts +29 -0
- package/src/derive.ts +12 -27
- package/src/index.ts +6 -5
- package/src/normalize.ts +140 -267
- package/src/oklch.ts +20 -35
- package/src/policy.ts +18 -4
- package/src/render.ts +82 -0
- package/src/sources.ts +160 -330
- package/src/step-search.ts +25 -0
- package/src/theme-token-projection.ts +126 -12
- package/src/validate.ts +31 -74
- package/dist/theme-token-projection-core.d.ts +0 -35
- package/dist/theme-token-projection-core.d.ts.map +0 -1
- package/dist/theme-token-projection-core.js +0 -84
- package/dist/theme-token-projection-core.js.map +0 -1
- package/src/theme-token-projection-core.ts +0 -131
package/dist/accents.d.ts
CHANGED
|
@@ -11,14 +11,10 @@
|
|
|
11
11
|
*
|
|
12
12
|
* They are colour data with a light/dark pair per preset — structurally the same
|
|
13
13
|
* thing as a theme's primary, and the last colour a consumer should have to author
|
|
14
|
-
* itself.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* button hovered backwards and picking any accent silently fixed it.
|
|
19
|
-
*
|
|
20
|
-
* Here the values and the derivation are one module, so a consumer emits both from
|
|
21
|
-
* the same rule and cannot produce that disagreement.
|
|
14
|
+
* itself. With the values and the derivation in one module, a consumer emits the
|
|
15
|
+
* preset list and its CSS from the same rule, and the two cannot drift apart — as
|
|
16
|
+
* they did when a consumer hand-wrote both and its default primary hovered the
|
|
17
|
+
* opposite way to every other accent.
|
|
22
18
|
*
|
|
23
19
|
* ## The hover rule
|
|
24
20
|
*
|
|
@@ -28,7 +24,7 @@
|
|
|
28
24
|
* Two rules were tried here before this one, and both are worth recording because
|
|
29
25
|
* each looks right until it is measured:
|
|
30
26
|
*
|
|
31
|
-
* - **Toward `--background`** —
|
|
27
|
+
* - **Toward `--background`** — inverted in both
|
|
32
28
|
* appearances: it moves the button toward the page it sits on, so a hovered button
|
|
33
29
|
* recedes.
|
|
34
30
|
* - **Toward `--foreground`** — correct in principle, since the foreground is
|
|
@@ -126,7 +122,7 @@ export declare const ACCENT_HOVER_STEP = 0.05;
|
|
|
126
122
|
* be written as a mix — see {@link ACCENT_HOVER_STEP}. That means it does **not**
|
|
127
123
|
* follow `--primary` on its own, so a consumer that applies themes at runtime has to
|
|
128
124
|
* write this token too; the alternative is a hover left over from the previous
|
|
129
|
-
* theme's primary. `
|
|
125
|
+
* theme's primary. `shadcnVariables` includes it for that reason.
|
|
130
126
|
*
|
|
131
127
|
* The direction is away from the canvas: darker on a light theme, lighter on a dark
|
|
132
128
|
* one. `shiftLightness` keeps chroma and hue and damps chroma near the extremes, so a
|
|
@@ -168,16 +164,20 @@ export declare const ACCENT_SUBTLE_MINIMUM_ALPHA = 4;
|
|
|
168
164
|
*
|
|
169
165
|
* True when `text` and `foreground` both clear `CONTRAST_FLOORS.text` on the tint
|
|
170
166
|
* at `alpha` percent composited over `surface`, for every primary the theme offers
|
|
171
|
-
* and every one in `primaries`. At `alpha` 0 it is the bare surface.
|
|
172
|
-
* normalizer calls this to fit the hover rung, and {@link primarySubtleAlpha} to
|
|
173
|
-
* fit the strength, so the two are measured by one rule.
|
|
167
|
+
* and every one in `primaries`. At `alpha` 0 it is the bare surface.
|
|
174
168
|
*/
|
|
175
169
|
export declare function primaryTintClears(theme: TintedTheme, surface: string, alpha: number, primaries?: readonly string[]): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* {@link primaryTintClears} for one theme and set of primaries, measuring the
|
|
172
|
+
* foregrounds and the offered primaries once for every surface and alpha it is
|
|
173
|
+
* asked about. The normalizer uses it to fit the interaction rungs.
|
|
174
|
+
*/
|
|
175
|
+
export declare function tintCheck(theme: TintedTheme, primaries?: readonly string[]): (surface: string, alpha: number) => boolean;
|
|
176
176
|
/**
|
|
177
177
|
* The tint strength a theme can carry, as a whole percentage.
|
|
178
178
|
*
|
|
179
|
-
* The appearance's {@link ACCENT_SUBTLE_ALPHA} ceiling, lowered
|
|
180
|
-
*
|
|
179
|
+
* The appearance's {@link ACCENT_SUBTLE_ALPHA} ceiling, lowered to the highest whole
|
|
180
|
+
* percentage at which body text clears `CONTRAST_FLOORS.text` on the tint over every floored
|
|
181
181
|
* surface, hover rung included, for every primary the theme offers. One value per
|
|
182
182
|
* theme rather than one per accent, so switching between offered accents at runtime
|
|
183
183
|
* needs no new tint: the expression follows `--primary` and the strength already
|
|
@@ -201,10 +201,10 @@ export declare function primarySubtleAlpha(theme: TintedTheme, primaries?: reado
|
|
|
201
201
|
* it as `primaries` to have the strength measured for it as well.
|
|
202
202
|
*
|
|
203
203
|
* Passing only an **appearance** gives the {@link ACCENT_SUBTLE_ALPHA} ceiling for
|
|
204
|
-
* that appearance, unmeasured.
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
204
|
+
* that appearance, unmeasured. It is not legible on every theme — One Dark's body
|
|
205
|
+
* text on its own primary's tint over a card measures 4.34:1 at the dark ceiling —
|
|
206
|
+
* so it is kept for a consumer without a theme object in hand, not as the default
|
|
207
|
+
* to reach for.
|
|
208
208
|
*/
|
|
209
209
|
export declare function primarySubtleCss(target: ThemeAppearance | TintedTheme, primaryVariable?: string, primaries?: readonly string[]): string;
|
|
210
210
|
/**
|
package/dist/accents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accents.d.ts","sourceRoot":"","sources":["../src/accents.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"accents.d.ts","sourceRoot":"","sources":["../src/accents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAW,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAU7F,OAAO,EACL,iBAAiB,EAKlB,MAAM,aAAa,CAAA;AAIpB,0DAA0D;AAC1D,MAAM,MAAM,YAAY,GAAG;IACzB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAA;IACnB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,EAAE,SAAS,YAAY,EA2CzC,CAAA;AAEF,mFAAmF;A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KAAK,OAAO,CAY7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAQhG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,eAAe,GAAG,WAAW,EACrC,eAAe,SAAc,EAC7B,SAAS,GAAE,SAAS,MAAM,EAAO,GAChC,MAAM,CAIR;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AA2ChE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,YAAY,EAAE,CAgBpF;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,MAAM,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY;AACpB;;;;GAIG;AACH,MAAM,EAAE,eAAe,GAAG,WAAW;AACrC,qFAAqF;AACrF,eAAe,SAAc,GAC5B,WAAW,CAab"}
|
package/dist/accents.js
CHANGED
|
@@ -11,14 +11,10 @@
|
|
|
11
11
|
*
|
|
12
12
|
* They are colour data with a light/dark pair per preset — structurally the same
|
|
13
13
|
* thing as a theme's primary, and the last colour a consumer should have to author
|
|
14
|
-
* itself.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* button hovered backwards and picking any accent silently fixed it.
|
|
19
|
-
*
|
|
20
|
-
* Here the values and the derivation are one module, so a consumer emits both from
|
|
21
|
-
* the same rule and cannot produce that disagreement.
|
|
14
|
+
* itself. With the values and the derivation in one module, a consumer emits the
|
|
15
|
+
* preset list and its CSS from the same rule, and the two cannot drift apart — as
|
|
16
|
+
* they did when a consumer hand-wrote both and its default primary hovered the
|
|
17
|
+
* opposite way to every other accent.
|
|
22
18
|
*
|
|
23
19
|
* ## The hover rule
|
|
24
20
|
*
|
|
@@ -28,7 +24,7 @@
|
|
|
28
24
|
* Two rules were tried here before this one, and both are worth recording because
|
|
29
25
|
* each looks right until it is measured:
|
|
30
26
|
*
|
|
31
|
-
* - **Toward `--background`** —
|
|
27
|
+
* - **Toward `--background`** — inverted in both
|
|
32
28
|
* appearances: it moves the button toward the page it sits on, so a hovered button
|
|
33
29
|
* recedes.
|
|
34
30
|
* - **Toward `--foreground`** — correct in principle, since the foreground is
|
|
@@ -64,8 +60,10 @@
|
|
|
64
60
|
* text sits closest to the floor get a lighter wash, and the colour, the
|
|
65
61
|
* foreground and the surfaces stay exactly as their authors wrote them.
|
|
66
62
|
*/
|
|
67
|
-
import {
|
|
68
|
-
import { ACCENT_PREFERENCE, CONTRAST_FLOORS, MINIMUM_ACCENT_CHROMA, REPAIR_BUDGET, } from './policy.js';
|
|
63
|
+
import { canonical, contrastDirection, contrastRatio, formatOklch, parseColor, shiftLightness, } from './oklch.js';
|
|
64
|
+
import { ACCENT_PREFERENCE, CONTRAST_FLOORS, MINIMUM_ACCENT_CHROMA, REPAIR_BUDGET, REPAIR_STEP, } from './policy.js';
|
|
65
|
+
import { compositeOver, mostContrasting, renderedColor } from './render.js';
|
|
66
|
+
import { smallestOffset } from './step-search.js';
|
|
69
67
|
/**
|
|
70
68
|
* The presets.
|
|
71
69
|
*
|
|
@@ -144,8 +142,7 @@ export function accentForeground(accent) {
|
|
|
144
142
|
return 'oklch(1 0 0)';
|
|
145
143
|
const black = { l: 0, c: 0, h: 0 };
|
|
146
144
|
const white = { l: 1, c: 0, h: 0 };
|
|
147
|
-
|
|
148
|
-
return formatOklch(best);
|
|
145
|
+
return formatOklch(mostContrasting(fill, [black, white]));
|
|
149
146
|
}
|
|
150
147
|
/** The contrast the chosen label achieves, for validation and reporting. */
|
|
151
148
|
export function accentForegroundContrast(accent) {
|
|
@@ -174,7 +171,7 @@ export const ACCENT_HOVER_STEP = 0.05;
|
|
|
174
171
|
* be written as a mix — see {@link ACCENT_HOVER_STEP}. That means it does **not**
|
|
175
172
|
* follow `--primary` on its own, so a consumer that applies themes at runtime has to
|
|
176
173
|
* write this token too; the alternative is a hover left over from the previous
|
|
177
|
-
* theme's primary. `
|
|
174
|
+
* theme's primary. `shadcnVariables` includes it for that reason.
|
|
178
175
|
*
|
|
179
176
|
* The direction is away from the canvas: darker on a light theme, lighter on a dark
|
|
180
177
|
* one. `shiftLightness` keeps chroma and hue and damps chroma near the extremes, so a
|
|
@@ -254,60 +251,37 @@ function offeredPrimaries(theme) {
|
|
|
254
251
|
]),
|
|
255
252
|
];
|
|
256
253
|
}
|
|
257
|
-
/** A colour as the screen draws it: through eight-bit sRGB. */
|
|
258
|
-
function rendered(value) {
|
|
259
|
-
const parsed = parseColor(value);
|
|
260
|
-
return parsed ? hexToOklch(oklchToHex(parsed)) : undefined;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* A translucent fill painted over an opaque one, the way a browser paints
|
|
264
|
-
* `color-mix(in oklch, <tint> N%, transparent)`: the mix keeps the tint's colour and
|
|
265
|
-
* takes the share as alpha, and the alpha is composited in gamma-encoded sRGB.
|
|
266
|
-
* Rounded to the eight-bit value that reaches the screen, which is the colour an
|
|
267
|
-
* accessibility audit samples.
|
|
268
|
-
*/
|
|
269
|
-
function compositeTint(tint, surface, alpha) {
|
|
270
|
-
const tintColor = parseColor(tint);
|
|
271
|
-
const surfaceColor = parseColor(surface);
|
|
272
|
-
if (!tintColor || !surfaceColor)
|
|
273
|
-
return undefined;
|
|
274
|
-
const front = oklchToHex(tintColor);
|
|
275
|
-
const back = oklchToHex(surfaceColor);
|
|
276
|
-
const channels = [1, 3, 5].map((offset) => {
|
|
277
|
-
const top = Number.parseInt(front.slice(offset, offset + 2), 16);
|
|
278
|
-
const bottom = Number.parseInt(back.slice(offset, offset + 2), 16);
|
|
279
|
-
return Math.round(top * alpha + bottom * (1 - alpha))
|
|
280
|
-
.toString(16)
|
|
281
|
-
.padStart(2, '0');
|
|
282
|
-
});
|
|
283
|
-
return hexToOklch(`#${channels.join('')}`);
|
|
284
|
-
}
|
|
285
254
|
/**
|
|
286
255
|
* Whether body text holds the floor on a surface under the primary tint.
|
|
287
256
|
*
|
|
288
257
|
* True when `text` and `foreground` both clear `CONTRAST_FLOORS.text` on the tint
|
|
289
258
|
* at `alpha` percent composited over `surface`, for every primary the theme offers
|
|
290
|
-
* and every one in `primaries`. At `alpha` 0 it is the bare surface.
|
|
291
|
-
* normalizer calls this to fit the hover rung, and {@link primarySubtleAlpha} to
|
|
292
|
-
* fit the strength, so the two are measured by one rule.
|
|
259
|
+
* and every one in `primaries`. At `alpha` 0 it is the bare surface.
|
|
293
260
|
*/
|
|
294
261
|
export function primaryTintClears(theme, surface, alpha, primaries = []) {
|
|
295
|
-
|
|
262
|
+
return tintCheck(theme, primaries)(surface, alpha);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* {@link primaryTintClears} for one theme and set of primaries, measuring the
|
|
266
|
+
* foregrounds and the offered primaries once for every surface and alpha it is
|
|
267
|
+
* asked about. The normalizer uses it to fit the interaction rungs.
|
|
268
|
+
*/
|
|
269
|
+
export function tintCheck(theme, primaries = []) {
|
|
270
|
+
const foregrounds = [...new Set([theme.colors.text, theme.colors.foreground])].map(renderedColor);
|
|
296
271
|
if (foregrounds.some((value) => value === undefined))
|
|
297
|
-
return false;
|
|
298
|
-
const tints =
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
272
|
+
return () => false;
|
|
273
|
+
const tints = [...new Set([...offeredPrimaries(theme), ...primaries])];
|
|
274
|
+
const legibleOn = (fill) => fill !== undefined &&
|
|
275
|
+
foregrounds.every((foreground) => contrastRatio(foreground, fill) >= CONTRAST_FLOORS.text);
|
|
276
|
+
return (surface, alpha) => alpha === 0
|
|
277
|
+
? legibleOn(renderedColor(surface))
|
|
278
|
+
: tints.every((tint) => legibleOn(compositeOver(tint, surface, alpha / 100)));
|
|
304
279
|
}
|
|
305
|
-
const subtleAlphaCache = new WeakMap();
|
|
306
280
|
/**
|
|
307
281
|
* The tint strength a theme can carry, as a whole percentage.
|
|
308
282
|
*
|
|
309
|
-
* The appearance's {@link ACCENT_SUBTLE_ALPHA} ceiling, lowered
|
|
310
|
-
*
|
|
283
|
+
* The appearance's {@link ACCENT_SUBTLE_ALPHA} ceiling, lowered to the highest whole
|
|
284
|
+
* percentage at which body text clears `CONTRAST_FLOORS.text` on the tint over every floored
|
|
311
285
|
* surface, hover rung included, for every primary the theme offers. One value per
|
|
312
286
|
* theme rather than one per accent, so switching between offered accents at runtime
|
|
313
287
|
* needs no new tint: the expression follows `--primary` and the strength already
|
|
@@ -319,25 +293,12 @@ const subtleAlphaCache = new WeakMap();
|
|
|
319
293
|
* a product's own brand primary, say. The offered set is always included.
|
|
320
294
|
*/
|
|
321
295
|
export function primarySubtleAlpha(theme, primaries = []) {
|
|
322
|
-
// Theme records are mutable; an identity-only cache can return a strength for
|
|
323
|
-
// colours that are no longer present on the same object.
|
|
324
|
-
const inputs = JSON.stringify([
|
|
325
|
-
theme.appearance,
|
|
326
|
-
theme.colors,
|
|
327
|
-
theme.ansi,
|
|
328
|
-
theme.shadcn,
|
|
329
|
-
ACCENTS,
|
|
330
|
-
primaries,
|
|
331
|
-
]);
|
|
332
|
-
const cached = subtleAlphaCache.get(theme);
|
|
333
|
-
if (cached?.inputs === inputs)
|
|
334
|
-
return cached.alpha;
|
|
335
296
|
const surfaces = tintSurfaces(theme);
|
|
336
|
-
const
|
|
297
|
+
const check = tintCheck(theme, primaries);
|
|
298
|
+
const clears = (alpha) => surfaces.every((surface) => check(surface, alpha));
|
|
337
299
|
let alpha = ACCENT_SUBTLE_ALPHA[theme.appearance];
|
|
338
300
|
while (alpha > 0 && !clears(alpha))
|
|
339
301
|
alpha -= 1;
|
|
340
|
-
subtleAlphaCache.set(theme, { inputs, alpha });
|
|
341
302
|
return alpha;
|
|
342
303
|
}
|
|
343
304
|
/**
|
|
@@ -352,16 +313,15 @@ export function primarySubtleAlpha(theme, primaries = []) {
|
|
|
352
313
|
* it as `primaries` to have the strength measured for it as well.
|
|
353
314
|
*
|
|
354
315
|
* Passing only an **appearance** gives the {@link ACCENT_SUBTLE_ALPHA} ceiling for
|
|
355
|
-
* that appearance, unmeasured.
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
316
|
+
* that appearance, unmeasured. It is not legible on every theme — One Dark's body
|
|
317
|
+
* text on its own primary's tint over a card measures 4.34:1 at the dark ceiling —
|
|
318
|
+
* so it is kept for a consumer without a theme object in hand, not as the default
|
|
319
|
+
* to reach for.
|
|
359
320
|
*/
|
|
360
321
|
export function primarySubtleCss(target, primaryVariable = '--primary', primaries = []) {
|
|
361
322
|
const alpha = typeof target === 'string' ? ACCENT_SUBTLE_ALPHA[target] : primarySubtleAlpha(target, primaries);
|
|
362
323
|
return `color-mix(in oklch, var(${primaryVariable}) ${alpha}%, transparent)`;
|
|
363
324
|
}
|
|
364
|
-
const REPAIR_STEP = 0.002;
|
|
365
325
|
/**
|
|
366
326
|
* A slot's offerable value on one theme: the palette's own colour when it already
|
|
367
327
|
* clears the accent floors on that theme's canvas, otherwise the catalogue's
|
|
@@ -378,27 +338,19 @@ function offeredSlotValue(theme, slot) {
|
|
|
378
338
|
return undefined;
|
|
379
339
|
if (value.c < MINIMUM_ACCENT_CHROMA)
|
|
380
340
|
return undefined;
|
|
381
|
-
// Measured in the canonical form the offer commits, so a repair cannot
|
|
382
|
-
// converge on a value that rounding then pushes back below the floor.
|
|
383
341
|
const clearsFloors = (candidate) => {
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return (contrastRatio(canonical, background) >= CONTRAST_FLOORS.accentRaised &&
|
|
388
|
-
accentForegroundContrast(formatOklch(canonical)) >= CONTRAST_FLOORS.accentForeground);
|
|
342
|
+
const committed = canonical(candidate);
|
|
343
|
+
return (contrastRatio(committed, background) >= CONTRAST_FLOORS.accentRaised &&
|
|
344
|
+
accentForegroundContrast(formatOklch(committed)) >= CONTRAST_FLOORS.accentForeground);
|
|
389
345
|
};
|
|
390
346
|
if (clearsFloors(value))
|
|
391
347
|
return original;
|
|
392
|
-
const
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (clearsFloors(candidate))
|
|
399
|
-
return formatOklch(candidate);
|
|
400
|
-
}
|
|
401
|
-
return undefined;
|
|
348
|
+
const shifted = (offset) => ({ ...value, l: value.l + offset });
|
|
349
|
+
const offset = smallestOffset(REPAIR_STEP, Math.floor(REPAIR_BUDGET.accent / REPAIR_STEP), [contrastDirection(value, background)], (trial) => {
|
|
350
|
+
const candidate = shifted(trial);
|
|
351
|
+
return candidate.l > 0 && candidate.l < 1 && clearsFloors(candidate);
|
|
352
|
+
});
|
|
353
|
+
return offset === undefined ? undefined : formatOklch(shifted(offset));
|
|
402
354
|
}
|
|
403
355
|
/**
|
|
404
356
|
* The accent slots the theme pair offers, ordered by preference, floors enforced.
|
package/dist/accents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accents.js","sourceRoot":"","sources":["../src/accents.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"accents.js","sourceRoot":"","sources":["../src/accents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAIH,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,iBAAiB,EACj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AG,WAAW;IAE7B,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAA;IAC1E,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC7C,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IAChC,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAEpD,OAAO;QACL,OAAO;QACP,iBAAiB,EAAE,gBAAgB,CAAC,KAAK,CAAC;QAC1C,YAAY,EAAE,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC;QAC7C,aAAa,EAAE,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,KAAK,CAAC,CAAC;QACjE,IAAI,EAAE,OAAO;KACd,CAAA;AACH,CAAC"}
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* `base09` (orange) and `base0F` (brown) have no counterpart in the canonical
|
|
22
22
|
* schema: Adea has no "constant" or "deprecated" role, because a UI does not. On
|
|
23
23
|
* export they are re-derived from `red` and `yellow` by a fixed rotation, and
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* `getBase24Scheme` returns the vendored schemes for callers who need the
|
|
25
|
+
* originals byte-for-byte. Round-tripping is therefore lossless for every
|
|
26
26
|
* role Adea models, and explicitly approximate for the two it does not — rather
|
|
27
27
|
* than silently lossy, which is what an unnamed slot would have been.
|
|
28
28
|
*/
|
|
@@ -44,17 +44,16 @@ export interface Base24Scheme {
|
|
|
44
44
|
/**
|
|
45
45
|
* What each slot means, in the specification's own terms.
|
|
46
46
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* the mapping is right.
|
|
47
|
+
* The documentation a reader needs to check the mappings below against the
|
|
48
|
+
* specification.
|
|
50
49
|
*/
|
|
51
50
|
export declare const BASE24_SLOT_MEANING: Readonly<Record<Base24Slot, string>>;
|
|
52
51
|
/**
|
|
53
|
-
*
|
|
52
|
+
* ANSI role → Base24 slot.
|
|
54
53
|
*
|
|
55
|
-
* `black`, `white` and `
|
|
56
|
-
* the background and foreground slots do double duty. The
|
|
57
|
-
*
|
|
54
|
+
* `black`, `brightBlack`, `white` and `brightWhite` are absent because Base24 does
|
|
55
|
+
* not name them: the background and foreground slots do double duty. The
|
|
56
|
+
* normalizer decides those four; see its `buildAnsiRamp` note for why.
|
|
58
57
|
*/
|
|
59
58
|
export declare const BASE24_TO_ANSI: Readonly<{
|
|
60
59
|
readonly red: 'base08';
|
|
@@ -88,9 +87,11 @@ export declare const ANSI_TO_BASE24: Readonly<{
|
|
|
88
87
|
/**
|
|
89
88
|
* How each semantic role is written back to a Base24 slot on export.
|
|
90
89
|
*
|
|
91
|
-
* The
|
|
92
|
-
*
|
|
93
|
-
*
|
|
90
|
+
* The accent and status roles are absent because their slots belong to the ANSI
|
|
91
|
+
* hues: `base08`–`base0E` are written from `BASE24_TO_ANSI`, the colours a terminal
|
|
92
|
+
* reads, not from the repaired UI roles. `base01` receives `black` rather than a
|
|
93
|
+
* role because an ANSI black that equals the background is invisible as foreground
|
|
94
|
+
* text — the defect the import side documents. The
|
|
94
95
|
* surface ladder has no Base24 slot at all, so it is deliberately absent here:
|
|
95
96
|
* Base24 cannot express it, and pretending otherwise by packing four rungs into
|
|
96
97
|
* `base01`/`base02` would make the export lie about what it preserves.
|
|
@@ -117,5 +118,13 @@ export declare function toBase24(theme: AdeaTheme, options?: {
|
|
|
117
118
|
}): Base24Scheme;
|
|
118
119
|
/** Serialises a scheme to the YAML dialect Base24 schemes are published in. */
|
|
119
120
|
export declare function formatBase24Scheme(scheme: Base24Scheme): string;
|
|
121
|
+
/**
|
|
122
|
+
* Reads the YAML dialect Base24 schemes are published in.
|
|
123
|
+
*
|
|
124
|
+
* Hand-written rather than pulled from a YAML library: the format is a fixed set
|
|
125
|
+
* of scalar keys, the package has no runtime dependencies, and a general parser would accept
|
|
126
|
+
* documents this bridge cannot actually honour. Anything outside the specification
|
|
127
|
+
* is rejected loudly instead of being parsed into a half-scheme.
|
|
128
|
+
*/
|
|
120
129
|
export declare function parseBase24Scheme(source: string): Base24Scheme;
|
|
121
130
|
//# sourceMappingURL=base24.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base24.d.ts","sourceRoot":"","sources":["../../src/adapters/base24.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAY,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"base24.d.ts","sourceRoot":"","sources":["../../src/adapters/base24.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAY,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AASxC,+EAA+E;AAC/E,eAAO,MAAM,YAAY,YACvB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,CACA,CAAA;AAEV,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD,uFAAuF;AACvF,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MA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