@adea-ai/themes 0.11.17 → 0.11.19
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/NOTICE +11 -11
- package/README.md +87 -100
- package/dist/accents.d.ts +29 -29
- package/dist/accents.js +28 -28
- package/dist/adapters/base24.d.ts +4 -4
- package/dist/adapters/base24.js +5 -5
- package/dist/adapters/css-variables.d.ts +1 -1
- package/dist/adapters/css-variables.js +1 -1
- package/dist/adapters/css.d.ts +3 -3
- package/dist/adapters/css.js +3 -3
- package/dist/adapters/shadcn.d.ts +8 -9
- package/dist/adapters/shadcn.d.ts.map +1 -1
- package/dist/adapters/shadcn.js +10 -11
- package/dist/adapters/shadcn.js.map +1 -1
- package/dist/adapters/shiki.d.ts +3 -3
- package/dist/adapters/shiki.js +4 -4
- package/dist/adapters/xterm.d.ts +1 -1
- package/dist/adapters/xterm.js +1 -1
- package/dist/catalogue.d.ts +4 -4
- package/dist/catalogue.js +4 -4
- package/dist/derive.d.ts +10 -10
- package/dist/derive.js +14 -14
- package/dist/derive.js.map +1 -1
- package/dist/generated/schemes.d.ts +2 -2
- package/dist/generated/schemes.js +2 -2
- package/dist/normalize.d.ts +9 -9
- package/dist/normalize.js +35 -35
- package/dist/normalize.js.map +1 -1
- package/dist/oklch.d.ts +2 -2
- package/dist/oklch.js +6 -6
- package/dist/oklch.js.map +1 -1
- package/dist/policy.d.ts +3 -3
- package/dist/policy.js +3 -3
- package/dist/schema.d.ts +5 -5
- package/dist/schema.js +4 -4
- package/dist/sources.d.ts +9 -9
- package/dist/sources.js +10 -10
- package/dist/validate.d.ts +8 -8
- package/dist/validate.js +7 -7
- package/dist/validate.js.map +1 -1
- package/package.json +1 -1
- package/src/accents.ts +32 -32
- package/src/adapters/base24.ts +5 -5
- package/src/adapters/css-variables.ts +1 -1
- package/src/adapters/css.ts +3 -3
- package/src/adapters/shadcn.ts +10 -11
- package/src/adapters/shiki.ts +4 -4
- package/src/adapters/xterm.ts +1 -1
- package/src/catalogue.ts +4 -4
- package/src/derive.ts +14 -14
- package/src/generated/schemes.ts +2 -2
- package/src/normalize.ts +40 -40
- package/src/oklch.ts +6 -6
- package/src/policy.ts +3 -3
- package/src/schema.ts +5 -5
- package/src/sources.ts +14 -14
- package/src/validate.ts +9 -9
package/src/accents.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The accent axis.
|
|
3
3
|
*
|
|
4
|
-
* A theme has one interactive colour
|
|
4
|
+
* A theme has one interactive colour, its primary, and the accent axis lets a
|
|
5
5
|
* user replace it without changing the theme. That is a different question from
|
|
6
6
|
* "which palette do you want": a user may like Catppuccin's surfaces and still want
|
|
7
7
|
* a violet primary, and a product may ship a brand colour that has to survive every
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
*
|
|
10
10
|
* ## Why the presets live here
|
|
11
11
|
*
|
|
12
|
-
* They are colour data with a light/dark pair per preset
|
|
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
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
|
|
15
|
+
* preset list and its CSS from the same rule, and the two cannot drift apart, as
|
|
16
16
|
* they did when a consumer hand-wrote both and its default primary hovered the
|
|
17
17
|
* opposite way to every other accent.
|
|
18
18
|
*
|
|
@@ -24,39 +24,39 @@
|
|
|
24
24
|
* Two rules were tried here before this one, and both are worth recording because
|
|
25
25
|
* each looks right until it is measured:
|
|
26
26
|
*
|
|
27
|
-
* - **Toward `--background
|
|
27
|
+
* - **Toward `--background`**: inverted in both
|
|
28
28
|
* appearances: it moves the button toward the page it sits on, so a hovered button
|
|
29
29
|
* recedes.
|
|
30
|
-
* - **Toward `--foreground
|
|
30
|
+
* - **Toward `--foreground`**: correct in principle, since the foreground is
|
|
31
31
|
* normally away from the canvas, and wrong in practice: a dark theme's foreground
|
|
32
|
-
* is mid-lightness (`0.79` in the default), so an accent lighter than that
|
|
33
|
-
* dark green is `0.80
|
|
34
|
-
* - **Toward white or black
|
|
32
|
+
* is mid-lightness (`0.79` in the default), so an accent lighter than that, the
|
|
33
|
+
* dark green is `0.80`, moves *toward* the canvas by a hair.
|
|
34
|
+
* - **Toward white or black**: always the right direction, but a *proportional*
|
|
35
35
|
* step: a mid-lightness light accent moves ~0.10 and a pale dark accent ~0.03, so
|
|
36
36
|
* the same rule gives one appearance a hover twice as strong as the other's.
|
|
37
37
|
*
|
|
38
38
|
* A uniform step needs a resolved value, which is why {@link primaryHover} returns
|
|
39
39
|
* one and why the tint below can stay an expression. `shiftLightness` is what keeps
|
|
40
|
-
* the step uniform *and* the hue intact
|
|
40
|
+
* the step uniform *and* the hue intact, a mix toward a neutral cannot do both.
|
|
41
41
|
*
|
|
42
42
|
* ## The tint rule
|
|
43
43
|
*
|
|
44
|
-
* The tint is the selected state across the component library
|
|
44
|
+
* The tint is the selected state across the component library, `bg-primary-subtle
|
|
45
45
|
* text-foreground` on an active nav row, a pressed toggle, the highlighted command
|
|
46
|
-
* row, a selected tab
|
|
46
|
+
* row, a selected tab, so body text on it is held to the body floor, on every
|
|
47
47
|
* surface body text is held to it on, for every accent the theme offers.
|
|
48
48
|
*
|
|
49
49
|
* It stays a translucent `color-mix()` rather than becoming an opaque value, and
|
|
50
50
|
* that is a measured choice rather than a habit. An opaque tint mixed into the
|
|
51
|
-
* canvas is legible everywhere by construction
|
|
52
|
-
* that way
|
|
51
|
+
* canvas is legible everywhere by construction, the status `-subtle` fills work
|
|
52
|
+
* that way, but it is a wash *of the canvas*: on a dark theme's popover, which is
|
|
53
53
|
* already lighter than the canvas, a selected command row resolved that way lands
|
|
54
54
|
* within ΔE 0.01 of the popover and disappears. A translucent tint is a wash of
|
|
55
55
|
* whatever it sits on, so it reads as selected on every rung.
|
|
56
56
|
*
|
|
57
57
|
* What moves instead is the **strength**, per theme. {@link ACCENT_SUBTLE_ALPHA} is
|
|
58
|
-
* the ceiling, and {@link primarySubtleAlpha} lowers it
|
|
59
|
-
* needs
|
|
58
|
+
* the ceiling, and {@link primarySubtleAlpha} lowers it, only as far as a theme
|
|
59
|
+
* needs, until the composite clears the floor everywhere. The palettes whose body
|
|
60
60
|
* text sits closest to the floor get a lighter wash, and the colour, the
|
|
61
61
|
* foreground and the surfaces stay exactly as their authors wrote them.
|
|
62
62
|
*/
|
|
@@ -165,7 +165,7 @@ export function accentValue(preset: AccentPreset, appearance: ThemeAppearance):
|
|
|
165
165
|
* The label to draw on an accent fill: black or white, whichever wins on contrast.
|
|
166
166
|
*
|
|
167
167
|
* Measured rather than conventional. The usual convention is "white on a coloured
|
|
168
|
-
* fill", which is wrong for the bright half of this set
|
|
168
|
+
* fill", which is wrong for the bright half of this set, white on `#a78bfa` is
|
|
169
169
|
* about 2.1:1, and black on it is about 9.9:1. That is why the same accent carries a
|
|
170
170
|
* black label in dark mode and a white one in light: the pair is designed so the
|
|
171
171
|
* polarity flips, and the label has to flip with it.
|
|
@@ -192,7 +192,7 @@ export function accentForegroundContrast(accent: string): number {
|
|
|
192
192
|
* A **uniform step**, not a proportional one, and the difference matters. Mixing a
|
|
193
193
|
* fixed share toward white or black moves an accent by a share of its headroom, so
|
|
194
194
|
* the same rule gives a mid-lightness light accent a step of ~0.10 and a pale dark
|
|
195
|
-
* accent one of ~0.03
|
|
195
|
+
* accent one of ~0.03, a hover that feels twice as strong in one appearance as the
|
|
196
196
|
* other, and nearly invisible on the palest accent.
|
|
197
197
|
*
|
|
198
198
|
* 0.05 is the step this system's accents were already hand-written with, so the
|
|
@@ -204,7 +204,7 @@ export const ACCENT_HOVER_STEP = 0.05
|
|
|
204
204
|
* The hovered primary, as a resolved colour.
|
|
205
205
|
*
|
|
206
206
|
* Resolved rather than expressed as a `color-mix()`, because a uniform step cannot
|
|
207
|
-
* be written as a mix
|
|
207
|
+
* be written as a mix, see {@link ACCENT_HOVER_STEP}. That means it does **not**
|
|
208
208
|
* follow `--primary` on its own, so a consumer that applies themes at runtime has to
|
|
209
209
|
* write this token too; the alternative is a hover left over from the previous
|
|
210
210
|
* theme's primary. `shadcnVariables` includes it for that reason.
|
|
@@ -249,8 +249,8 @@ type TintedTheme = Pick<AdeaTheme, 'appearance' | 'colors' | 'ansi'> & {
|
|
|
249
249
|
*
|
|
250
250
|
* {@link primarySubtleAlpha} lowers a theme's strength for legibility, and this is
|
|
251
251
|
* how far it may go: below it the selected state stops reading as a state at all.
|
|
252
|
-
* The normalizer reserves it
|
|
253
|
-
* clears the floor under a tint this strong
|
|
252
|
+
* The normalizer reserves it, it fits a theme's hover rung so body text still
|
|
253
|
+
* clears the floor under a tint this strong, so every theme in the catalogue can
|
|
254
254
|
* carry at least this much. At 4% the tint over One Dark's popover measures ΔE 0.018
|
|
255
255
|
* against the popover, about the same as its hover rung's feedback there.
|
|
256
256
|
*/
|
|
@@ -261,7 +261,7 @@ export const ACCENT_SUBTLE_MINIMUM_ALPHA = 4
|
|
|
261
261
|
* on.
|
|
262
262
|
*
|
|
263
263
|
* The canvas, the two raised rungs and the hover rung, plus whatever a source
|
|
264
|
-
* substitutes for them in the shadcn bridge
|
|
264
|
+
* substitutes for them in the shadcn bridge, `--card`, `--popover`, `--muted` and
|
|
265
265
|
* `--secondary`; `--sidebar` is the first rung and `--accent` the hover rung. The
|
|
266
266
|
* hover rung is here because a selected item that is also hovered paints the tint
|
|
267
267
|
* over it in some components. The active rung is not: it is the pressed state of an
|
|
@@ -350,7 +350,7 @@ export function tintCheck(
|
|
|
350
350
|
* {@link ACCENT_SUBTLE_MINIMUM_ALPHA}, because the normalizer fits its hover rung to
|
|
351
351
|
* leave room for it.
|
|
352
352
|
*
|
|
353
|
-
* Pass `primaries` to hold the strength for colours outside the offered set too
|
|
353
|
+
* Pass `primaries` to hold the strength for colours outside the offered set too,
|
|
354
354
|
* a product's own brand primary, say. The offered set is always included.
|
|
355
355
|
*/
|
|
356
356
|
export function primarySubtleAlpha(theme: TintedTheme, primaries: readonly string[] = []): number {
|
|
@@ -369,14 +369,14 @@ export function primarySubtleAlpha(theme: TintedTheme, primaries: readonly strin
|
|
|
369
369
|
* Pass the **theme**: the expression then carries that theme's measured strength
|
|
370
370
|
* ({@link primarySubtleAlpha}) and body text on it is held to the floor for every
|
|
371
371
|
* accent the theme offers. It still reads `var(--primary)`, so it follows a runtime
|
|
372
|
-
* accent switch
|
|
372
|
+
* accent switch, but the strength is the theme's, so a consumer that applies
|
|
373
373
|
* themes at runtime has to write this token per theme, as it already does for
|
|
374
374
|
* {@link primaryHover}. A consumer whose primary is not one the theme offers passes
|
|
375
375
|
* it as `primaries` to have the strength measured for it as well.
|
|
376
376
|
*
|
|
377
377
|
* Passing only an **appearance** gives the {@link ACCENT_SUBTLE_ALPHA} ceiling for
|
|
378
|
-
* that appearance, unmeasured. It is not legible on every theme
|
|
379
|
-
* text on its own primary's tint over a card measures 4.34:1 at the dark ceiling
|
|
378
|
+
* that appearance, unmeasured. It is not legible on every theme: One Dark's body
|
|
379
|
+
* text on its own primary's tint over a card measures 4.34:1 at the dark ceiling,
|
|
380
380
|
* so it is kept for a consumer without a theme object in hand, not as the default
|
|
381
381
|
* to reach for.
|
|
382
382
|
*/
|
|
@@ -394,7 +394,7 @@ export function primarySubtleCss(
|
|
|
394
394
|
* ## The accents a theme offers
|
|
395
395
|
*
|
|
396
396
|
* The {@link ACCENTS} presets are brand colours: the same six everywhere, chosen
|
|
397
|
-
* once. They read as visitors on a theme whose palette disagrees with them
|
|
397
|
+
* once. They read as visitors on a theme whose palette disagrees with them, a
|
|
398
398
|
* Gruvbox canvas with a cool cyan primary is two palettes sharing one window. A
|
|
399
399
|
* theme also carries colours of its *own* that are accent-shaped: its ANSI row is
|
|
400
400
|
* full of vivid, hue-distinct colours that the palette's authors already tuned to
|
|
@@ -402,14 +402,14 @@ export function primarySubtleCss(
|
|
|
402
402
|
*
|
|
403
403
|
* `themeAccentPresets` offers those. It pairs the two appearances on the accent
|
|
404
404
|
* slots {@link ACCENT_PREFERENCE} ranks, keeps a slot only when it clears the
|
|
405
|
-
* same floors a catalogue accent must clear
|
|
406
|
-
* against the theme's own canvas, and a legible label
|
|
405
|
+
* same floors a catalogue accent must clear, chroma, the raised-surface floor
|
|
406
|
+
* against the theme's own canvas, and a legible label, and returns the theme's
|
|
407
407
|
* values verbatim. Nothing here authors a colour: the slots are the palette's, the
|
|
408
408
|
* floors are the catalogue's, and the pairing is the only new decision.
|
|
409
409
|
*
|
|
410
410
|
* The ids are role-shaped (`ansi-blue`), not value-shaped, so a stored accent
|
|
411
411
|
* survives switching themes: the blue stays the blue, of whichever theme is
|
|
412
|
-
* active. That is what "pulled from the selected theme" means
|
|
412
|
+
* active. That is what "pulled from the selected theme" means, the offering
|
|
413
413
|
* follows the theme, and so does the resolved colour.
|
|
414
414
|
*/
|
|
415
415
|
export type ThemeAccentSlot = (typeof ACCENT_PREFERENCE)[number]
|
|
@@ -417,8 +417,8 @@ export type ThemeAccentSlot = (typeof ACCENT_PREFERENCE)[number]
|
|
|
417
417
|
/**
|
|
418
418
|
* A slot's offerable value on one theme: the palette's own colour when it already
|
|
419
419
|
* clears the accent floors on that theme's canvas, otherwise the catalogue's
|
|
420
|
-
* contrast repair
|
|
421
|
-
* canvas, within the accent budget
|
|
420
|
+
* contrast repair, lightness moved, hue and chroma kept, direction away from the
|
|
421
|
+
* canvas, within the accent budget, applied to reach the raised-surface floor
|
|
422
422
|
* with a legible label. `undefined` when even the budget cannot get there, which
|
|
423
423
|
* is the one case where the theme honestly cannot offer the slot.
|
|
424
424
|
*/
|
|
@@ -497,7 +497,7 @@ export function accentRoles(
|
|
|
497
497
|
preset: AccentPreset,
|
|
498
498
|
/**
|
|
499
499
|
* The theme the accent is applied to, or only its appearance. A theme gives the
|
|
500
|
-
* tint that theme's measured strength
|
|
500
|
+
* tint that theme's measured strength, see {@link primarySubtleCss}; an
|
|
501
501
|
* appearance gives the unmeasured ceiling.
|
|
502
502
|
*/
|
|
503
503
|
target: ThemeAppearance | TintedTheme,
|
package/src/adapters/base24.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ## The slot order is not the ANSI order
|
|
10
10
|
*
|
|
11
11
|
* Base24's `base12`–`base17` are *bright red, bright yellow, bright green, bright
|
|
12
|
-
* cyan, bright blue, bright magenta
|
|
12
|
+
* cyan, bright blue, bright magenta*, the order Base16 needed to keep its ramps
|
|
13
13
|
* monotonic, not the ANSI order of yellow before green. Reading them positionally
|
|
14
14
|
* as ANSI 1–6 silently swaps green and yellow and blue and cyan, which is the kind
|
|
15
15
|
* of mistake that survives review because the theme still *looks* like itself.
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* export they are re-derived from `red` and `yellow` by a fixed rotation, and
|
|
24
24
|
* `getBase24Scheme` returns the vendored schemes for callers who need the
|
|
25
25
|
* originals byte-for-byte. Round-tripping is therefore lossless for every
|
|
26
|
-
* role Adea models, and explicitly approximate for the two it does not
|
|
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
|
*/
|
|
29
29
|
|
|
@@ -148,7 +148,7 @@ export const ANSI_TO_BASE24 = Object.freeze(
|
|
|
148
148
|
* hues: `base08`–`base0E` are written from `BASE24_TO_ANSI`, the colours a terminal
|
|
149
149
|
* reads, not from the repaired UI roles. `base01` receives `black` rather than a
|
|
150
150
|
* role because an ANSI black that equals the background is invisible as foreground
|
|
151
|
-
* text
|
|
151
|
+
* text, the defect the import side documents. The
|
|
152
152
|
* surface ladder has no Base24 slot at all, so it is deliberately absent here:
|
|
153
153
|
* Base24 cannot express it, and pretending otherwise by packing four rungs into
|
|
154
154
|
* `base01`/`base02` would make the export lie about what it preserves.
|
|
@@ -205,7 +205,7 @@ export function parseBase24Palette(palette: Base24Palette): Record<Base24Slot, O
|
|
|
205
205
|
/**
|
|
206
206
|
* Writes a theme back to Base24.
|
|
207
207
|
*
|
|
208
|
-
* `base09` and `base0F` are synthesised
|
|
208
|
+
* `base09` and `base0F` are synthesised, see this module's header. `base10` and
|
|
209
209
|
* `base11` are the two rungs below `base00`, which is what the specification
|
|
210
210
|
* defines them as and what a terminal needs in order to draw a black that is
|
|
211
211
|
* darker than the background.
|
|
@@ -271,7 +271,7 @@ export function formatBase24Scheme(scheme: Base24Scheme): string {
|
|
|
271
271
|
*
|
|
272
272
|
* Written as a scan rather than `replace(/\s+#.*$/, '')`, which is what it was: that
|
|
273
273
|
* pattern is a quantified `\s+` followed by `.*`, so on a line with many spaces and no
|
|
274
|
-
* `#` the engine retries every split of the run at every start position
|
|
274
|
+
* `#` the engine retries every split of the run at every start position, quadratic
|
|
275
275
|
* in the line length, on input this function does not control. CodeQL reports it as
|
|
276
276
|
* `js/polynomial-redos`, which is how it was found.
|
|
277
277
|
*
|
|
@@ -40,7 +40,7 @@ export const CANONICAL_VARIABLES: readonly CssVariable[] = Object.freeze([
|
|
|
40
40
|
* fills and the text drawn on them, and the sunken surface.
|
|
41
41
|
*
|
|
42
42
|
* A status fill is the role at low strength against the canvas; its foreground is the
|
|
43
|
-
* theme's legible extreme for that fill, not the body text
|
|
43
|
+
* theme's legible extreme for that fill, not the body text, see
|
|
44
44
|
* `derive.statusForeground`. The sunken surface is the one step below the canvas that
|
|
45
45
|
* a well or a code block sits in.
|
|
46
46
|
*/
|
package/src/adapters/css.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ## Two names for the same values
|
|
9
9
|
*
|
|
10
|
-
* {@link themeCssVariables} emits the canonical names
|
|
11
|
-
* `--adea-surface
|
|
10
|
+
* {@link themeCssVariables} emits the canonical names, `--adea-background`,
|
|
11
|
+
* `--adea-surface`, and is what a new consumer should use.
|
|
12
12
|
* `adapters/shadcn.ts` emits the shadcn vocabulary this organisation's components
|
|
13
13
|
* are already written against. Both are generated from the same theme object, so
|
|
14
14
|
* the two can never disagree about what `surface` is; that is the entire reason to
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
* Custom properties are evaluated by the browser. Writing OKLCH means the values
|
|
26
26
|
* stay on the perceptual axis all the way to paint, so a consumer can compose them
|
|
27
|
-
*
|
|
27
|
+
* `color-mix(in oklch, var(--adea-accent), transparent 20%)`, and get a
|
|
28
28
|
* predictable result. Converted to hex on the way out, that composition would be
|
|
29
29
|
* an sRGB blend, which is what makes hand-mixed tints go muddy.
|
|
30
30
|
*/
|
package/src/adapters/shadcn.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The shadcn bridge.
|
|
3
3
|
*
|
|
4
|
-
* This organisation's components are written against shadcn's vocabulary
|
|
5
|
-
* `--background`, `--card`, `--muted-foreground`, `--primary`, `--ring
|
|
4
|
+
* This organisation's components are written against shadcn's vocabulary,
|
|
5
|
+
* `--background`, `--card`, `--muted-foreground`, `--primary`, `--ring`, and that
|
|
6
6
|
* vocabulary is not the canonical schema. Rather than rename every component, the
|
|
7
7
|
* two are bridged here, in one place, from one theme object.
|
|
8
8
|
*
|
|
@@ -10,16 +10,15 @@
|
|
|
10
10
|
*
|
|
11
11
|
* - **Adea's `accent` becomes shadcn's `primary`.** In shadcn, `--primary` is the
|
|
12
12
|
* main action colour and `--accent` is a *subtle hover background*. Adea's
|
|
13
|
-
* `accent` is the interactive colour
|
|
14
|
-
* what a focus ring is drawn in
|
|
13
|
+
* `accent` is the interactive colour, what a primary button is filled with,
|
|
14
|
+
* what a focus ring is drawn in, so it is shadcn's `primary`. Mapping it to
|
|
15
15
|
* `--accent` instead would turn every primary button into a hover wash. The
|
|
16
16
|
* shadcn `accent` slot is filled from `surfaceHover`, which is what it is
|
|
17
17
|
* actually used for.
|
|
18
18
|
* - **Adea's `surface` ladder becomes `card` and `popover`.** shadcn has two
|
|
19
19
|
* surfaces rather than four, so `surface` maps to `card` and `surfaceElevated`
|
|
20
20
|
* to `popover`, and the remaining two rungs keep their own names.
|
|
21
|
-
|
|
22
|
-
* A table of the whole mapping is in `docs/shadcn-bridge.md`.
|
|
21
|
+
|
|
23
22
|
*/
|
|
24
23
|
|
|
25
24
|
import type { AdeaTheme, AdeaThemeColors, ShadcnThemeProjection } from '../schema.js'
|
|
@@ -158,8 +157,8 @@ export const SHADCN_MAPPING: Readonly<Record<keyof AdeaThemeColors, string | nul
|
|
|
158
157
|
/**
|
|
159
158
|
* The shadcn roles as an object, keyed by role name without the `--` prefix.
|
|
160
159
|
*
|
|
161
|
-
* For a consumer that keeps a theme as data
|
|
162
|
-
* screen, a component reading `theme.colors.card
|
|
160
|
+
* For a consumer that keeps a theme as data, a picker showing swatches, a settings
|
|
161
|
+
* screen, a component reading `theme.colors.card`, rather than writing it straight
|
|
163
162
|
* to the document.
|
|
164
163
|
*/
|
|
165
164
|
export function shadcnRoles(theme: ShadcnTheme): Record<string, string> {
|
|
@@ -172,7 +171,7 @@ export function shadcnRoles(theme: ShadcnTheme): Record<string, string> {
|
|
|
172
171
|
* The shadcn custom properties for a theme.
|
|
173
172
|
*
|
|
174
173
|
* `--accent` is filled from `surfaceHover` because that is what shadcn components
|
|
175
|
-
* use it for
|
|
174
|
+
* use it for, the background of a hovered menu item, and `--ring` from the
|
|
176
175
|
* accent, because that is what a focus ring must be drawn in for the focus state
|
|
177
176
|
* to be visible.
|
|
178
177
|
*/
|
|
@@ -200,8 +199,8 @@ export function shadcnVariables(theme: ShadcnTheme): Record<string, string> {
|
|
|
200
199
|
variables['--input'] = theme.shadcn?.input ?? theme.colors.border
|
|
201
200
|
|
|
202
201
|
// The rest of shadcn's default vocabulary. These are not in `SHADCN_MAPPING`
|
|
203
|
-
// because they are not new *roles
|
|
204
|
-
// first surface rung used as a fill, and its `card-foreground` is the body text
|
|
202
|
+
// because they are not new *roles*, shadcn's `secondary` and `muted` are both the
|
|
203
|
+
// first surface rung used as a fill, and its `card-foreground` is the body text,
|
|
205
204
|
// so they are filled from the roles that already exist rather than getting
|
|
206
205
|
// second-class entries of their own.
|
|
207
206
|
variables['--card'] = theme.shadcn?.card ?? theme.colors.surface
|
package/src/adapters/shiki.ts
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* Shiki drives the code views and diffs in Adea's editor and conversation surfaces,
|
|
5
5
|
* and its theme contract is an editor contract: a `colors` map for the chrome and a
|
|
6
6
|
* `settings` list of scope selectors. Neither is in the canonical schema, so both
|
|
7
|
-
* are derived
|
|
7
|
+
* are derived, the chrome from the semantic roles, the scopes from the ANSI
|
|
8
8
|
* colours via `derive.syntaxRoles`.
|
|
9
9
|
*
|
|
10
10
|
* ## Hex, not OKLCH
|
|
11
11
|
*
|
|
12
12
|
* Shiki is the one adapter that gets hex. Its colour resolution runs through a
|
|
13
13
|
* syntax highlighter that does not evaluate CSS colour functions, and its output is
|
|
14
|
-
* used to build inline styles and a text-mate scopes map
|
|
14
|
+
* used to build inline styles and a text-mate scopes map, places where an
|
|
15
15
|
* `oklch()` string is not a colour but a string. The conversion gamut-maps rather
|
|
16
16
|
* than clipping, so an out-of-gamut accent becomes a slightly less saturated real
|
|
17
17
|
* colour instead of a broken channel.
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* `toShikiTheme` returns the object; it does not call `loadTheme`, and it does
|
|
22
22
|
* not import Shiki. That keeps this package free of a dependency on a library that
|
|
23
23
|
* is an application's choice, and it means a consumer can register the result
|
|
24
|
-
* however it likes
|
|
24
|
+
* however it likes, synchronously, into a custom highlighter, or inside a worker.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import type { AdeaTheme } from '../schema.js'
|
|
@@ -64,7 +64,7 @@ export interface ShikiTokenSetting {
|
|
|
64
64
|
* claim more than one scope because grammars disagree: a type annotation may arrive
|
|
65
65
|
* as `entity.name.type`, as `support.type`, or as `storage.type` depending on the
|
|
66
66
|
* language, and a theme that names only one of them renders that language
|
|
67
|
-
* unhighlighted. The lists are conservative
|
|
67
|
+
* unhighlighted. The lists are conservative, they claim the scopes that mean the
|
|
68
68
|
* role unambiguously, and leave the rest to the editor's default.
|
|
69
69
|
*/
|
|
70
70
|
const SHIKI_SCOPES: Readonly<Record<SyntaxRole, readonly string[]>> = Object.freeze({
|
package/src/adapters/xterm.ts
CHANGED
|
@@ -72,7 +72,7 @@ const CURSOR_FLOOR = 3
|
|
|
72
72
|
* The two derived fields are the whole point:
|
|
73
73
|
*
|
|
74
74
|
* - **`cursorAccent`** is the glyph *under* the block cursor. xterm draws it in
|
|
75
|
-
* this colour, so it must contrast with `cursor
|
|
75
|
+
* this colour, so it must contrast with `cursor`, not with the background.
|
|
76
76
|
* Palettes frequently set their cursor to the foreground colour, which puts the
|
|
77
77
|
* accent at the far end of the canvas.
|
|
78
78
|
* - **`selectionForeground`** is text inside a selection. Base24's `base02` is
|
package/src/catalogue.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* The catalogue's public surface.
|
|
3
3
|
*
|
|
4
4
|
* The generated data is a flat, sorted array; everything a consumer wants to *do*
|
|
5
|
-
* with it
|
|
6
|
-
* stored preference still names a real theme
|
|
5
|
+
* with it, find one theme, group it by family, list what exists, check that a
|
|
6
|
+
* stored preference still names a real theme, is here.
|
|
7
7
|
*
|
|
8
8
|
* ## Lookups answer, they do not throw
|
|
9
9
|
*
|
|
@@ -99,8 +99,8 @@ export function themesByAppearance(
|
|
|
99
99
|
* The vendored Base24 scheme for a theme, untouched.
|
|
100
100
|
*
|
|
101
101
|
* Present for interop and for licence auditing. `toBase24()` writes a scheme too,
|
|
102
|
-
* but it has to re-derive Base24's orange and brown slots
|
|
103
|
-
* has no role for them
|
|
102
|
+
* but it has to re-derive Base24's orange and brown slots, the canonical schema
|
|
103
|
+
* has no role for them, so it is not a byte-exact round trip. This returns the
|
|
104
104
|
* artefact as it was reproduced, so a caller that needs exactness has it.
|
|
105
105
|
*/
|
|
106
106
|
export function getBase24Scheme(id: string): Base24Scheme | undefined {
|
package/src/derive.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Colours a theme does not store, derived from the ones it does.
|
|
3
3
|
*
|
|
4
|
-
* The canonical schema is deliberately small
|
|
5
|
-
* ANSI colours, a cursor and a selection
|
|
4
|
+
* The canonical schema is deliberately small, seventeen surface roles, sixteen
|
|
5
|
+
* ANSI colours, a cursor and a selection, and three things an application needs
|
|
6
6
|
* are deliberately absent from it: the **syntax roles** a code view wants, the
|
|
7
7
|
* **chart series** a graph wants, and the **fills and foregrounds** a status chip
|
|
8
8
|
* wants.
|
|
9
9
|
*
|
|
10
10
|
* They are absent because each is a *function of* the roles that are present, and a
|
|
11
11
|
* schema that stored them would be a schema with three ways to say the same thing.
|
|
12
|
-
* Deriving them here, once, means every consumer derives them identically
|
|
12
|
+
* Deriving them here, once, means every consumer derives them identically, the
|
|
13
13
|
* alternative, which this replaces, is each application inventing its own mapping
|
|
14
14
|
* and two applications disagreeing about what colour a type is.
|
|
15
15
|
*
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* Reading the roles off the sixteen ANSI colours instead has a property worth more
|
|
25
25
|
* than per-theme tuning: the ANSI set is the part of a palette its author *did*
|
|
26
26
|
* choose carefully, every theme in the catalogue has one, and it is already tuned
|
|
27
|
-
* for legibility against that theme's background
|
|
27
|
+
* for legibility against that theme's background, the same requirement a code view
|
|
28
28
|
* has. It is the reasoning that makes `ls --color` readable in each of these
|
|
29
29
|
* palettes today.
|
|
30
30
|
*/
|
|
@@ -83,13 +83,13 @@ const EDITOR_ROLES = [
|
|
|
83
83
|
* instead.
|
|
84
84
|
*
|
|
85
85
|
* `variable` and `operator` mean "the ink most of the code is drawn in", and ANSI
|
|
86
|
-
* `white` is that slot *on a dark terminal
|
|
86
|
+
* `white` is that slot *on a dark terminal*, a light grey against a dark canvas.
|
|
87
87
|
* On a light theme the same slot is the terminal's brightest colour, at or near
|
|
88
88
|
* the paper itself, so the mapping hands the editor a foreground it cannot draw
|
|
89
89
|
* with: `editorRolesHex`'s bounded repair could not reach 4.5:1 from a chroma-less
|
|
90
90
|
* near-white within its lightness budget, and every community light theme threw.
|
|
91
91
|
* ANSI `black` is the same "default ink" slot from the paper's side of the
|
|
92
|
-
* palette
|
|
92
|
+
* palette, dark by construction, and it keeps each palette's own tint
|
|
93
93
|
* (Solarized Light's variables stay dark teal, not a repaired grey).
|
|
94
94
|
*/
|
|
95
95
|
const LIGHT_SYNTAX_SOURCE: Readonly<Partial<Record<SyntaxRole, keyof AdeaTheme['ansi']>>> =
|
|
@@ -132,7 +132,7 @@ const SYNTAX_SOURCE: Readonly<Record<SyntaxRole, keyof AdeaTheme['ansi']>> = Obj
|
|
|
132
132
|
*
|
|
133
133
|
* Comment and punctuation are additionally measured against the canvas: a
|
|
134
134
|
* palette's dim grey is chosen to be read against its *terminal* background, which
|
|
135
|
-
* is the same colour as the canvas here, so the measurement normally passes
|
|
135
|
+
* is the same colour as the canvas here, so the measurement normally passes, but
|
|
136
136
|
* when it does not, the same minimal lightness repair the semantic roles use is
|
|
137
137
|
* applied rather than leaving unreadable comments.
|
|
138
138
|
*/
|
|
@@ -148,7 +148,7 @@ export function syntaxRoles(
|
|
|
148
148
|
* Their whole purpose is to be the faintest thing on screen, and every palette
|
|
149
149
|
* here defines its comment colour that way on purpose: Everforest Light's is
|
|
150
150
|
* 1.9:1 against its own canvas. Holding them to 3:1 could only be satisfied by
|
|
151
|
-
* promoting comments to the body text's colour, which inverts the role
|
|
151
|
+
* promoting comments to the body text's colour, which inverts the role, and the
|
|
152
152
|
* floors that *do* carry text are measured separately and are not relaxed.
|
|
153
153
|
*/
|
|
154
154
|
const floor = options.commentFloor ?? 2
|
|
@@ -210,7 +210,7 @@ export function editorRolesHex(theme: AdeaTheme): Record<EditorRole, string> {
|
|
|
210
210
|
// because a light theme's brightest ANSI slots start near the paper: a
|
|
211
211
|
// pastel yellow `number` has more lightness between it and 4.5:1 than the
|
|
212
212
|
// default budget allows, and this projection's contract is to hold the role
|
|
213
|
-
// to AA however far the lightness has to travel
|
|
213
|
+
// to AA however far the lightness has to travel, darkening a chromatic
|
|
214
214
|
// colour keeps its hue, so the number stays yellow, just amber.
|
|
215
215
|
const repaired = repairToHex(source, background, CONTRAST_FLOORS.text, 0.55)
|
|
216
216
|
if (repaired) return [role, repaired]
|
|
@@ -225,8 +225,8 @@ export function editorRolesHex(theme: AdeaTheme): Record<EditorRole, string> {
|
|
|
225
225
|
* Six series, taken in the order that keeps adjacent ones furthest apart on the
|
|
226
226
|
* hue circle: blue, magenta, cyan, green, yellow, red. A palette's own ordering
|
|
227
227
|
* would put red next to green, which is the pair a pie chart most needs to
|
|
228
|
-
* separate. Constant across themes by construction
|
|
229
|
-
* slots
|
|
228
|
+
* separate. Constant across themes by construction, every theme has these six
|
|
229
|
+
* slots, so a chart's series colours mean the same thing in every theme.
|
|
230
230
|
*/
|
|
231
231
|
export const CHART_SERIES: readonly (keyof AdeaTheme['ansi'])[] = Object.freeze([
|
|
232
232
|
'blue',
|
|
@@ -247,7 +247,7 @@ export function chartSeries(theme: AdeaTheme): readonly string[] {
|
|
|
247
247
|
*
|
|
248
248
|
* Status chips need a fill that is the role's colour at low strength, and doing
|
|
249
249
|
* that with alpha would put a translucent colour into a token whose contrast was
|
|
250
|
-
* measured as opaque
|
|
250
|
+
* measured as opaque, and a translucent fill's real contrast depends on whatever
|
|
251
251
|
* happens to be behind it. Blending toward the canvas in OKLCH keeps the result
|
|
252
252
|
* opaque, so the chip's own text pairing can be asserted like any other.
|
|
253
253
|
*/
|
|
@@ -267,11 +267,11 @@ export type StatusRole = (typeof STATUS_ROLES)[number]
|
|
|
267
267
|
*
|
|
268
268
|
* Not the appearance's `foreground`, which is the shortcut and is wrong half the
|
|
269
269
|
* time: a dark theme's foreground is near-white, and near-white on Adea Dark's
|
|
270
|
-
* `success` at `#3fb950` measures 2.6:1
|
|
270
|
+
* `success` at `#3fb950` measures 2.6:1, illegible. The correct answer is
|
|
271
271
|
* whichever of the theme's two extremes measures better against the fill, which
|
|
272
272
|
* for a bright green is black and for a deep red is white.
|
|
273
273
|
*
|
|
274
|
-
* Where neither clears the floor
|
|
274
|
+
* Where neither clears the floor, a mid-tone fill, which some palettes have,
|
|
275
275
|
* the better of the two is returned and {@link validateTheme} is what reports the
|
|
276
276
|
* pairing as failing, rather than a silent blend being substituted here.
|
|
277
277
|
*/
|
package/src/generated/schemes.ts
CHANGED
|
@@ -11,8 +11,8 @@ import type { Base24Scheme } from '../adapters/base24.js'
|
|
|
11
11
|
/**
|
|
12
12
|
* The Base24 schemes as they were vendored, keyed by theme id.
|
|
13
13
|
*
|
|
14
|
-
* Untouched, so a consumer that needs the original bytes
|
|
15
|
-
* licence audit
|
|
14
|
+
* Untouched, so a consumer that needs the original bytes, an interop export, a
|
|
15
|
+
* licence audit, gets them rather than a re-derivation.
|
|
16
16
|
*/
|
|
17
17
|
export const generatedSchemes: Readonly<Record<string, Base24Scheme>> = Object.freeze({
|
|
18
18
|
"aardvark-blue": {
|