@rtkelly-labs/design-system 0.17.0 → 0.18.0
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/CHANGELOG.md +10 -0
- package/dist/components/docs/figures/ChangeSummary.js +5 -5
- package/dist/components/docs/figures/ChangeSummary.js.map +1 -1
- package/dist/components/docs/figures/FileChangeTree.js +4 -4
- package/dist/components/docs/figures/FileChangeTree.js.map +1 -1
- package/dist/index.d.ts +35 -3
- package/dist/lib/theme.js +12 -0
- package/dist/lib/theme.js.map +1 -1
- package/dist/theme/contrast.js +15 -0
- package/dist/theme/contrast.js.map +1 -1
- package/dist/theme/levels.js +31 -0
- package/dist/theme/levels.js.map +1 -1
- package/dist/theme.css +30 -0
- package/package.json +1 -1
- package/tokens/palette.midnight.tokens.json +50 -0
- package/tokens/palette.sketch.tokens.json +50 -0
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,16 @@ Proper release notes start at 1.0. Until then this file records only what a
|
|
|
9
9
|
consumer has to *do*, newest first. The reasoning lives in the pull requests and
|
|
10
10
|
in [`docs/adr/`](./docs/adr/).
|
|
11
11
|
|
|
12
|
+
## 0.18.0
|
|
13
|
+
|
|
14
|
+
A `delta` role group — `added`, `removed`, `moved`, and `deltaGround` `added`, `removed`,
|
|
15
|
+
`hunk` for diff rows — as `text-delta-*`, `bg-delta-*`, `fill-delta-*` and
|
|
16
|
+
`bg-delta-ground-*`. Change is not meaning, so it does not use `intent`.
|
|
17
|
+
|
|
18
|
+
`FileChangeTree` and `ChangeSummary` colour changes with the `delta` roles. `FileChangeTree`
|
|
19
|
+
no longer paints an added file as a success or a modified one as a warning; `ChangeSummary`'s
|
|
20
|
+
signs no longer follow `palette`. Nothing to change in code. Re-baseline both figures.
|
|
21
|
+
|
|
12
22
|
## 0.17.0
|
|
13
23
|
|
|
14
24
|
Traces. `TraceWaterfall` and `TraceViewer` draw distributed traces — spans nested by parent on
|
|
@@ -31,15 +31,15 @@ function diffFromList(children) {
|
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
function signClass(
|
|
35
|
-
if (sign === "add") return "text-
|
|
36
|
-
if (sign === "remove") return
|
|
34
|
+
function signClass(sign) {
|
|
35
|
+
if (sign === "add") return "text-delta-added";
|
|
36
|
+
if (sign === "remove") return "text-delta-removed";
|
|
37
37
|
return "text-content-primary";
|
|
38
38
|
}
|
|
39
39
|
function lineText(row) {
|
|
40
40
|
return `${row.label ?? ""} ${row.value}`.trim();
|
|
41
41
|
}
|
|
42
|
-
var ChangeSummary = React.forwardRef(function ChangeSummary2({ label = "Change summary", rows: rowsProp, footer: footerProp, children, palette, className, ...rest }, ref) {
|
|
42
|
+
var ChangeSummary = React.forwardRef(function ChangeSummary2({ label = "Change summary", rows: rowsProp, footer: footerProp, children, palette: _palette, className, ...rest }, ref) {
|
|
43
43
|
const listed = diffFromList(children);
|
|
44
44
|
const tagged = childItems(children, Line).map((entry) => ({ ...entry, label: entry.label ?? textOf(entry.children) }));
|
|
45
45
|
const lines = listed.length > 0 ? listed : tagged;
|
|
@@ -49,7 +49,7 @@ var ChangeSummary = React.forwardRef(function ChangeSummary2({ label = "Change s
|
|
|
49
49
|
return /* @__PURE__ */ jsxs(AsciiFrameBody, { "data-slot": "change-summary", ref, ...rest, className: cn("flex flex-col gap-3", className), children: [
|
|
50
50
|
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-2", "aria-label": label, children: rows.map((row, index) => {
|
|
51
51
|
const sign = row.sign ?? "keep";
|
|
52
|
-
const tone = signClass(
|
|
52
|
+
const tone = signClass(sign);
|
|
53
53
|
return /* @__PURE__ */ jsxs("li", { className: "grid grid-cols-[1.25rem_minmax(0,1fr)_8ch] items-baseline gap-x-3", "aria-label": `${sign}: ${lineText(row)}`, children: [
|
|
54
54
|
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("select-none text-center", sign === "keep" ? "text-content-muted" : tone), children: sign === "keep" ? " " : sign === "add" ? "+" : "-" }),
|
|
55
55
|
/* @__PURE__ */ jsx("span", { className: tone, children: row.label }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/docs/figures/ChangeSummary.tsx"],"sourcesContent":["/**\n * Adapted from mdxcn by Keshav Bagaade, MIT licensed.\n * Source: https://github.com/keshav-exe/mdxcn/blob/2928126ba146ebbae9c2351deca27d27bb40e744/registry/default/graph-diff/graph-diff.tsx\n * The local port removes motion and graph variables while retaining the\n * source component's Markdown and `<Line>` data forms.\n */\n\nimport type { ReactNode } from 'react';\nimport * as React from 'react';\nimport {\n childItems,\n defineAsciiItem,\n AsciiFrameBody,\n AsciiFrameRule,\n hasHost,\n itemText,\n listItems,\n splitLabel,\n textOf,\n type FigurePalette,\n} from './FigureFrame';\nimport { cn } from '../../../lib/recipe';\n\nexport type DiffSign = 'add' | 'remove' | 'keep';\n\nexport interface DiffRow {\n /** Falls back to the child text for `<Line value=\"31 kb\">app</Line>`. */\n label?: string;\n value: string;\n sign?: DiffSign;\n}\n\nexport interface DiffLineProps extends DiffRow {\n /** Draw the row under a rule as the total. */\n total?: boolean;\n}\n\nexport interface ChangeSummaryProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Accessible name; the enclosing FigureFrame owns the caption. */\n label?: string;\n /** Data form. If omitted, the component reads Markdown or `<Line>` children. */\n rows?: DiffRow[];\n /** Optional typed total shown below the row rule. */\n footer?: DiffRow;\n /** Markdown list or `<Line>` content used to derive rows. */\n children?: ReactNode;\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/docs/figures/ChangeSummary.tsx"],"sourcesContent":["/**\n * Adapted from mdxcn by Keshav Bagaade, MIT licensed.\n * Source: https://github.com/keshav-exe/mdxcn/blob/2928126ba146ebbae9c2351deca27d27bb40e744/registry/default/graph-diff/graph-diff.tsx\n * The local port removes motion and graph variables while retaining the\n * source component's Markdown and `<Line>` data forms.\n */\n\nimport type { ReactNode } from 'react';\nimport * as React from 'react';\nimport {\n childItems,\n defineAsciiItem,\n AsciiFrameBody,\n AsciiFrameRule,\n hasHost,\n itemText,\n listItems,\n splitLabel,\n textOf,\n type FigurePalette,\n} from './FigureFrame';\nimport { cn } from '../../../lib/recipe';\n\nexport type DiffSign = 'add' | 'remove' | 'keep';\n\nexport interface DiffRow {\n /** Falls back to the child text for `<Line value=\"31 kb\">app</Line>`. */\n label?: string;\n value: string;\n sign?: DiffSign;\n}\n\nexport interface DiffLineProps extends DiffRow {\n /** Draw the row under a rule as the total. */\n total?: boolean;\n}\n\nexport interface ChangeSummaryProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Accessible name; the enclosing FigureFrame owns the caption. */\n label?: string;\n /** Data form. If omitted, the component reads Markdown or `<Line>` children. */\n rows?: DiffRow[];\n /** Optional typed total shown below the row rule. */\n footer?: DiffRow;\n /** Markdown list or `<Line>` content used to derive rows. */\n children?: ReactNode;\n /**\n * Accepted for symmetry with the other figures and ignored: additions and removals take the\n * `delta` roles, so a summary reads the same in a `multi` figure as in a `mono` one.\n */\n palette?: FigurePalette;\n /** Additional classes for this summary. */\n className?: string;\n}\n\n/** MDX-only diff item, for example `<Line sign=\"add\" value=\"31 kb\">app</Line>`. */\nexport const Line = defineAsciiItem<DiffLineProps>('Line');\n\nfunction signOf(value: string): DiffSign | undefined {\n if (/^\\+/.test(value.trim())) return 'add';\n if (/^[−-]/.test(value.trim())) return 'remove';\n return undefined;\n}\n\nfunction diffFromList(children: ReactNode): DiffLineProps[] {\n return listItems(children).map((item) => {\n const { label, rest } = splitLabel(itemText(item));\n const content = (item.props as { children?: ReactNode }).children;\n return {\n label,\n value: rest.replace(/^[+−-]\\s*/, '') || rest,\n sign: signOf(rest),\n total: hasHost(content, ['strong', 'b']),\n };\n });\n}\n\n/** Signs are change, so they take the `delta` roles whatever palette the surrounding figures use. */\nfunction signClass(sign: DiffSign): string {\n if (sign === 'add') return 'text-delta-added';\n if (sign === 'remove') return 'text-delta-removed';\n return 'text-content-primary';\n}\n\nfunction lineText(row: DiffRow): string {\n return `${row.label ?? ''} ${row.value}`.trim();\n}\n\n/** Renders additions, removals, and unchanged rows with a readable text summary. */\nexport const ChangeSummary = React.forwardRef<HTMLDivElement, ChangeSummaryProps>(function ChangeSummary({ label = 'Change summary', rows: rowsProp, footer: footerProp, children, palette: _palette, className, ...rest }, ref) {\n const listed = diffFromList(children);\n const tagged = childItems(children, Line).map((entry) => ({ ...entry, label: entry.label ?? textOf(entry.children) }));\n const lines = listed.length > 0 ? listed : tagged;\n const rows = (rowsProp ?? lines.filter((entry) => !entry.total)).map((entry) => ({ ...entry, label: entry.label ?? '' }));\n const footerLine = footerProp ?? lines.find((entry) => entry.total);\n const footer = footerLine ? { ...footerLine, label: footerLine.label ?? '' } : undefined;\n\n return (\n <AsciiFrameBody data-slot=\"change-summary\" ref={ref} {...rest} className={cn('flex flex-col gap-3', className)}>\n <ul className=\"flex flex-col gap-2\" aria-label={label}>\n {rows.map((row, index) => {\n const sign = row.sign ?? 'keep';\n const tone = signClass(sign);\n return (\n <li className=\"grid grid-cols-[1.25rem_minmax(0,1fr)_8ch] items-baseline gap-x-3\" key={`${lineText(row)}-${index}`} aria-label={`${sign}: ${lineText(row)}`}>\n <span aria-hidden=\"true\" className={cn('select-none text-center', sign === 'keep' ? 'text-content-muted' : tone)}>{sign === 'keep' ? ' ' : sign === 'add' ? '+' : '-'}</span>\n <span className={tone}>{row.label}</span>\n <span className={cn('text-right tabular-nums', tone)}>{row.value}</span>\n </li>\n );\n })}\n </ul>\n {footer ? <><AsciiFrameRule /><div className=\"grid grid-cols-[1.25rem_minmax(0,1fr)_8ch] items-baseline gap-x-3\" aria-label={`total: ${lineText(footer)}`}><span aria-hidden=\"true\" className=\"text-content-muted\"> </span><span className=\"text-content-primary\">{footer.label}</span><span className=\"text-right tabular-nums text-content-primary\">{footer.value}</span></div></> : null}\n <span className=\"sr-only\">{rows.length === 0 && !footer ? 'Empty diff.' : `${rows.length} changed row${rows.length === 1 ? '' : 's'}${footer ? `, total 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;AAAA,QAAO,oBAAC,UAAK,WAAU,gDAAgD,iBAAO,OAAM;AAAA,SAAO;AAAA,OAAM,IAAM;AAAA,IACvX,oBAAC,UAAK,WAAU,WAAW,eAAK,WAAW,KAAK,CAAC,SAAS,gBAAgB,GAAG,KAAK,MAAM,eAAe,KAAK,WAAW,IAAI,KAAK,GAAG,GAAG,SAAS,WAAW,SAAS,MAAM,CAAC,KAAK,EAAE,KAAI;AAAA,KACvL;AAEN,CAAC;","names":["ChangeSummary"]}
|
|
@@ -11,10 +11,10 @@ var DEFAULT_VIEW_LABELS = { before: "Before", changes: "Changes", after: "After"
|
|
|
11
11
|
var DEFAULT_CHANGE_LABELS = { add: "added", modify: "modified", rename: "renamed", remove: "removed" };
|
|
12
12
|
var GLYPH = { add: "+", modify: "~", rename: "\u2192", remove: "\u2212" };
|
|
13
13
|
var TONE = {
|
|
14
|
-
add: { text: "text-
|
|
15
|
-
modify: { text: "text-
|
|
16
|
-
rename: { text: "text-
|
|
17
|
-
remove: { text: "text-
|
|
14
|
+
add: { text: "text-delta-added", fill: "bg-delta-added" },
|
|
15
|
+
modify: { text: "text-content-secondary", fill: "bg-content-secondary" },
|
|
16
|
+
rename: { text: "text-delta-moved", fill: "bg-delta-moved" },
|
|
17
|
+
remove: { text: "text-delta-removed", fill: "bg-delta-removed" }
|
|
18
18
|
};
|
|
19
19
|
function isDirectory(node) {
|
|
20
20
|
return node.children != null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/docs/figures/FileChangeTree.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport * as React from 'react';\nimport { AsciiFrameBody } from './FigureFrame';\nimport { cn } from '../../../lib/recipe';\n\nexport type FileChange = 'add' | 'modify' | 'remove' | 'rename';\nexport type FileChangeView = 'before' | 'changes' | 'after';\n\nexport interface FileChangeNode {\n /** File or directory name. A node with `children` is drawn as a directory. */\n name: string;\n /** How the file changed. Omit for an unchanged file or a directory. */\n change?: FileChange;\n /** One line on what changed, drawn under the name. */\n note?: ReactNode;\n /** Entries inside a directory. */\n children?: FileChangeNode[];\n}\n\nexport interface FileChangeTreeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {\n /** Accessible name; the enclosing frame owns the caption. */\n label?: string;\n /** Top-level entries. Each one becomes a column under the shared connector. */\n nodes: FileChangeNode[];\n /** Controlled view. `changes` marks every entry; `before` and `after` show the tree on one side of the change. */\n view?: FileChangeView;\n /** Initial view when uncontrolled. */\n defaultView?: FileChangeView;\n /** Called when the reader picks a view. */\n onViewChange?: (view: FileChangeView) => void;\n /** Hide the before / changes / after switch and the tallies. */\n hideFooter?: boolean;\n /** Accessible label for the view selection button group. */\n viewGroupLabel?: string;\n /** Replaces the switch's button text, for translated pages. */\n viewLabels?: Partial<Record<FileChangeView, string>>;\n /** Replaces the tally words, for translated pages. */\n changeLabels?: Partial<Record<FileChange, string>>;\n /** Additional classes for the root. */\n className?: string;\n}\n\nconst VIEWS: readonly FileChangeView[] = ['before', 'changes', 'after'];\nconst CHANGES: readonly FileChange[] = ['add', 'modify', 'rename', 'remove'];\n\nconst DEFAULT_VIEW_LABELS: Record<FileChangeView, string> = { before: 'Before', changes: 'Changes', after: 'After' };\nconst DEFAULT_CHANGE_LABELS: Record<FileChange, string> = { add: 'added', modify: 'modified', rename: 'renamed', remove: 'removed' };\n\nconst GLYPH: Record<FileChange, string> = { add: '+', modify: '~', rename: '→', remove: '−' };\n\n/** A change is meaning, so it is addressed through intent roles, never accents. */\nconst TONE: Record<FileChange, { text: string; fill: string }> = {\n add: { text: 'text-intent-success', fill: 'bg-intent-success' },\n modify: { text: 'text-intent-warning', fill: 'bg-intent-warning' },\n rename: { text: 'text-intent-info', fill: 'bg-intent-info' },\n remove: { text: 'text-intent-danger', fill: 'bg-intent-danger' },\n};\n\nfunction isDirectory(node: FileChangeNode): boolean {\n return node.children != null;\n}\n\n/** Drops what does not exist on one side of the change, and empty directories with it. */\nfunction visible(nodes: FileChangeNode[], view: FileChangeView): FileChangeNode[] {\n return nodes.flatMap((node) => {\n if (view === 'before' && node.change === 'add') return [];\n if (view === 'after' && node.change === 'remove') return [];\n if (!isDirectory(node)) return [node];\n const children = visible(node.children ?? [], view);\n return children.length > 0 || view === 'changes' ? [{ ...node, children }] : [];\n });\n}\n\nfunction tally(nodes: FileChangeNode[], counts: Record<FileChange, number> = { add: 0, modify: 0, rename: 0, remove: 0 }): Record<FileChange, number> {\n for (const node of nodes) {\n if (node.change) counts[node.change] += 1;\n if (node.children) tally(node.children, counts);\n }\n return counts;\n}\n\nfunction ChangeMark({ change }: { change: FileChange }) {\n return (\n <span\n aria-hidden=\"true\"\n data-slot=\"file-change-tree-mark\"\n className={cn('inline-flex size-4 shrink-0 select-none items-center justify-center text-[0.7rem] font-bold leading-none text-content-inverse', TONE[change].fill)}\n >\n {GLYPH[change]}\n </span>\n );\n}\n\nfunction Entries({ nodes, view, changeLabels }: { nodes: FileChangeNode[]; view: FileChangeView; changeLabels: Record<FileChange, string> }) {\n return (\n <ul className=\"flex flex-col gap-3\" data-slot=\"file-change-tree-list\">\n {nodes.map((node, index) => {\n const last = index === nodes.length - 1;\n const marked = view === 'changes' && node.change != null;\n const change = marked ? node.change : undefined;\n return (\n <li key={`${node.name}-${index}`} className=\"relative pl-6\" data-slot=\"file-change-tree-entry\">\n {/* The elbow: a stem down to this row, then a tick across to it. The last row's stem stops at its tick. */}\n <span aria-hidden=\"true\" className={cn('absolute left-0 top-0 border-l-2 border-edge-subtle', last ? 'h-[0.8em]' : '-bottom-3')} />\n <span aria-hidden=\"true\" className=\"absolute left-0 top-[0.8em] w-4 border-t-2 border-edge-subtle\" />\n <div className=\"flex items-center gap-2\">\n {change ? <ChangeMark change={change} /> : null}\n <span data-slot=\"file-change-tree-name\" className={cn('min-w-0 break-all font-mono', change ? TONE[change].text : 'text-content-primary', change === 'remove' && 'line-through')}>\n {node.name}\n </span>\n {change ? <span className=\"sr-only\">({changeLabels[change]})</span> : null}\n </div>\n {node.note != null && !isDirectory(node) ? <p data-slot=\"file-change-tree-note\" className=\"m-0 mt-1 text-pretty text-content-secondary\">{node.note}</p> : null}\n {isDirectory(node) && (node.children?.length ?? 0) > 0 ? (\n <div className=\"mt-3\">\n <Entries nodes={node.children ?? []} view={view} changeLabels={changeLabels} />\n </div>\n ) : null}\n </li>\n );\n })}\n </ul>\n );\n}\n\n/**\n * A changeset drawn as its directory layout: each top-level directory is a boxed column under\n * one connector, its files hang from a ruled tree with a change mark and a one-line note, and a\n * footer tallies the change and switches between the tree before, the change itself, and after.\n *\n * Stacks into one column below the `sm` breakpoint, where the connector is dropped.\n */\nexport const FileChangeTree = React.forwardRef<HTMLDivElement, FileChangeTreeProps>(function FileChangeTree(\n { label = 'File changes', nodes, view: viewProp, defaultView = 'changes', onViewChange, hideFooter = false, viewGroupLabel, viewLabels, changeLabels, className, ...rest },\n ref,\n) {\n const [uncontrolled, setUncontrolled] = React.useState<FileChangeView>(defaultView);\n const view = viewProp ?? uncontrolled;\n const views = { ...DEFAULT_VIEW_LABELS, ...viewLabels };\n const changes = { ...DEFAULT_CHANGE_LABELS, ...changeLabels };\n const columns = visible(nodes, view);\n const counts = tally(nodes);\n const connected = columns.length > 1;\n\n const pick = (next: FileChangeView) => {\n if (viewProp == null) setUncontrolled(next);\n onViewChange?.(next);\n };\n\n return (\n <AsciiFrameBody ref={ref} {...rest} data-slot=\"file-change-tree\" className={cn('flex flex-col gap-6 font-mono text-sm', className)}>\n <div role=\"list\" aria-label={label} className=\"flex flex-col gap-8 sm:flex-row sm:gap-6\">\n {columns.map((column, index) => {\n const first = index === 0;\n const last = index === columns.length - 1;\n const marked = view === 'changes' && column.change != null;\n return (\n <div role=\"listitem\" key={`${column.name}-${index}`} className=\"relative flex min-w-0 flex-1 flex-col\" data-slot=\"file-change-tree-column\">\n {connected ? (\n <span aria-hidden=\"true\" className=\"relative hidden h-6 sm:block\">\n {/* The shared bar, carried half a gap past each side so neighbours meet; the ends stop at the drop. */}\n <span className={cn('absolute top-0 border-t-2 border-edge-strong', first ? 'left-1/2' : '-left-3', last ? 'right-1/2' : '-right-3')} />\n <span className=\"absolute left-1/2 top-0 h-full border-l-2 border-edge-strong\" />\n </span>\n ) : null}\n <div className=\"flex items-center justify-center gap-2 border-2 border-edge-strong bg-surface-base px-3 py-3 font-semibold text-content-primary\" data-slot=\"file-change-tree-root\">\n {marked && column.change ? <ChangeMark change={column.change} /> : null}\n <span className={cn('break-all', marked && column.change ? TONE[column.change].text : undefined)}>{column.name}</span>\n {marked && column.change ? <span className=\"sr-only\">({changes[column.change]})</span> : null}\n </div>\n {column.note != null ? <p data-slot=\"file-change-tree-note\" className=\"m-0 mt-2 text-pretty text-content-secondary\">{column.note}</p> : null}\n {(column.children?.length ?? 0) > 0 ? (\n <div className=\"ml-4 mt-4\">\n <Entries nodes={column.children ?? []} view={view} changeLabels={changes} />\n </div>\n ) : null}\n </div>\n );\n })}\n </div>\n {hideFooter ? null : (\n <div className=\"flex flex-wrap items-center justify-between gap-4\" data-slot=\"file-change-tree-footer\">\n <p className=\"m-0 flex flex-wrap gap-x-5 gap-y-1 font-mono tabular-nums\" data-slot=\"file-change-tree-tally\">\n {CHANGES.filter((change) => counts[change] > 0).map((change) => (\n <span key={change} className={TONE[change].text}>\n <span aria-hidden=\"true\">{GLYPH[change]}</span>\n {counts[change]} {changes[change]}\n </span>\n ))}\n </p>\n <div role=\"group\" aria-label={viewGroupLabel ?? 'View'} className=\"flex border-2 border-edge-default\" data-slot=\"file-change-tree-views\">\n {VIEWS.map((option, index) => (\n <button\n key={option}\n type=\"button\"\n aria-pressed={view === option}\n onClick={() => pick(option)}\n className={cn(\n 'px-4 py-1.5 text-content-secondary hover:bg-surface-raised',\n index > 0 && 'border-l-2 border-edge-default',\n view === option && 'bg-content-primary font-semibold text-content-inverse hover:bg-content-primary',\n )}\n >\n {views[option]}\n </button>\n ))}\n </div>\n </div>\n )}\n </AsciiFrameBody>\n );\n});\n"],"mappings":";;;AAGA,YAA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B;AAAA,QAAC;AAAA;AAAA,UAEC,MAAK;AAAA,UACL,gBAAc,SAAS;AAAA,UACvB,SAAS,MAAM,KAAK,MAAM;AAAA,UAC1B,WAAW;AAAA,YACT;AAAA,YACA,QAAQ,KAAK;AAAA,YACb,SAAS,UAAU;AAAA,UACrB;AAAA,UAEC,gBAAM,MAAM;AAAA;AAAA,QAVR;AAAA,MAWP,CACD,GACH;AAAA,OACF;AAAA,KAEJ;AAEJ,CAAC;","names":["FileChangeTree"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/docs/figures/FileChangeTree.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport * as React from 'react';\nimport { AsciiFrameBody } from './FigureFrame';\nimport { cn } from '../../../lib/recipe';\n\nexport type FileChange = 'add' | 'modify' | 'remove' | 'rename';\nexport type FileChangeView = 'before' | 'changes' | 'after';\n\nexport interface FileChangeNode {\n /** File or directory name. A node with `children` is drawn as a directory. */\n name: string;\n /** How the file changed. Omit for an unchanged file or a directory. */\n change?: FileChange;\n /** One line on what changed, drawn under the name. */\n note?: ReactNode;\n /** Entries inside a directory. */\n children?: FileChangeNode[];\n}\n\nexport interface FileChangeTreeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {\n /** Accessible name; the enclosing frame owns the caption. */\n label?: string;\n /** Top-level entries. Each one becomes a column under the shared connector. */\n nodes: FileChangeNode[];\n /** Controlled view. `changes` marks every entry; `before` and `after` show the tree on one side of the change. */\n view?: FileChangeView;\n /** Initial view when uncontrolled. */\n defaultView?: FileChangeView;\n /** Called when the reader picks a view. */\n onViewChange?: (view: FileChangeView) => void;\n /** Hide the before / changes / after switch and the tallies. */\n hideFooter?: boolean;\n /** Accessible label for the view selection button group. */\n viewGroupLabel?: string;\n /** Replaces the switch's button text, for translated pages. */\n viewLabels?: Partial<Record<FileChangeView, string>>;\n /** Replaces the tally words, for translated pages. */\n changeLabels?: Partial<Record<FileChange, string>>;\n /** Additional classes for the root. */\n className?: string;\n}\n\nconst VIEWS: readonly FileChangeView[] = ['before', 'changes', 'after'];\nconst CHANGES: readonly FileChange[] = ['add', 'modify', 'rename', 'remove'];\n\nconst DEFAULT_VIEW_LABELS: Record<FileChangeView, string> = { before: 'Before', changes: 'Changes', after: 'After' };\nconst DEFAULT_CHANGE_LABELS: Record<FileChange, string> = { add: 'added', modify: 'modified', rename: 'renamed', remove: 'removed' };\n\nconst GLYPH: Record<FileChange, string> = { add: '+', modify: '~', rename: '→', remove: '−' };\n\n/**\n * A change is a change, so it is addressed through the `delta` roles — not `intent`, which would\n * call an added file a success and a removed one a danger, and not accents, which carry nothing.\n * A modification has no delta role of its own: it is neither an addition nor a removal, so it\n * takes the secondary ink and is told apart by its `~` mark.\n */\nconst TONE: Record<FileChange, { text: string; fill: string }> = {\n add: { text: 'text-delta-added', fill: 'bg-delta-added' },\n modify: { text: 'text-content-secondary', fill: 'bg-content-secondary' },\n rename: { text: 'text-delta-moved', fill: 'bg-delta-moved' },\n remove: { text: 'text-delta-removed', fill: 'bg-delta-removed' },\n};\n\nfunction isDirectory(node: FileChangeNode): boolean {\n return node.children != null;\n}\n\n/** Drops what does not exist on one side of the change, and empty directories with it. */\nfunction visible(nodes: FileChangeNode[], view: FileChangeView): FileChangeNode[] {\n return nodes.flatMap((node) => {\n if (view === 'before' && node.change === 'add') return [];\n if (view === 'after' && node.change === 'remove') return [];\n if (!isDirectory(node)) return [node];\n const children = visible(node.children ?? [], view);\n return children.length > 0 || view === 'changes' ? [{ ...node, children }] : [];\n });\n}\n\nfunction tally(nodes: FileChangeNode[], counts: Record<FileChange, number> = { add: 0, modify: 0, rename: 0, remove: 0 }): Record<FileChange, number> {\n for (const node of nodes) {\n if (node.change) counts[node.change] += 1;\n if (node.children) tally(node.children, counts);\n }\n return counts;\n}\n\nfunction ChangeMark({ change }: { change: FileChange }) {\n return (\n <span\n aria-hidden=\"true\"\n data-slot=\"file-change-tree-mark\"\n className={cn('inline-flex size-4 shrink-0 select-none items-center justify-center text-[0.7rem] font-bold leading-none text-content-inverse', TONE[change].fill)}\n >\n {GLYPH[change]}\n </span>\n );\n}\n\nfunction Entries({ nodes, view, changeLabels }: { nodes: FileChangeNode[]; view: FileChangeView; changeLabels: Record<FileChange, string> }) {\n return (\n <ul className=\"flex flex-col gap-3\" data-slot=\"file-change-tree-list\">\n {nodes.map((node, index) => {\n const last = index === nodes.length - 1;\n const marked = view === 'changes' && node.change != null;\n const change = marked ? node.change : undefined;\n return (\n <li key={`${node.name}-${index}`} className=\"relative pl-6\" data-slot=\"file-change-tree-entry\">\n {/* The elbow: a stem down to this row, then a tick across to it. The last row's stem stops at its tick. */}\n <span aria-hidden=\"true\" className={cn('absolute left-0 top-0 border-l-2 border-edge-subtle', last ? 'h-[0.8em]' : '-bottom-3')} />\n <span aria-hidden=\"true\" className=\"absolute left-0 top-[0.8em] w-4 border-t-2 border-edge-subtle\" />\n <div className=\"flex items-center gap-2\">\n {change ? <ChangeMark change={change} /> : null}\n <span data-slot=\"file-change-tree-name\" className={cn('min-w-0 break-all font-mono', change ? TONE[change].text : 'text-content-primary', change === 'remove' && 'line-through')}>\n {node.name}\n </span>\n {change ? <span className=\"sr-only\">({changeLabels[change]})</span> : null}\n </div>\n {node.note != null && !isDirectory(node) ? <p data-slot=\"file-change-tree-note\" className=\"m-0 mt-1 text-pretty text-content-secondary\">{node.note}</p> : null}\n {isDirectory(node) && (node.children?.length ?? 0) > 0 ? (\n <div className=\"mt-3\">\n <Entries nodes={node.children ?? []} view={view} changeLabels={changeLabels} />\n </div>\n ) : null}\n </li>\n );\n })}\n </ul>\n );\n}\n\n/**\n * A changeset drawn as its directory layout: each top-level directory is a boxed column under\n * one connector, its files hang from a ruled tree with a change mark and a one-line note, and a\n * footer tallies the change and switches between the tree before, the change itself, and after.\n *\n * Stacks into one column below the `sm` breakpoint, where the connector is dropped.\n */\nexport const FileChangeTree = React.forwardRef<HTMLDivElement, FileChangeTreeProps>(function FileChangeTree(\n { label = 'File changes', nodes, view: viewProp, defaultView = 'changes', onViewChange, hideFooter = false, viewGroupLabel, viewLabels, changeLabels, className, ...rest },\n ref,\n) {\n const [uncontrolled, setUncontrolled] = React.useState<FileChangeView>(defaultView);\n const view = viewProp ?? uncontrolled;\n const views = { ...DEFAULT_VIEW_LABELS, ...viewLabels };\n const changes = { ...DEFAULT_CHANGE_LABELS, ...changeLabels };\n const columns = visible(nodes, view);\n const counts = tally(nodes);\n const connected = columns.length > 1;\n\n const pick = (next: FileChangeView) => {\n if (viewProp == null) setUncontrolled(next);\n onViewChange?.(next);\n };\n\n return (\n <AsciiFrameBody ref={ref} {...rest} data-slot=\"file-change-tree\" className={cn('flex flex-col gap-6 font-mono text-sm', className)}>\n <div role=\"list\" aria-label={label} className=\"flex flex-col gap-8 sm:flex-row sm:gap-6\">\n {columns.map((column, index) => {\n const first = index === 0;\n const last = index === columns.length - 1;\n const marked = view === 'changes' && column.change != null;\n return (\n <div role=\"listitem\" key={`${column.name}-${index}`} className=\"relative flex min-w-0 flex-1 flex-col\" data-slot=\"file-change-tree-column\">\n {connected ? (\n <span aria-hidden=\"true\" className=\"relative hidden h-6 sm:block\">\n {/* The shared bar, carried half a gap past each side so neighbours meet; the ends stop at the drop. */}\n <span className={cn('absolute top-0 border-t-2 border-edge-strong', first ? 'left-1/2' : '-left-3', last ? 'right-1/2' : '-right-3')} />\n <span className=\"absolute left-1/2 top-0 h-full border-l-2 border-edge-strong\" />\n </span>\n ) : null}\n <div className=\"flex items-center justify-center gap-2 border-2 border-edge-strong bg-surface-base px-3 py-3 font-semibold text-content-primary\" data-slot=\"file-change-tree-root\">\n {marked && column.change ? <ChangeMark change={column.change} /> : null}\n <span className={cn('break-all', marked && column.change ? TONE[column.change].text : undefined)}>{column.name}</span>\n {marked && column.change ? <span className=\"sr-only\">({changes[column.change]})</span> : null}\n </div>\n {column.note != null ? <p data-slot=\"file-change-tree-note\" className=\"m-0 mt-2 text-pretty text-content-secondary\">{column.note}</p> : null}\n {(column.children?.length ?? 0) > 0 ? (\n <div className=\"ml-4 mt-4\">\n <Entries nodes={column.children ?? []} view={view} changeLabels={changes} />\n </div>\n ) : null}\n </div>\n );\n })}\n </div>\n {hideFooter ? null : (\n <div className=\"flex flex-wrap items-center justify-between gap-4\" data-slot=\"file-change-tree-footer\">\n <p className=\"m-0 flex flex-wrap gap-x-5 gap-y-1 font-mono tabular-nums\" data-slot=\"file-change-tree-tally\">\n {CHANGES.filter((change) => counts[change] > 0).map((change) => (\n <span key={change} className={TONE[change].text}>\n <span aria-hidden=\"true\">{GLYPH[change]}</span>\n {counts[change]} {changes[change]}\n </span>\n ))}\n </p>\n <div role=\"group\" aria-label={viewGroupLabel ?? 'View'} className=\"flex border-2 border-edge-default\" data-slot=\"file-change-tree-views\">\n {VIEWS.map((option, index) => (\n <button\n key={option}\n type=\"button\"\n aria-pressed={view === option}\n onClick={() => pick(option)}\n className={cn(\n 'px-4 py-1.5 text-content-secondary hover:bg-surface-raised',\n index > 0 && 'border-l-2 border-edge-default',\n view === option && 'bg-content-primary font-semibold text-content-inverse hover:bg-content-primary',\n )}\n >\n {views[option]}\n </button>\n ))}\n </div>\n </div>\n )}\n </AsciiFrameBody>\n );\n});\n"],"mappings":";;;AAGA,YAAY,WAAW;AACvB,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AAqFf,cA2BoB,YA3BpB;AA9CJ,IAAM,QAAmC,CAAC,UAAU,WAAW,OAAO;AACtE,IAAM,UAAiC,CAAC,OAAO,UAAU,UAAU,QAAQ;AAE3E,IAAM,sBAAsD,EAAE,QAAQ,UAAU,SAAS,WAAW,OAAO,QAAQ;AACnH,IAAM,wBAAoD,EAAE,KAAK,SAAS,QAAQ,YAAY,QAAQ,WAAW,QAAQ,UAAU;AAEnI,IAAM,QAAoC,EAAE,KAAK,KAAK,QAAQ,KAAK,QAAQ,UAAK,QAAQ,SAAI;AAQ5F,IAAM,OAA2D;AAAA,EAC/D,KAAK,EAAE,MAAM,oBAAoB,MAAM,iBAAiB;AAAA,EACx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AAU,yBAAwB,WAAU,+CAA+C,iBAAO,MAAK,IAAO;AAAA,SACtI,OAAO,UAAU,UAAU,KAAK,IAChC,oBAAC,SAAI,WAAU,aACb,8BAAC,WAAQ,OAAO,OAAO,YAAY,CAAC,GAAG,MAAY,cAAc,SAAS,GAC5E,IACE;AAAA,WAlBoB,GAAG,OAAO,IAAI,IAAI,KAAK,EAmBjD;AAAA,IAEJ,CAAC,GACH;AAAA,IACC,aAAa,OACZ,qBAAC,SAAI,WAAU,qDAAoD,aAAU,2BAC3E;AAAA,0BAAC,OAAE,WAAU,6DAA4D,aAAU,0BAChF,kBAAQ,OAAO,CAAC,WAAW,OAAO,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,WACnD,qBAAC,UAAkB,WAAW,KAAK,MAAM,EAAE,MACzC;AAAA,4BAAC,UAAK,eAAY,QAAQ,gBAAM,MAAM,GAAE;AAAA,QACvC,OAAO,MAAM;AAAA,QAAE;AAAA,QAAE,QAAQ,MAAM;AAAA,WAFvB,MAGX,CACD,GACH;AAAA,MACA,oBAAC,SAAI,MAAK,SAAQ,cAAY,kBAAkB,QAAQ,WAAU,qCAAoC,aAAU,0BAC7G,gBAAM,IAAI,CAAC,QAAQ,UAClB;AAAA,QAAC;AAAA;AAAA,UAEC,MAAK;AAAA,UACL,gBAAc,SAAS;AAAA,UACvB,SAAS,MAAM,KAAK,MAAM;AAAA,UAC1B,WAAW;AAAA,YACT;AAAA,YACA,QAAQ,KAAK;AAAA,YACb,SAAS,UAAU;AAAA,UACrB;AAAA,UAEC,gBAAM,MAAM;AAAA;AAAA,QAVR;AAAA,MAWP,CACD,GACH;AAAA,OACF;AAAA,KAEJ;AAEJ,CAAC;","names":["FileChangeTree"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,14 @@ type Emphasis = 'primary' | 'secondary' | 'tertiary' | 'quiet';
|
|
|
30
30
|
* when their hues are not.
|
|
31
31
|
*/
|
|
32
32
|
type Intent = 'info' | 'success' | 'warning' | 'danger';
|
|
33
|
+
/**
|
|
34
|
+
* Change, as a comparison reports it. Use for diff signs, change counts and
|
|
35
|
+
* change bars — never for whether the change is acceptable, which is an
|
|
36
|
+
* {@link Intent}. Red text on a removed line says *removed*, not *wrong*.
|
|
37
|
+
*/
|
|
38
|
+
type Delta = 'added' | 'removed' | 'moved';
|
|
39
|
+
/** The grounds a diff paints behind its rows. `hunk` sits behind a hunk header. */
|
|
40
|
+
type DeltaGround = 'added' | 'removed' | 'hunk';
|
|
33
41
|
/**
|
|
34
42
|
* Background elevation. `base` is the page, `raised` sits above it (cards,
|
|
35
43
|
* header, drawers), `sunken` is inset (code wells), `overlay` is modal.
|
|
@@ -108,6 +116,8 @@ declare const HEADING_EMPHASIS: Record<1 | 2 | 3 | 4 | 5 | 6, Emphasis>;
|
|
|
108
116
|
declare const semanticTokens: {
|
|
109
117
|
readonly accent: Record<Emphasis, string>;
|
|
110
118
|
readonly intent: Record<Intent, string>;
|
|
119
|
+
readonly delta: Record<Delta, string>;
|
|
120
|
+
readonly deltaGround: Record<DeltaGround, string>;
|
|
111
121
|
readonly surface: Record<Surface, string>;
|
|
112
122
|
readonly text: Record<TextTone, string>;
|
|
113
123
|
readonly border: Record<BorderTone, string>;
|
|
@@ -160,7 +170,7 @@ declare const semanticTokens: {
|
|
|
160
170
|
* hold at the light end — `border-subtle` at 28% is a visible hairline on
|
|
161
171
|
* black and invisible on paper. Literals also make the ladder *checkable*:
|
|
162
172
|
* `pnpm check:contrast` can compute every text-on-surface ratio without a
|
|
163
|
-
* browser —
|
|
173
|
+
* browser — 296 pairs, 148 per Level, including every Hue against every
|
|
164
174
|
* ground, which is what makes hand-tuned literals sustainable rather than
|
|
165
175
|
* twenty times the manual review. Stated per Level deliberately: 440 was
|
|
166
176
|
* written here in the commit that collapsed four Levels to two, so the total
|
|
@@ -230,6 +240,23 @@ interface LevelDefinition {
|
|
|
230
240
|
readonly border: Readonly<Record<BorderTone, string>>;
|
|
231
241
|
readonly accent: Readonly<Record<Emphasis, string>>;
|
|
232
242
|
readonly intent: Readonly<Record<Intent, string>>;
|
|
243
|
+
/**
|
|
244
|
+
* Change, as a comparison reports it: a line or record added, removed, or
|
|
245
|
+
* moved. Separate from `intent` on purpose. An added line is not a success
|
|
246
|
+
* and a removed one is not a danger; whether a change is acceptable is a
|
|
247
|
+
* policy's call, and a renderer that paints it green or red has made that
|
|
248
|
+
* call for the reader. The two groups may share a Hue, as `added` and
|
|
249
|
+
* `intent.success` do, and still diverge where the meanings would clash:
|
|
250
|
+
* `midnight`'s `removed` is red while its `danger` is pink.
|
|
251
|
+
*/
|
|
252
|
+
readonly delta: Readonly<Record<Delta, string>>;
|
|
253
|
+
/**
|
|
254
|
+
* The grounds a diff paints behind changed rows, and behind a hunk header.
|
|
255
|
+
* Literal tints rather than `color-mix()` for the reason given in the
|
|
256
|
+
* module header. `text.primary` and the matching `delta` role must both
|
|
257
|
+
* clear the text floor on each, which `check:contrast` asserts.
|
|
258
|
+
*/
|
|
259
|
+
readonly deltaGround: Readonly<Record<DeltaGround, string>>;
|
|
233
260
|
/**
|
|
234
261
|
* The Hue vocabulary — appearance, not job. Declared *below* the Roles above
|
|
235
262
|
* and referenced by them, never derived from them. Only a Target with no
|
|
@@ -258,6 +285,8 @@ interface LevelDefinition {
|
|
|
258
285
|
readonly accentHue: Readonly<Record<Emphasis, HueRef>>;
|
|
259
286
|
/** As `accentHue`, for the meaning Roles. */
|
|
260
287
|
readonly intentHue: Readonly<Record<Intent, HueRef>>;
|
|
288
|
+
/** As `accentHue`, for the change Roles. */
|
|
289
|
+
readonly deltaHue: Readonly<Record<Delta, HueRef>>;
|
|
261
290
|
/** Colour of the hard offset shadows. Normally tracks `border.strong`. */
|
|
262
291
|
readonly shadow: string;
|
|
263
292
|
}
|
|
@@ -7366,7 +7395,10 @@ interface ChangeSummaryProps extends react.HTMLAttributes<HTMLDivElement> {
|
|
|
7366
7395
|
footer?: DiffRow;
|
|
7367
7396
|
/** Markdown list or `<Line>` content used to derive rows. */
|
|
7368
7397
|
children?: ReactNode;
|
|
7369
|
-
/**
|
|
7398
|
+
/**
|
|
7399
|
+
* Accepted for symmetry with the other figures and ignored: additions and removals take the
|
|
7400
|
+
* `delta` roles, so a summary reads the same in a `multi` figure as in a `mono` one.
|
|
7401
|
+
*/
|
|
7370
7402
|
palette?: FigurePalette$1;
|
|
7371
7403
|
/** Additional classes for this summary. */
|
|
7372
7404
|
className?: string;
|
|
@@ -7952,4 +7984,4 @@ declare const mdxComponents: {
|
|
|
7952
7984
|
};
|
|
7953
7985
|
type MdxComponents = typeof mdxComponents;
|
|
7954
7986
|
|
|
7955
|
-
export { ALERT_STATE_ORDER, ANSI_SLOTS, type AccentToken, type ActivityDay, ActivityGrid, type ActivityGridProps, type Alert, AlertDialog, type AlertDialogProps, AlertList, type AlertListProps, type AlertSeverity, type AlertState, AnchorHeading, type AnchorHeadingProps, type AnsiChrome, type AnsiHue, type AnsiScheme, type AnsiSlot, AppMain, type AppMainProps, type AppNavItem, AppShell, type AppShellProps, AppSidebar, AppSidebarNav, type AppSidebarNavProps, type AppSidebarProps, AppTopbar, type AppTopbarProps, AsciiDivider, type AsciiDividerProps, AsciiGauge, type AsciiGaugeProps, type AsciiGaugeVariant, Avatar, type AvatarProps, Badge, type BadgeProps, BarChart, type BarChartDatum, type BarChartProps, BeforeAfter, type BeforeAfterProps, type BlogAuthor, BlogPost, type BlogPostProps, BlueskyIcon, type BorderTone, BracketText, type BracketTextProps, Breadcrumbs, type BreadcrumbsProps, type BrutalistTheme, type BuildTraceOptions, BulletChart, type BulletChartProps, Button, type ButtonElementProps, type ButtonLinkProps, type ButtonProps, type ButtonVariant, CSS_MEDIUM, CTASection, type CTASectionAccent, type CTASectionProps, Card, type CardProps, type CardVariant, ChangeSummary, type ChangeSummaryProps, ChartTooltip, type ChartTooltipProps, Checkbox, type CheckboxProps, type ClassInput, CodeBlock, CodeBlockAttachment, type CodeBlockProps, CodeTab, type CodeTabProps, CodeTabs, type CodeTabsProps, type CodeTabsVariant, ColophonCard, type ColophonCardProps, type ColophonLink, type Column, type ContrastCheck, type ContrastFloor, type Crumb, DEFAULT_DEPLOY_LOG, DEFAULT_EXPERIMENTS, DEFAULT_LEVEL, DEFAULT_PRICING_TIERS, DIVIDER_PATTERNS, DataTable, type DataTableProps, type DataTableVirtualization, Decision, type DecisionOption, type DecisionProps, DesignSandbox, type DiffLineProps, type DiffRow, type DiffSign, Divider, type DividerProps, type DividerVariant, DocPager, type DocPagerProps, type DocPagerTarget, DocsHeader, type DocsHeaderProps, DocsLayout, type DocsLayoutProps, DocsLink, type DocsLinkProps, DocsLinkProvider, type DocsLinkProviderProps, type DocsNavItem, type DocsNavNode, DocsSidebar, type DocsSidebarProps, Drawer, type DrawerPlacement, type DrawerProps, DrawingSheet, type DrawingSheetProps, type Emphasis, EmptyState, type EmptyStateProps, ErrorSummary, type ErrorSummaryError, type ErrorSummaryProps, Event, type ExperimentItem, ExperimentsView, type ExperimentsViewProps, FILTER_OPERATORS, FILTER_OPERATOR_LABELS, FIXED_COLOURS, FREE_TEXT_KEY, Feature, FeatureGrid, type FeatureGridProps, type FeatureProps, Fieldset, type FieldsetProps, FigureFrame, type FigureFrameProps, type FileChange, type FileChangeNode, FileChangeTree, type FileChangeTreeProps, type FileChangeView, type Filter, FilterBar, type FilterBarField, type FilterBarProps, type FilterOperator, type FilterParseResult, type Finding, type FixedColour, FlowDiagram, type FlowDiagramProps, type FlowNode, type FlowPathProps, type FlowRow, type FlowTone, FreshnessIndicator, type FreshnessIndicatorProps, type FreshnessState, GanttChart, type GanttChartProps, type GanttItem, GitHubIcon, Glyph, type GlyphProps, HEADING_EMPHASIS, type HeadingLevel, Hero, type HeroProps, type Hue, type HueAgreementCheck, type HueRef, INK_WEIGHT, IdChip, type IdChipProps, type IncidentEvent, type IncidentEventKind, type IncidentSummary, IncidentTimeline, type IncidentTimelineProps, IndexedSection, type IndexedSectionProps, Input, type InputProps, type IntensityScale, type Intent, LATENCY_HEATMAP_VARIANTS, LATENCY_HISTOGRAM_VARIANTS, LEVELS, LOG_SEVERITIES, type LatencyBucket, type LatencyCell, type LatencyGrid, LatencyHeatmap, type LatencyHeatmapProps, LatencyHistogram, type LatencyHistogramProps, type LatencyPoint, type LatencySlo, Legend, type LegendProps, type LevelDefinition, Line, type LinkComponentProps, LinkProvider, type LinkProviderProps, LinkedInIcon, type LogEntry, type LogFieldValue, type LogFilter, type LogHighlightPart, type LogSeverity, LogViewer, type LogViewerProps, LoremIpsumPost, MAXIMUM_NEUTRAL_CHROMA, MEDIA, MEDIA_DEFINITIONS, MINIMUM_RATIO, MailIcon, type MdxComponents, type Medium, type MediumDefinition, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuRadioGroup, type MenuRadioGroupProps, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, type MenuSeparatorProps, MetadataGrid, type MetadataGridCustomItem, type MetadataGridProps, type MetadataGridSeries, type Metric, MetricStrip, type MetricStripProps, type MetricTone, MobileNav, type MobileNavProps, Modal, type ModalProps, type Motion, NERD_GLYPHS, NerdIcon, type NerdIconAccent, type NerdIconName, type NerdIconProps, Node, type NodeProps, NotFoundPage, type NotFoundPageProps, NoteBlock, type NoteBlockProps, OBSERVABILITY_INCIDENT_WINDOW, ObservabilityConsole, type ObservabilityConsoleProps, Option, type OverlayAlign, type OverlaySide, PALETTE_HUES, PageHeader, type PageHeaderProps, PageTitle, type PageTitleProps, Pagination, type PaginationProps, Path, type Polarity, Popover, type PopoverProps, PricingGrid, type PricingGridProps, PricingTier, type PricingTierAccent, type PricingTierProps, Progress, type ProgressProps, Prose, type ProseProps, RECOMMENDED_COLOURS, RECOMMENDED_COLOUR_CLASSES, RECOMMENDED_COLOUR_NAMESPACES, RECOMMENDED_COLOUR_PROPERTIES, RECOMMENDED_COLOUR_ROLES, RECOMMENDED_COLOUR_VARS, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RecommendedColourClass, type RecommendedColourNamespace, type RecommendedColourProperty, type RecommendedThemeColours, ReportDetails, type ReportDetailsProps, ReportDocument, type ReportDocumentProps, type ReportMetaItem, ReportSection, type ReportSectionProps, type Rgb, SEVERITY_ACCENTS, SLIDE_DECK_HOTKEYS, SLOTS, SYSTEM_LEVEL, SaasLandingPage, type SaasLandingPageProps, type SectionAlign, type SectionColumns, SectionContainer, type SectionContainerProps, Select, type SelectOption, type SelectProps, type SelectionDevice, type SelectionDeviceCheck, ServerErrorPage, type ServerErrorPageProps, type ServiceEdge, type ServiceGraph, type ServiceGraphLayout, type ServiceGraphLayoutEdge, type ServiceGraphLayoutNode, type ServiceGraphLayoutOptions, type ServiceGraphPoint, ServiceMap, type ServiceMapProps, type ServiceNode, type ServiceNodeKind, type Severity, SeverityBadge, type SeverityBadgeProps, SiteFooter, type SiteFooterProps, SiteHeader, type SiteHeaderCollapse, type SiteHeaderProps, SiteLink, type SiteLinkProps, SiteNav, type SiteNavGroupItemProps, SiteNavItem, type SiteNavItemProps, type SiteNavLinkItemProps, type SiteNavOrientation, type SiteNavProps, Skeleton, type SkeletonProps, Slide, SlideDeck, type SlideDeckHotkey, type SlideDeckProps, type SlideProps, Slope, type SlopeItem, Slugger, SocialIcon, type SocialIconName, type SocialIconProps, Sparkline, type SparklineProps, Spinner, type SpinnerProps, StatCard, type StatCardAccent, type StatCardProps, StatusPage, type StatusPageProps, Step, type StepProps, type StepState, Steps, type StepsProps, type Surface, Swatch, type SwatchColumn, SwatchCompare, type SwatchCompareProps, SwatchGroup, type SwatchGroupProps, type SwatchProps, type SwatchRow, Switch, type SwitchProps, THEME_ATTRIBUTE, THEME_LEVELS, THEME_STORAGE_KEY, TIME_RANGE_PRESETS, TIME_SERIES_VARIANTS, TLDR, type TLDRProps, TOKEN_RULES, Table, type TableAppearance, TableBody, TableCaption, TableCell, type TableDensity, TableFooter, TableHead, TableHeader, TableOfContents, type TableOfContentsProps, TableRow, Tabs, type TabsFont, TabsList, type TabsListProps, type TabsOrientation, TabsPanel, type TabsPanelProps, type TabsProps, TabsTab, type TabsTabProps, type TabsVariant, Tag, type TagProps, TelemetryGauge, type TelemetryGaugeProps, type TelemetryMachineState, Term, TermGrid, type TermGridProps, type TermItem, Terminal, type TerminalProps, TextArea, type TextAreaProps, type TextHierarchyStep, type TextTone, type ThemeContextValue, type ThemeLevel, ThemeProvider, type ThemeProviderProps, TickerTape, type TickerTapeProps, type TimeCursorState, type TimeRange, TimeRangePicker, type TimeRangePickerProps, type TimeRangePreset, TimeRangeProvider, type TimeRangeProviderProps, type TimeRangeState, type TimeSeries, type TimeSeriesAnnotation, TimeSeriesChart, type TimeSeriesChartProps, type TimeSeriesColorStrategy, type TimeSeriesCurve, type TimeSeriesDensity, type TimeSeriesGrid, type TimeSeriesLegend, type TimeSeriesPoint, type TimeSeriesPointMarkers, type TimeSeriesThreshold, type TimeSeriesVariant, type TimeSeriesYDomain, type TimeSeriesYScale, Timeline, type TimelineEvent, type TimelineProps, type TimelineState, type ToastActionOptions, type ToastApi, type ToastIntent, type ToastOptions, ToastProvider, type ToastProviderProps, type TocEntry, type TokenRow, type TokenRule, TokenTable, type TokenTableProps, Tooltip, type TooltipProps, type TraceAttributeValue, type TraceModel, type TraceReplay, type TraceSpan, type TraceSpanInput, type TraceSpanStatus, TraceViewer, type TraceViewerProps, TraceWaterfall, type TraceWaterfallProps, TrackCard, type TrackCardProps, type TrackItem, type TrackItemStatus, TreeDiagram, type TreeDiagramProps, type TreeNode, type TypeStep, type TypeStepName, type UptimeStatus, UptimeStrip, type UptimeStripProps, type UseActiveHeadingOptions, type UseCopyToClipboardResult, type UseTraceClockOptions, type UseTraceReplayOptions, type VerdictTone, WEB_FLOOR, XIcon, accentVar, ansiScheme, apcaContrast, assertNever, auditContrast, auditHueAgreement, auditSelectionDevices, auditTextHierarchy, borderVar, bucketIndex, bucketPercentile, bucketTimes, buildTrace, childrenToText, clampToRange, cn, collectHeadings, composite, contrastRatio, createAnchorHeading, describeFilter, describeLogEntry, describeTraceSpan, filterLogEntries, fontVar, formatAge, formatAlertDuration, formatClock, formatCount, formatDay, formatFilter, formatLatencyRange, formatRange, formatRangeDuration, formatRequests, formatServiceCount, formatServiceErrorRate, formatShare, formatTimeTick, formatTimestamp, formatTraceDuration, getRecommendedColours, getThemeInitScript, heatmapCells, highlightLogText, histogram, inLogRange, intensityLevel, intensityThresholds, isExternalHref, isMedium, isRecommendedColourClass, isThemeLevel, latencyBuckets, latencyExtent, latencyRowPosition, layoutServiceGraph, linearBuckets, logTicks, lookupField, matchFilters, matchLogEntry, matchTraceSpan, mdxComponents, nearestLogIndex, nextLevel, normaliseRange, parseColor, parseFilter, parseOtlpTrace, parseTraceDocument, percentile, percentiles, presetRange, relativeLuminance, replayTrace, sameFilter, scanRules, scanTokenRules, semanticTokens, serviceEdgeMidpoint, serviceEdgePath, serviceGraph, severityAccent, shareAbove, slugify, sortAlerts, sortLogEntries, summariseIncident, surfaceVar, textVar, timeTicks, truncateId, tryParseFilter, useActiveHeading, useCopyToClipboard, useDocsLinkComponent, useIsCurrentHref, useLinkComponent, useOptionalTheme, useOptionalToast, useTheme, useTimeCursor, useTimeRange, useToast, useTraceClock, useTraceReplay, visibleTraceSpans };
|
|
7987
|
+
export { ALERT_STATE_ORDER, ANSI_SLOTS, type AccentToken, type ActivityDay, ActivityGrid, type ActivityGridProps, type Alert, AlertDialog, type AlertDialogProps, AlertList, type AlertListProps, type AlertSeverity, type AlertState, AnchorHeading, type AnchorHeadingProps, type AnsiChrome, type AnsiHue, type AnsiScheme, type AnsiSlot, AppMain, type AppMainProps, type AppNavItem, AppShell, type AppShellProps, AppSidebar, AppSidebarNav, type AppSidebarNavProps, type AppSidebarProps, AppTopbar, type AppTopbarProps, AsciiDivider, type AsciiDividerProps, AsciiGauge, type AsciiGaugeProps, type AsciiGaugeVariant, Avatar, type AvatarProps, Badge, type BadgeProps, BarChart, type BarChartDatum, type BarChartProps, BeforeAfter, type BeforeAfterProps, type BlogAuthor, BlogPost, type BlogPostProps, BlueskyIcon, type BorderTone, BracketText, type BracketTextProps, Breadcrumbs, type BreadcrumbsProps, type BrutalistTheme, type BuildTraceOptions, BulletChart, type BulletChartProps, Button, type ButtonElementProps, type ButtonLinkProps, type ButtonProps, type ButtonVariant, CSS_MEDIUM, CTASection, type CTASectionAccent, type CTASectionProps, Card, type CardProps, type CardVariant, ChangeSummary, type ChangeSummaryProps, ChartTooltip, type ChartTooltipProps, Checkbox, type CheckboxProps, type ClassInput, CodeBlock, CodeBlockAttachment, type CodeBlockProps, CodeTab, type CodeTabProps, CodeTabs, type CodeTabsProps, type CodeTabsVariant, ColophonCard, type ColophonCardProps, type ColophonLink, type Column, type ContrastCheck, type ContrastFloor, type Crumb, DEFAULT_DEPLOY_LOG, DEFAULT_EXPERIMENTS, DEFAULT_LEVEL, DEFAULT_PRICING_TIERS, DIVIDER_PATTERNS, DataTable, type DataTableProps, type DataTableVirtualization, Decision, type DecisionOption, type DecisionProps, type Delta, type DeltaGround, DesignSandbox, type DiffLineProps, type DiffRow, type DiffSign, Divider, type DividerProps, type DividerVariant, DocPager, type DocPagerProps, type DocPagerTarget, DocsHeader, type DocsHeaderProps, DocsLayout, type DocsLayoutProps, DocsLink, type DocsLinkProps, DocsLinkProvider, type DocsLinkProviderProps, type DocsNavItem, type DocsNavNode, DocsSidebar, type DocsSidebarProps, Drawer, type DrawerPlacement, type DrawerProps, DrawingSheet, type DrawingSheetProps, type Emphasis, EmptyState, type EmptyStateProps, ErrorSummary, type ErrorSummaryError, type ErrorSummaryProps, Event, type ExperimentItem, ExperimentsView, type ExperimentsViewProps, FILTER_OPERATORS, FILTER_OPERATOR_LABELS, FIXED_COLOURS, FREE_TEXT_KEY, Feature, FeatureGrid, type FeatureGridProps, type FeatureProps, Fieldset, type FieldsetProps, FigureFrame, type FigureFrameProps, type FileChange, type FileChangeNode, FileChangeTree, type FileChangeTreeProps, type FileChangeView, type Filter, FilterBar, type FilterBarField, type FilterBarProps, type FilterOperator, type FilterParseResult, type Finding, type FixedColour, FlowDiagram, type FlowDiagramProps, type FlowNode, type FlowPathProps, type FlowRow, type FlowTone, FreshnessIndicator, type FreshnessIndicatorProps, type FreshnessState, GanttChart, type GanttChartProps, type GanttItem, GitHubIcon, Glyph, type GlyphProps, HEADING_EMPHASIS, type HeadingLevel, Hero, type HeroProps, type Hue, type HueAgreementCheck, type HueRef, INK_WEIGHT, IdChip, type IdChipProps, type IncidentEvent, type IncidentEventKind, type IncidentSummary, IncidentTimeline, type IncidentTimelineProps, IndexedSection, type IndexedSectionProps, Input, type InputProps, type IntensityScale, type Intent, LATENCY_HEATMAP_VARIANTS, LATENCY_HISTOGRAM_VARIANTS, LEVELS, LOG_SEVERITIES, type LatencyBucket, type LatencyCell, type LatencyGrid, LatencyHeatmap, type LatencyHeatmapProps, LatencyHistogram, type LatencyHistogramProps, type LatencyPoint, type LatencySlo, Legend, type LegendProps, type LevelDefinition, Line, type LinkComponentProps, LinkProvider, type LinkProviderProps, LinkedInIcon, type LogEntry, type LogFieldValue, type LogFilter, type LogHighlightPart, type LogSeverity, LogViewer, type LogViewerProps, LoremIpsumPost, MAXIMUM_NEUTRAL_CHROMA, MEDIA, MEDIA_DEFINITIONS, MINIMUM_RATIO, MailIcon, type MdxComponents, type Medium, type MediumDefinition, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuRadioGroup, type MenuRadioGroupProps, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, type MenuSeparatorProps, MetadataGrid, type MetadataGridCustomItem, type MetadataGridProps, type MetadataGridSeries, type Metric, MetricStrip, type MetricStripProps, type MetricTone, MobileNav, type MobileNavProps, Modal, type ModalProps, type Motion, NERD_GLYPHS, NerdIcon, type NerdIconAccent, type NerdIconName, type NerdIconProps, Node, type NodeProps, NotFoundPage, type NotFoundPageProps, NoteBlock, type NoteBlockProps, OBSERVABILITY_INCIDENT_WINDOW, ObservabilityConsole, type ObservabilityConsoleProps, Option, type OverlayAlign, type OverlaySide, PALETTE_HUES, PageHeader, type PageHeaderProps, PageTitle, type PageTitleProps, Pagination, type PaginationProps, Path, type Polarity, Popover, type PopoverProps, PricingGrid, type PricingGridProps, PricingTier, type PricingTierAccent, type PricingTierProps, Progress, type ProgressProps, Prose, type ProseProps, RECOMMENDED_COLOURS, RECOMMENDED_COLOUR_CLASSES, RECOMMENDED_COLOUR_NAMESPACES, RECOMMENDED_COLOUR_PROPERTIES, RECOMMENDED_COLOUR_ROLES, RECOMMENDED_COLOUR_VARS, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RecommendedColourClass, type RecommendedColourNamespace, type RecommendedColourProperty, type RecommendedThemeColours, ReportDetails, type ReportDetailsProps, ReportDocument, type ReportDocumentProps, type ReportMetaItem, ReportSection, type ReportSectionProps, type Rgb, SEVERITY_ACCENTS, SLIDE_DECK_HOTKEYS, SLOTS, SYSTEM_LEVEL, SaasLandingPage, type SaasLandingPageProps, type SectionAlign, type SectionColumns, SectionContainer, type SectionContainerProps, Select, type SelectOption, type SelectProps, type SelectionDevice, type SelectionDeviceCheck, ServerErrorPage, type ServerErrorPageProps, type ServiceEdge, type ServiceGraph, type ServiceGraphLayout, type ServiceGraphLayoutEdge, type ServiceGraphLayoutNode, type ServiceGraphLayoutOptions, type ServiceGraphPoint, ServiceMap, type ServiceMapProps, type ServiceNode, type ServiceNodeKind, type Severity, SeverityBadge, type SeverityBadgeProps, SiteFooter, type SiteFooterProps, SiteHeader, type SiteHeaderCollapse, type SiteHeaderProps, SiteLink, type SiteLinkProps, SiteNav, type SiteNavGroupItemProps, SiteNavItem, type SiteNavItemProps, type SiteNavLinkItemProps, type SiteNavOrientation, type SiteNavProps, Skeleton, type SkeletonProps, Slide, SlideDeck, type SlideDeckHotkey, type SlideDeckProps, type SlideProps, Slope, type SlopeItem, Slugger, SocialIcon, type SocialIconName, type SocialIconProps, Sparkline, type SparklineProps, Spinner, type SpinnerProps, StatCard, type StatCardAccent, type StatCardProps, StatusPage, type StatusPageProps, Step, type StepProps, type StepState, Steps, type StepsProps, type Surface, Swatch, type SwatchColumn, SwatchCompare, type SwatchCompareProps, SwatchGroup, type SwatchGroupProps, type SwatchProps, type SwatchRow, Switch, type SwitchProps, THEME_ATTRIBUTE, THEME_LEVELS, THEME_STORAGE_KEY, TIME_RANGE_PRESETS, TIME_SERIES_VARIANTS, TLDR, type TLDRProps, TOKEN_RULES, Table, type TableAppearance, TableBody, TableCaption, TableCell, type TableDensity, TableFooter, TableHead, TableHeader, TableOfContents, type TableOfContentsProps, TableRow, Tabs, type TabsFont, TabsList, type TabsListProps, type TabsOrientation, TabsPanel, type TabsPanelProps, type TabsProps, TabsTab, type TabsTabProps, type TabsVariant, Tag, type TagProps, TelemetryGauge, type TelemetryGaugeProps, type TelemetryMachineState, Term, TermGrid, type TermGridProps, type TermItem, Terminal, type TerminalProps, TextArea, type TextAreaProps, type TextHierarchyStep, type TextTone, type ThemeContextValue, type ThemeLevel, ThemeProvider, type ThemeProviderProps, TickerTape, type TickerTapeProps, type TimeCursorState, type TimeRange, TimeRangePicker, type TimeRangePickerProps, type TimeRangePreset, TimeRangeProvider, type TimeRangeProviderProps, type TimeRangeState, type TimeSeries, type TimeSeriesAnnotation, TimeSeriesChart, type TimeSeriesChartProps, type TimeSeriesColorStrategy, type TimeSeriesCurve, type TimeSeriesDensity, type TimeSeriesGrid, type TimeSeriesLegend, type TimeSeriesPoint, type TimeSeriesPointMarkers, type TimeSeriesThreshold, type TimeSeriesVariant, type TimeSeriesYDomain, type TimeSeriesYScale, Timeline, type TimelineEvent, type TimelineProps, type TimelineState, type ToastActionOptions, type ToastApi, type ToastIntent, type ToastOptions, ToastProvider, type ToastProviderProps, type TocEntry, type TokenRow, type TokenRule, TokenTable, type TokenTableProps, Tooltip, type TooltipProps, type TraceAttributeValue, type TraceModel, type TraceReplay, type TraceSpan, type TraceSpanInput, type TraceSpanStatus, TraceViewer, type TraceViewerProps, TraceWaterfall, type TraceWaterfallProps, TrackCard, type TrackCardProps, type TrackItem, type TrackItemStatus, TreeDiagram, type TreeDiagramProps, type TreeNode, type TypeStep, type TypeStepName, type UptimeStatus, UptimeStrip, type UptimeStripProps, type UseActiveHeadingOptions, type UseCopyToClipboardResult, type UseTraceClockOptions, type UseTraceReplayOptions, type VerdictTone, WEB_FLOOR, XIcon, accentVar, ansiScheme, apcaContrast, assertNever, auditContrast, auditHueAgreement, auditSelectionDevices, auditTextHierarchy, borderVar, bucketIndex, bucketPercentile, bucketTimes, buildTrace, childrenToText, clampToRange, cn, collectHeadings, composite, contrastRatio, createAnchorHeading, describeFilter, describeLogEntry, describeTraceSpan, filterLogEntries, fontVar, formatAge, formatAlertDuration, formatClock, formatCount, formatDay, formatFilter, formatLatencyRange, formatRange, formatRangeDuration, formatRequests, formatServiceCount, formatServiceErrorRate, formatShare, formatTimeTick, formatTimestamp, formatTraceDuration, getRecommendedColours, getThemeInitScript, heatmapCells, highlightLogText, histogram, inLogRange, intensityLevel, intensityThresholds, isExternalHref, isMedium, isRecommendedColourClass, isThemeLevel, latencyBuckets, latencyExtent, latencyRowPosition, layoutServiceGraph, linearBuckets, logTicks, lookupField, matchFilters, matchLogEntry, matchTraceSpan, mdxComponents, nearestLogIndex, nextLevel, normaliseRange, parseColor, parseFilter, parseOtlpTrace, parseTraceDocument, percentile, percentiles, presetRange, relativeLuminance, replayTrace, sameFilter, scanRules, scanTokenRules, semanticTokens, serviceEdgeMidpoint, serviceEdgePath, serviceGraph, severityAccent, shareAbove, slugify, sortAlerts, sortLogEntries, summariseIncident, surfaceVar, textVar, timeTicks, truncateId, tryParseFilter, useActiveHeading, useCopyToClipboard, useDocsLinkComponent, useIsCurrentHref, useLinkComponent, useOptionalTheme, useOptionalToast, useTheme, useTimeCursor, useTimeRange, useToast, useTraceClock, useTraceReplay, visibleTraceSpans };
|
package/dist/lib/theme.js
CHANGED
|
@@ -11,6 +11,16 @@ var INTENT_VARS = {
|
|
|
11
11
|
warning: "var(--ds-intent-warning)",
|
|
12
12
|
danger: "var(--ds-intent-danger)"
|
|
13
13
|
};
|
|
14
|
+
var DELTA_VARS = {
|
|
15
|
+
added: "var(--ds-delta-added)",
|
|
16
|
+
removed: "var(--ds-delta-removed)",
|
|
17
|
+
moved: "var(--ds-delta-moved)"
|
|
18
|
+
};
|
|
19
|
+
var DELTA_GROUND_VARS = {
|
|
20
|
+
added: "var(--ds-delta-ground-added)",
|
|
21
|
+
removed: "var(--ds-delta-ground-removed)",
|
|
22
|
+
hunk: "var(--ds-delta-ground-hunk)"
|
|
23
|
+
};
|
|
14
24
|
var SURFACE_VARS = {
|
|
15
25
|
base: "var(--ds-surface-base)",
|
|
16
26
|
raised: "var(--ds-surface-raised)",
|
|
@@ -58,6 +68,8 @@ var HEADING_EMPHASIS = {
|
|
|
58
68
|
var semanticTokens = {
|
|
59
69
|
accent: EMPHASIS_VARS,
|
|
60
70
|
intent: INTENT_VARS,
|
|
71
|
+
delta: DELTA_VARS,
|
|
72
|
+
deltaGround: DELTA_GROUND_VARS,
|
|
61
73
|
surface: SURFACE_VARS,
|
|
62
74
|
text: TEXT_VARS,
|
|
63
75
|
border: BORDER_VARS,
|
package/dist/lib/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/theme.ts"],"sourcesContent":["/**\n * Semantic theming layer.\n *\n * Components should describe *what a thing is* — a primary accent, a danger\n * state, a raised surface — never which colour it happens to be. The brutalist\n * palette (cyan/pink/yellow/green) is one mapping of those roles; `.dim` and\n * `.sketch` are others, and a future mode is a third. Referencing\n * `var(--brutalist-cyan)` directly hard-codes today's mapping into every\n * component and makes retheming a find-and-replace across the package.\n *\n * The CSS variables below are declared in `theme.css` and resolve through the\n * raw palette, so they follow every mode swap automatically.\n */\n\n/**\n * Visual weight within a hierarchy. Use for decorative and navigational\n * emphasis — which of several things should draw the eye first — not for\n * meaning. `quiet` is the de-emphasised step, not a fifth colour.\n */\nexport type Emphasis = 'primary' | 'secondary' | 'tertiary' | 'quiet';\n\n/**\n * Communicated meaning. Use when the colour carries information the reader\n * must act on; these survive retheming because their semantics are fixed even\n * when their hues are not.\n */\nexport type Intent = 'info' | 'success' | 'warning' | 'danger';\n\n/**\n * Background elevation. `base` is the page, `raised` sits above it (cards,\n * header, drawers), `sunken` is inset (code wells), `overlay` is modal.\n */\nexport type Surface = 'base' | 'raised' | 'sunken' | 'overlay';\n\n/** Text prominence, coarsest to faintest. */\nexport type TextTone = 'primary' | 'secondary' | 'muted' | 'inverse';\n\n/** Rule weight. `strong` is the full-contrast brutalist border. */\nexport type BorderTone = 'strong' | 'default' | 'subtle';\n\n/**\n * Palette names accepted by components predating the semantic layer.\n *\n * @deprecated Pass an {@link Emphasis} or {@link Intent} instead. These remain\n * accepted so existing consumers keep compiling, and they resolve to the same\n * values, but they defeat the point of the abstraction.\n */\n/**\n * A colour's *appearance*, independent of any job — the vocabulary a Target\n * addresses when it has no notion of jobs. A terminal has sixteen positions\n * named by colour and no concept of a keyword.\n *\n * Declared below the Role vocabulary and referenced by it, never the reverse:\n * Hue -> Role is a declared lookup, Role -> Hue is a guess. See\n * `docs/adr/0001-hues-declared-below-roles.md`.\n *\n * **A Hue in component code is a defect.** Components address Roles only.\n * Ten is the ceiling rather than a comfortable middle — the tightest pair\n * already sits at deltaE 0.049. See `docs/palette-provenance.md`.\n */\nexport type Hue =\n | 'red'\n | 'orange'\n | 'yellow'\n | 'green'\n | 'teal'\n | 'cyan'\n | 'blue'\n | 'violet'\n | 'magenta'\n | 'pink';\n\n/**\n * The eight ANSI base slots a terminal needs, beyond which `bright` variants\n * fill the upper eight. `black` and `white` come from `FIXED_COLOURS`.\n */\nexport type AnsiHue = Extract<Hue, 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan'>;\n\n/**\n * What a Role points at in the Hue vocabulary.\n *\n * `'neutral'` is not a cop-out: some Roles genuinely are not hues.\n * `accent.quiet` is a warm or cool grey by design, and the palette has no\n * neutral ramp to point it at. Saying so explicitly keeps the map exhaustive —\n * a new Emphasis is still a compile error — while letting the gate distinguish\n * \"declared as not-a-hue\" from \"forgot to wire it up\", which a `Partial` could\n * not.\n */\nexport type HueRef = Hue | 'neutral';\n\n\n/** Anything a component's `accent`-style prop will take. */\nexport type AccentToken = Emphasis | Intent;\n\nconst EMPHASIS_VARS: Record<Emphasis, string> = {\n primary: 'var(--ds-accent-primary)',\n secondary: 'var(--ds-accent-secondary)',\n tertiary: 'var(--ds-accent-tertiary)',\n quiet: 'var(--ds-accent-quiet)',\n};\n\nconst INTENT_VARS: Record<Intent, string> = {\n info: 'var(--ds-intent-info)',\n success: 'var(--ds-intent-success)',\n warning: 'var(--ds-intent-warning)',\n danger: 'var(--ds-intent-danger)',\n};\n\nconst SURFACE_VARS: Record<Surface, string> = {\n base: 'var(--ds-surface-base)',\n raised: 'var(--ds-surface-raised)',\n sunken: 'var(--ds-surface-sunken)',\n overlay: 'var(--ds-surface-overlay)',\n};\n\nconst TEXT_VARS: Record<TextTone, string> = {\n primary: 'var(--ds-text-primary)',\n secondary: 'var(--ds-text-secondary)',\n muted: 'var(--ds-text-muted)',\n inverse: 'var(--ds-text-inverse)',\n};\n\nconst BORDER_VARS: Record<BorderTone, string> = {\n strong: 'var(--ds-border-strong)',\n default: 'var(--ds-border-default)',\n subtle: 'var(--ds-border-subtle)',\n};\n\n/**\n * Resolve any accent token to the CSS variable expression that renders it.\n *\n * Unknown values fall back to the primary accent rather than throwing —\n * a mistyped prop should degrade to something legible, not blank out a\n * component's colour and leave `color: undefined` on the element.\n */\nexport function accentVar(token: AccentToken | undefined, fallback: AccentToken = 'primary'): string {\n const resolved = token ?? fallback;\n return (\n EMPHASIS_VARS[resolved as Emphasis] ??\n INTENT_VARS[resolved as Intent] ??\n EMPHASIS_VARS.primary\n );\n}\n\nexport function surfaceVar(token: Surface = 'base'): string {\n return SURFACE_VARS[token] ?? SURFACE_VARS.base;\n}\n\nexport function textVar(token: TextTone = 'primary'): string {\n return TEXT_VARS[token] ?? TEXT_VARS.primary;\n}\n\nexport function borderVar(token: BorderTone = 'strong'): string {\n return BORDER_VARS[token] ?? BORDER_VARS.strong;\n}\n\n/** Semantic font roles. */\nexport const fontVar = {\n display: 'var(--ds-font-display)',\n body: 'var(--ds-font-body)',\n mono: 'var(--ds-font-mono)',\n pixel: 'var(--ds-font-pixel)',\n} as const;\n\n/**\n * Default emphasis per heading level, so a document's colour hierarchy follows\n * its structural hierarchy without every call site restating it.\n */\nexport const HEADING_EMPHASIS: Record<1 | 2 | 3 | 4 | 5 | 6, Emphasis> = {\n 1: 'primary',\n 2: 'primary',\n 3: 'secondary',\n 4: 'tertiary',\n 5: 'quiet',\n 6: 'quiet',\n};\n\n/**\n * The full semantic token surface, as CSS variable expressions. Useful for\n * inline styles and for consumers building their own components on the system.\n */\nexport const semanticTokens = {\n accent: EMPHASIS_VARS,\n intent: INTENT_VARS,\n surface: SURFACE_VARS,\n text: TEXT_VARS,\n border: BORDER_VARS,\n font: fontVar,\n shadowColor: 'var(--ds-shadow-color)',\n} as const;\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/lib/theme.ts"],"sourcesContent":["/**\n * Semantic theming layer.\n *\n * Components should describe *what a thing is* — a primary accent, a danger\n * state, a raised surface — never which colour it happens to be. The brutalist\n * palette (cyan/pink/yellow/green) is one mapping of those roles; `.dim` and\n * `.sketch` are others, and a future mode is a third. Referencing\n * `var(--brutalist-cyan)` directly hard-codes today's mapping into every\n * component and makes retheming a find-and-replace across the package.\n *\n * The CSS variables below are declared in `theme.css` and resolve through the\n * raw palette, so they follow every mode swap automatically.\n */\n\n/**\n * Visual weight within a hierarchy. Use for decorative and navigational\n * emphasis — which of several things should draw the eye first — not for\n * meaning. `quiet` is the de-emphasised step, not a fifth colour.\n */\nexport type Emphasis = 'primary' | 'secondary' | 'tertiary' | 'quiet';\n\n/**\n * Communicated meaning. Use when the colour carries information the reader\n * must act on; these survive retheming because their semantics are fixed even\n * when their hues are not.\n */\nexport type Intent = 'info' | 'success' | 'warning' | 'danger';\n\n/**\n * Change, as a comparison reports it. Use for diff signs, change counts and\n * change bars — never for whether the change is acceptable, which is an\n * {@link Intent}. Red text on a removed line says *removed*, not *wrong*.\n */\nexport type Delta = 'added' | 'removed' | 'moved';\n\n/** The grounds a diff paints behind its rows. `hunk` sits behind a hunk header. */\nexport type DeltaGround = 'added' | 'removed' | 'hunk';\n\n/**\n * Background elevation. `base` is the page, `raised` sits above it (cards,\n * header, drawers), `sunken` is inset (code wells), `overlay` is modal.\n */\nexport type Surface = 'base' | 'raised' | 'sunken' | 'overlay';\n\n/** Text prominence, coarsest to faintest. */\nexport type TextTone = 'primary' | 'secondary' | 'muted' | 'inverse';\n\n/** Rule weight. `strong` is the full-contrast brutalist border. */\nexport type BorderTone = 'strong' | 'default' | 'subtle';\n\n/**\n * Palette names accepted by components predating the semantic layer.\n *\n * @deprecated Pass an {@link Emphasis} or {@link Intent} instead. These remain\n * accepted so existing consumers keep compiling, and they resolve to the same\n * values, but they defeat the point of the abstraction.\n */\n/**\n * A colour's *appearance*, independent of any job — the vocabulary a Target\n * addresses when it has no notion of jobs. A terminal has sixteen positions\n * named by colour and no concept of a keyword.\n *\n * Declared below the Role vocabulary and referenced by it, never the reverse:\n * Hue -> Role is a declared lookup, Role -> Hue is a guess. See\n * `docs/adr/0001-hues-declared-below-roles.md`.\n *\n * **A Hue in component code is a defect.** Components address Roles only.\n * Ten is the ceiling rather than a comfortable middle — the tightest pair\n * already sits at deltaE 0.049. See `docs/palette-provenance.md`.\n */\nexport type Hue =\n | 'red'\n | 'orange'\n | 'yellow'\n | 'green'\n | 'teal'\n | 'cyan'\n | 'blue'\n | 'violet'\n | 'magenta'\n | 'pink';\n\n/**\n * The eight ANSI base slots a terminal needs, beyond which `bright` variants\n * fill the upper eight. `black` and `white` come from `FIXED_COLOURS`.\n */\nexport type AnsiHue = Extract<Hue, 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan'>;\n\n/**\n * What a Role points at in the Hue vocabulary.\n *\n * `'neutral'` is not a cop-out: some Roles genuinely are not hues.\n * `accent.quiet` is a warm or cool grey by design, and the palette has no\n * neutral ramp to point it at. Saying so explicitly keeps the map exhaustive —\n * a new Emphasis is still a compile error — while letting the gate distinguish\n * \"declared as not-a-hue\" from \"forgot to wire it up\", which a `Partial` could\n * not.\n */\nexport type HueRef = Hue | 'neutral';\n\n\n/** Anything a component's `accent`-style prop will take. */\nexport type AccentToken = Emphasis | Intent;\n\nconst EMPHASIS_VARS: Record<Emphasis, string> = {\n primary: 'var(--ds-accent-primary)',\n secondary: 'var(--ds-accent-secondary)',\n tertiary: 'var(--ds-accent-tertiary)',\n quiet: 'var(--ds-accent-quiet)',\n};\n\nconst INTENT_VARS: Record<Intent, string> = {\n info: 'var(--ds-intent-info)',\n success: 'var(--ds-intent-success)',\n warning: 'var(--ds-intent-warning)',\n danger: 'var(--ds-intent-danger)',\n};\n\nconst DELTA_VARS: Record<Delta, string> = {\n added: 'var(--ds-delta-added)',\n removed: 'var(--ds-delta-removed)',\n moved: 'var(--ds-delta-moved)',\n};\n\nconst DELTA_GROUND_VARS: Record<DeltaGround, string> = {\n added: 'var(--ds-delta-ground-added)',\n removed: 'var(--ds-delta-ground-removed)',\n hunk: 'var(--ds-delta-ground-hunk)',\n};\n\nconst SURFACE_VARS: Record<Surface, string> = {\n base: 'var(--ds-surface-base)',\n raised: 'var(--ds-surface-raised)',\n sunken: 'var(--ds-surface-sunken)',\n overlay: 'var(--ds-surface-overlay)',\n};\n\nconst TEXT_VARS: Record<TextTone, string> = {\n primary: 'var(--ds-text-primary)',\n secondary: 'var(--ds-text-secondary)',\n muted: 'var(--ds-text-muted)',\n inverse: 'var(--ds-text-inverse)',\n};\n\nconst BORDER_VARS: Record<BorderTone, string> = {\n strong: 'var(--ds-border-strong)',\n default: 'var(--ds-border-default)',\n subtle: 'var(--ds-border-subtle)',\n};\n\n/**\n * Resolve any accent token to the CSS variable expression that renders it.\n *\n * Unknown values fall back to the primary accent rather than throwing —\n * a mistyped prop should degrade to something legible, not blank out a\n * component's colour and leave `color: undefined` on the element.\n */\nexport function accentVar(token: AccentToken | undefined, fallback: AccentToken = 'primary'): string {\n const resolved = token ?? fallback;\n return (\n EMPHASIS_VARS[resolved as Emphasis] ??\n INTENT_VARS[resolved as Intent] ??\n EMPHASIS_VARS.primary\n );\n}\n\nexport function surfaceVar(token: Surface = 'base'): string {\n return SURFACE_VARS[token] ?? SURFACE_VARS.base;\n}\n\nexport function textVar(token: TextTone = 'primary'): string {\n return TEXT_VARS[token] ?? TEXT_VARS.primary;\n}\n\nexport function borderVar(token: BorderTone = 'strong'): string {\n return BORDER_VARS[token] ?? BORDER_VARS.strong;\n}\n\n/** Semantic font roles. */\nexport const fontVar = {\n display: 'var(--ds-font-display)',\n body: 'var(--ds-font-body)',\n mono: 'var(--ds-font-mono)',\n pixel: 'var(--ds-font-pixel)',\n} as const;\n\n/**\n * Default emphasis per heading level, so a document's colour hierarchy follows\n * its structural hierarchy without every call site restating it.\n */\nexport const HEADING_EMPHASIS: Record<1 | 2 | 3 | 4 | 5 | 6, Emphasis> = {\n 1: 'primary',\n 2: 'primary',\n 3: 'secondary',\n 4: 'tertiary',\n 5: 'quiet',\n 6: 'quiet',\n};\n\n/**\n * The full semantic token surface, as CSS variable expressions. Useful for\n * inline styles and for consumers building their own components on the system.\n */\nexport const semanticTokens = {\n accent: EMPHASIS_VARS,\n intent: INTENT_VARS,\n delta: DELTA_VARS,\n deltaGround: DELTA_GROUND_VARS,\n surface: SURFACE_VARS,\n text: TEXT_VARS,\n border: BORDER_VARS,\n font: fontVar,\n shadowColor: 'var(--ds-shadow-color)',\n} as const;\n"],"mappings":";AAwGA,IAAM,gBAA0C;AAAA,EAC9C,SAAS;AAAA,EACT,WAAW;AAAA,EACX,UAAU;AAAA,EACV,OAAO;AACT;AAEA,IAAM,cAAsC;AAAA,EAC1C,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AACV;AAEA,IAAM,aAAoC;AAAA,EACxC,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AACT;AAEA,IAAM,oBAAiD;AAAA,EACrD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AACR;AAEA,IAAM,eAAwC;AAAA,EAC5C,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX;AAEA,IAAM,YAAsC;AAAA,EAC1C,SAAS;AAAA,EACT,WAAW;AAAA,EACX,OAAO;AAAA,EACP,SAAS;AACX;AAEA,IAAM,cAA0C;AAAA,EAC9C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AACV;AASO,SAAS,UAAU,OAAgC,WAAwB,WAAmB;AACnG,QAAM,WAAW,SAAS;AAC1B,SACE,cAAc,QAAoB,KAClC,YAAY,QAAkB,KAC9B,cAAc;AAElB;AAEO,SAAS,WAAW,QAAiB,QAAgB;AAC1D,SAAO,aAAa,KAAK,KAAK,aAAa;AAC7C;AAEO,SAAS,QAAQ,QAAkB,WAAmB;AAC3D,SAAO,UAAU,KAAK,KAAK,UAAU;AACvC;AAEO,SAAS,UAAU,QAAoB,UAAkB;AAC9D,SAAO,YAAY,KAAK,KAAK,YAAY;AAC3C;AAGO,IAAM,UAAU;AAAA,EACrB,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAMO,IAAM,mBAA4D;AAAA,EACvE,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAMO,IAAM,iBAAiB;AAAA,EAC5B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AACf;","names":[]}
|
package/dist/theme/contrast.js
CHANGED
|
@@ -177,6 +177,9 @@ function auditHueAgreement(ladder) {
|
|
|
177
177
|
for (const [role, ref] of Object.entries(def.intentHue)) {
|
|
178
178
|
check(`intent.${role}`, def.intent[role], ref);
|
|
179
179
|
}
|
|
180
|
+
for (const [role, ref] of Object.entries(def.deltaHue)) {
|
|
181
|
+
check(`delta.${role}`, def.delta[role], ref);
|
|
182
|
+
}
|
|
180
183
|
}
|
|
181
184
|
return results;
|
|
182
185
|
}
|
|
@@ -216,6 +219,9 @@ function auditContrast(ladder, floor = WEB_FLOOR) {
|
|
|
216
219
|
for (const tone of ["info", "success", "warning", "danger"]) {
|
|
217
220
|
check(`intent.${tone} on ${groundName}`, def.intent[tone], ground, floor.role);
|
|
218
221
|
}
|
|
222
|
+
for (const tone of ["added", "removed", "moved"]) {
|
|
223
|
+
check(`delta.${tone} on ${groundName}`, def.delta[tone], ground, floor.role);
|
|
224
|
+
}
|
|
219
225
|
for (const hue of PALETTE_HUES_ORDER) {
|
|
220
226
|
check(`palette.${hue} on ${groundName}`, def.palette[hue], ground, floor.hue);
|
|
221
227
|
check(
|
|
@@ -237,6 +243,10 @@ function auditContrast(ladder, floor = WEB_FLOOR) {
|
|
|
237
243
|
floor.role
|
|
238
244
|
);
|
|
239
245
|
}
|
|
246
|
+
for (const tone of ["added", "removed", "moved"]) {
|
|
247
|
+
check(`text.inverse on delta.${tone}`, def.text.inverse, def.delta[tone], floor.role);
|
|
248
|
+
}
|
|
249
|
+
check("text.inverse on text.secondary", def.text.inverse, def.text.secondary, floor.role);
|
|
240
250
|
for (const tone of ["info", "success", "warning", "danger"]) {
|
|
241
251
|
check(
|
|
242
252
|
`text.inverse on intent.${tone}`,
|
|
@@ -245,6 +255,11 @@ function auditContrast(ladder, floor = WEB_FLOOR) {
|
|
|
245
255
|
floor.role
|
|
246
256
|
);
|
|
247
257
|
}
|
|
258
|
+
for (const tone of ["added", "removed"]) {
|
|
259
|
+
check(`diff row: text.primary on deltaGround.${tone}`, def.text.primary, def.deltaGround[tone], floor.role);
|
|
260
|
+
check(`diff sign: delta.${tone} on deltaGround.${tone}`, def.delta[tone], def.deltaGround[tone], floor.role);
|
|
261
|
+
}
|
|
262
|
+
check("diff hunk: text.secondary on deltaGround.hunk", def.text.secondary, def.deltaGround.hunk, floor.role);
|
|
248
263
|
check("select.option: text.primary on surface.raised", def.text.primary, def.surface.raised, floor.role);
|
|
249
264
|
check("select.option disabled: text.muted on surface.raised", def.text.muted, def.surface.raised, floor.role);
|
|
250
265
|
check("select.placeholder: text.muted on surface.base", def.text.muted, def.surface.base, floor.role);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/theme/contrast.ts"],"sourcesContent":["/**\n * Contrast arithmetic over the ladder.\n *\n * Every colour in `levels.ts` is a literal, so contrast can be computed as data\n * — no browser, no screenshot, no rendering. `pnpm check:contrast` walks every\n * level and fails CI on a violation, which is the thing that makes the ladder\n * maintainable: every level times every role pair is a matrix nobody eyeballs\n * reliably twice.\n *\n * The gate is WCAG 2.1 relative luminance. APCA is the better predictor of\n * perceived contrast, but it is not yet normative and its thresholds are not\n * stable; WCAG ratios are what an audit will be run against. So APCA is\n * computed alongside and reported, never gated. It is reported because WCAG 2\n * overrates light text on a dark ground: midnight's `text.muted` passed at\n * 5.90:1 while scoring Lc -41, the weakest text pair in the system (#372).\n */\n\nimport type { Emphasis, Hue, HueRef, Intent, TextTone } from '../lib/theme';\nimport type { LevelDefinition, ThemeLevel } from './levels';\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n /** 0–1. Colours without an alpha channel parse as 1. */\n a: number;\n}\n\nconst HEX = /^#([0-9a-f]{3,8})$/i;\nconst RGB_FN = /^rgba?\\(\\s*([0-9.]+)[\\s,]+([0-9.]+)[\\s,]+([0-9.]+)(?:[\\s,/]+([0-9.]+))?\\s*\\)$/i;\n\n/** Parse `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()` and `rgba()`. */\nexport function parseColor(value: string): Rgb {\n const input = value.trim();\n\n const hex = HEX.exec(input);\n if (hex) {\n const digits = hex[1]!;\n const expand = (s: string) => Number.parseInt(s.length === 1 ? s + s : s, 16);\n if (digits.length === 3 || digits.length === 4) {\n return {\n r: expand(digits[0]!),\n g: expand(digits[1]!),\n b: expand(digits[2]!),\n a: digits.length === 4 ? expand(digits[3]!) / 255 : 1,\n };\n }\n if (digits.length === 6 || digits.length === 8) {\n return {\n r: expand(digits.slice(0, 2)),\n g: expand(digits.slice(2, 4)),\n b: expand(digits.slice(4, 6)),\n a: digits.length === 8 ? expand(digits.slice(6, 8)) / 255 : 1,\n };\n }\n }\n\n const fn = RGB_FN.exec(input);\n if (fn) {\n return {\n r: Number(fn[1]),\n g: Number(fn[2]),\n b: Number(fn[3]),\n a: fn[4] === undefined ? 1 : Number(fn[4]),\n };\n }\n\n throw new Error(`Unparseable colour: ${value}`);\n}\n\n/**\n * Flatten a possibly-translucent colour onto an opaque backdrop.\n *\n * Contrast is a property of what the eye receives, so a token with alpha has to\n * be composited before it can be measured. Without this step a scrim at 70%\n * would score against its own nominal colour and pass regardless of the surface\n * it actually sits on.\n */\nexport function composite(foreground: Rgb, backdrop: Rgb): Rgb {\n if (foreground.a >= 1) return foreground;\n const a = foreground.a;\n return {\n r: foreground.r * a + backdrop.r * (1 - a),\n g: foreground.g * a + backdrop.g * (1 - a),\n b: foreground.b * a + backdrop.b * (1 - a),\n a: 1,\n };\n}\n\n/** WCAG 2.1 relative luminance. */\nexport function relativeLuminance(color: Rgb): number {\n const channel = (value: number) => {\n const c = value / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(color.r) + 0.7152 * channel(color.g) + 0.0722 * channel(color.b);\n}\n\n/**\n * WCAG contrast ratio between two colours, 1–21.\n *\n * The foreground is composited onto the background first, so translucent\n * tokens are measured as they render.\n */\nexport function contrastRatio(foreground: string, background: string): number {\n const bg = parseColor(background);\n const fg = composite(parseColor(foreground), bg);\n const lighter = Math.max(relativeLuminance(fg), relativeLuminance(bg));\n const darker = Math.min(relativeLuminance(fg), relativeLuminance(bg));\n return (lighter + 0.05) / (darker + 0.05);\n}\n\n/**\n * APCA lightness contrast (Lc), per APCA-W3 0.0.98G — roughly -108 to 106.\n *\n * Signed by polarity: positive is dark text on a light ground, negative is\n * light on dark, and the magnitude is what compares across the two. Unlike a\n * WCAG ratio it is not symmetric, which is the point: the same pair of colours\n * reads differently depending on which one is the text.\n *\n * Constants are the published 0.0.98G set; the luminance is APCA's own simple\n * 2.4 power curve, not WCAG's piecewise one. Reported, not gated — see the\n * module comment.\n */\nexport function apcaContrast(foreground: string, background: string): number {\n const bg = parseColor(background);\n const fg = composite(parseColor(foreground), bg);\n const y = (c: Rgb) =>\n 0.2126729 * (c.r / 255) ** 2.4 + 0.7151522 * (c.g / 255) ** 2.4 + 0.072175 * (c.b / 255) ** 2.4;\n const clamp = (lum: number) => (lum > 0.022 ? lum : lum + (0.022 - lum) ** 1.414);\n const text = clamp(y(fg));\n const ground = clamp(y(bg));\n if (Math.abs(ground - text) < 0.0005) return 0;\n if (ground > text) {\n const sapc = (ground ** 0.56 - text ** 0.57) * 1.14;\n return sapc < 0.1 ? 0 : (sapc - 0.027) * 100;\n }\n const sapc = (ground ** 0.65 - text ** 0.62) * 1.14;\n return sapc > -0.1 ? 0 : (sapc + 0.027) * 100;\n}\n\n/**\n * The bar each role has to clear, and why it differs.\n *\n * `text` and the accents clear WCAG AA for body copy, because they are read.\n * `borderStrong` and `borderDefault` clear the 3:1 non-text bar of WCAG 1.4.11,\n * because they are the load-bearing edges this system draws components with.\n * `borderSubtle` is a decorative divider — 1.4.11 does not cover it, so the bar\n * is only that it must be *visible* rather than accessible as a control.\n * Setting it to AA would force every hairline in the system to read as a rule.\n */\n/**\n * The Hue vocabulary, in wheel order. Declared here rather than imported so the\n * gate stays runnable by `scripts/check-contrast.mjs` without a `.ts` import\n * extension — and `satisfies` still makes a missing or misspelled Hue a\n * compile error, which is the property that matters.\n */\n/**\n * Above this, a colour declared `'neutral'` is not one. `accent.quiet` measures\n * 0.036 on `midnight` and 0.027 on `sketch` — both warm or cool greys with a\n * deliberate tint, which is why the bar is not zero.\n */\nexport const MAXIMUM_NEUTRAL_CHROMA = 0.045;\n\nexport interface HueAgreementCheck {\n readonly level: ThemeLevel;\n readonly role: string;\n readonly declared: HueRef;\n readonly value: string;\n /** The Hue's value, or null when the Role is declared `'neutral'`. */\n readonly expected: string | null;\n readonly passes: boolean;\n readonly detail: string;\n}\n\n/** OKLab chroma. Only used to prove a `'neutral'` really is one. */\nfunction oklabChroma(hex: string): number {\n const decode = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\n const [r, g, b] = [1, 3, 5].map((i) => decode(Number.parseInt(hex.slice(i, i + 2), 16) / 255));\n const l = Math.cbrt(0.4122214708 * r! + 0.5363325363 * g! + 0.0514459929 * b!);\n const m = Math.cbrt(0.2119034982 * r! + 0.6806995451 * g! + 0.1073969566 * b!);\n const s = Math.cbrt(0.0883024619 * r! + 0.2817188376 * g! + 0.6299787005 * b!);\n const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;\n const bb = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;\n return Math.hypot(a, bb);\n}\n\nconst PALETTE_HUES_ORDER = [\n 'red',\n 'orange',\n 'yellow',\n 'green',\n 'teal',\n 'cyan',\n 'blue',\n 'violet',\n 'magenta',\n 'pink',\n] as const satisfies readonly Hue[];\n\nexport const MINIMUM_RATIO = {\n text: 4.5,\n /** `text.inverse` sits on an accent fill, not on a surface. */\n textInverse: 4.5,\n accent: 4.5,\n intent: 4.5,\n /**\n * A Hue, above WCAG AA deliberately. An editor draws selection, current-line,\n * find-match and diff backgrounds *behind* the same tokens, so a palette\n * solved to exactly 4.5:1 has no room left to tint the ground. At 4.5 the\n * light palette has one sRGB step of headroom; at 5.5 it has twenty-two.\n * See `docs/palette-provenance.md` and #78.\n */\n palette: 5.5,\n /**\n * These numbers are the **web** Medium's, and that indexing is the point.\n *\n * ADR 0004 names this the asymmetry most likely to be got wrong later:\n * *colour values do not vary by Medium, but the floors they must clear do.* A\n * projected 1080p frame, a compression-damaged video and an unantialiased\n * terminal cell are not the browser's legibility problem, and until now this\n * was one set of numbers for every surface the system emits to.\n *\n * `MEDIA_DEFINITIONS[medium].contrastFloor` carries the per-Medium values;\n * `auditContrast` takes a Medium and reads them. The constants here remain as\n * the web Medium's, so nothing moves on merge and a caller that does not care\n * about Media keeps working.\n */\n /** `bright` Hues carry emphasis, not body text, so AA is the right bar. */\n paletteBright: 4.5,\n borderStrong: 3,\n borderDefault: 3,\n borderSubtle: 1.4,\n /**\n * A modal's dialog against the scrimmed page behind it. Not an accessibility\n * threshold — an assertion that the scrim does the one job it exists for.\n */\n overlaySeparation: 3,\n /**\n * A selection device — the accent `fill` behind a chosen tab, or the 4px\n * accent `edge` beside it — against the surface it sits on. WCAG 1.4.11's\n * non-text bar: the device is a UI component boundary, not text.\n */\n stateDevice: 3,\n} as const;\n\nexport interface ContrastCheck {\n level: ThemeLevel;\n /** e.g. `text.muted on surface.raised`. */\n pair: string;\n foreground: string;\n background: string;\n ratio: number;\n /** APCA Lc for the same pair, reported alongside the ratio and never gated. Null where the pair is a separation rather than a foreground on a ground. */\n apca: number | null;\n minimum: number;\n passes: boolean;\n}\n\n/**\n * Every pair worth asserting, for every level.\n *\n * Text, accents and intents are checked against `base`, `raised` *and*\n * `sunken`, because a component is free to sit on any of the three and a token\n * that only works on the page ground is a bug waiting for the first card.\n *\n * The ladder is passed in rather than imported so this module is pure colour\n * arithmetic over data — it can audit a consumer's own overrides, and it stays\n * runnable from a plain Node script with no bundler in the path.\n */\n/**\n * Does every Role actually hold the value of the Hue it says it is?\n *\n * `check:contrast` cannot answer this, and that is not an oversight in it — a\n * Role and a Hue are both foregrounds, both clear their own floors, and a\n * mismatch between them is not a contrast fault. It is a *drift* fault, and it\n * is the one ADR 0001 rejects its third option over:\n *\n * > the two sets then drift silently, and there is no arithmetic that can\n * > catch a `palette.cyan` that no longer matches the `accent.primary` it is\n * > supposed to be.\n *\n * This is that arithmetic. It exists because the repo shipped the fault: after\n * `palette` landed, `midnight`'s `accent.tertiary` sat at `#ec4899` (5.12:1,\n * clearing the 4.5 Role floor) while `palette.pink` sat at `#f955a4` (5.90:1,\n * clearing the 5.5 Hue floor). Both gates passed. The two values are 0.036\n * apart in OKLab — indistinguishable, so no screenshot would have caught it\n * either.\n *\n * A Role declared `'neutral'` is asserted to *be* neutral rather than skipped,\n * because \"declared as not-a-hue\" and \"quietly wrong\" must not look the same.\n */\nexport function auditHueAgreement(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): HueAgreementCheck[] {\n const results: HueAgreementCheck[] = [];\n\n for (const level of Object.keys(ladder) as ThemeLevel[]) {\n const def = ladder[level];\n\n const check = (role: string, value: string, ref: HueRef) => {\n if (ref === 'neutral') {\n const chroma = oklabChroma(value);\n results.push({\n level,\n role,\n declared: ref,\n value,\n expected: null,\n passes: chroma <= MAXIMUM_NEUTRAL_CHROMA,\n detail: `chroma ${chroma.toFixed(3)} (max ${MAXIMUM_NEUTRAL_CHROMA})`,\n });\n return;\n }\n const expected = def.palette[ref];\n results.push({\n level,\n role,\n declared: ref,\n value,\n expected,\n passes: value.toLowerCase() === expected.toLowerCase(),\n detail: `palette.${ref} is ${expected}`,\n });\n };\n\n for (const [role, ref] of Object.entries(def.accentHue)) {\n check(`accent.${role}`, def.accent[role as Emphasis], ref);\n }\n for (const [role, ref] of Object.entries(def.intentHue)) {\n check(`intent.${role}`, def.intent[role as Intent], ref);\n }\n }\n\n return results;\n}\n\n/** The three floors a Medium supplies. See `MediumDefinition.contrastFloor`. */\nexport interface ContrastFloor {\n readonly role: number;\n readonly hue: number;\n readonly hueBright: number;\n}\n\n/** The web Medium's floors, restated so the default call is unchanged. */\nexport const WEB_FLOOR: ContrastFloor = {\n role: MINIMUM_RATIO.text,\n hue: MINIMUM_RATIO.palette,\n hueBright: MINIMUM_RATIO.paletteBright,\n};\n\nexport function auditContrast(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n /**\n * The Medium's floors. Passed in rather than read from `media.ts`, because\n * this module has to stay importable by `scripts/check-contrast.mjs`, and a\n * runtime import there needs a `.ts` extension that `tsc` rejects. The script\n * owns the Medium; this module owns the arithmetic.\n */\n floor: ContrastFloor = WEB_FLOOR,\n): ContrastCheck[] {\n const results: ContrastCheck[] = [];\n\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n const grounds = [\n ['surface.base', def.surface.base],\n ['surface.raised', def.surface.raised],\n ['surface.sunken', def.surface.sunken],\n ] as const;\n\n const check = (pair: string, foreground: string, background: string, minimum: number) => {\n const ratio = contrastRatio(foreground, background);\n results.push({\n level,\n pair,\n foreground,\n background,\n ratio,\n apca: apcaContrast(foreground, background),\n minimum,\n passes: ratio >= minimum,\n });\n };\n\n for (const [groundName, ground] of grounds) {\n for (const tone of ['primary', 'secondary', 'muted'] as const satisfies readonly TextTone[]) {\n check(`text.${tone} on ${groundName}`, def.text[tone], ground, floor.role);\n }\n for (const tone of ['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]) {\n check(`accent.${tone} on ${groundName}`, def.accent[tone], ground, floor.role);\n }\n for (const tone of ['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]) {\n check(`intent.${tone} on ${groundName}`, def.intent[tone], ground, floor.role);\n }\n // ADR 0001: gate `palette` once per Hue rather than once per Role that\n // consumes it. Separate the palette, not each of its consumers.\n for (const hue of PALETTE_HUES_ORDER) {\n check(`palette.${hue} on ${groundName}`, def.palette[hue], ground, floor.hue);\n check(\n `palette.bright.${hue} on ${groundName}`,\n def.paletteBright[hue],\n ground,\n floor.hueBright,\n );\n }\n check(`border.strong on ${groundName}`, def.border.strong, ground, MINIMUM_RATIO.borderStrong);\n check(`border.default on ${groundName}`, def.border.default, ground, MINIMUM_RATIO.borderDefault);\n check(`border.subtle on ${groundName}`, def.border.subtle, ground, MINIMUM_RATIO.borderSubtle);\n }\n\n // `text.inverse` is what a filled accent button prints in, so it is measured\n // against the accents rather than against a surface.\n // `quiet` is in this list because `Tag` ships `bg-accent-quiet\n // text-content-inverse`. It was omitted while the other three were checked,\n // so a palette edit to `quiet` would have gone unmeasured — a coverage gap\n // rather than a live defect, but the README claims every pair is audited.\n for (const tone of ['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]) {\n check(\n `text.inverse on accent.${tone}`,\n def.text.inverse,\n def.accent[tone],\n floor.role,\n );\n }\n for (const tone of ['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]) {\n check(\n `text.inverse on intent.${tone}`,\n def.text.inverse,\n def.intent[tone],\n floor.role,\n );\n }\n // `Select`'s open list (#164), named for the component because it used to\n // be the one surface the palette did not reach: the operating system\n // painted it. The rows are `text.primary` on `surface.raised`; a disabled\n // row is `text.muted`; the highlighted row is `text.inverse` on the field's\n // accent fill, and the chosen row's mark is that accent on the list. The\n // accent is whichever the caller passes, so every Emphasis and Intent is\n // measured rather than only the default. The values repeat pairs above —\n // the point is that removing one of those cannot silently un-gate the list.\n check('select.option: text.primary on surface.raised', def.text.primary, def.surface.raised, floor.role);\n check('select.option disabled: text.muted on surface.raised', def.text.muted, def.surface.raised, floor.role);\n check('select.placeholder: text.muted on surface.base', def.text.muted, def.surface.base, floor.role);\n const listAccents = [\n ...(['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]).map(\n (tone) => [`accent.${tone}`, def.accent[tone]] as const,\n ),\n ...(['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]).map(\n (tone) => [`intent.${tone}`, def.intent[tone]] as const,\n ),\n ];\n for (const [name, fill] of listAccents) {\n check(`select.option highlighted: text.inverse on ${name}`, def.text.inverse, fill, floor.role);\n check(`select.option selected mark: ${name} on surface.raised`, fill, def.surface.raised, floor.role);\n }\n\n // A scrim's job is to separate the dialog from the page behind it. Nothing\n // renders text on the scrim, so the assertion is about separation — and it\n // can be satisfied by either edge of the dialog, because this system draws\n // components with a load-bearing 2px border as often as with a fill. On a\n // dark level the fill barely differs from the scrim and the white border\n // does the work; on a light level the white fill does it and the dark\n // border is the one that disappears. Requiring both would fail every level.\n const scrimOverBase = composite(\n parseColor(def.surface.overlay),\n parseColor(def.surface.base),\n );\n const scrim = `rgb(${Math.round(scrimOverBase.r)}, ${Math.round(scrimOverBase.g)}, ${Math.round(scrimOverBase.b)})`;\n const separation = Math.max(\n contrastRatio(def.surface.raised, scrim),\n contrastRatio(def.border.strong, scrim),\n );\n results.push({\n level,\n pair: 'dialog (fill or border) against scrimmed page',\n foreground: `${def.surface.raised} / ${def.border.strong}`,\n background: scrim,\n ratio: separation,\n apca: null,\n minimum: MINIMUM_RATIO.overlaySeparation,\n passes: separation >= MINIMUM_RATIO.overlaySeparation,\n });\n }\n\n return results;\n}\n\n/**\n * How far apart the text tones sit, in APCA Lc, on each ground.\n *\n * Reported, not gated. It is the other half of tuning `text.muted`: darkening it\n * for legibility is free until it lands so close to `text.secondary` that the\n * two stop reading as two tones. #372 measured `#4f4a3d` on sketch at 7 Lc from\n * secondary, which is why `#5c5546` was chosen instead.\n */\nexport interface TextHierarchyStep {\n level: ThemeLevel;\n ground: string;\n /** Lc magnitude of primary, secondary and muted on this ground. */\n lc: Readonly<Record<'primary' | 'secondary' | 'muted', number>>;\n /** secondary minus muted, in Lc magnitude. */\n mutedStep: number;\n}\n\nexport function auditTextHierarchy(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): TextHierarchyStep[] {\n const steps: TextHierarchyStep[] = [];\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n for (const ground of ['base', 'raised', 'sunken'] as const) {\n const lc = (tone: 'primary' | 'secondary' | 'muted') =>\n Math.abs(apcaContrast(def.text[tone], def.surface[ground]));\n const tones = { primary: lc('primary'), secondary: lc('secondary'), muted: lc('muted') };\n steps.push({ level, ground: `surface.${ground}`, lc: tones, mutedStep: tones.secondary - tones.muted });\n }\n }\n return steps;\n}\n\n/** How a component may mark a selected item. */\nexport type SelectionDevice = 'fill' | 'edge' | 'surface pair';\n\nexport interface SelectionDeviceCheck {\n level: ThemeLevel;\n device: SelectionDevice;\n /** e.g. `accent.primary on surface.raised`. */\n pair: string;\n foreground: string;\n background: string;\n ratio: number;\n minimum: number;\n /** For `fill` and `edge`: the device is usable. For `surface pair`: it would be, and that is the trap. */\n passes: boolean;\n}\n\n/**\n * The state rule, as arithmetic.\n *\n * Selected state is carried by an accent **fill** or an accent **edge**, never\n * by swapping one surface for another. The reason is not taste: the surfaces\n * exist to *layer* — a strip behind its tabs, a panel over a page — so they\n * are deliberately close in lightness, and on the light rungs they are a few\n * percent apart. A widget that marks its chosen tab `surface.base` among\n * `surface.raised` siblings reads acceptably on `midnight` and is invisible on\n * `bright`. That is how the bug ships: it passes review on the dark rung the\n * reviewer happens to be on.\n *\n * So this audits both halves. The fill and edge devices — the accent against\n * every surface a tab can sit on — must clear the non-text bar on every level,\n * which is what makes the rule safe to follow. The surface pairs are measured\n * too, and reported, so the number that makes them unusable is in the gate's\n * output rather than in someone's memory. They are not expected to pass; a\n * level on which they *did* would be the one where a surface-pair widget\n * slips through.\n */\nexport function auditSelectionDevices(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): SelectionDeviceCheck[] {\n const results: SelectionDeviceCheck[] = [];\n\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n const grounds = [\n ['surface.base', def.surface.base],\n ['surface.raised', def.surface.raised],\n ] as const;\n\n const check = (\n device: SelectionDevice,\n pair: string,\n foreground: string,\n background: string,\n ) => {\n const ratio = contrastRatio(foreground, background);\n results.push({\n level,\n device,\n pair,\n foreground,\n background,\n ratio,\n minimum: MINIMUM_RATIO.stateDevice,\n passes: ratio >= MINIMUM_RATIO.stateDevice,\n });\n };\n\n for (const [groundName, ground] of grounds) {\n // `quiet` is the de-emphasised step, not a fifth colour — a tab it\n // marks is meant to recede, so it is not a selection device.\n for (const tone of ['primary', 'secondary', 'tertiary'] as const satisfies readonly Emphasis[]) {\n check('fill', `accent.${tone} fill on ${groundName}`, def.accent[tone], ground);\n check('edge', `accent.${tone} edge on ${groundName}`, def.accent[tone], ground);\n }\n }\n\n check('surface pair', 'surface.raised against surface.base', def.surface.raised, def.surface.base);\n check('surface pair', 'surface.sunken against surface.base', def.surface.sunken, def.surface.base);\n check('surface pair', 'surface.sunken against surface.raised', def.surface.sunken, def.surface.raised);\n }\n\n return results;\n}\n"],"mappings":";AA4BA,IAAM,MAAM;AACZ,IAAM,SAAS;AAGR,SAAS,WAAW,OAAoB;AAC7C,QAAM,QAAQ,MAAM,KAAK;AAEzB,QAAM,MAAM,IAAI,KAAK,KAAK;AAC1B,MAAI,KAAK;AACP,UAAM,SAAS,IAAI,CAAC;AACpB,UAAM,SAAS,CAAC,MAAc,OAAO,SAAS,EAAE,WAAW,IAAI,IAAI,IAAI,GAAG,EAAE;AAC5E,QAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GAAG;AAC9C,aAAO;AAAA,QACL,GAAG,OAAO,OAAO,CAAC,CAAE;AAAA,QACpB,GAAG,OAAO,OAAO,CAAC,CAAE;AAAA,QACpB,GAAG,OAAO,OAAO,CAAC,CAAE;AAAA,QACpB,GAAG,OAAO,WAAW,IAAI,OAAO,OAAO,CAAC,CAAE,IAAI,MAAM;AAAA,MACtD;AAAA,IACF;AACA,QAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GAAG;AAC9C,aAAO;AAAA,QACL,GAAG,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AAAA,QAC5B,GAAG,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AAAA,QAC5B,GAAG,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AAAA,QAC5B,GAAG,OAAO,WAAW,IAAI,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AAEA,QAAM,KAAK,OAAO,KAAK,KAAK;AAC5B,MAAI,IAAI;AACN,WAAO;AAAA,MACL,GAAG,OAAO,GAAG,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AI,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AACjG,UAAM,gBAAgB,yCAAyC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,MAAM;AAAA,EACvG;AAEA,SAAO;AACT;","names":["sapc"]}
|
|
1
|
+
{"version":3,"sources":["../../src/theme/contrast.ts"],"sourcesContent":["/**\n * Contrast arithmetic over the ladder.\n *\n * Every colour in `levels.ts` is a literal, so contrast can be computed as data\n * — no browser, no screenshot, no rendering. `pnpm check:contrast` walks every\n * level and fails CI on a violation, which is the thing that makes the ladder\n * maintainable: every level times every role pair is a matrix nobody eyeballs\n * reliably twice.\n *\n * The gate is WCAG 2.1 relative luminance. APCA is the better predictor of\n * perceived contrast, but it is not yet normative and its thresholds are not\n * stable; WCAG ratios are what an audit will be run against. So APCA is\n * computed alongside and reported, never gated. It is reported because WCAG 2\n * overrates light text on a dark ground: midnight's `text.muted` passed at\n * 5.90:1 while scoring Lc -41, the weakest text pair in the system (#372).\n */\n\nimport type { Delta, DeltaGround, Emphasis, Hue, HueRef, Intent, TextTone } from '../lib/theme';\nimport type { LevelDefinition, ThemeLevel } from './levels';\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n /** 0–1. Colours without an alpha channel parse as 1. */\n a: number;\n}\n\nconst HEX = /^#([0-9a-f]{3,8})$/i;\nconst RGB_FN = /^rgba?\\(\\s*([0-9.]+)[\\s,]+([0-9.]+)[\\s,]+([0-9.]+)(?:[\\s,/]+([0-9.]+))?\\s*\\)$/i;\n\n/** Parse `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()` and `rgba()`. */\nexport function parseColor(value: string): Rgb {\n const input = value.trim();\n\n const hex = HEX.exec(input);\n if (hex) {\n const digits = hex[1]!;\n const expand = (s: string) => Number.parseInt(s.length === 1 ? s + s : s, 16);\n if (digits.length === 3 || digits.length === 4) {\n return {\n r: expand(digits[0]!),\n g: expand(digits[1]!),\n b: expand(digits[2]!),\n a: digits.length === 4 ? expand(digits[3]!) / 255 : 1,\n };\n }\n if (digits.length === 6 || digits.length === 8) {\n return {\n r: expand(digits.slice(0, 2)),\n g: expand(digits.slice(2, 4)),\n b: expand(digits.slice(4, 6)),\n a: digits.length === 8 ? expand(digits.slice(6, 8)) / 255 : 1,\n };\n }\n }\n\n const fn = RGB_FN.exec(input);\n if (fn) {\n return {\n r: Number(fn[1]),\n g: Number(fn[2]),\n b: Number(fn[3]),\n a: fn[4] === undefined ? 1 : Number(fn[4]),\n };\n }\n\n throw new Error(`Unparseable colour: ${value}`);\n}\n\n/**\n * Flatten a possibly-translucent colour onto an opaque backdrop.\n *\n * Contrast is a property of what the eye receives, so a token with alpha has to\n * be composited before it can be measured. Without this step a scrim at 70%\n * would score against its own nominal colour and pass regardless of the surface\n * it actually sits on.\n */\nexport function composite(foreground: Rgb, backdrop: Rgb): Rgb {\n if (foreground.a >= 1) return foreground;\n const a = foreground.a;\n return {\n r: foreground.r * a + backdrop.r * (1 - a),\n g: foreground.g * a + backdrop.g * (1 - a),\n b: foreground.b * a + backdrop.b * (1 - a),\n a: 1,\n };\n}\n\n/** WCAG 2.1 relative luminance. */\nexport function relativeLuminance(color: Rgb): number {\n const channel = (value: number) => {\n const c = value / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(color.r) + 0.7152 * channel(color.g) + 0.0722 * channel(color.b);\n}\n\n/**\n * WCAG contrast ratio between two colours, 1–21.\n *\n * The foreground is composited onto the background first, so translucent\n * tokens are measured as they render.\n */\nexport function contrastRatio(foreground: string, background: string): number {\n const bg = parseColor(background);\n const fg = composite(parseColor(foreground), bg);\n const lighter = Math.max(relativeLuminance(fg), relativeLuminance(bg));\n const darker = Math.min(relativeLuminance(fg), relativeLuminance(bg));\n return (lighter + 0.05) / (darker + 0.05);\n}\n\n/**\n * APCA lightness contrast (Lc), per APCA-W3 0.0.98G — roughly -108 to 106.\n *\n * Signed by polarity: positive is dark text on a light ground, negative is\n * light on dark, and the magnitude is what compares across the two. Unlike a\n * WCAG ratio it is not symmetric, which is the point: the same pair of colours\n * reads differently depending on which one is the text.\n *\n * Constants are the published 0.0.98G set; the luminance is APCA's own simple\n * 2.4 power curve, not WCAG's piecewise one. Reported, not gated — see the\n * module comment.\n */\nexport function apcaContrast(foreground: string, background: string): number {\n const bg = parseColor(background);\n const fg = composite(parseColor(foreground), bg);\n const y = (c: Rgb) =>\n 0.2126729 * (c.r / 255) ** 2.4 + 0.7151522 * (c.g / 255) ** 2.4 + 0.072175 * (c.b / 255) ** 2.4;\n const clamp = (lum: number) => (lum > 0.022 ? lum : lum + (0.022 - lum) ** 1.414);\n const text = clamp(y(fg));\n const ground = clamp(y(bg));\n if (Math.abs(ground - text) < 0.0005) return 0;\n if (ground > text) {\n const sapc = (ground ** 0.56 - text ** 0.57) * 1.14;\n return sapc < 0.1 ? 0 : (sapc - 0.027) * 100;\n }\n const sapc = (ground ** 0.65 - text ** 0.62) * 1.14;\n return sapc > -0.1 ? 0 : (sapc + 0.027) * 100;\n}\n\n/**\n * The bar each role has to clear, and why it differs.\n *\n * `text` and the accents clear WCAG AA for body copy, because they are read.\n * `borderStrong` and `borderDefault` clear the 3:1 non-text bar of WCAG 1.4.11,\n * because they are the load-bearing edges this system draws components with.\n * `borderSubtle` is a decorative divider — 1.4.11 does not cover it, so the bar\n * is only that it must be *visible* rather than accessible as a control.\n * Setting it to AA would force every hairline in the system to read as a rule.\n */\n/**\n * The Hue vocabulary, in wheel order. Declared here rather than imported so the\n * gate stays runnable by `scripts/check-contrast.mjs` without a `.ts` import\n * extension — and `satisfies` still makes a missing or misspelled Hue a\n * compile error, which is the property that matters.\n */\n/**\n * Above this, a colour declared `'neutral'` is not one. `accent.quiet` measures\n * 0.036 on `midnight` and 0.027 on `sketch` — both warm or cool greys with a\n * deliberate tint, which is why the bar is not zero.\n */\nexport const MAXIMUM_NEUTRAL_CHROMA = 0.045;\n\nexport interface HueAgreementCheck {\n readonly level: ThemeLevel;\n readonly role: string;\n readonly declared: HueRef;\n readonly value: string;\n /** The Hue's value, or null when the Role is declared `'neutral'`. */\n readonly expected: string | null;\n readonly passes: boolean;\n readonly detail: string;\n}\n\n/** OKLab chroma. Only used to prove a `'neutral'` really is one. */\nfunction oklabChroma(hex: string): number {\n const decode = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\n const [r, g, b] = [1, 3, 5].map((i) => decode(Number.parseInt(hex.slice(i, i + 2), 16) / 255));\n const l = Math.cbrt(0.4122214708 * r! + 0.5363325363 * g! + 0.0514459929 * b!);\n const m = Math.cbrt(0.2119034982 * r! + 0.6806995451 * g! + 0.1073969566 * b!);\n const s = Math.cbrt(0.0883024619 * r! + 0.2817188376 * g! + 0.6299787005 * b!);\n const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;\n const bb = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;\n return Math.hypot(a, bb);\n}\n\nconst PALETTE_HUES_ORDER = [\n 'red',\n 'orange',\n 'yellow',\n 'green',\n 'teal',\n 'cyan',\n 'blue',\n 'violet',\n 'magenta',\n 'pink',\n] as const satisfies readonly Hue[];\n\nexport const MINIMUM_RATIO = {\n text: 4.5,\n /** `text.inverse` sits on an accent fill, not on a surface. */\n textInverse: 4.5,\n accent: 4.5,\n intent: 4.5,\n /**\n * A Hue, above WCAG AA deliberately. An editor draws selection, current-line,\n * find-match and diff backgrounds *behind* the same tokens, so a palette\n * solved to exactly 4.5:1 has no room left to tint the ground. At 4.5 the\n * light palette has one sRGB step of headroom; at 5.5 it has twenty-two.\n * See `docs/palette-provenance.md` and #78.\n */\n palette: 5.5,\n /**\n * These numbers are the **web** Medium's, and that indexing is the point.\n *\n * ADR 0004 names this the asymmetry most likely to be got wrong later:\n * *colour values do not vary by Medium, but the floors they must clear do.* A\n * projected 1080p frame, a compression-damaged video and an unantialiased\n * terminal cell are not the browser's legibility problem, and until now this\n * was one set of numbers for every surface the system emits to.\n *\n * `MEDIA_DEFINITIONS[medium].contrastFloor` carries the per-Medium values;\n * `auditContrast` takes a Medium and reads them. The constants here remain as\n * the web Medium's, so nothing moves on merge and a caller that does not care\n * about Media keeps working.\n */\n /** `bright` Hues carry emphasis, not body text, so AA is the right bar. */\n paletteBright: 4.5,\n borderStrong: 3,\n borderDefault: 3,\n borderSubtle: 1.4,\n /**\n * A modal's dialog against the scrimmed page behind it. Not an accessibility\n * threshold — an assertion that the scrim does the one job it exists for.\n */\n overlaySeparation: 3,\n /**\n * A selection device — the accent `fill` behind a chosen tab, or the 4px\n * accent `edge` beside it — against the surface it sits on. WCAG 1.4.11's\n * non-text bar: the device is a UI component boundary, not text.\n */\n stateDevice: 3,\n} as const;\n\nexport interface ContrastCheck {\n level: ThemeLevel;\n /** e.g. `text.muted on surface.raised`. */\n pair: string;\n foreground: string;\n background: string;\n ratio: number;\n /** APCA Lc for the same pair, reported alongside the ratio and never gated. Null where the pair is a separation rather than a foreground on a ground. */\n apca: number | null;\n minimum: number;\n passes: boolean;\n}\n\n/**\n * Every pair worth asserting, for every level.\n *\n * Text, accents and intents are checked against `base`, `raised` *and*\n * `sunken`, because a component is free to sit on any of the three and a token\n * that only works on the page ground is a bug waiting for the first card.\n *\n * The ladder is passed in rather than imported so this module is pure colour\n * arithmetic over data — it can audit a consumer's own overrides, and it stays\n * runnable from a plain Node script with no bundler in the path.\n */\n/**\n * Does every Role actually hold the value of the Hue it says it is?\n *\n * `check:contrast` cannot answer this, and that is not an oversight in it — a\n * Role and a Hue are both foregrounds, both clear their own floors, and a\n * mismatch between them is not a contrast fault. It is a *drift* fault, and it\n * is the one ADR 0001 rejects its third option over:\n *\n * > the two sets then drift silently, and there is no arithmetic that can\n * > catch a `palette.cyan` that no longer matches the `accent.primary` it is\n * > supposed to be.\n *\n * This is that arithmetic. It exists because the repo shipped the fault: after\n * `palette` landed, `midnight`'s `accent.tertiary` sat at `#ec4899` (5.12:1,\n * clearing the 4.5 Role floor) while `palette.pink` sat at `#f955a4` (5.90:1,\n * clearing the 5.5 Hue floor). Both gates passed. The two values are 0.036\n * apart in OKLab — indistinguishable, so no screenshot would have caught it\n * either.\n *\n * A Role declared `'neutral'` is asserted to *be* neutral rather than skipped,\n * because \"declared as not-a-hue\" and \"quietly wrong\" must not look the same.\n */\nexport function auditHueAgreement(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): HueAgreementCheck[] {\n const results: HueAgreementCheck[] = [];\n\n for (const level of Object.keys(ladder) as ThemeLevel[]) {\n const def = ladder[level];\n\n const check = (role: string, value: string, ref: HueRef) => {\n if (ref === 'neutral') {\n const chroma = oklabChroma(value);\n results.push({\n level,\n role,\n declared: ref,\n value,\n expected: null,\n passes: chroma <= MAXIMUM_NEUTRAL_CHROMA,\n detail: `chroma ${chroma.toFixed(3)} (max ${MAXIMUM_NEUTRAL_CHROMA})`,\n });\n return;\n }\n const expected = def.palette[ref];\n results.push({\n level,\n role,\n declared: ref,\n value,\n expected,\n passes: value.toLowerCase() === expected.toLowerCase(),\n detail: `palette.${ref} is ${expected}`,\n });\n };\n\n for (const [role, ref] of Object.entries(def.accentHue)) {\n check(`accent.${role}`, def.accent[role as Emphasis], ref);\n }\n for (const [role, ref] of Object.entries(def.intentHue)) {\n check(`intent.${role}`, def.intent[role as Intent], ref);\n }\n for (const [role, ref] of Object.entries(def.deltaHue)) {\n check(`delta.${role}`, def.delta[role as Delta], ref);\n }\n }\n\n return results;\n}\n\n/** The three floors a Medium supplies. See `MediumDefinition.contrastFloor`. */\nexport interface ContrastFloor {\n readonly role: number;\n readonly hue: number;\n readonly hueBright: number;\n}\n\n/** The web Medium's floors, restated so the default call is unchanged. */\nexport const WEB_FLOOR: ContrastFloor = {\n role: MINIMUM_RATIO.text,\n hue: MINIMUM_RATIO.palette,\n hueBright: MINIMUM_RATIO.paletteBright,\n};\n\nexport function auditContrast(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n /**\n * The Medium's floors. Passed in rather than read from `media.ts`, because\n * this module has to stay importable by `scripts/check-contrast.mjs`, and a\n * runtime import there needs a `.ts` extension that `tsc` rejects. The script\n * owns the Medium; this module owns the arithmetic.\n */\n floor: ContrastFloor = WEB_FLOOR,\n): ContrastCheck[] {\n const results: ContrastCheck[] = [];\n\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n const grounds = [\n ['surface.base', def.surface.base],\n ['surface.raised', def.surface.raised],\n ['surface.sunken', def.surface.sunken],\n ] as const;\n\n const check = (pair: string, foreground: string, background: string, minimum: number) => {\n const ratio = contrastRatio(foreground, background);\n results.push({\n level,\n pair,\n foreground,\n background,\n ratio,\n apca: apcaContrast(foreground, background),\n minimum,\n passes: ratio >= minimum,\n });\n };\n\n for (const [groundName, ground] of grounds) {\n for (const tone of ['primary', 'secondary', 'muted'] as const satisfies readonly TextTone[]) {\n check(`text.${tone} on ${groundName}`, def.text[tone], ground, floor.role);\n }\n for (const tone of ['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]) {\n check(`accent.${tone} on ${groundName}`, def.accent[tone], ground, floor.role);\n }\n for (const tone of ['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]) {\n check(`intent.${tone} on ${groundName}`, def.intent[tone], ground, floor.role);\n }\n for (const tone of ['added', 'removed', 'moved'] as const satisfies readonly Delta[]) {\n check(`delta.${tone} on ${groundName}`, def.delta[tone], ground, floor.role);\n }\n // ADR 0001: gate `palette` once per Hue rather than once per Role that\n // consumes it. Separate the palette, not each of its consumers.\n for (const hue of PALETTE_HUES_ORDER) {\n check(`palette.${hue} on ${groundName}`, def.palette[hue], ground, floor.hue);\n check(\n `palette.bright.${hue} on ${groundName}`,\n def.paletteBright[hue],\n ground,\n floor.hueBright,\n );\n }\n check(`border.strong on ${groundName}`, def.border.strong, ground, MINIMUM_RATIO.borderStrong);\n check(`border.default on ${groundName}`, def.border.default, ground, MINIMUM_RATIO.borderDefault);\n check(`border.subtle on ${groundName}`, def.border.subtle, ground, MINIMUM_RATIO.borderSubtle);\n }\n\n // `text.inverse` is what a filled accent button prints in, so it is measured\n // against the accents rather than against a surface.\n // `quiet` is in this list because `Tag` ships `bg-accent-quiet\n // text-content-inverse`. It was omitted while the other three were checked,\n // so a palette edit to `quiet` would have gone unmeasured — a coverage gap\n // rather than a live defect, but the README claims every pair is audited.\n for (const tone of ['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]) {\n check(\n `text.inverse on accent.${tone}`,\n def.text.inverse,\n def.accent[tone],\n floor.role,\n );\n }\n // `FileChangeTree` prints its change mark in `text.inverse` on a `delta` fill.\n for (const tone of ['added', 'removed', 'moved'] as const satisfies readonly Delta[]) {\n check(`text.inverse on delta.${tone}`, def.text.inverse, def.delta[tone], floor.role);\n }\n check('text.inverse on text.secondary', def.text.inverse, def.text.secondary, floor.role);\n for (const tone of ['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]) {\n check(\n `text.inverse on intent.${tone}`,\n def.text.inverse,\n def.intent[tone],\n floor.role,\n );\n }\n // A diff row: the line in `text.primary`, its sign in the matching `delta`\n // role, both on that row's ground. The hunk header is `text.secondary`.\n for (const tone of ['added', 'removed'] as const satisfies readonly DeltaGround[]) {\n check(`diff row: text.primary on deltaGround.${tone}`, def.text.primary, def.deltaGround[tone], floor.role);\n check(`diff sign: delta.${tone} on deltaGround.${tone}`, def.delta[tone], def.deltaGround[tone], floor.role);\n }\n check('diff hunk: text.secondary on deltaGround.hunk', def.text.secondary, def.deltaGround.hunk, floor.role);\n // `Select`'s open list (#164), named for the component because it used to\n // be the one surface the palette did not reach: the operating system\n // painted it. The rows are `text.primary` on `surface.raised`; a disabled\n // row is `text.muted`; the highlighted row is `text.inverse` on the field's\n // accent fill, and the chosen row's mark is that accent on the list. The\n // accent is whichever the caller passes, so every Emphasis and Intent is\n // measured rather than only the default. The values repeat pairs above —\n // the point is that removing one of those cannot silently un-gate the list.\n check('select.option: text.primary on surface.raised', def.text.primary, def.surface.raised, floor.role);\n check('select.option disabled: text.muted on surface.raised', def.text.muted, def.surface.raised, floor.role);\n check('select.placeholder: text.muted on surface.base', def.text.muted, def.surface.base, floor.role);\n const listAccents = [\n ...(['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]).map(\n (tone) => [`accent.${tone}`, def.accent[tone]] as const,\n ),\n ...(['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]).map(\n (tone) => [`intent.${tone}`, def.intent[tone]] as const,\n ),\n ];\n for (const [name, fill] of listAccents) {\n check(`select.option highlighted: text.inverse on ${name}`, def.text.inverse, fill, floor.role);\n check(`select.option selected mark: ${name} on surface.raised`, fill, def.surface.raised, floor.role);\n }\n\n // A scrim's job is to separate the dialog from the page behind it. Nothing\n // renders text on the scrim, so the assertion is about separation — and it\n // can be satisfied by either edge of the dialog, because this system draws\n // components with a load-bearing 2px border as often as with a fill. On a\n // dark level the fill barely differs from the scrim and the white border\n // does the work; on a light level the white fill does it and the dark\n // border is the one that disappears. Requiring both would fail every level.\n const scrimOverBase = composite(\n parseColor(def.surface.overlay),\n parseColor(def.surface.base),\n );\n const scrim = `rgb(${Math.round(scrimOverBase.r)}, ${Math.round(scrimOverBase.g)}, ${Math.round(scrimOverBase.b)})`;\n const separation = Math.max(\n contrastRatio(def.surface.raised, scrim),\n contrastRatio(def.border.strong, scrim),\n );\n results.push({\n level,\n pair: 'dialog (fill or border) against scrimmed page',\n foreground: `${def.surface.raised} / ${def.border.strong}`,\n background: scrim,\n ratio: separation,\n apca: null,\n minimum: MINIMUM_RATIO.overlaySeparation,\n passes: separation >= MINIMUM_RATIO.overlaySeparation,\n });\n }\n\n return results;\n}\n\n/**\n * How far apart the text tones sit, in APCA Lc, on each ground.\n *\n * Reported, not gated. It is the other half of tuning `text.muted`: darkening it\n * for legibility is free until it lands so close to `text.secondary` that the\n * two stop reading as two tones. #372 measured `#4f4a3d` on sketch at 7 Lc from\n * secondary, which is why `#5c5546` was chosen instead.\n */\nexport interface TextHierarchyStep {\n level: ThemeLevel;\n ground: string;\n /** Lc magnitude of primary, secondary and muted on this ground. */\n lc: Readonly<Record<'primary' | 'secondary' | 'muted', number>>;\n /** secondary minus muted, in Lc magnitude. */\n mutedStep: number;\n}\n\nexport function auditTextHierarchy(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): TextHierarchyStep[] {\n const steps: TextHierarchyStep[] = [];\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n for (const ground of ['base', 'raised', 'sunken'] as const) {\n const lc = (tone: 'primary' | 'secondary' | 'muted') =>\n Math.abs(apcaContrast(def.text[tone], def.surface[ground]));\n const tones = { primary: lc('primary'), secondary: lc('secondary'), muted: lc('muted') };\n steps.push({ level, ground: `surface.${ground}`, lc: tones, mutedStep: tones.secondary - tones.muted });\n }\n }\n return steps;\n}\n\n/** How a component may mark a selected item. */\nexport type SelectionDevice = 'fill' | 'edge' | 'surface pair';\n\nexport interface SelectionDeviceCheck {\n level: ThemeLevel;\n device: SelectionDevice;\n /** e.g. `accent.primary on surface.raised`. */\n pair: string;\n foreground: string;\n background: string;\n ratio: number;\n minimum: number;\n /** For `fill` and `edge`: the device is usable. For `surface pair`: it would be, and that is the trap. */\n passes: boolean;\n}\n\n/**\n * The state rule, as arithmetic.\n *\n * Selected state is carried by an accent **fill** or an accent **edge**, never\n * by swapping one surface for another. The reason is not taste: the surfaces\n * exist to *layer* — a strip behind its tabs, a panel over a page — so they\n * are deliberately close in lightness, and on the light rungs they are a few\n * percent apart. A widget that marks its chosen tab `surface.base` among\n * `surface.raised` siblings reads acceptably on `midnight` and is invisible on\n * `bright`. That is how the bug ships: it passes review on the dark rung the\n * reviewer happens to be on.\n *\n * So this audits both halves. The fill and edge devices — the accent against\n * every surface a tab can sit on — must clear the non-text bar on every level,\n * which is what makes the rule safe to follow. The surface pairs are measured\n * too, and reported, so the number that makes them unusable is in the gate's\n * output rather than in someone's memory. They are not expected to pass; a\n * level on which they *did* would be the one where a surface-pair widget\n * slips through.\n */\nexport function auditSelectionDevices(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): SelectionDeviceCheck[] {\n const results: SelectionDeviceCheck[] = [];\n\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n const grounds = [\n ['surface.base', def.surface.base],\n ['surface.raised', def.surface.raised],\n ] as const;\n\n const check = (\n device: SelectionDevice,\n pair: string,\n foreground: string,\n background: string,\n ) => {\n const ratio = contrastRatio(foreground, background);\n results.push({\n level,\n device,\n pair,\n foreground,\n background,\n ratio,\n minimum: MINIMUM_RATIO.stateDevice,\n passes: ratio >= MINIMUM_RATIO.stateDevice,\n });\n };\n\n for (const [groundName, ground] of grounds) {\n // `quiet` is the de-emphasised step, not a fifth colour — a tab it\n // marks is meant to recede, so it is not a selection device.\n for (const tone of ['primary', 'secondary', 'tertiary'] as const satisfies readonly Emphasis[]) {\n check('fill', `accent.${tone} fill on ${groundName}`, def.accent[tone], ground);\n check('edge', `accent.${tone} edge on ${groundName}`, def.accent[tone], ground);\n }\n }\n\n check('surface pair', 'surface.raised against surface.base', def.surface.raised, def.surface.base);\n check('surface pair', 'surface.sunken against surface.base', def.surface.sunken, def.surface.base);\n check('surface pair', 'surface.sunken against surface.raised', def.surface.sunken, def.surface.raised);\n }\n\n return results;\n}\n"],"mappings":";AA4BA,IAAM,MAAM;AACZ,IAAM,SAAS;AAGR,SAAS,WAAW,OAAoB;AAC7C,QAAM,QAAQ,MAAM,KAAK;AAEzB,QAAM,MAAM,IAAI,KAAK,KAAK;AAC1B,MAAI,KAAK;AACP,UAAM,SAAS,IAAI,CAAC;AACpB,UAAM,SAAS,CAAC,MAAc,OAAO,SAAS,EAAE,WAAW,IAAI,IAAI,IAAI,GAAG,EAAE;AAC5E,QAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GAAG;AAC9C,aAAO;AAAA,QACL,GAAG,OAAO,OAAO,CAAC,CAAE;AAAA,QACpB,GAAG,OAAO,OAAO,CAAC,CAAE;AAAA,QACpB,GAAG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AI,IAAI,OAAO,IAAI,GAAG,MAAM;AAAA,MAChF;AAAA,IACF;AAEA,UAAM,gBAAgB,uCAAuC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AACjG,UAAM,gBAAgB,uCAAuC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AACjG,UAAM,gBAAgB,yCAAyC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,MAAM;AAAA,EACvG;AAEA,SAAO;AACT;","names":["sapc"]}
|
package/dist/theme/levels.js
CHANGED
|
@@ -58,6 +58,17 @@ var LEVELS = {
|
|
|
58
58
|
warning: "#facc15",
|
|
59
59
|
danger: "#f955a4"
|
|
60
60
|
},
|
|
61
|
+
delta: {
|
|
62
|
+
added: "#39ff14",
|
|
63
|
+
removed: "#ff586e",
|
|
64
|
+
// red, not intent.danger's pink: a removal is not an alarm
|
|
65
|
+
moved: "#c3afff"
|
|
66
|
+
},
|
|
67
|
+
deltaGround: {
|
|
68
|
+
added: "#0f2a17",
|
|
69
|
+
removed: "#2e1020",
|
|
70
|
+
hunk: "#1c1c38"
|
|
71
|
+
},
|
|
61
72
|
accentHue: {
|
|
62
73
|
primary: "cyan",
|
|
63
74
|
secondary: "yellow",
|
|
@@ -70,6 +81,11 @@ var LEVELS = {
|
|
|
70
81
|
warning: "yellow",
|
|
71
82
|
danger: "pink"
|
|
72
83
|
},
|
|
84
|
+
deltaHue: {
|
|
85
|
+
added: "green",
|
|
86
|
+
removed: "red",
|
|
87
|
+
moved: "violet"
|
|
88
|
+
},
|
|
73
89
|
palette: {
|
|
74
90
|
red: "#ff586e",
|
|
75
91
|
// 16deg — lifted from #f43f5e (dim accent.tertiary), 4.59:1
|
|
@@ -151,6 +167,16 @@ var LEVELS = {
|
|
|
151
167
|
warning: "#974503",
|
|
152
168
|
danger: "#bd0010"
|
|
153
169
|
},
|
|
170
|
+
delta: {
|
|
171
|
+
added: "#006b2e",
|
|
172
|
+
removed: "#bd0010",
|
|
173
|
+
moved: "#7d00f4"
|
|
174
|
+
},
|
|
175
|
+
deltaGround: {
|
|
176
|
+
added: "#dcefdc",
|
|
177
|
+
removed: "#f6dcd8",
|
|
178
|
+
hunk: "#e7e2d4"
|
|
179
|
+
},
|
|
154
180
|
accentHue: {
|
|
155
181
|
primary: "blue",
|
|
156
182
|
secondary: "green",
|
|
@@ -163,6 +189,11 @@ var LEVELS = {
|
|
|
163
189
|
warning: "orange",
|
|
164
190
|
danger: "red"
|
|
165
191
|
},
|
|
192
|
+
deltaHue: {
|
|
193
|
+
added: "green",
|
|
194
|
+
removed: "red",
|
|
195
|
+
moved: "violet"
|
|
196
|
+
},
|
|
166
197
|
palette: {
|
|
167
198
|
red: "#bd0010",
|
|
168
199
|
// 16deg — was #dc2626, 4.03:1 — failed WCAG AA
|
package/dist/theme/levels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/theme/levels.ts"],"sourcesContent":["/**\n * The theme ladder — the single place a level name or a level's colour is written.\n *\n * Everything else in the system derives from this file: the CSS in\n * `theme.generated.css`, the runtime provider, the Storybook toolbar, the\n * walkthrough matrix, and the contrast gate. Adding a level here is a type\n * error everywhere it has not been handled; adding a *role* is a type error in\n * every level at once. That is the guarantee — not a convention.\n *\n * ## Why a ladder and not a polarity, at two levels\n *\n * The ladder ran to four rungs — `midnight`, `dim`, `bright`, `white` — on the\n * argument that two themes can share a polarity and still want different\n * grounds. That argument was sound; the assumption under it was not. Nothing\n * consumed the fourth rung and nothing reached the second, so three of the four\n * were paid for and never collected. The pair is `midnight` and `light`.\n *\n * Polarity nevertheless stays a *declared property of a level* rather than the\n * axis, and this is worth stating because the collapse is usually assumed to\n * end it. It does not, because **neither level is named for its polarity**:\n * `midnight` has polarity `dark`, `sketch` has polarity `light`. So\n * {@link SYSTEM_LEVEL} still has a real job — mapping two media states onto two\n * names that are neither of them — and a `Record<Polarity, T>` remains a\n * different type from a `Record<ThemeLevel, T>`. Had the levels been called\n * `dark` and `light` the two would have collapsed into one thing and polarity\n * could have gone with them.\n *\n * Both polarity variants therefore survive: `dark:` and `light:` each span a\n * polarity rather than naming a level, so neither collides with a level\n * variant. `midnight` names a ground; `sketch` names a surface and a way of\n * drawing on it. Neither is a synonym for its polarity, which is the property\n * that keeps a third level cheap.\n *\n * ## Why every value is a literal\n *\n * The previous token layer derived surfaces, text and borders from two poles\n * with `color-mix()` percentages. Percentages tuned against near-black do not\n * hold at the light end — `border-subtle` at 28% is a visible hairline on\n * black and invisible on paper. Literals also make the ladder *checkable*:\n * `pnpm check:contrast` can compute every text-on-surface ratio without a\n * browser — 260 pairs, 130 per Level, including every Hue against every\n * ground, which is what makes hand-tuned literals sustainable rather than\n * twenty times the manual review. Stated per Level deliberately: 440 was\n * written here in the commit that collapsed four Levels to two, so the total\n * was stale the moment it was typed.\n *\n * The one exception is `surface.overlay`, which is a scrim and needs alpha.\n */\n\nimport type { BorderTone, Emphasis, Hue, HueRef, Intent, Surface, TextTone } from '../lib/theme';\n\n/**\n * The ladder, ordered from darkest to lightest. Order is meaningful: it is what\n * `cycleLevel` steps through and what the Storybook toolbar and walkthrough\n * matrix render in.\n */\nexport const THEME_LEVELS = ['midnight', 'sketch'] as const;\n\n/** A level of the ladder. */\nexport type ThemeLevel = (typeof THEME_LEVELS)[number];\n\n/**\n * Whether a level reads as dark-on-light or light-on-dark. Declared per level\n * rather than inferred, because it drives things a luminance calculation should\n * not silently decide: the `color-scheme` property (which controls native form\n * controls, scrollbars and the caret), the `dark:`/`light:` Tailwind variants,\n * and the `prefers-color-scheme` mapping.\n */\nexport type Polarity = 'dark' | 'light';\n\n/**\n * The three colours that do **not** vary by level.\n *\n * Every other colour in this module is declared once per level and swaps with\n * it. These do not, and that invariance is the whole point: `#ffffff` means\n * *white*, not \"whatever this level calls its lightest ground\". The\n * `--color-black` / `--color-white` compat aliases are the counter-example —\n * they track `surface.base` and `text.primary`, so `--color-black` resolves to\n * `#ffffff` on the `white` level. A token named for an appearance, holding the\n * opposite appearance.\n *\n * Use these when true black or true white is genuinely meant: a print surface,\n * an SVG fill, a scrim. Not as a page ground — that is `surface.base`.\n */\nexport const FIXED_COLOURS = {\n black: '#000000',\n white: '#ffffff',\n transparent: 'transparent',\n} as const;\n\nexport type FixedColour = keyof typeof FIXED_COLOURS;\n\n/**\n * The Hue vocabulary, in wheel order starting at red.\n *\n * Ten is the ceiling, not a comfortable middle: the tightest pair already sits\n * at deltaE 0.049 on the light levels, and an eleventh candidate was dropped\n * during derivation for landing 13 degrees from the measured blue at deltaE\n * 0.024. Adding one means checking the separation gate, not just this array.\n */\nexport const PALETTE_HUES = [\n 'red',\n 'orange',\n 'yellow',\n 'green',\n 'teal',\n 'cyan',\n 'blue',\n 'violet',\n 'magenta',\n 'pink',\n] as const satisfies readonly Hue[];\n\n/**\n * Every colour a level must define. Adding a field here is a compile error in\n * all four levels until each one answers it — the property that a bare string\n * union cannot provide.\n */\nexport interface LevelDefinition {\n /** Human-facing name, used in the Storybook toolbar and the sandbox. */\n readonly label: string;\n /** One line on what the level is for. Rendered in the sandbox. */\n readonly description: string;\n readonly polarity: Polarity;\n readonly surface: Readonly<Record<Surface, string>>;\n readonly text: Readonly<Record<TextTone, string>>;\n readonly border: Readonly<Record<BorderTone, string>>;\n readonly accent: Readonly<Record<Emphasis, string>>;\n readonly intent: Readonly<Record<Intent, string>>;\n /**\n * The Hue vocabulary — appearance, not job. Declared *below* the Roles above\n * and referenced by them, never derived from them. Only a Target with no\n * notion of jobs addresses these: a terminal's sixteen ANSI slots, half a\n * JetBrains scheme, a generated diagram needing N distinguishable colours.\n *\n * Every entry clears 5.5:1 against the tightest of this level's three\n * grounds — above WCAG AA, so an editor still has room to tint the ground\n * behind it. `bright` fills the upper eight ANSI slots at a 4.5:1 floor,\n * since those carry emphasis rather than body text.\n */\n readonly palette: Readonly<Record<Hue, string>>;\n /** The `bright` half of each Hue. ANSI's upper eight, and nothing else yet. */\n readonly paletteBright: Readonly<Record<Hue, string>>;\n /**\n * Which Hue each Role is. **The declared lookup ADR 0001 requires.**\n *\n * The ADR rejects deriving this by inspecting hex — ambiguous when two Roles\n * share a value, lossy when no Hue sits on a Role's. So it is declared, and\n * `check:contrast` asserts the Role's value actually equals the Hue's. That\n * assertion is the point: without it the two vocabularies drift silently,\n * which is the failure the ADR's rejected \"both, independently declared\"\n * option was rejected for — and which this repo shipped for exactly one\n * commit, with two pinks on `midnight` 0.036 apart.\n */\n readonly accentHue: Readonly<Record<Emphasis, HueRef>>;\n /** As `accentHue`, for the meaning Roles. */\n readonly intentHue: Readonly<Record<Intent, HueRef>>;\n /** Colour of the hard offset shadows. Normally tracks `border.strong`. */\n readonly shadow: string;\n}\n\n/**\n * Surfaces do not move in the same direction on every level, and that is the\n * point of declaring them.\n *\n * On the dark levels a raised card sits *above* the page and so lightens. On\n * `bright` — a warm desk with paper on it — a raised card is a fresh white\n * sheet, so it also lightens, but past the ground rather than away from black.\n * On `white` there is nowhere lighter to go, so elevation is carried by the\n * hard border and shadow while the panel itself takes a faint cool grey. A\n * single derived formula cannot express those three behaviours; four literal\n * ramps can.\n */\nexport const LEVELS: Readonly<Record<ThemeLevel, LevelDefinition>> = {\n midnight: {\n label: 'Midnight',\n description: 'Neon on blue-black. The maximal end of the ladder.',\n polarity: 'dark',\n surface: {\n base: '#0a0a1a',\n raised: '#14142a',\n sunken: '#050510',\n overlay: 'rgba(5, 5, 16, 0.82)',\n },\n text: {\n primary: '#ffffff',\n secondary: '#c3c3d4',\n // Was #8b8ba3: 5.90:1, but APCA Lc -41, the weakest text pair in the\n // system. WCAG 2 overrates light-on-dark. Now 7.39:1 / Lc -50, still 21 Lc\n // below `secondary`. accent.quiet keeps the old value — a fill, not text.\n muted: '#9d9db4',\n inverse: '#0a0a1a',\n },\n border: {\n strong: '#ffffff',\n default: '#9d9db4',\n subtle: '#33334d',\n },\n accent: {\n primary: '#22d3ee',\n secondary: '#facc15',\n // Was #ec4899 — the brand pink, and 5.12:1, which cleared the 4.5 Role\n // floor while `palette.pink` sat at 5.90:1. Two pinks 0.036 apart in one\n // level, invisibly different and therefore worse than visibly. Now the\n // Hue's value, per `accentHue` below.\n tertiary: '#f955a4',\n quiet: '#8b8ba3',\n },\n intent: {\n info: '#22d3ee',\n success: '#39ff14',\n warning: '#facc15',\n danger: '#f955a4',\n },\n accentHue: {\n primary: 'cyan',\n secondary: 'yellow',\n tertiary: 'pink',\n quiet: 'neutral',\n },\n intentHue: {\n info: 'cyan',\n success: 'green',\n warning: 'yellow',\n danger: 'pink',\n },\n palette: {\n red: '#ff586e', // 16deg — lifted from #f43f5e (dim accent.tertiary), 4.59:1\n orange: '#ff8c00', // 58deg — kept — 410 commits\n yellow: '#facc15', // 92deg — kept — 533 commits, brand\n green: '#39ff14', // 142deg — kept — 533 commits, brand\n teal: '#34d399', // 163deg — kept — 364 commits\n cyan: '#22d3ee', // 212deg — kept — 534 commits, brand\n blue: '#38bdf8', // 233deg — kept — dim accent.primary, 233deg (a sky blue by heritage)\n violet: '#c3afff', // 295deg — new — 57 tried across six years, none canonical\n magenta: '#ff1cff', // 328deg — lifted from #ff00ff, 5.37:1\n pink: '#f955a4', // 354deg — lifted from #ec4899 (brand), 4.77:1 — deltaE 0.036\n },\n paletteBright: {\n red: '#ff939b',\n orange: '#ffba85',\n yellow: '#ffeaab',\n green: '#c0ffb8',\n teal: '#00f7ae',\n cyan: '#88ebff',\n blue: '#8cd7ff',\n violet: '#ddd4ff',\n magenta: '#ff88fd',\n pink: '#ff8ebe',\n },\n shadow: '#ffffff',\n },\n\n sketch: {\n label: 'Sketch',\n description: 'Warm paper and pen ink. The light half of the pair.',\n polarity: 'light',\n surface: {\n base: '#f5f3ec', // sketch paper\n raised: '#ffffff', // FIXED_COLOURS.white — a fresh sheet on the desk\n sunken: '#efeadf', // the binding ground: every value below is solved against this\n overlay: 'rgba(35, 38, 46, 0.72)',\n },\n text: {\n primary: '#23262e', // sketch ink\n secondary: '#33373f',\n // Was #6a6252: 5.03:1 / APCA Lc 68 on `sunken`, carried by 11px labels.\n // Now 6.16:1 / Lc 73 there. Darker still (#4f4a3d) left muted 7 Lc from\n // `secondary`, and the two tones stopped reading as two. accent.quiet keeps\n // the old value.\n muted: '#5c5546',\n inverse: '#f5f3ec',\n },\n border: {\n strong: '#23262e',\n default: '#8f8672',\n subtle: '#c8c3b4', // darker than sketch's #d8d3c4, which was 1.25:1 on a pure-white `raised`\n },\n accent: {\n primary: '#1450d7', // palette.blue\n secondary: '#006b2e', // palette.green\n tertiary: '#bd0010', // palette.red\n quiet: '#6a6252',\n },\n intent: {\n info: '#1450d7',\n success: '#006b2e',\n warning: '#974503',\n danger: '#bd0010',\n },\n accentHue: {\n primary: 'blue',\n secondary: 'green',\n tertiary: 'red',\n quiet: 'neutral',\n },\n intentHue: {\n info: 'blue',\n success: 'green',\n warning: 'orange',\n danger: 'red',\n },\n palette: {\n red: '#bd0010', // 16deg — was #dc2626, 4.03:1 — failed WCAG AA\n orange: '#974503', // 58deg — was #9a4708, 5.34:1\n yellow: '#705a00', // 92deg — new — no light yellow was ever authored\n green: '#006b2e', // 142deg — was #15803d, 4.18:1 — failed\n teal: '#006859', // 163deg — new\n cyan: '#006675', // 212deg — new\n blue: '#1450d7', // 233deg — was #2563eb, 4.31:1 — failed\n violet: '#7d00f4', // 295deg — new\n magenta: '#a300ad', // 328deg — new\n pink: '#b4006c', // 354deg — new\n },\n paletteBright: {\n red: '#8f002a',\n orange: '#6c3700',\n yellow: '#534200',\n green: '#024f00',\n teal: '#004d34',\n cyan: '#004b56',\n blue: '#004e6d',\n violet: '#6000bd',\n magenta: '#7f0080',\n pink: '#8a0052',\n },\n shadow: '#23262e',\n },\n};\n\n/** The level applied when nothing else has been chosen or persisted. */\nexport const DEFAULT_LEVEL: ThemeLevel = 'midnight';\n\n/**\n * Which level each OS colour-scheme preference maps to. `prefers-color-scheme`\n * is binary, so the ladder has to nominate a representative at each end; making\n * that an explicit constant means it can be changed in one place rather than\n * being an accident of ordering.\n */\nexport const SYSTEM_LEVEL: Readonly<Record<Polarity, ThemeLevel>> = {\n dark: 'midnight',\n light: 'sketch',\n};\n\n/**\n * The weight running text is drawn at, by polarity — not by level.\n *\n * Light strokes on a dark ground spread optically and read heavier than they\n * are; dark strokes on a light ground do not, so one weight cannot look the\n * same at both ends. The type was tuned on `midnight`, and on `sketch` body copy\n * read thin, most visibly on paper (#372). Same argument as `syntaxEmphasis`:\n * light grounds compress the usable luma band, so weight does work colour cannot.\n *\n * Keyed on Polarity because a Level carries colour and only colour (ADR 0004,\n * asserted in `media.test.ts`), and this is exactly the non-colour,\n * light-vs-dark property the polarity variants exist for. Emitted per level as\n * `--ds-ink-weight` and applied in `styles.css`'s base layer, so any weight\n * utility still wins. Inter and Space Grotesk are variable and draw 450 as\n * asked; IBM Plex Mono ships static cuts and resolves 450 to its 500.\n */\nexport const INK_WEIGHT: Readonly<Record<Polarity, number>> = {\n dark: 400,\n light: 450,\n};\n\n/** Type guard for values arriving from `localStorage`, URLs, or props. */\nexport function isThemeLevel(value: unknown): value is ThemeLevel {\n return typeof value === 'string' && (THEME_LEVELS as readonly string[]).includes(value);\n}\n\n/** The next level on the ladder, wrapping from the lightest back to the darkest. */\nexport function nextLevel(level: ThemeLevel): ThemeLevel {\n const index = THEME_LEVELS.indexOf(level);\n return THEME_LEVELS[(index + 1) % THEME_LEVELS.length]!;\n}\n\n/**\n * Exhaustiveness guard for `switch` statements over a level.\n *\n * Prefer a `Record<ThemeLevel, T>` where the branches are values — it is\n * checked without any call site remembering to add a default. Where control\n * flow genuinely has to branch, end the switch with `assertNever(level)` so\n * adding a fifth level fails the build instead of falling through.\n */\nexport function assertNever(value: never, message = 'Unhandled theme level'): never {\n throw new Error(`${message}: ${String(value)}`);\n}\n"],"mappings":";AAwDO,IAAM,eAAe,CAAC,YAAY,QAAQ;AA4B1C,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,aAAa;AACf;AAYO,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,E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AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,EACV;AACF;AAGO,IAAM,gBAA4B;AAQlC,IAAM,eAAuD;AAAA,EAClE,MAAM;AAAA,EACN,OAAO;AACT;AAkBO,IAAM,aAAiD;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AACT;AAGO,SAAS,aAAa,OAAqC;AAChE,SAAO,OAAO,UAAU,YAAa,aAAmC,SAAS,KAAK;AACxF;AAGO,SAAS,UAAU,OAA+B;AACvD,QAAM,QAAQ,aAAa,QAAQ,KAAK;AACxC,SAAO,cAAc,QAAQ,KAAK,aAAa,MAAM;AACvD;AAUO,SAAS,YAAY,OAAc,UAAU,yBAAgC;AAClF,QAAM,IAAI,MAAM,GAAG,OAAO,KAAK,OAAO,KAAK,CAAC,EAAE;AAChD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/theme/levels.ts"],"sourcesContent":["/**\n * The theme ladder — the single place a level name or a level's colour is written.\n *\n * Everything else in the system derives from this file: the CSS in\n * `theme.generated.css`, the runtime provider, the Storybook toolbar, the\n * walkthrough matrix, and the contrast gate. Adding a level here is a type\n * error everywhere it has not been handled; adding a *role* is a type error in\n * every level at once. That is the guarantee — not a convention.\n *\n * ## Why a ladder and not a polarity, at two levels\n *\n * The ladder ran to four rungs — `midnight`, `dim`, `bright`, `white` — on the\n * argument that two themes can share a polarity and still want different\n * grounds. That argument was sound; the assumption under it was not. Nothing\n * consumed the fourth rung and nothing reached the second, so three of the four\n * were paid for and never collected. The pair is `midnight` and `light`.\n *\n * Polarity nevertheless stays a *declared property of a level* rather than the\n * axis, and this is worth stating because the collapse is usually assumed to\n * end it. It does not, because **neither level is named for its polarity**:\n * `midnight` has polarity `dark`, `sketch` has polarity `light`. So\n * {@link SYSTEM_LEVEL} still has a real job — mapping two media states onto two\n * names that are neither of them — and a `Record<Polarity, T>` remains a\n * different type from a `Record<ThemeLevel, T>`. Had the levels been called\n * `dark` and `light` the two would have collapsed into one thing and polarity\n * could have gone with them.\n *\n * Both polarity variants therefore survive: `dark:` and `light:` each span a\n * polarity rather than naming a level, so neither collides with a level\n * variant. `midnight` names a ground; `sketch` names a surface and a way of\n * drawing on it. Neither is a synonym for its polarity, which is the property\n * that keeps a third level cheap.\n *\n * ## Why every value is a literal\n *\n * The previous token layer derived surfaces, text and borders from two poles\n * with `color-mix()` percentages. Percentages tuned against near-black do not\n * hold at the light end — `border-subtle` at 28% is a visible hairline on\n * black and invisible on paper. Literals also make the ladder *checkable*:\n * `pnpm check:contrast` can compute every text-on-surface ratio without a\n * browser — 296 pairs, 148 per Level, including every Hue against every\n * ground, which is what makes hand-tuned literals sustainable rather than\n * twenty times the manual review. Stated per Level deliberately: 440 was\n * written here in the commit that collapsed four Levels to two, so the total\n * was stale the moment it was typed.\n *\n * The one exception is `surface.overlay`, which is a scrim and needs alpha.\n */\n\nimport type { BorderTone, Delta, DeltaGround, Emphasis, Hue, HueRef, Intent, Surface, TextTone } from '../lib/theme';\n\n/**\n * The ladder, ordered from darkest to lightest. Order is meaningful: it is what\n * `cycleLevel` steps through and what the Storybook toolbar and walkthrough\n * matrix render in.\n */\nexport const THEME_LEVELS = ['midnight', 'sketch'] as const;\n\n/** A level of the ladder. */\nexport type ThemeLevel = (typeof THEME_LEVELS)[number];\n\n/**\n * Whether a level reads as dark-on-light or light-on-dark. Declared per level\n * rather than inferred, because it drives things a luminance calculation should\n * not silently decide: the `color-scheme` property (which controls native form\n * controls, scrollbars and the caret), the `dark:`/`light:` Tailwind variants,\n * and the `prefers-color-scheme` mapping.\n */\nexport type Polarity = 'dark' | 'light';\n\n/**\n * The three colours that do **not** vary by level.\n *\n * Every other colour in this module is declared once per level and swaps with\n * it. These do not, and that invariance is the whole point: `#ffffff` means\n * *white*, not \"whatever this level calls its lightest ground\". The\n * `--color-black` / `--color-white` compat aliases are the counter-example —\n * they track `surface.base` and `text.primary`, so `--color-black` resolves to\n * `#ffffff` on the `white` level. A token named for an appearance, holding the\n * opposite appearance.\n *\n * Use these when true black or true white is genuinely meant: a print surface,\n * an SVG fill, a scrim. Not as a page ground — that is `surface.base`.\n */\nexport const FIXED_COLOURS = {\n black: '#000000',\n white: '#ffffff',\n transparent: 'transparent',\n} as const;\n\nexport type FixedColour = keyof typeof FIXED_COLOURS;\n\n/**\n * The Hue vocabulary, in wheel order starting at red.\n *\n * Ten is the ceiling, not a comfortable middle: the tightest pair already sits\n * at deltaE 0.049 on the light levels, and an eleventh candidate was dropped\n * during derivation for landing 13 degrees from the measured blue at deltaE\n * 0.024. Adding one means checking the separation gate, not just this array.\n */\nexport const PALETTE_HUES = [\n 'red',\n 'orange',\n 'yellow',\n 'green',\n 'teal',\n 'cyan',\n 'blue',\n 'violet',\n 'magenta',\n 'pink',\n] as const satisfies readonly Hue[];\n\n/**\n * Every colour a level must define. Adding a field here is a compile error in\n * all four levels until each one answers it — the property that a bare string\n * union cannot provide.\n */\nexport interface LevelDefinition {\n /** Human-facing name, used in the Storybook toolbar and the sandbox. */\n readonly label: string;\n /** One line on what the level is for. Rendered in the sandbox. */\n readonly description: string;\n readonly polarity: Polarity;\n readonly surface: Readonly<Record<Surface, string>>;\n readonly text: Readonly<Record<TextTone, string>>;\n readonly border: Readonly<Record<BorderTone, string>>;\n readonly accent: Readonly<Record<Emphasis, string>>;\n readonly intent: Readonly<Record<Intent, string>>;\n /**\n * Change, as a comparison reports it: a line or record added, removed, or\n * moved. Separate from `intent` on purpose. An added line is not a success\n * and a removed one is not a danger; whether a change is acceptable is a\n * policy's call, and a renderer that paints it green or red has made that\n * call for the reader. The two groups may share a Hue, as `added` and\n * `intent.success` do, and still diverge where the meanings would clash:\n * `midnight`'s `removed` is red while its `danger` is pink.\n */\n readonly delta: Readonly<Record<Delta, string>>;\n /**\n * The grounds a diff paints behind changed rows, and behind a hunk header.\n * Literal tints rather than `color-mix()` for the reason given in the\n * module header. `text.primary` and the matching `delta` role must both\n * clear the text floor on each, which `check:contrast` asserts.\n */\n readonly deltaGround: Readonly<Record<DeltaGround, string>>;\n /**\n * The Hue vocabulary — appearance, not job. Declared *below* the Roles above\n * and referenced by them, never derived from them. Only a Target with no\n * notion of jobs addresses these: a terminal's sixteen ANSI slots, half a\n * JetBrains scheme, a generated diagram needing N distinguishable colours.\n *\n * Every entry clears 5.5:1 against the tightest of this level's three\n * grounds — above WCAG AA, so an editor still has room to tint the ground\n * behind it. `bright` fills the upper eight ANSI slots at a 4.5:1 floor,\n * since those carry emphasis rather than body text.\n */\n readonly palette: Readonly<Record<Hue, string>>;\n /** The `bright` half of each Hue. ANSI's upper eight, and nothing else yet. */\n readonly paletteBright: Readonly<Record<Hue, string>>;\n /**\n * Which Hue each Role is. **The declared lookup ADR 0001 requires.**\n *\n * The ADR rejects deriving this by inspecting hex — ambiguous when two Roles\n * share a value, lossy when no Hue sits on a Role's. So it is declared, and\n * `check:contrast` asserts the Role's value actually equals the Hue's. That\n * assertion is the point: without it the two vocabularies drift silently,\n * which is the failure the ADR's rejected \"both, independently declared\"\n * option was rejected for — and which this repo shipped for exactly one\n * commit, with two pinks on `midnight` 0.036 apart.\n */\n readonly accentHue: Readonly<Record<Emphasis, HueRef>>;\n /** As `accentHue`, for the meaning Roles. */\n readonly intentHue: Readonly<Record<Intent, HueRef>>;\n /** As `accentHue`, for the change Roles. */\n readonly deltaHue: Readonly<Record<Delta, HueRef>>;\n /** Colour of the hard offset shadows. Normally tracks `border.strong`. */\n readonly shadow: string;\n}\n\n/**\n * Surfaces do not move in the same direction on every level, and that is the\n * point of declaring them.\n *\n * On the dark levels a raised card sits *above* the page and so lightens. On\n * `bright` — a warm desk with paper on it — a raised card is a fresh white\n * sheet, so it also lightens, but past the ground rather than away from black.\n * On `white` there is nowhere lighter to go, so elevation is carried by the\n * hard border and shadow while the panel itself takes a faint cool grey. A\n * single derived formula cannot express those three behaviours; four literal\n * ramps can.\n */\nexport const LEVELS: Readonly<Record<ThemeLevel, LevelDefinition>> = {\n midnight: {\n label: 'Midnight',\n description: 'Neon on blue-black. The maximal end of the ladder.',\n polarity: 'dark',\n surface: {\n base: '#0a0a1a',\n raised: '#14142a',\n sunken: '#050510',\n overlay: 'rgba(5, 5, 16, 0.82)',\n },\n text: {\n primary: '#ffffff',\n secondary: '#c3c3d4',\n // Was #8b8ba3: 5.90:1, but APCA Lc -41, the weakest text pair in the\n // system. WCAG 2 overrates light-on-dark. Now 7.39:1 / Lc -50, still 21 Lc\n // below `secondary`. accent.quiet keeps the old value — a fill, not text.\n muted: '#9d9db4',\n inverse: '#0a0a1a',\n },\n border: {\n strong: '#ffffff',\n default: '#9d9db4',\n subtle: '#33334d',\n },\n accent: {\n primary: '#22d3ee',\n secondary: '#facc15',\n // Was #ec4899 — the brand pink, and 5.12:1, which cleared the 4.5 Role\n // floor while `palette.pink` sat at 5.90:1. Two pinks 0.036 apart in one\n // level, invisibly different and therefore worse than visibly. Now the\n // Hue's value, per `accentHue` below.\n tertiary: '#f955a4',\n quiet: '#8b8ba3',\n },\n intent: {\n info: '#22d3ee',\n success: '#39ff14',\n warning: '#facc15',\n danger: '#f955a4',\n },\n delta: {\n added: '#39ff14',\n removed: '#ff586e', // red, not intent.danger's pink: a removal is not an alarm\n moved: '#c3afff',\n },\n deltaGround: {\n added: '#0f2a17',\n removed: '#2e1020',\n hunk: '#1c1c38',\n },\n accentHue: {\n primary: 'cyan',\n secondary: 'yellow',\n tertiary: 'pink',\n quiet: 'neutral',\n },\n intentHue: {\n info: 'cyan',\n success: 'green',\n warning: 'yellow',\n danger: 'pink',\n },\n deltaHue: {\n added: 'green',\n removed: 'red',\n moved: 'violet',\n },\n palette: {\n red: '#ff586e', // 16deg — lifted from #f43f5e (dim accent.tertiary), 4.59:1\n orange: '#ff8c00', // 58deg — kept — 410 commits\n yellow: '#facc15', // 92deg — kept — 533 commits, brand\n green: '#39ff14', // 142deg — kept — 533 commits, brand\n teal: '#34d399', // 163deg — kept — 364 commits\n cyan: '#22d3ee', // 212deg — kept — 534 commits, brand\n blue: '#38bdf8', // 233deg — kept — dim accent.primary, 233deg (a sky blue by heritage)\n violet: '#c3afff', // 295deg — new — 57 tried across six years, none canonical\n magenta: '#ff1cff', // 328deg — lifted from #ff00ff, 5.37:1\n pink: '#f955a4', // 354deg — lifted from #ec4899 (brand), 4.77:1 — deltaE 0.036\n },\n paletteBright: {\n red: '#ff939b',\n orange: '#ffba85',\n yellow: '#ffeaab',\n green: '#c0ffb8',\n teal: '#00f7ae',\n cyan: '#88ebff',\n blue: '#8cd7ff',\n violet: '#ddd4ff',\n magenta: '#ff88fd',\n pink: '#ff8ebe',\n },\n shadow: '#ffffff',\n },\n\n sketch: {\n label: 'Sketch',\n description: 'Warm paper and pen ink. The light half of the pair.',\n polarity: 'light',\n surface: {\n base: '#f5f3ec', // sketch paper\n raised: '#ffffff', // FIXED_COLOURS.white — a fresh sheet on the desk\n sunken: '#efeadf', // the binding ground: every value below is solved against this\n overlay: 'rgba(35, 38, 46, 0.72)',\n },\n text: {\n primary: '#23262e', // sketch ink\n secondary: '#33373f',\n // Was #6a6252: 5.03:1 / APCA Lc 68 on `sunken`, carried by 11px labels.\n // Now 6.16:1 / Lc 73 there. Darker still (#4f4a3d) left muted 7 Lc from\n // `secondary`, and the two tones stopped reading as two. accent.quiet keeps\n // the old value.\n muted: '#5c5546',\n inverse: '#f5f3ec',\n },\n border: {\n strong: '#23262e',\n default: '#8f8672',\n subtle: '#c8c3b4', // darker than sketch's #d8d3c4, which was 1.25:1 on a pure-white `raised`\n },\n accent: {\n primary: '#1450d7', // palette.blue\n secondary: '#006b2e', // palette.green\n tertiary: '#bd0010', // palette.red\n quiet: '#6a6252',\n },\n intent: {\n info: '#1450d7',\n success: '#006b2e',\n warning: '#974503',\n danger: '#bd0010',\n },\n delta: {\n added: '#006b2e',\n removed: '#bd0010',\n moved: '#7d00f4',\n },\n deltaGround: {\n added: '#dcefdc',\n removed: '#f6dcd8',\n hunk: '#e7e2d4',\n },\n accentHue: {\n primary: 'blue',\n secondary: 'green',\n tertiary: 'red',\n quiet: 'neutral',\n },\n intentHue: {\n info: 'blue',\n success: 'green',\n warning: 'orange',\n danger: 'red',\n },\n deltaHue: {\n added: 'green',\n removed: 'red',\n moved: 'violet',\n },\n palette: {\n red: '#bd0010', // 16deg — was #dc2626, 4.03:1 — failed WCAG AA\n orange: '#974503', // 58deg — was #9a4708, 5.34:1\n yellow: '#705a00', // 92deg — new — no light yellow was ever authored\n green: '#006b2e', // 142deg — was #15803d, 4.18:1 — failed\n teal: '#006859', // 163deg — new\n cyan: '#006675', // 212deg — new\n blue: '#1450d7', // 233deg — was #2563eb, 4.31:1 — failed\n violet: '#7d00f4', // 295deg — new\n magenta: '#a300ad', // 328deg — new\n pink: '#b4006c', // 354deg — new\n },\n paletteBright: {\n red: '#8f002a',\n orange: '#6c3700',\n yellow: '#534200',\n green: '#024f00',\n teal: '#004d34',\n cyan: '#004b56',\n blue: '#004e6d',\n violet: '#6000bd',\n magenta: '#7f0080',\n pink: '#8a0052',\n },\n shadow: '#23262e',\n },\n};\n\n/** The level applied when nothing else has been chosen or persisted. */\nexport const DEFAULT_LEVEL: ThemeLevel = 'midnight';\n\n/**\n * Which level each OS colour-scheme preference maps to. `prefers-color-scheme`\n * is binary, so the ladder has to nominate a representative at each end; making\n * that an explicit constant means it can be changed in one place rather than\n * being an accident of ordering.\n */\nexport const SYSTEM_LEVEL: Readonly<Record<Polarity, ThemeLevel>> = {\n dark: 'midnight',\n light: 'sketch',\n};\n\n/**\n * The weight running text is drawn at, by polarity — not by level.\n *\n * Light strokes on a dark ground spread optically and read heavier than they\n * are; dark strokes on a light ground do not, so one weight cannot look the\n * same at both ends. The type was tuned on `midnight`, and on `sketch` body copy\n * read thin, most visibly on paper (#372). Same argument as `syntaxEmphasis`:\n * light grounds compress the usable luma band, so weight does work colour cannot.\n *\n * Keyed on Polarity because a Level carries colour and only colour (ADR 0004,\n * asserted in `media.test.ts`), and this is exactly the non-colour,\n * light-vs-dark property the polarity variants exist for. Emitted per level as\n * `--ds-ink-weight` and applied in `styles.css`'s base layer, so any weight\n * utility still wins. Inter and Space Grotesk are variable and draw 450 as\n * asked; IBM Plex Mono ships static cuts and resolves 450 to its 500.\n */\nexport const INK_WEIGHT: Readonly<Record<Polarity, number>> = {\n dark: 400,\n light: 450,\n};\n\n/** Type guard for values arriving from `localStorage`, URLs, or props. */\nexport function isThemeLevel(value: unknown): value is ThemeLevel {\n return typeof value === 'string' && (THEME_LEVELS as readonly string[]).includes(value);\n}\n\n/** The next level on the ladder, wrapping from the lightest back to the darkest. */\nexport function nextLevel(level: ThemeLevel): ThemeLevel {\n const index = THEME_LEVELS.indexOf(level);\n return THEME_LEVELS[(index + 1) % THEME_LEVELS.length]!;\n}\n\n/**\n * Exhaustiveness guard for `switch` statements over a level.\n *\n * Prefer a `Record<ThemeLevel, T>` where the branches are values — it is\n * checked without any call site remembering to add a default. Where control\n * flow genuinely has to branch, end the switch with `assertNever(level)` so\n * adding a fifth level fails the build instead of falling through.\n */\nexport function assertNever(value: never, message = 'Unhandled theme level'): never {\n throw new Error(`${message}: ${String(value)}`);\n}\n"],"mappings":";AAwDO,IAAM,eAAe,CAAC,YAAY,QAAQ;AA4B1C,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,aAAa;AACf;AAYO,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAiFO,IAAM,SAAwD;AAAA,EACnE,UAAU;AAAA,IACR,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,IACV,SAAS;AAAA,MACP,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,IACX;A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AA,MACR,OAAO;AAAA;AAAA,MACP,MAAM;AAAA;AAAA,MACN,MAAM;AAAA;AAAA,MACN,MAAM;AAAA;AAAA,MACN,QAAQ;AAAA;AAAA,MACR,SAAS;AAAA;AAAA,MACT,MAAM;AAAA;AAAA,IACR;AAAA,IACA,eAAe;AAAA,MACb,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,EACV;AACF;AAGO,IAAM,gBAA4B;AAQlC,IAAM,eAAuD;AAAA,EAClE,MAAM;AAAA,EACN,OAAO;AACT;AAkBO,IAAM,aAAiD;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AACT;AAGO,SAAS,aAAa,OAAqC;AAChE,SAAO,OAAO,UAAU,YAAa,aAAmC,SAAS,KAAK;AACxF;AAGO,SAAS,UAAU,OAA+B;AACvD,QAAM,QAAQ,aAAa,QAAQ,KAAK;AACxC,SAAO,cAAc,QAAQ,KAAK,aAAa,MAAM;AACvD;AAUO,SAAS,YAAY,OAAc,UAAU,yBAAgC;AAClF,QAAM,IAAI,MAAM,GAAG,OAAO,KAAK,OAAO,KAAK,CAAC,EAAE;AAChD;","names":[]}
|
package/dist/theme.css
CHANGED
|
@@ -82,6 +82,12 @@
|
|
|
82
82
|
--color-intent-success: var(--ds-intent-success);
|
|
83
83
|
--color-intent-warning: var(--ds-intent-warning);
|
|
84
84
|
--color-intent-danger: var(--ds-intent-danger);
|
|
85
|
+
--color-delta-added: var(--ds-delta-added);
|
|
86
|
+
--color-delta-removed: var(--ds-delta-removed);
|
|
87
|
+
--color-delta-moved: var(--ds-delta-moved);
|
|
88
|
+
--color-delta-ground-added: var(--ds-delta-ground-added);
|
|
89
|
+
--color-delta-ground-removed: var(--ds-delta-ground-removed);
|
|
90
|
+
--color-delta-ground-hunk: var(--ds-delta-ground-hunk);
|
|
85
91
|
--color-palette-red: var(--ds-palette-red);
|
|
86
92
|
--color-palette-orange: var(--ds-palette-orange);
|
|
87
93
|
--color-palette-yellow: var(--ds-palette-yellow);
|
|
@@ -331,6 +337,12 @@
|
|
|
331
337
|
--ds-intent-success: #39ff14;
|
|
332
338
|
--ds-intent-warning: #facc15;
|
|
333
339
|
--ds-intent-danger: #f955a4;
|
|
340
|
+
--ds-delta-added: #39ff14;
|
|
341
|
+
--ds-delta-removed: #ff586e;
|
|
342
|
+
--ds-delta-moved: #c3afff;
|
|
343
|
+
--ds-delta-ground-added: #0f2a17;
|
|
344
|
+
--ds-delta-ground-removed: #2e1020;
|
|
345
|
+
--ds-delta-ground-hunk: #1c1c38;
|
|
334
346
|
--ds-palette-red: #ff586e;
|
|
335
347
|
--ds-palette-orange: #ff8c00;
|
|
336
348
|
--ds-palette-yellow: #facc15;
|
|
@@ -373,6 +385,12 @@
|
|
|
373
385
|
--color-intent-success: var(--ds-intent-success);
|
|
374
386
|
--color-intent-warning: var(--ds-intent-warning);
|
|
375
387
|
--color-intent-danger: var(--ds-intent-danger);
|
|
388
|
+
--color-delta-added: var(--ds-delta-added);
|
|
389
|
+
--color-delta-removed: var(--ds-delta-removed);
|
|
390
|
+
--color-delta-moved: var(--ds-delta-moved);
|
|
391
|
+
--color-delta-ground-added: var(--ds-delta-ground-added);
|
|
392
|
+
--color-delta-ground-removed: var(--ds-delta-ground-removed);
|
|
393
|
+
--color-delta-ground-hunk: var(--ds-delta-ground-hunk);
|
|
376
394
|
--color-palette-red: var(--ds-palette-red);
|
|
377
395
|
--color-palette-orange: var(--ds-palette-orange);
|
|
378
396
|
--color-palette-yellow: var(--ds-palette-yellow);
|
|
@@ -440,6 +458,12 @@
|
|
|
440
458
|
--ds-intent-success: #006b2e;
|
|
441
459
|
--ds-intent-warning: #974503;
|
|
442
460
|
--ds-intent-danger: #bd0010;
|
|
461
|
+
--ds-delta-added: #006b2e;
|
|
462
|
+
--ds-delta-removed: #bd0010;
|
|
463
|
+
--ds-delta-moved: #7d00f4;
|
|
464
|
+
--ds-delta-ground-added: #dcefdc;
|
|
465
|
+
--ds-delta-ground-removed: #f6dcd8;
|
|
466
|
+
--ds-delta-ground-hunk: #e7e2d4;
|
|
443
467
|
--ds-palette-red: #bd0010;
|
|
444
468
|
--ds-palette-orange: #974503;
|
|
445
469
|
--ds-palette-yellow: #705a00;
|
|
@@ -482,6 +506,12 @@
|
|
|
482
506
|
--color-intent-success: var(--ds-intent-success);
|
|
483
507
|
--color-intent-warning: var(--ds-intent-warning);
|
|
484
508
|
--color-intent-danger: var(--ds-intent-danger);
|
|
509
|
+
--color-delta-added: var(--ds-delta-added);
|
|
510
|
+
--color-delta-removed: var(--ds-delta-removed);
|
|
511
|
+
--color-delta-moved: var(--ds-delta-moved);
|
|
512
|
+
--color-delta-ground-added: var(--ds-delta-ground-added);
|
|
513
|
+
--color-delta-ground-removed: var(--ds-delta-ground-removed);
|
|
514
|
+
--color-delta-ground-hunk: var(--ds-delta-ground-hunk);
|
|
485
515
|
--color-palette-red: var(--ds-palette-red);
|
|
486
516
|
--color-palette-orange: var(--ds-palette-orange);
|
|
487
517
|
--color-palette-yellow: var(--ds-palette-yellow);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rtkelly-labs/design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Brutalist design system for Ryan Kelly websites: a two-level theme ladder, role-addressed tokens, and Base UI-backed components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -459,6 +459,56 @@
|
|
|
459
459
|
"$value": "{palette.pink}"
|
|
460
460
|
}
|
|
461
461
|
},
|
|
462
|
+
"delta": {
|
|
463
|
+
"$type": "color",
|
|
464
|
+
"$description": "Change Roles, aliased onto Hues by the declared `deltaHue` map. Not meaning: an added line is not a success.",
|
|
465
|
+
"added": {
|
|
466
|
+
"$value": "{palette.green}"
|
|
467
|
+
},
|
|
468
|
+
"removed": {
|
|
469
|
+
"$value": "{palette.red}"
|
|
470
|
+
},
|
|
471
|
+
"moved": {
|
|
472
|
+
"$value": "{palette.violet}"
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
"deltaGround": {
|
|
476
|
+
"$type": "color",
|
|
477
|
+
"$description": "The grounds a diff paints behind changed rows and hunk headers.",
|
|
478
|
+
"added": {
|
|
479
|
+
"$value": {
|
|
480
|
+
"colorSpace": "oklch",
|
|
481
|
+
"components": [
|
|
482
|
+
0.2576,
|
|
483
|
+
0.0488,
|
|
484
|
+
151.26
|
|
485
|
+
],
|
|
486
|
+
"hex": "#0f2a17"
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
"removed": {
|
|
490
|
+
"$value": {
|
|
491
|
+
"colorSpace": "oklch",
|
|
492
|
+
"components": [
|
|
493
|
+
0.2265,
|
|
494
|
+
0.0544,
|
|
495
|
+
349.12
|
|
496
|
+
],
|
|
497
|
+
"hex": "#2e1020"
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
"hunk": {
|
|
501
|
+
"$value": {
|
|
502
|
+
"colorSpace": "oklch",
|
|
503
|
+
"components": [
|
|
504
|
+
0.2423,
|
|
505
|
+
0.0527,
|
|
506
|
+
281.74
|
|
507
|
+
],
|
|
508
|
+
"hex": "#1c1c38"
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
},
|
|
462
512
|
"shadow": {
|
|
463
513
|
"$type": "color",
|
|
464
514
|
"color": {
|
|
@@ -459,6 +459,56 @@
|
|
|
459
459
|
"$value": "{palette.red}"
|
|
460
460
|
}
|
|
461
461
|
},
|
|
462
|
+
"delta": {
|
|
463
|
+
"$type": "color",
|
|
464
|
+
"$description": "Change Roles, aliased onto Hues by the declared `deltaHue` map. Not meaning: an added line is not a success.",
|
|
465
|
+
"added": {
|
|
466
|
+
"$value": "{palette.green}"
|
|
467
|
+
},
|
|
468
|
+
"removed": {
|
|
469
|
+
"$value": "{palette.red}"
|
|
470
|
+
},
|
|
471
|
+
"moved": {
|
|
472
|
+
"$value": "{palette.violet}"
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
"deltaGround": {
|
|
476
|
+
"$type": "color",
|
|
477
|
+
"$description": "The grounds a diff paints behind changed rows and hunk headers.",
|
|
478
|
+
"added": {
|
|
479
|
+
"$value": {
|
|
480
|
+
"colorSpace": "oklch",
|
|
481
|
+
"components": [
|
|
482
|
+
0.9329,
|
|
483
|
+
0.0323,
|
|
484
|
+
145.31
|
|
485
|
+
],
|
|
486
|
+
"hex": "#dcefdc"
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
"removed": {
|
|
490
|
+
"$value": {
|
|
491
|
+
"colorSpace": "oklch",
|
|
492
|
+
"components": [
|
|
493
|
+
0.9147,
|
|
494
|
+
0.0294,
|
|
495
|
+
28.13
|
|
496
|
+
],
|
|
497
|
+
"hex": "#f6dcd8"
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
"hunk": {
|
|
501
|
+
"$value": {
|
|
502
|
+
"colorSpace": "oklch",
|
|
503
|
+
"components": [
|
|
504
|
+
0.9129,
|
|
505
|
+
0.0195,
|
|
506
|
+
90.55
|
|
507
|
+
],
|
|
508
|
+
"hex": "#e7e2d4"
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
},
|
|
462
512
|
"shadow": {
|
|
463
513
|
"$type": "color",
|
|
464
514
|
"color": {
|