@adea-ai/themes 0.11.16 → 0.11.18
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 +7 -7
- package/dist/adapters/shadcn.js +9 -9
- 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 +4 -4
- 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 +9 -9
- 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/NOTICE
CHANGED
|
@@ -27,11 +27,11 @@ from any package at runtime. They were produced once, by
|
|
|
27
27
|
`scripts/vendor-palettes.ts`, which reproduces the Base24 scheme for each theme from
|
|
28
28
|
one pinned revision of:
|
|
29
29
|
|
|
30
|
-
- **oklch-terminal-themes
|
|
31
|
-
|
|
30
|
+
- **oklch-terminal-themes**: https://github.com/williamzujkowski/oklch-terminal-themes,
|
|
31
|
+
revision `9e800e7fe760081d4c10317498038ed4227341d6`, MIT.
|
|
32
32
|
This is the bootstrap dataset. Its Base24 schemes are, in turn, derived from the
|
|
33
33
|
terminal ports published in:
|
|
34
|
-
- **iTerm2-Color-Schemes
|
|
34
|
+
- **iTerm2-Color-Schemes**: https://github.com/mbadolato/iTerm2-Color-Schemes, MIT.
|
|
35
35
|
|
|
36
36
|
`oklch-terminal-themes` is a build-time input only. It is not a dependency of this
|
|
37
37
|
package, in either `dependencies` or `devDependencies`, and nothing here reads it at
|
|
@@ -40,8 +40,8 @@ against each palette's own project before being committed.
|
|
|
40
40
|
|
|
41
41
|
## The palettes, and the terms they are used under
|
|
42
42
|
|
|
43
|
-
Each entry names the project the palette belongs to
|
|
44
|
-
defined and the authority on what "Catppuccin Mocha" means
|
|
43
|
+
Each entry names the project the palette belongs to, the place its design is
|
|
44
|
+
defined and the authority on what "Catppuccin Mocha" means, and the licence the
|
|
45
45
|
vendored values are used under. `tests/provenance.test.ts` asserts that the
|
|
46
46
|
background and foreground of every one of these matches the project's published
|
|
47
47
|
palette.
|
|
@@ -96,8 +96,8 @@ of the catalogue, so the composed results are used under MIT as well as under th
|
|
|
96
96
|
package's Apache-2.0.
|
|
97
97
|
|
|
98
98
|
**Neither canvas was adjusted to make the composition work, and no hue was either.**
|
|
99
|
-
GitHub's hues measure between 7.2:1 and 8.8:1 against Aardvark Ink's canvas
|
|
100
|
-
contrast than they have against GitHub's own
|
|
99
|
+
GitHub's hues measure between 7.2:1 and 8.8:1 against Aardvark Ink's canvas, *more*
|
|
100
|
+
contrast than they have against GitHub's own, so the dark theme's vibrant set arrives
|
|
101
101
|
intact. On Nord Light's canvas the same hues measure between 2.5:1 and 4.1:1, which is
|
|
102
102
|
legible as an accent and not as terminal text, so the whole set is **transposed down by
|
|
103
103
|
one common step of 0.244 in lightness**; hue and chroma are untouched, and the relative
|
|
@@ -107,8 +107,8 @@ are asserted rather than assumed.
|
|
|
107
107
|
One value *is* a deliberate deviation, and it is aesthetic rather than a correction:
|
|
108
108
|
Nord Light's canvas carries 0.010 of chroma against Aardvark Ink's 0.024, so rendering
|
|
109
109
|
the same hue at half the tint made the light theme read as neutral grey beside a partner
|
|
110
|
-
that is plainly navy. The light canvas is deepened to 0.016
|
|
111
|
-
theme's
|
|
110
|
+
that is plainly navy. The light canvas is deepened to 0.016, two thirds of the dark
|
|
111
|
+
theme's, at the same lightness and hue, so no contrast pairing moves. It is recorded in
|
|
112
112
|
`COMPOSED_SOURCES` and can be reverted by deleting one line.
|
|
113
113
|
|
|
114
114
|
### Two entries that need a note
|
|
@@ -125,7 +125,7 @@ licensed artefact of Monokai's own to vendor from. The values in this package ar
|
|
|
125
125
|
therefore taken from the MIT-licensed iTerm2-Color-Schemes port through the chain
|
|
126
126
|
above, which is the artefact the MIT licence attaches to, and Monokai is credited as
|
|
127
127
|
the design's origin without a licence claim being made on its behalf. If Monokai's
|
|
128
|
-
terms are ever clarified, this entry should be revisited
|
|
128
|
+
terms are ever clarified, this entry should be revisited, and if they turn out to
|
|
129
129
|
be incompatible, `monokai` should be removed from `VENDORED_SOURCES` and the
|
|
130
130
|
catalogue regenerated, which is a one-line change plus a rebuild.
|
|
131
131
|
|
|
@@ -149,7 +149,7 @@ own background. Solarized Light's body text is the clearest case: `#657b83` on
|
|
|
149
149
|
`#fdf6e3` measures 4.28:1, below the WCAG AA floor of 4.5:1.
|
|
150
150
|
|
|
151
151
|
Where that happens, the value's **lightness** is moved by the smallest amount that
|
|
152
|
-
clears the floor, and nothing else is changed
|
|
152
|
+
clears the floor, and nothing else is changed, OKLCH makes that a single-axis edit
|
|
153
153
|
that preserves hue and chroma exactly, and `tests/provenance.test.ts` asserts the hue
|
|
154
154
|
is unmoved. In the rare case where lightness alone cannot reach the floor, the colour
|
|
155
155
|
is blended toward the palette's own foreground, which is recorded on the entry and
|
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# @adea-ai/themes
|
|
2
2
|
|
|
3
|
-
The Adea theme catalogue
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
the same adapters.
|
|
3
|
+
The Adea theme catalogue: 34 themes, each with the full set of surface roles,
|
|
4
|
+
16 ANSI colours, a cursor and a selection, all in OKLCH. Six are Adea's own; the
|
|
5
|
+
rest are well-known upstream palettes run through the same pipeline.
|
|
7
6
|
|
|
8
7
|
```sh
|
|
9
8
|
bun add @adea-ai/themes
|
|
@@ -26,8 +25,8 @@ bun add @adea-ai/themes
|
|
|
26
25
|
| **Nord** | Nord, Light |
|
|
27
26
|
| **Dracula**, **One Dark**, **Kanagawa**, **Vesper** | one each |
|
|
28
27
|
|
|
29
|
-
The six **Adea** variants are the managed family
|
|
30
|
-
accessibility variants
|
|
28
|
+
The six **Adea** variants are the managed family, two appearances × three
|
|
29
|
+
accessibility variants, and all of them are **composed** from upstream palettes
|
|
31
30
|
rather than authored or copied:
|
|
32
31
|
|
|
33
32
|
| Variant | canvas | hues | accent |
|
|
@@ -40,13 +39,13 @@ rather than authored or copied:
|
|
|
40
39
|
| Adea Light High Contrast | GitHub Light High Contrast | GitHub Dark High Contrast, transposed | its violet |
|
|
41
40
|
|
|
42
41
|
The re-greying is the one family-wide customisation: GitHub's dark greyscale is cut
|
|
43
|
-
blue (`h≈258`), so its chroma is halved and the hue rotated to violet-grey
|
|
42
|
+
blue (`h≈258`), so its chroma is halved and the hue rotated to violet-grey, the
|
|
44
43
|
ground the family's violet accent is meant to read on. The hue slots are untouched
|
|
45
44
|
(GitHub's dark palette stays GitHub's), the accessibility variants are compositions
|
|
46
45
|
of GitHub's own accessibility variants, and every light variant is its dark
|
|
47
46
|
counterpart's hues transposed onto paper, so a red is the same red in both modes of
|
|
48
47
|
a variant and switching appearance changes lightness and nothing else.
|
|
49
|
-
`tests/provenance.test.ts` asserts the partnership
|
|
48
|
+
`tests/provenance.test.ts` asserts the partnership, identical hue and chroma for
|
|
50
49
|
every chromatic role across a variant's two appearances, the re-tinted canvases,
|
|
51
50
|
and the violet accent on all six.
|
|
52
51
|
|
|
@@ -55,7 +54,10 @@ credited in [NOTICE](NOTICE).
|
|
|
55
54
|
|
|
56
55
|
## Using it
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
### One theme
|
|
58
|
+
|
|
59
|
+
An app that needs a single palette imports its generated module. This loads
|
|
60
|
+
that palette only, with no catalogue or normalization code:
|
|
59
61
|
|
|
60
62
|
```ts
|
|
61
63
|
import theme from '@adea-ai/themes/themes/adea-dark'
|
|
@@ -64,31 +66,52 @@ import { toXtermTheme } from '@adea-ai/themes/adapters/xterm'
|
|
|
64
66
|
terminal.options.theme = toXtermTheme(theme)
|
|
65
67
|
```
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
For a theme picker, `@adea-ai/themes/metadata` exports `themeMetadata`: id,
|
|
70
|
+
family, appearance, description, tags and provenance, without palette values.
|
|
71
|
+
Load the chosen palette through a static map of dynamic imports so the bundler
|
|
72
|
+
splits each one into its own chunk.
|
|
73
|
+
|
|
74
|
+
`tests/package.test.ts` packs the real archive, resolves every public export in
|
|
75
|
+
Node, and checks that a single-theme bundle stays under 16 KiB and leaves out the
|
|
76
|
+
other palettes. The package has no runtime dependencies and ships native ESM.
|
|
77
|
+
|
|
78
|
+
### The whole catalogue
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { getTheme, themeFamilies, resolveTheme } from '@adea-ai/themes'
|
|
82
|
+
import { themeCssVariables } from '@adea-ai/themes/adapters/css'
|
|
83
|
+
import { toXtermTheme } from '@adea-ai/themes/adapters/xterm'
|
|
84
|
+
import { toShikiTheme } from '@adea-ai/themes/adapters/shiki'
|
|
85
|
+
|
|
86
|
+
// Apply a theme to the document.
|
|
87
|
+
const theme = resolveTheme('catppuccin-mocha', 'dark')
|
|
88
|
+
for (const [name, value] of Object.entries(themeCssVariables(theme))) {
|
|
89
|
+
document.documentElement.style.setProperty(name, value)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Colour a terminal.
|
|
93
|
+
terminal.options.theme = toXtermTheme(theme)
|
|
94
|
+
|
|
95
|
+
// Register a syntax theme.
|
|
96
|
+
const highlighter = await createHighlighter({ themes: [toShikiTheme(theme)], langs: [...] })
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Every theme value is an `oklch()` string, so the browser does the colour maths
|
|
100
|
+
and `color-mix(in oklch, var(--adea-accent), transparent 20%)` behaves
|
|
101
|
+
predictably. Adapters that need hex (xterm, Shiki) convert with gamut mapping
|
|
102
|
+
rather than clipping.
|
|
73
103
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
exports in Node, and checks that a single-theme browser bundle excludes other
|
|
78
|
-
palettes and catalogue tooling. Its 16 KiB uncompressed ceiling leaves headroom
|
|
79
|
-
for one record and the terminal adapter while detecting catalogue inclusion.
|
|
80
|
-
This package still has no runtime dependencies.
|
|
104
|
+
`syntaxRolesHex(theme)` keeps comments at the catalogue's quiet default.
|
|
105
|
+
`editorRolesHex(theme)` returns editor roles with every rounded hex value lifted
|
|
106
|
+
to at least 4.5:1, for editors where comments and diff markers are small text.
|
|
81
107
|
|
|
82
|
-
###
|
|
108
|
+
### Filling gaps in a stored token map
|
|
83
109
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
consumers that need to derive missing custom properties from an older stored token
|
|
87
|
-
map. The runtime API returns a new map and never mutates or persists the input:
|
|
110
|
+
`projectThemeTokens` derives missing custom properties from an older stored token
|
|
111
|
+
map. It returns a new map and never changes or saves the input:
|
|
88
112
|
|
|
89
113
|
```ts
|
|
90
114
|
import { projectThemeTokens } from '@adea-ai/themes/theme-token-projection'
|
|
91
|
-
import { themeTokenProjectionBundle } from '@adea-ai/themes/theme-token-projection/script'
|
|
92
115
|
|
|
93
116
|
const sidebarProjection = [
|
|
94
117
|
{ target: '--sidebar', source: '--card' },
|
|
@@ -102,68 +125,49 @@ const sidebarProjection = [
|
|
|
102
125
|
const hydratedTokens = projectThemeTokens(storedTokens, sidebarProjection)
|
|
103
126
|
```
|
|
104
127
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
128
|
+
Rules are plain data and run in order, so a generated surface can anchor a later
|
|
129
|
+
foreground. Tokens that already exist are kept exactly, even if they miss the
|
|
130
|
+
requested floor. A malformed or translucent colour is kept as is; use
|
|
131
|
+
`projectThemeTokensDetailed` to see which colours or floors could not be handled.
|
|
109
132
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
133
|
+
For a pre-paint script, `@adea-ai/themes/theme-token-projection/script` exports
|
|
134
|
+
`themeTokenProjectionBundle`, a JavaScript expression string for
|
|
135
|
+
`(tokens, rules) => projectedTokens`. Pass the parsed map as a variable and
|
|
136
|
+
serialize only rule data you own. Never interpolate stored token values into the
|
|
137
|
+
script:
|
|
115
138
|
|
|
116
139
|
```ts
|
|
140
|
+
import { themeTokenProjectionBundle } from '@adea-ai/themes/theme-token-projection/script'
|
|
141
|
+
|
|
117
142
|
const serializedRules = JSON.stringify(sidebarProjection).replaceAll('<', '\\u003c')
|
|
118
143
|
const prepaintCall = `(${themeTokenProjectionBundle})(tokens, ${serializedRules})`
|
|
119
|
-
// Include `prepaintCall` in the script after `tokens` has been parsed.
|
|
120
144
|
```
|
|
121
145
|
|
|
122
|
-
|
|
123
|
-
source. The expression evaluates to `(tokens, rules) => projectedTokens`; it adds
|
|
124
|
-
only missing tokens and does not write to storage. A malformed or translucent color
|
|
125
|
-
is preserved when it cannot be measured safely; use
|
|
126
|
-
`projectThemeTokensDetailed` to inspect unsupported colors or unreachable floors.
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
import { getTheme, themeFamilies, resolveTheme } from '@adea-ai/themes'
|
|
130
|
-
import { themeCssVariables } from '@adea-ai/themes/adapters/css'
|
|
131
|
-
import { toXtermTheme } from '@adea-ai/themes/adapters/xterm'
|
|
132
|
-
import { toShikiTheme } from '@adea-ai/themes/adapters/shiki'
|
|
133
|
-
|
|
134
|
-
// Apply a theme to the document.
|
|
135
|
-
const theme = resolveTheme('catppuccin-mocha', 'dark')
|
|
136
|
-
for (const [name, value] of Object.entries(themeCssVariables(theme))) {
|
|
137
|
-
document.documentElement.style.setProperty(name, value)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Colour a terminal.
|
|
141
|
-
terminal.options.theme = toXtermTheme(theme)
|
|
142
|
-
|
|
143
|
-
// Register a syntax theme.
|
|
144
|
-
const highlighter = await createHighlighter({ themes: [toShikiTheme(theme)], langs: [...] })
|
|
145
|
-
```
|
|
146
|
+
### Adapters
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
`
|
|
150
|
-
|
|
148
|
+
| Import | For | Output |
|
|
149
|
+
| ------------------- | --------------------- | --------------------------------------------- |
|
|
150
|
+
| `adapters/css` | the app | CSS custom properties in OKLCH |
|
|
151
|
+
| `adapters/tailwind` | the app | a Tailwind v4 `@theme inline` block |
|
|
152
|
+
| `adapters/shadcn` | this org's components | shadcn token names, mapped from the same data |
|
|
153
|
+
| `adapters/xterm` | terminals | xterm.js's hex-only `ITheme` |
|
|
154
|
+
| `adapters/shiki` | code views | a Shiki theme registration |
|
|
155
|
+
| `adapters/base24` | interop | Base24, both directions |
|
|
151
156
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
Shiki) convert, gamut-mapping rather than clipping.
|
|
157
|
+
One mapping surprises people: Adea's `accent` becomes shadcn's `primary`, because
|
|
158
|
+
in shadcn `--primary` is the action colour and `--accent` is a hover wash. See
|
|
159
|
+
[docs/shadcn-bridge.md](docs/shadcn-bridge.md) for the full mapping.
|
|
156
160
|
|
|
157
|
-
##
|
|
161
|
+
## How it is built
|
|
158
162
|
|
|
159
163
|
**Adea owns the schema and the transformation.** The seventeen surface roles in
|
|
160
164
|
`src/schema.ts` are the contract. No upstream project is asked to satisfy it.
|
|
161
|
-
`palettes/` holds Base24 schemes reproduced from a pinned revision
|
|
165
|
+
`palettes/` holds Base24 schemes reproduced from a pinned revision, and
|
|
162
166
|
`src/normalize.ts` is the single place an input becomes a canonical application theme.
|
|
163
167
|
Adding a theme is a line in `src/sources.ts` plus a rebuild.
|
|
164
168
|
|
|
165
|
-
A theme may also be **composed from two donors
|
|
166
|
-
the hues
|
|
169
|
+
A theme may also be **composed from two donors**, one supplying the structure, another
|
|
170
|
+
the hues, which is how all six of Adea's own themes are built. The composition is a slot
|
|
167
171
|
map in `COMPOSED_SOURCES`, so both parents stay named and freshening either one is a
|
|
168
172
|
one-line diff rather than a re-transcription. A composition can also declare
|
|
169
173
|
`hueTranspose`, which moves a borrowed hue set onto a different kind of canvas as a
|
|
@@ -174,11 +178,11 @@ surface ladder buildable by adding fixed steps, a contrast failure repairable by
|
|
|
174
178
|
moving one axis, and a theme re-hueable without re-deriving its ramp by eye.
|
|
175
179
|
|
|
176
180
|
**Contrast is measured, not assumed.** Nothing enters the catalogue without clearing
|
|
177
|
-
the floors
|
|
178
|
-
cannot be repaired within budget. The pipeline caught real defects that a
|
|
181
|
+
the floors in `src/policy.ts`, checked by `src/validate.ts`. `bun run catalogue:build`
|
|
182
|
+
fails if a theme cannot be repaired within budget. The pipeline caught real defects that a
|
|
179
183
|
hand-authored catalogue would have shipped:
|
|
180
184
|
|
|
181
|
-
- Solarized Light's body text measures 4.28:1 on its own background
|
|
185
|
+
- Solarized Light's body text measures 4.28:1 on its own background, under WCAG AA.
|
|
182
186
|
- Tokyo Night's black is 1.17:1 against its canvas, and Gruvbox Light's `white` was
|
|
183
187
|
resolving to a near-black, both from light schemes that invert Base24's greyscale
|
|
184
188
|
ramp.
|
|
@@ -189,7 +193,7 @@ hand-authored catalogue would have shipped:
|
|
|
189
193
|
functions of the roles a theme does hold (`src/derive.ts`), so two consumers cannot
|
|
190
194
|
disagree about what colour a keyword is.
|
|
191
195
|
|
|
192
|
-
|
|
196
|
+
### Base24 is a bridge, not the schema
|
|
193
197
|
|
|
194
198
|
Base24 is an excellent interchange format and a poor application schema: it has a
|
|
195
199
|
slot for the colour of a deprecated API and nothing that means "the surface one step
|
|
@@ -207,22 +211,6 @@ getBase24Scheme('nord') // the vendored original, untouched
|
|
|
207
211
|
role for them; `getBase24Scheme` returns the artefact as reproduced, for callers that
|
|
208
212
|
need it byte-for-byte. The mapping is documented in `src/adapters/base24.ts`.
|
|
209
213
|
|
|
210
|
-
## Adapters
|
|
211
|
-
|
|
212
|
-
| Import | For | Output |
|
|
213
|
-
| ------------------- | --------------------- | --------------------------------------------------- |
|
|
214
|
-
| `adapters/css` | the application | CSS custom properties in OKLCH |
|
|
215
|
-
| `adapters/tailwind` | the application | a Tailwind v4 `@theme inline` block |
|
|
216
|
-
| `adapters/shadcn` | this org's components | the shadcn vocabulary, bridged from the same source |
|
|
217
|
-
| `adapters/xterm` | shells | xterm.js's hex-only `ITheme` |
|
|
218
|
-
| `adapters/shiki` | code views | a Shiki theme registration |
|
|
219
|
-
| `adapters/base24` | interop | Base24, both directions |
|
|
220
|
-
|
|
221
|
-
The shadcn bridge is worth knowing about before you read the code: Adea's `accent`
|
|
222
|
-
becomes shadcn's **`primary`**, because in shadcn `--primary` is the action colour and
|
|
223
|
-
`--accent` is a hover wash. Mapping it the other way turns every primary button grey.
|
|
224
|
-
The mapping is in `src/adapters/shadcn.ts`.
|
|
225
|
-
|
|
226
214
|
## Working on it
|
|
227
215
|
|
|
228
216
|
```sh
|
|
@@ -233,13 +221,12 @@ bun run catalogue:check # fail if the committed catalogue is stale
|
|
|
233
221
|
bun run vendor # refresh palettes/ from the pinned upstream revision
|
|
234
222
|
```
|
|
235
223
|
|
|
236
|
-
The generated catalogue is
|
|
237
|
-
inputs
|
|
238
|
-
invisible drift.
|
|
224
|
+
The generated catalogue is committed, and `catalogue:check` fails when it no longer
|
|
225
|
+
matches its inputs, so every palette change shows up as a reviewable diff.
|
|
239
226
|
|
|
240
227
|
`palettes/` is regenerated by `bun run vendor`, which reproduces Base24 schemes from
|
|
241
228
|
a revision pinned in `src/sources.ts`. To adopt a newer upstream, change
|
|
242
|
-
`CATALOGUE_REVISION`, run `vendor`, then `catalogue:build
|
|
229
|
+
`CATALOGUE_REVISION`, run `vendor`, then `catalogue:build`, and read the diff. The
|
|
243
230
|
build prints every value it repaired and why.
|
|
244
231
|
|
|
245
232
|
### Composing a theme from two palettes
|
|
@@ -256,11 +243,11 @@ against its donor in `tests/provenance.test.ts`.
|
|
|
256
243
|
1. Add its Base24 scheme to `palettes/` (or let `vendor` fetch it: add the slug to
|
|
257
244
|
`VENDORED_SOURCES` in `src/sources.ts` first).
|
|
258
245
|
2. Record its family's project, URL and licence in `FAMILY_PROVENANCE`, and its
|
|
259
|
-
entry in `VENDORED_SOURCES`
|
|
246
|
+
entry in `VENDORED_SOURCES` (id, labels, description, appearance, tags).
|
|
260
247
|
3. Declare `accentSlot` if the family's identity is not in its blue slot. Everforest
|
|
261
248
|
is green, Rosé Pine is iris, Monokai is magenta.
|
|
262
249
|
4. Add a fidelity assertion to `tests/provenance.test.ts`. The suite fails without
|
|
263
|
-
one
|
|
250
|
+
one, so every theme records where its colours come from.
|
|
264
251
|
5. `bun run catalogue:build && bun run verify`.
|
|
265
252
|
|
|
266
253
|
If the build reports a role it could not repair within budget, the answer is a
|
package/dist/accents.d.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
|
*/
|
|
@@ -94,7 +94,7 @@ export declare function accentValue(preset: AccentPreset, appearance: ThemeAppea
|
|
|
94
94
|
* The label to draw on an accent fill: black or white, whichever wins on contrast.
|
|
95
95
|
*
|
|
96
96
|
* Measured rather than conventional. The usual convention is "white on a coloured
|
|
97
|
-
* fill", which is wrong for the bright half of this set
|
|
97
|
+
* fill", which is wrong for the bright half of this set, white on `#a78bfa` is
|
|
98
98
|
* about 2.1:1, and black on it is about 9.9:1. That is why the same accent carries a
|
|
99
99
|
* black label in dark mode and a white one in light: the pair is designed so the
|
|
100
100
|
* polarity flips, and the label has to flip with it.
|
|
@@ -108,7 +108,7 @@ export declare function accentForegroundContrast(accent: string): number;
|
|
|
108
108
|
* A **uniform step**, not a proportional one, and the difference matters. Mixing a
|
|
109
109
|
* fixed share toward white or black moves an accent by a share of its headroom, so
|
|
110
110
|
* the same rule gives a mid-lightness light accent a step of ~0.10 and a pale dark
|
|
111
|
-
* accent one of ~0.03
|
|
111
|
+
* accent one of ~0.03, a hover that feels twice as strong in one appearance as the
|
|
112
112
|
* other, and nearly invisible on the palest accent.
|
|
113
113
|
*
|
|
114
114
|
* 0.05 is the step this system's accents were already hand-written with, so the
|
|
@@ -119,7 +119,7 @@ export declare const ACCENT_HOVER_STEP = 0.05;
|
|
|
119
119
|
* The hovered primary, as a resolved colour.
|
|
120
120
|
*
|
|
121
121
|
* Resolved rather than expressed as a `color-mix()`, because a uniform step cannot
|
|
122
|
-
* be written as a mix
|
|
122
|
+
* be written as a mix, see {@link ACCENT_HOVER_STEP}. That means it does **not**
|
|
123
123
|
* follow `--primary` on its own, so a consumer that applies themes at runtime has to
|
|
124
124
|
* write this token too; the alternative is a hover left over from the previous
|
|
125
125
|
* theme's primary. `shadcnVariables` includes it for that reason.
|
|
@@ -153,8 +153,8 @@ type TintedTheme = Pick<AdeaTheme, 'appearance' | 'colors' | 'ansi'> & {
|
|
|
153
153
|
*
|
|
154
154
|
* {@link primarySubtleAlpha} lowers a theme's strength for legibility, and this is
|
|
155
155
|
* how far it may go: below it the selected state stops reading as a state at all.
|
|
156
|
-
* The normalizer reserves it
|
|
157
|
-
* clears the floor under a tint this strong
|
|
156
|
+
* The normalizer reserves it, it fits a theme's hover rung so body text still
|
|
157
|
+
* clears the floor under a tint this strong, so every theme in the catalogue can
|
|
158
158
|
* carry at least this much. At 4% the tint over One Dark's popover measures ΔE 0.018
|
|
159
159
|
* against the popover, about the same as its hover rung's feedback there.
|
|
160
160
|
*/
|
|
@@ -185,7 +185,7 @@ export declare function tintCheck(theme: TintedTheme, primaries?: readonly strin
|
|
|
185
185
|
* {@link ACCENT_SUBTLE_MINIMUM_ALPHA}, because the normalizer fits its hover rung to
|
|
186
186
|
* leave room for it.
|
|
187
187
|
*
|
|
188
|
-
* Pass `primaries` to hold the strength for colours outside the offered set too
|
|
188
|
+
* Pass `primaries` to hold the strength for colours outside the offered set too,
|
|
189
189
|
* a product's own brand primary, say. The offered set is always included.
|
|
190
190
|
*/
|
|
191
191
|
export declare function primarySubtleAlpha(theme: TintedTheme, primaries?: readonly string[]): number;
|
|
@@ -195,14 +195,14 @@ export declare function primarySubtleAlpha(theme: TintedTheme, primaries?: reado
|
|
|
195
195
|
* Pass the **theme**: the expression then carries that theme's measured strength
|
|
196
196
|
* ({@link primarySubtleAlpha}) and body text on it is held to the floor for every
|
|
197
197
|
* accent the theme offers. It still reads `var(--primary)`, so it follows a runtime
|
|
198
|
-
* accent switch
|
|
198
|
+
* accent switch, but the strength is the theme's, so a consumer that applies
|
|
199
199
|
* themes at runtime has to write this token per theme, as it already does for
|
|
200
200
|
* {@link primaryHover}. A consumer whose primary is not one the theme offers passes
|
|
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. It is not legible on every theme
|
|
205
|
-
* text on its own primary's tint over a card measures 4.34:1 at the dark ceiling
|
|
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
206
|
* so it is kept for a consumer without a theme object in hand, not as the default
|
|
207
207
|
* to reach for.
|
|
208
208
|
*/
|
|
@@ -211,7 +211,7 @@ export declare function primarySubtleCss(target: ThemeAppearance | TintedTheme,
|
|
|
211
211
|
* ## The accents a theme offers
|
|
212
212
|
*
|
|
213
213
|
* The {@link ACCENTS} presets are brand colours: the same six everywhere, chosen
|
|
214
|
-
* once. They read as visitors on a theme whose palette disagrees with them
|
|
214
|
+
* once. They read as visitors on a theme whose palette disagrees with them, a
|
|
215
215
|
* Gruvbox canvas with a cool cyan primary is two palettes sharing one window. A
|
|
216
216
|
* theme also carries colours of its *own* that are accent-shaped: its ANSI row is
|
|
217
217
|
* full of vivid, hue-distinct colours that the palette's authors already tuned to
|
|
@@ -219,14 +219,14 @@ export declare function primarySubtleCss(target: ThemeAppearance | TintedTheme,
|
|
|
219
219
|
*
|
|
220
220
|
* `themeAccentPresets` offers those. It pairs the two appearances on the accent
|
|
221
221
|
* slots {@link ACCENT_PREFERENCE} ranks, keeps a slot only when it clears the
|
|
222
|
-
* same floors a catalogue accent must clear
|
|
223
|
-
* against the theme's own canvas, and a legible label
|
|
222
|
+
* same floors a catalogue accent must clear, chroma, the raised-surface floor
|
|
223
|
+
* against the theme's own canvas, and a legible label, and returns the theme's
|
|
224
224
|
* values verbatim. Nothing here authors a colour: the slots are the palette's, the
|
|
225
225
|
* floors are the catalogue's, and the pairing is the only new decision.
|
|
226
226
|
*
|
|
227
227
|
* The ids are role-shaped (`ansi-blue`), not value-shaped, so a stored accent
|
|
228
228
|
* survives switching themes: the blue stays the blue, of whichever theme is
|
|
229
|
-
* active. That is what "pulled from the selected theme" means
|
|
229
|
+
* active. That is what "pulled from the selected theme" means, the offering
|
|
230
230
|
* follows the theme, and so does the resolved colour.
|
|
231
231
|
*/
|
|
232
232
|
export type ThemeAccentSlot = (typeof ACCENT_PREFERENCE)[number];
|
|
@@ -253,7 +253,7 @@ export type AccentRoles = {
|
|
|
253
253
|
export declare function accentRoles(preset: AccentPreset,
|
|
254
254
|
/**
|
|
255
255
|
* The theme the accent is applied to, or only its appearance. A theme gives the
|
|
256
|
-
* tint that theme's measured strength
|
|
256
|
+
* tint that theme's measured strength, see {@link primarySubtleCss}; an
|
|
257
257
|
* appearance gives the unmeasured ceiling.
|
|
258
258
|
*/
|
|
259
259
|
target: ThemeAppearance | TintedTheme,
|