@adea-ai/themes 0.9.8 → 0.9.10
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 +95 -11
- package/dist/accents.d.ts.map +1 -1
- package/dist/accents.js +179 -9
- package/dist/accents.js.map +1 -1
- package/dist/adapters/shadcn.d.ts.map +1 -1
- package/dist/adapters/shadcn.js +3 -2
- package/dist/adapters/shadcn.js.map +1 -1
- package/dist/generated/themes/ayu-light.js +2 -2
- package/dist/generated/themes/one-dark.js +2 -2
- package/dist/generated/themes/rosepine-dawn.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/normalize.d.ts +2 -65
- package/dist/normalize.d.ts.map +1 -1
- package/dist/normalize.js +73 -74
- package/dist/normalize.js.map +1 -1
- package/dist/policy.d.ts +76 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +81 -0
- package/dist/policy.js.map +1 -0
- package/dist/validate.d.ts +5 -4
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +9 -4
- package/dist/validate.js.map +1 -1
- package/package.json +5 -5
- package/src/accents.ts +220 -16
- package/src/adapters/shadcn.ts +3 -2
- package/src/generated/themes/ayu-light.ts +2 -2
- package/src/generated/themes/one-dark.ts +2 -2
- package/src/generated/themes/rosepine-dawn.ts +1 -1
- package/src/index.ts +3 -0
- package/src/normalize.ts +103 -77
- package/src/policy.ts +86 -0
- package/src/validate.ts +9 -4
package/src/policy.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The catalogue's policy: the contrast floors, the repair budgets and the accent
|
|
3
|
+
* preference.
|
|
4
|
+
*
|
|
5
|
+
* Kept apart from the normalizer, which applies them, so that the accent axis —
|
|
6
|
+
* which the normalizer now consults to fit the interaction rungs around the primary
|
|
7
|
+
* tint — can read the same numbers without the two modules importing each other.
|
|
8
|
+
* `normalize.ts` re-exports everything here.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { AnsiKey } from './schema.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The contrast floors.
|
|
15
|
+
*
|
|
16
|
+
* These are the catalogue's policy, and they are the reason an external palette
|
|
17
|
+
* can be admitted at all: nothing enters the catalogue on taste. `text` sits at
|
|
18
|
+
* the WCAG AA body-text floor; `border` is measured on the non-text scale, where
|
|
19
|
+
* the requirement is perceptibility rather than legibility.
|
|
20
|
+
*/
|
|
21
|
+
export const CONTRAST_FLOORS = Object.freeze({
|
|
22
|
+
text: 4.5,
|
|
23
|
+
textMuted: 4.5,
|
|
24
|
+
/** Large or non-essential text, per WCAG 1.4.3. */
|
|
25
|
+
textSubtle: 3,
|
|
26
|
+
accent: 4.5,
|
|
27
|
+
/**
|
|
28
|
+
* The accent on a raised surface, where it is a fill rather than a label.
|
|
29
|
+
*
|
|
30
|
+
* The same two-tier reasoning as `statusRaised`: a button or a selected tab is a
|
|
31
|
+
* user-interface component, which WCAG holds to 3:1, and the pairing that
|
|
32
|
+
* actually carries text — the accent's own label — is measured separately at 4.5
|
|
33
|
+
* against the accent itself. Holding the accent to 4.5 on every surface instead
|
|
34
|
+
* made Everforest Light's every hue collapse into its body text, because that
|
|
35
|
+
* palette's colours are all around 2:1 on its own canvas.
|
|
36
|
+
*/
|
|
37
|
+
accentRaised: 3,
|
|
38
|
+
accentForeground: 4.5,
|
|
39
|
+
/**
|
|
40
|
+
* Status colours drawn on the canvas, where they are read as small text.
|
|
41
|
+
*/
|
|
42
|
+
status: 4.5,
|
|
43
|
+
/**
|
|
44
|
+
* Status colours drawn on a raised surface, where they are an indicator.
|
|
45
|
+
*
|
|
46
|
+
* The two-tier policy is deliberate and it is not a relaxation for convenience.
|
|
47
|
+
* A status role on a card is nearly always a dot, an icon or a chip's own fill —
|
|
48
|
+
* a graphical object, which WCAG holds to 3:1 — and it is that way because the
|
|
49
|
+
* alternative does not exist: Ayu Light and Everforest Light are muted palettes
|
|
50
|
+
* built for a near-white canvas and neither contains a yellow that is legible as
|
|
51
|
+
* small text on one. Forcing 4.5:1 there required blending the warning colour
|
|
52
|
+
* 94% of the way to the body text, which produces a warning that is the same
|
|
53
|
+
* colour as the text beside it and is therefore not a warning at all.
|
|
54
|
+
*
|
|
55
|
+
* A component that renders small status *text* on a raised surface should put it
|
|
56
|
+
* on the role's `-subtle` fill, which is a tint of the canvas and is measured at
|
|
57
|
+
* the body floor.
|
|
58
|
+
*/
|
|
59
|
+
statusRaised: 3,
|
|
60
|
+
/** A divider is decorative; it must be seen, not read. */
|
|
61
|
+
border: 1.15,
|
|
62
|
+
borderMuted: 1.08,
|
|
63
|
+
/** A raised surface must be distinguishable from the canvas it sits on. */
|
|
64
|
+
surface: 1.03,
|
|
65
|
+
/** A selection must be visible under the text it selects. */
|
|
66
|
+
selection: 1.2,
|
|
67
|
+
} as const)
|
|
68
|
+
|
|
69
|
+
/** How far the normalizer may move a colour's lightness before it gives up. */
|
|
70
|
+
export const REPAIR_BUDGET = Object.freeze({
|
|
71
|
+
/** Body text: some palettes publish a foreground that fails on their own canvas. */
|
|
72
|
+
text: 0.2,
|
|
73
|
+
status: 0.24,
|
|
74
|
+
accent: 0.24,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
/** The accent preference order, best first. */
|
|
78
|
+
export const ACCENT_PREFERENCE = [
|
|
79
|
+
'blue',
|
|
80
|
+
'magenta',
|
|
81
|
+
'cyan',
|
|
82
|
+
'green',
|
|
83
|
+
] as const satisfies readonly AnsiKey[]
|
|
84
|
+
|
|
85
|
+
/** The smallest chroma a colour needs before it reads as "a colour" rather than grey. */
|
|
86
|
+
export const MINIMUM_ACCENT_CHROMA = 0.035
|
package/src/validate.ts
CHANGED
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
* than a legibility one.
|
|
16
16
|
*
|
|
17
17
|
* Not measured: a colour against itself, and the surface ladder against anything
|
|
18
|
-
* but the canvas. A rung's job is to be distinguishable from the
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* but the canvas and body text. A rung's job is to be distinguishable from the
|
|
19
|
+
* canvas, and measuring it against every foreground would produce failures no theme
|
|
20
|
+
* could pass and no component would care about. Body text is the exception: it is
|
|
21
|
+
* drawn on every rung, the hover and active rungs included, because a hovered or
|
|
22
|
+
* pressed row keeps its label.
|
|
22
23
|
*
|
|
23
24
|
* ## Why the validator is exported
|
|
24
25
|
*
|
|
@@ -77,6 +78,10 @@ export const REQUIRED_PAIRINGS: readonly Pairing[] = Object.freeze([
|
|
|
77
78
|
{ role: 'textMuted', against: ['background'], minimum: CONTRAST_FLOORS.textMuted },
|
|
78
79
|
{ role: 'text', against: ['surface'], minimum: CONTRAST_FLOORS.text },
|
|
79
80
|
{ role: 'text', against: ['surfaceElevated'], minimum: CONTRAST_FLOORS.text },
|
|
81
|
+
// A hovered or pressed row keeps its label, so the interaction rungs carry the
|
|
82
|
+
// body floor too. The normalizer fits the rungs to it; see `fitInteractionRungs`.
|
|
83
|
+
{ role: 'text', against: ['surfaceHover'], minimum: CONTRAST_FLOORS.text },
|
|
84
|
+
{ role: 'text', against: ['surfaceActive'], minimum: CONTRAST_FLOORS.text },
|
|
80
85
|
{ role: 'textMuted', against: ['surface'], minimum: CONTRAST_FLOORS.textMuted },
|
|
81
86
|
{ role: 'textSubtle', against: ['background'], minimum: CONTRAST_FLOORS.textSubtle },
|
|
82
87
|
{ role: 'accent', against: ['background'], minimum: CONTRAST_FLOORS.accent },
|