@dqa-ai-solutions/ui-runtime 0.2.0 → 0.2.1
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/README.md +34 -2
- package/dist/_types/ui-kit/primitives/component-css.d.ts +10 -0
- package/dist/_types/ui-kit/primitives/index.d.ts +3 -0
- package/dist/_types/ui-kit/primitives/spec.d.ts +102 -0
- package/dist/_types/ui-kit/primitives/stylesheet.d.ts +37 -0
- package/dist/_types/ui-kit/tokens/emit.d.ts +70 -0
- package/dist/_types/ui-kit/tokens/index.d.ts +5 -0
- package/dist/_types/ui-kit/tokens/oklch.d.ts +53 -0
- package/dist/_types/ui-kit/tokens/resolve.d.ts +4 -0
- package/dist/_types/ui-kit/tokens/scales.d.ts +325 -0
- package/dist/_types/ui-kit/tokens/theme.dqa.d.ts +2 -0
- package/dist/chunks/chunk-5NTG4J62.js +11 -0
- package/dist/chunks/chunk-66DQVLFK.js +5 -0
- package/dist/chunks/chunk-JOIDPECM.js +3 -0
- package/dist/chunks/{chunk-VS5FCRGY.js → chunk-MS2W22ER.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/kit.css +2291 -0
- package/dist/lens.js +1 -1
- package/dist/primitives.js +1 -1
- package/dist/react.js +1 -1
- package/dist/tokens.js +1 -1
- package/package.json +2 -1
- package/dist/chunks/chunk-4LX2HZJU.js +0 -0
- package/dist/chunks/chunk-X6SR5UHK.js +0 -1
package/README.md
CHANGED
|
@@ -11,8 +11,40 @@ npm i @dqa-ai-solutions/core-runtime @dqa-ai-solutions/ui-runtime
|
|
|
11
11
|
|
|
12
12
|
| Import | What |
|
|
13
13
|
|---|---|
|
|
14
|
-
| `@dqa-ai-solutions/ui-runtime` (`/tokens`, `/primitives`, `/lens`, `/shell`) | what a screen element must be, decided from the `ViewContract` the server resolved |
|
|
15
|
-
| `@dqa-ai-solutions/ui-runtime/
|
|
14
|
+
| `@dqa-ai-solutions/ui-runtime` (`/tokens`, `/primitives`, `/lens`, `/shell`) | what a screen element must be, decided from the `ViewContract` the server resolved; the theme → CSS generator |
|
|
15
|
+
| `@dqa-ai-solutions/ui-runtime/kit.css` | the whole kit, ready to load: tokens, base, layout and a rule for every `fos-*` class the React elements put on — default theme, with the `compact` and `roomy` densities |
|
|
16
|
+
| `@dqa-ai-solutions/ui-runtime/tokens.css` (`.generated`, `.dark`, `.high`) | the token variables alone |
|
|
16
17
|
| `@dqa-ai-solutions/ui-runtime/react` | the React renderer (`react` is an optional peer) |
|
|
17
18
|
|
|
18
19
|
Every entry loads in a browser. ES modules only.
|
|
20
|
+
|
|
21
|
+
## Styling the elements
|
|
22
|
+
|
|
23
|
+
The React elements carry class names (`fos-btn`, `fos-field`, `fos-dialog`, …) and no style of their
|
|
24
|
+
own. Load one stylesheet before your own:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import '@dqa-ai-solutions/ui-runtime/kit.css'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Element defaults are zero-specificity, so anything you write afterwards wins without `!important`.
|
|
31
|
+
|
|
32
|
+
### Your own theme
|
|
33
|
+
|
|
34
|
+
`kit.css` is the default theme. For your own colours and type, generate the same stylesheet from a
|
|
35
|
+
theme declaration — at build time, into a file you commit:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { writeFileSync } from 'node:fs'
|
|
39
|
+
import { resolveTheme, formatThemeDiagnostics, DQA_THEME } from '@dqa-ai-solutions/ui-runtime/tokens'
|
|
40
|
+
import { emitStylesheet } from '@dqa-ai-solutions/ui-runtime/primitives'
|
|
41
|
+
|
|
42
|
+
const { theme, diagnostics, ok } = resolveTheme({ ...DQA_THEME /* your hues, fonts, … */ })
|
|
43
|
+
if (diagnostics.length) console.log(formatThemeDiagnostics(diagnostics))
|
|
44
|
+
if (!ok) process.exit(1) // a colour pair failed its contrast check
|
|
45
|
+
writeFileSync('src/kit.css', emitStylesheet(theme, { densities: ['compact', 'roomy'] }))
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`resolveTheme` computes every colour from a hue and checks it for contrast against every ground it
|
|
49
|
+
can land on; `emitStylesheet` writes the four layers (tokens, base, layout, components) in one file.
|
|
50
|
+
To rename `fos-`, pass the same `prefix` to `emitStylesheet` and to `setPrefix` from `./react`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ComponentCssOptions {
|
|
2
|
+
prefix?: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Structural CSS for every element the grammar covers.
|
|
6
|
+
*
|
|
7
|
+
* Load it AFTER the theme's variables and before the app's own stylesheet, so
|
|
8
|
+
* an app can still override a specific screen — it simply no longer has to.
|
|
9
|
+
*/
|
|
10
|
+
export declare function emitComponentCss(options?: ComponentCssOptions): string;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { type SurfaceKind, type SkeletonKind, type EmptyReason, type NextStep, type EmptyCopy, type Fault, type SurfaceState, type SurfaceInput, type StateHandlers, skeletonFor, surfaceState, matchState, assertNever, } from './state.js';
|
|
2
2
|
export { type ActionTier, type ActionFacts, type DisabledReason, type ActionView, actionViews, actionBar, primaryOf, inSightCount, VISIBLE_SECONDARY, TIER_PAINT, type ActionBar, type ActionSurface, } from './action.js';
|
|
3
|
+
export { type Surface, type Token, type TextRole, type TextSpec, type ButtonSpec, type FieldSpec, type TabSpec, type TableSpec, type MenuItemSpec, textSpec, buttonSpec, fieldSpec, tabSpec, tableSpec, menuItemSpec, SURFACES, TEXT_ROLES, } from './spec.js';
|
|
4
|
+
export { emitComponentCss, type ComponentCssOptions } from './component-css.js';
|
|
5
|
+
export { emitStylesheet, emitBaseCss, emitLayoutCss, type StylesheetOptions, } from './stylesheet.js';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { ActionTier } from './action.js';
|
|
2
|
+
/** Where an element stands. Position, not appearance. */
|
|
3
|
+
export type Surface = 'page' | 'dialog' | 'form' | 'table' | 'rail' | 'card';
|
|
4
|
+
/** A token reference — never a value. */
|
|
5
|
+
export type Token = string;
|
|
6
|
+
/**
|
|
7
|
+
* Every job text does. Naming the JOB, never the size.
|
|
8
|
+
*
|
|
9
|
+
* ⚠️ `label` and `hint` are different roles even though a lazy system would
|
|
10
|
+
* render both as small grey text. A label names a field and is read before
|
|
11
|
+
* the answer; a hint qualifies it and is read only when the answer is
|
|
12
|
+
* unclear. Giving them the same weight makes the form one flat wall.
|
|
13
|
+
*/
|
|
14
|
+
export type TextRole = 'page-title' | 'section-title' | 'card-title' | 'lead' | 'body' | 'label' | 'hint' | 'error' | 'table-header' | 'table-cell' | 'table-cell-sub' | 'badge' | 'empty-title' | 'empty-body' | 'rail-item' | 'tab' | 'note' | 'delta';
|
|
15
|
+
export interface TextSpec {
|
|
16
|
+
/** Type step — the class from `emitTypeUtilities`, all four numbers. */
|
|
17
|
+
step: string;
|
|
18
|
+
ink: Token;
|
|
19
|
+
/** Overrides the step's weight when the ROLE needs more emphasis than the size. */
|
|
20
|
+
weight?: number;
|
|
21
|
+
numeric?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const textSpec: (role: TextRole) => TextSpec;
|
|
24
|
+
export interface ButtonSpec {
|
|
25
|
+
tier: ActionTier;
|
|
26
|
+
/** Token for the control's height. */
|
|
27
|
+
height: Token;
|
|
28
|
+
padX: Token;
|
|
29
|
+
gap: Token;
|
|
30
|
+
text: TextRole;
|
|
31
|
+
background: Token;
|
|
32
|
+
ink: Token;
|
|
33
|
+
border: Token | null;
|
|
34
|
+
}
|
|
35
|
+
export declare function buttonSpec(where: {
|
|
36
|
+
surface: Surface;
|
|
37
|
+
tier: ActionTier;
|
|
38
|
+
}): ButtonSpec;
|
|
39
|
+
export interface FieldSpec {
|
|
40
|
+
height: Token;
|
|
41
|
+
padX: Token;
|
|
42
|
+
radius: Token;
|
|
43
|
+
background: Token;
|
|
44
|
+
ink: Token;
|
|
45
|
+
border: Token;
|
|
46
|
+
label: TextRole;
|
|
47
|
+
hint: TextRole;
|
|
48
|
+
error: TextRole;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* ⚠️ An input inside a TABLE (inline editing) keeps the row's height; anywhere
|
|
52
|
+
* else it takes the full target. Same rule as a button, same one reason.
|
|
53
|
+
*/
|
|
54
|
+
export declare const fieldSpec: (surface: Surface) => FieldSpec;
|
|
55
|
+
export interface TabSpec {
|
|
56
|
+
height: Token;
|
|
57
|
+
padX: Token;
|
|
58
|
+
text: TextRole;
|
|
59
|
+
ink: Token;
|
|
60
|
+
activeInk: Token;
|
|
61
|
+
/** How the current tab is marked. */
|
|
62
|
+
marker: 'underline' | 'filled';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Two levels, and they must not look alike.
|
|
66
|
+
*
|
|
67
|
+
* ⚠️ Page tabs switch what the screen IS; tabs inside a card switch a slice of
|
|
68
|
+
* one thing. Drawn the same, a reader cannot tell how far a click will take
|
|
69
|
+
* them — so the page level underlines and the nested level fills.
|
|
70
|
+
*/
|
|
71
|
+
export declare const tabSpec: (surface: Surface) => TabSpec;
|
|
72
|
+
export interface TableSpec {
|
|
73
|
+
headerHeight: Token;
|
|
74
|
+
rowHeight: Token;
|
|
75
|
+
padX: Token;
|
|
76
|
+
padY: Token;
|
|
77
|
+
header: TextRole;
|
|
78
|
+
cell: TextRole;
|
|
79
|
+
cellSub: TextRole;
|
|
80
|
+
/** Between rows. A long table without one lets the eye slip a line. */
|
|
81
|
+
rule: Token;
|
|
82
|
+
/** Under the header — heavier, so the head reads as a head. */
|
|
83
|
+
headerRule: Token;
|
|
84
|
+
hover: Token;
|
|
85
|
+
selected: Token;
|
|
86
|
+
}
|
|
87
|
+
export declare const tableSpec: () => TableSpec;
|
|
88
|
+
export interface MenuItemSpec {
|
|
89
|
+
height: Token;
|
|
90
|
+
padX: Token;
|
|
91
|
+
text: TextRole;
|
|
92
|
+
ink: Token;
|
|
93
|
+
activeInk: Token;
|
|
94
|
+
activeBackground: Token;
|
|
95
|
+
hover: Token;
|
|
96
|
+
/** Declared scope with no screen behind it yet — see `NavItem.path`. */
|
|
97
|
+
unbuiltInk: Token;
|
|
98
|
+
}
|
|
99
|
+
export declare const menuItemSpec: () => MenuItemSpec;
|
|
100
|
+
/** Every surface, so a caller can prove it covered them all. */
|
|
101
|
+
export declare const SURFACES: readonly Surface[];
|
|
102
|
+
export declare const TEXT_ROLES: TextRole[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type EmitOptions } from '../tokens/emit.js';
|
|
2
|
+
import type { ResolvedTheme, Density } from '../tokens/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Element defaults, so semantic HTML is already right.
|
|
5
|
+
*
|
|
6
|
+
* ⚠️ Everything here is `:where(...)`. An app overrides any of it with a plain
|
|
7
|
+
* selector and never has to think about specificity.
|
|
8
|
+
*/
|
|
9
|
+
export declare function emitBaseCss(prefix?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* The mould — page frame, rhythm, and the few layouts every screen repeats.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ Deliberately small. A kit that also owns page composition stops being a kit
|
|
14
|
+
* and becomes a framework nobody can build an unusual screen in. What is here
|
|
15
|
+
* is the shape an operational product repeats on every screen: a page with a
|
|
16
|
+
* header, sections at one rhythm, a form that does not step, a table that
|
|
17
|
+
* scrolls sideways instead of breaking the page.
|
|
18
|
+
*/
|
|
19
|
+
export declare function emitLayoutCss(prefix?: string): string;
|
|
20
|
+
export interface StylesheetOptions extends EmitOptions {
|
|
21
|
+
/** Density blocks to emit alongside the default — see `emitCss`. */
|
|
22
|
+
densities?: Density[];
|
|
23
|
+
/** Leave out the element defaults if the app already has its own reset. */
|
|
24
|
+
base?: boolean;
|
|
25
|
+
/** Leave out the page frame if the app composes its own layout. */
|
|
26
|
+
layout?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The whole kit, in cascade order, from one call.
|
|
30
|
+
*
|
|
31
|
+
* writeFileSync('ui-kit.css', emitStylesheet(theme))
|
|
32
|
+
*
|
|
33
|
+
* Order matters and is not the caller's problem: base (zero specificity) →
|
|
34
|
+
* tokens → type → components → layout. An application's own stylesheet loads
|
|
35
|
+
* after this one and wins wherever it says anything.
|
|
36
|
+
*/
|
|
37
|
+
export declare function emitStylesheet(theme: ResolvedTheme, options?: StylesheetOptions): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ResolvedTheme, Density } from './types.js';
|
|
2
|
+
export interface EmitOptions {
|
|
3
|
+
/** Where the variables land. Two themes = two calls, two selectors. */
|
|
4
|
+
selector?: string;
|
|
5
|
+
/** Variable prefix, without dashes. */
|
|
6
|
+
prefix?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Write each spacing and radius step's purpose beside it.
|
|
9
|
+
*
|
|
10
|
+
* ⭐ On by default. A developer reads the generated file far more often than
|
|
11
|
+
* they read this package, and a scale whose steps explain themselves is the
|
|
12
|
+
* difference between "24 or 32?" and "this is a card".
|
|
13
|
+
*/
|
|
14
|
+
annotate?: boolean;
|
|
15
|
+
/** Prepended verbatim, inside the block. For an app's own bridge aliases. */
|
|
16
|
+
tail?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Also emit `:root[data-density="…"]` overrides, so a density switch is a
|
|
19
|
+
* single attribute rather than a second stylesheet.
|
|
20
|
+
*
|
|
21
|
+
* ⭐ Only the tokens density actually governs appear in these blocks — the
|
|
22
|
+
* package knows which, so the app never has to guess.
|
|
23
|
+
*
|
|
24
|
+
* ⛔ `--fos-touch` IS NEVER AMONG THEM, and that absence is deliberate enough
|
|
25
|
+
* to be tested. It is fixed at 44px across all three densities because a
|
|
26
|
+
* finger does not get smaller when a layout gets tighter; a density block
|
|
27
|
+
* containing it would invite the next reader to believe otherwise.
|
|
28
|
+
*
|
|
29
|
+
* ⚠️ The theme's own density is added if missing. Without it there is no
|
|
30
|
+
* selector to switch BACK to the default, and the app discovers that after
|
|
31
|
+
* shipping the switch.
|
|
32
|
+
*/
|
|
33
|
+
densities?: Density[];
|
|
34
|
+
}
|
|
35
|
+
export declare function emitCss(theme: ResolvedTheme, options?: EmitOptions): string;
|
|
36
|
+
/**
|
|
37
|
+
* Every variable name this theme defines.
|
|
38
|
+
*
|
|
39
|
+
* ⭐ Exported so an app can check its own stylesheet against it. A `var(--fos-x)`
|
|
40
|
+
* naming nothing is the failure CSS handles worst: no warning, no fallback —
|
|
41
|
+
* it DROPS THE WHOLE DECLARATION. The app measured for this package lost a red
|
|
42
|
+
* marker bar exactly that way and found out by looking at the screen.
|
|
43
|
+
*/
|
|
44
|
+
export declare function tokenNames(theme: ResolvedTheme, prefix?: string): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Type steps as CLASSES — the ergonomic half, and it exists because the
|
|
47
|
+
* variables alone measurably failed.
|
|
48
|
+
*
|
|
49
|
+
* ⛔ THE MEASUREMENT THAT FORCED THIS
|
|
50
|
+
*
|
|
51
|
+
* `emitCss` publishes four variables per step: size, line, weight, tracking —
|
|
52
|
+
* 24 in all. The first application to adopt the package wired **the size, and
|
|
53
|
+
* nothing else**: 0 of the 18 secondary tokens. The other three ended up
|
|
54
|
+
* scattered through 4,788 lines of stylesheet, a different answer each time,
|
|
55
|
+
* and that inconsistency is exactly what makes an interface read as patchwork.
|
|
56
|
+
*
|
|
57
|
+
* Nobody was careless. Four variables per step means an author has to REMEMBER
|
|
58
|
+
* to compose four, and under any deadline they take the one that visibly
|
|
59
|
+
* changes something. This is the same shape as a shared component that ships
|
|
60
|
+
* with six call sites and sixty-two hand-rolled copies: the right thing existed
|
|
61
|
+
* and the easy thing won.
|
|
62
|
+
*
|
|
63
|
+
* ⚠️ AND IT BENDS A RULE THIS PACKAGE STATES ELSEWHERE — that the engine emits
|
|
64
|
+
* variables and never CSS rules. The rule holds where it was aimed: nothing
|
|
65
|
+
* here decides what a card or a button looks like. A type step is different,
|
|
66
|
+
* because the engine already owns all four of its numbers; withholding them
|
|
67
|
+
* as four separate parts was not restraint, it was an assembly instruction
|
|
68
|
+
* nobody follows.
|
|
69
|
+
*/
|
|
70
|
+
export declare function emitTypeUtilities(theme: ResolvedTheme, prefix?: string): string;
|
|
@@ -1 +1,6 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
+
export { resolveTheme, formatThemeDiagnostics } from './resolve.js';
|
|
3
|
+
export { emitCss, emitTypeUtilities, tokenNames, type EmitOptions } from './emit.js';
|
|
4
|
+
export { DQA_THEME } from './theme.dqa.js';
|
|
5
|
+
export { SPACE, SPACE_PURPOSE, RADIUS, RADIUS_PURPOSE, TEXT, FONT, STATIC, LADDER, GREY_TINT, TONE_HUE, TONE_ALIAS, CONTROL, TARGET_FLOOR, } from './scales.js';
|
|
6
|
+
export { toHex, fromHex, contrast, luminance, type Oklch } from './oklch.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Lightness 0–1, chroma 0–~0.4, hue in degrees. */
|
|
2
|
+
export interface Oklch {
|
|
3
|
+
l: number;
|
|
4
|
+
c: number;
|
|
5
|
+
h: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Rgb {
|
|
8
|
+
r: number;
|
|
9
|
+
g: number;
|
|
10
|
+
b: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Pull chroma down until the colour fits in sRGB, keeping lightness and hue.
|
|
14
|
+
*
|
|
15
|
+
* ⚠️ NOT a per-channel clamp. Clamping moves the hue — ask for a saturated blue
|
|
16
|
+
* at high lightness and a clamp hands back something visibly purple: the
|
|
17
|
+
* app's brand colour rendered wrong, with no complaint. Reducing chroma keeps
|
|
18
|
+
* the colour recognisably itself and merely duller, and `clipped` says so out
|
|
19
|
+
* loud so the resolver can report it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function fit(colour: Oklch): {
|
|
22
|
+
rgb: Rgb;
|
|
23
|
+
clipped: boolean;
|
|
24
|
+
};
|
|
25
|
+
/** OKLCH → `#rrggbb`, chroma-fitted. */
|
|
26
|
+
export declare function toHex(colour: Oklch): {
|
|
27
|
+
hex: string;
|
|
28
|
+
clipped: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* WCAG relative luminance, measured on the BYTES that ship.
|
|
32
|
+
*
|
|
33
|
+
* ⭐ Deliberately re-read from the hex rather than kept from the float pipeline.
|
|
34
|
+
* The browser paints the rounded 8-bit value, so that is the value whose
|
|
35
|
+
* contrast has to pass. A theme that passes at full precision and fails after
|
|
36
|
+
* rounding would be a check that lies in the app's favour.
|
|
37
|
+
*/
|
|
38
|
+
export declare function luminance(hex: string): number;
|
|
39
|
+
/** WCAG 2.x contrast ratio, 1–21. */
|
|
40
|
+
export declare function contrast(a: string, b: string): number;
|
|
41
|
+
/**
|
|
42
|
+
* `#rrggbb` → OKLCH. The inverse, and it earns its place twice.
|
|
43
|
+
*
|
|
44
|
+
* ⭐ It is how the ladders in `scales.ts` were DERIVED rather than invented: the
|
|
45
|
+
* hand-written palette that shipped before this package was read back into
|
|
46
|
+
* OKLCH, and the rungs are where its own colours already sat. A computed
|
|
47
|
+
* system that lands somewhere else than the brand it replaces is a redesign
|
|
48
|
+
* wearing the costume of a refactor.
|
|
49
|
+
*
|
|
50
|
+
* ⚠️ Also the migration tool. An app holding a legacy hex can ask what hue it
|
|
51
|
+
* actually is, instead of guessing a declaration and comparing screenshots.
|
|
52
|
+
*/
|
|
53
|
+
export declare function fromHex(hex: string): Oklch;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ThemeDecl, ThemeDiagnostic, ThemeResult } from './types.js';
|
|
2
|
+
export declare function resolveTheme(decl: ThemeDecl): ThemeResult;
|
|
3
|
+
/** One block a build step or a start-up can print. */
|
|
4
|
+
export declare function formatThemeDiagnostics(list: ThemeDiagnostic[]): string;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chroma of each grey rung, as a multiple of `tint`.
|
|
3
|
+
*
|
|
4
|
+
* ⭐ One number would have been tidier and wrong. The shipped palette tints its
|
|
5
|
+
* ink seven times harder than its page ground (0.021 vs 0.003), and it is
|
|
6
|
+
* right to: a near-black at zero chroma reads as a different material from
|
|
7
|
+
* the surface it sits on, while the same tint on a near-white is invisible.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GREY_TINT: {
|
|
10
|
+
readonly light: {
|
|
11
|
+
readonly bg: 1;
|
|
12
|
+
/** White, by definition. Tinting it makes it a colour, not a ground. */
|
|
13
|
+
readonly surface: 0;
|
|
14
|
+
readonly 'surface-2': 0.6;
|
|
15
|
+
readonly ink: 7;
|
|
16
|
+
readonly 'ink-2': 8;
|
|
17
|
+
readonly 'ink-3': 10;
|
|
18
|
+
readonly line: 2.5;
|
|
19
|
+
readonly 'line-2': 2;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* ⛔ NOT the light table, and getting this wrong shipped twice in one session.
|
|
23
|
+
*
|
|
24
|
+
* ① `surface: 0` is a statement about WHITE. In dark the card ground is a
|
|
25
|
+
* grey, so zero tint left it flatly neutral while the page around it went
|
|
26
|
+
* navy — one panel visibly not belonging to the app.
|
|
27
|
+
* ② The ink multipliers invert. Near black there is room for chroma; near
|
|
28
|
+
* white there is almost none, so carrying 7× tint onto a near-white ink
|
|
29
|
+
* ran out of sRGB and came back clipped on every build.
|
|
30
|
+
*
|
|
31
|
+
* A single table read as one decision. It is two.
|
|
32
|
+
*/
|
|
33
|
+
readonly dark: {
|
|
34
|
+
readonly bg: 1;
|
|
35
|
+
readonly surface: 1.1;
|
|
36
|
+
readonly 'surface-2': 1.05;
|
|
37
|
+
readonly ink: 1.2;
|
|
38
|
+
readonly 'ink-2': 2;
|
|
39
|
+
readonly 'ink-3': 2.6;
|
|
40
|
+
readonly line: 1.8;
|
|
41
|
+
readonly 'line-2': 1.6;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const LADDER: {
|
|
45
|
+
readonly light: {
|
|
46
|
+
readonly bg: 0.973;
|
|
47
|
+
readonly surface: 1;
|
|
48
|
+
readonly 'surface-2': 0.988;
|
|
49
|
+
readonly ink: 0.239;
|
|
50
|
+
readonly 'ink-2': 0.477;
|
|
51
|
+
/**
|
|
52
|
+
* ⛔ 0.545, NOT the shipped 0.555 — and this one is the whole argument for
|
|
53
|
+
* checking by machine.
|
|
54
|
+
*
|
|
55
|
+
* `tokens.css` says of its own `--fos-ink-3`: *"≥4.5:1 trên nền trắng"*.
|
|
56
|
+
* True, and beside the point: the page ground is `--fos-bg`, not white, and
|
|
57
|
+
* against that the shipped value is 4.40:1. A careful human checked the
|
|
58
|
+
* wrong pair once and it has shipped ever since.
|
|
59
|
+
*/
|
|
60
|
+
readonly 'ink-3': 0.545;
|
|
61
|
+
readonly line: 0.924;
|
|
62
|
+
readonly 'line-2': 0.955;
|
|
63
|
+
/** Where the app's own colour sits so a white label clears AA on it. */
|
|
64
|
+
readonly accent: 0.428;
|
|
65
|
+
readonly accentBg: 0.946;
|
|
66
|
+
/**
|
|
67
|
+
* ⛔ 0.515, NOT the 0.545 the shipped inks average to — and the guard is why.
|
|
68
|
+
*
|
|
69
|
+
* Measured on the palette this replaces: the `warn` chip is 4.10:1 and the
|
|
70
|
+
* `muted` chip 2.84:1 against their own grounds. Both ship today. A badge
|
|
71
|
+
* is the one place a user reads a single word and acts on it, so the rung
|
|
72
|
+
* sits where the worst tone (`done`, at this ground) still clears 4.5:1.
|
|
73
|
+
*/
|
|
74
|
+
readonly toneInk: 0.515;
|
|
75
|
+
readonly toneGround: 0.952;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* ⭐ Dark is a DECLARATION here, not a second palette.
|
|
79
|
+
*
|
|
80
|
+
* `tokens.css` records the debt honestly: *"CHƯA đưa dark-mode vào đây…
|
|
81
|
+
* Nhập chung ngay bây giờ là bật dark-mode cho một app chưa từng thiết kế
|
|
82
|
+
* cho nó."* That reasoning was right about the risk and is now cheap to
|
|
83
|
+
* satisfy — the rungs exist, nothing switches until an app asks.
|
|
84
|
+
*
|
|
85
|
+
* LIGHTNESS is anchored on the admin shell ground that already ships
|
|
86
|
+
* (`#08213f`, L 0.247, H 255) so a dark theme reads as the same product.
|
|
87
|
+
*
|
|
88
|
+
* ⚠️ Its CHROMA is not, and cannot be: colourfulness comes from `tint`, and
|
|
89
|
+
* at the default 0.003 the dark grounds land near-neutral rather than the
|
|
90
|
+
* cobalt navy of that shell. An app wanting the navy declares
|
|
91
|
+
* `tint: 0.02`. Baking it in here would make every dark theme on the
|
|
92
|
+
* kernel navy, which is the app's taste smuggled into the engine.
|
|
93
|
+
*/
|
|
94
|
+
readonly dark: {
|
|
95
|
+
readonly bg: 0.2;
|
|
96
|
+
readonly surface: 0.247;
|
|
97
|
+
readonly 'surface-2': 0.224;
|
|
98
|
+
readonly ink: 0.96;
|
|
99
|
+
readonly 'ink-2': 0.8;
|
|
100
|
+
readonly 'ink-3': 0.7;
|
|
101
|
+
readonly line: 0.33;
|
|
102
|
+
readonly 'line-2': 0.285;
|
|
103
|
+
readonly accent: 0.68;
|
|
104
|
+
readonly accentBg: 0.3;
|
|
105
|
+
readonly toneInk: 0.82;
|
|
106
|
+
readonly toneGround: 0.31;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The six weights a state can carry, and the DQA default hue for each.
|
|
111
|
+
*
|
|
112
|
+
* ⚠️ `wait` has no colour in the shipped palette — there are five states there
|
|
113
|
+
* and the ontology vocabulary has six. A tone with nowhere to go is a badge
|
|
114
|
+
* that silently renders as `plain`, which is the failure this package exists
|
|
115
|
+
* to remove, so it gets a hue here.
|
|
116
|
+
*/
|
|
117
|
+
export declare const TONE_HUE: Record<string, {
|
|
118
|
+
hue: number;
|
|
119
|
+
chroma: number;
|
|
120
|
+
}>;
|
|
121
|
+
/** Legacy name each tone also publishes, so the shipped stylesheets keep working. */
|
|
122
|
+
export declare const TONE_ALIAS: Record<string, string>;
|
|
123
|
+
/**
|
|
124
|
+
* Spacing, 4px base. Density scales SPACING ONLY.
|
|
125
|
+
*
|
|
126
|
+
* ⚠️ Never type size, never hit targets. A compact theme is a tighter layout,
|
|
127
|
+
* not a smaller word or a harder button to hit — shrinking those is how
|
|
128
|
+
* "dense" becomes "unusable", and it is the failure mode of every tool that
|
|
129
|
+
* ships a density switch.
|
|
130
|
+
*/
|
|
131
|
+
export declare const SPACE: Record<'compact' | 'cosy' | 'roomy', Record<string, number>>;
|
|
132
|
+
/**
|
|
133
|
+
* A table row, per density — height and cell padding.
|
|
134
|
+
*
|
|
135
|
+
* ⛔ ADDED AFTER `density` WAS FOUND TOO NARROW TO DO ITS JOB.
|
|
136
|
+
*
|
|
137
|
+
* The comment above says density scales spacing and nothing else. That was
|
|
138
|
+
* right about type size and hit targets, and WRONG about a table row: a row's
|
|
139
|
+
* height and its cell padding ARE spacing, and leaving them out meant the one
|
|
140
|
+
* surface where density matters most had no density.
|
|
141
|
+
*
|
|
142
|
+
* Measured on the first app to adopt: cell padding was 8px, 9px and 10px
|
|
143
|
+
* depending on which table you were looking at — three answers to a question
|
|
144
|
+
* the theme was supposed to have settled.
|
|
145
|
+
*
|
|
146
|
+
* ⭐ This is what makes a "comfortable / compact" switch a package feature
|
|
147
|
+
* instead of something each app invents. An officer working a grid all day
|
|
148
|
+
* needs compact; someone opening it weekly needs comfortable.
|
|
149
|
+
*/
|
|
150
|
+
export declare const ROW: Record<'compact' | 'cosy' | 'roomy', {
|
|
151
|
+
h: number;
|
|
152
|
+
padX: number;
|
|
153
|
+
padY: number;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* How TALL a control is drawn — separate from how big its TARGET is.
|
|
157
|
+
*
|
|
158
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
159
|
+
* ⭐ TWO NUMBERS, BECAUSE THEY ANSWER TWO QUESTIONS
|
|
160
|
+
*
|
|
161
|
+
* The first cut drew every control at the full 44px target, and it read as
|
|
162
|
+
* heavy — correct by the letter of the guideline and wrong for a keyboard-led
|
|
163
|
+
* admin product, where a row of 44px buttons pushes the work down the page.
|
|
164
|
+
*
|
|
165
|
+
* The fix is NOT to shrink the target. It is to notice that "how tall does
|
|
166
|
+
* this look" and "how big an area must a finger hit" were never the same
|
|
167
|
+
* question, and the earlier version answered both with one number.
|
|
168
|
+
*
|
|
169
|
+
* So a control is drawn at `CONTROL[density]`, and on a coarse pointer its
|
|
170
|
+
* hit area is expanded back out to `TOUCH_TARGET` with a transparent
|
|
171
|
+
* ::after — the finger keeps its 44px, the eye gets a 36px button, and
|
|
172
|
+
* nothing was traded away.
|
|
173
|
+
*
|
|
174
|
+
* ⛔ 24px IS THE FLOOR AND IS NOT A STYLE CHOICE. WCAG 2.2 §2.5.8 sets it at
|
|
175
|
+
* AA; `compact` sits at 30 and there is deliberately no density below it.
|
|
176
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
177
|
+
*/
|
|
178
|
+
export declare const CONTROL: Record<'compact' | 'cosy' | 'roomy', number>;
|
|
179
|
+
/** WCAG 2.2 §2.5.8 (AA). Nothing drawn may go under it. */
|
|
180
|
+
export declare const TARGET_FLOOR = 24;
|
|
181
|
+
/**
|
|
182
|
+
* Minimum interactive target, and it does NOT follow density.
|
|
183
|
+
*
|
|
184
|
+
* ⚠️ WCAG 2.2 sets a floor because a finger does not get smaller when a layout
|
|
185
|
+
* gets tighter. An app that runs on tablets in the field — the case that
|
|
186
|
+
* prompted this — cannot trade hit area for rows on screen. `compact` moves
|
|
187
|
+
* the rows closer together; it never shrinks the thing being pressed.
|
|
188
|
+
*/
|
|
189
|
+
export declare const TOUCH_TARGET = 44;
|
|
190
|
+
/** What each step is for. Read this before reaching for a number in between. */
|
|
191
|
+
export declare const SPACE_PURPOSE: Record<string, string>;
|
|
192
|
+
/**
|
|
193
|
+
* Type. Sizes are the ones already shipping; the other three numbers are new.
|
|
194
|
+
*
|
|
195
|
+
* ⛔ Size alone is not a typographic decision, and shipping it alone is why a
|
|
196
|
+
* "type scale" still needs a designer at every use. A 28px heading tracked
|
|
197
|
+
* like body text reads loose; tracking has to tighten as size grows.
|
|
198
|
+
*/
|
|
199
|
+
/**
|
|
200
|
+
* Type — a LADDER around the body size, not a table of pixels.
|
|
201
|
+
*
|
|
202
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
203
|
+
* ⛔ WHY IT STOPPED BEING A TABLE
|
|
204
|
+
*
|
|
205
|
+
* The fixed table had ONE step below 14px. An application built for dense
|
|
206
|
+
* data grids had three, and they were carrying three different jobs: the
|
|
207
|
+
* smallest label, secondary text and column heads, and dense table body.
|
|
208
|
+
* Joining that table would have collapsed two of the three.
|
|
209
|
+
*
|
|
210
|
+
* And it could not simply raise everything, because that application had
|
|
211
|
+
* ruled — on paper, with a reason — that its body text stays at 15px: field
|
|
212
|
+
* officers read accented Vietnamese on low-end machines in poor light. The
|
|
213
|
+
* nearest step above 14 was 20. Joining meant body text growing 15 → 20 on
|
|
214
|
+
* 126 screens.
|
|
215
|
+
*
|
|
216
|
+
* ⭐ So the app declares the ONE number it actually has a reason for — the body
|
|
217
|
+
* size — and the ladder is computed around it. `base: 14` reproduces the old
|
|
218
|
+
* table exactly, so nothing already shipping moves.
|
|
219
|
+
*
|
|
220
|
+
* ⚠️ THIS IS THE UI LADDER AND NOTHING ELSE. Print sheets are laid out in `pt`
|
|
221
|
+
* against a paper standard; a screen's body size has no business reaching
|
|
222
|
+
* them. Same restraint as `density`, which scales spacing and never touches
|
|
223
|
+
* hit targets.
|
|
224
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
225
|
+
*/
|
|
226
|
+
export declare const TEXT_RATIO: Record<string, {
|
|
227
|
+
r: number;
|
|
228
|
+
line: number;
|
|
229
|
+
weight: number;
|
|
230
|
+
tracking: number;
|
|
231
|
+
}>;
|
|
232
|
+
/** Body size when the app does not say. Reproduces the table that shipped. */
|
|
233
|
+
export declare const TEXT_BASE = 14;
|
|
234
|
+
export declare const textScale: (base?: number) => Record<string, {
|
|
235
|
+
size: number;
|
|
236
|
+
line: number;
|
|
237
|
+
weight: number;
|
|
238
|
+
tracking: number;
|
|
239
|
+
}>;
|
|
240
|
+
/** @deprecated The fixed table. `textScale()` replaces it; kept for 0.4.x callers. */
|
|
241
|
+
export declare const TEXT: Record<string, {
|
|
242
|
+
size: number;
|
|
243
|
+
line: number;
|
|
244
|
+
weight: number;
|
|
245
|
+
tracking: number;
|
|
246
|
+
}>;
|
|
247
|
+
export declare const RADIUS: Record<'sharp' | 'soft' | 'round', Record<string, number>>;
|
|
248
|
+
export declare const RADIUS_PURPOSE: Record<string, string>;
|
|
249
|
+
/**
|
|
250
|
+
* Shadow, motion and fonts pass through unchanged.
|
|
251
|
+
*
|
|
252
|
+
* ⚠️ Not computed, and deliberately not: a shadow is a statement about a light
|
|
253
|
+
* source, and there is no ladder to derive it from. They stay as the shipped
|
|
254
|
+
* values so nothing moves under the two apps already using them.
|
|
255
|
+
*/
|
|
256
|
+
export declare const STATIC: {
|
|
257
|
+
readonly 'sh-1': "0 1px 2px rgba(19, 23, 34, .04)";
|
|
258
|
+
readonly 'sh-2': "0 1px 3px rgba(19, 23, 34, .07), 0 1px 2px rgba(19, 23, 34, .04)";
|
|
259
|
+
readonly 'sh-3': "0 12px 28px -10px rgba(19, 23, 34, .16)";
|
|
260
|
+
readonly 'dur-fast': "120ms";
|
|
261
|
+
readonly 'dur-base': "180ms";
|
|
262
|
+
readonly 'ease-out': "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
263
|
+
readonly 'ease-standard': "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
264
|
+
};
|
|
265
|
+
export declare const FONT: {
|
|
266
|
+
sans: string;
|
|
267
|
+
mono: string;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Chart colour — and the one rule that matters more than the palette.
|
|
271
|
+
*
|
|
272
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
273
|
+
* ⛔ NEVER SEPARATE TWO SERIES BY HUE ALONE.
|
|
274
|
+
*
|
|
275
|
+
* Roughly one man in twelve cannot reliably tell red from green. A palette
|
|
276
|
+
* that walks the hue wheel at constant lightness looks varied to the person
|
|
277
|
+
* who picked it and collapses into one grey band for that reader — and the
|
|
278
|
+
* chart is not merely uglier, it is unreadable, with nothing on screen saying
|
|
279
|
+
* so.
|
|
280
|
+
*
|
|
281
|
+
* So the series ladder ALTERNATES LIGHTNESS as it rotates hue. Adjacent
|
|
282
|
+
* series then differ twice over, and the second difference survives when the
|
|
283
|
+
* first one does not. `SERIES_INDISTINCT` measures it rather than trusting it.
|
|
284
|
+
*
|
|
285
|
+
* ⚠️ And the honest limit: past eight categories no palette helps, because the
|
|
286
|
+
* reader is matching swatches to a legend rather than reading a chart. Nine
|
|
287
|
+
* is a `SERIES_TOO_MANY` — a chart problem wearing a colour problem's clothes.
|
|
288
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
289
|
+
*/
|
|
290
|
+
export declare const SERIES: {
|
|
291
|
+
readonly light: {
|
|
292
|
+
readonly lo: 0.52;
|
|
293
|
+
readonly hi: 0.68;
|
|
294
|
+
readonly chroma: 0.15;
|
|
295
|
+
};
|
|
296
|
+
readonly dark: {
|
|
297
|
+
readonly lo: 0.62;
|
|
298
|
+
readonly hi: 0.78;
|
|
299
|
+
readonly chroma: 0.13;
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
/** Beyond this a legend is doing the work, not the colour. */
|
|
303
|
+
export declare const SERIES_MAX = 8;
|
|
304
|
+
/** Adjacent series must differ in lightness by at least this, hue aside. */
|
|
305
|
+
export declare const SERIES_MIN_LIGHTNESS_GAP = 0.1;
|
|
306
|
+
/**
|
|
307
|
+
* An ordered scale — low to high — for a measure, not for categories.
|
|
308
|
+
*
|
|
309
|
+
* ⚠️ ONE HUE, stepped lightness. A rainbow scale reorders itself in the reader's
|
|
310
|
+
* head (is yellow more than blue?) and is the single most common way a
|
|
311
|
+
* quantity chart lies. Lightness has an obvious direction and keeps it in
|
|
312
|
+
* greyscale, in a photocopy, and for every kind of colour vision.
|
|
313
|
+
*/
|
|
314
|
+
export declare const LEVELS: {
|
|
315
|
+
readonly light: {
|
|
316
|
+
readonly from: 0.93;
|
|
317
|
+
readonly to: 0.45;
|
|
318
|
+
readonly chroma: 0.11;
|
|
319
|
+
};
|
|
320
|
+
readonly dark: {
|
|
321
|
+
readonly from: 0.3;
|
|
322
|
+
readonly to: 0.85;
|
|
323
|
+
readonly chroma: 0.1;
|
|
324
|
+
};
|
|
325
|
+
};
|