@spunto/design-system 0.65.0 → 0.67.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/package.json +10 -3
- package/palettes.css +1705 -0
- package/src/components/tasks/composer.tsx +2 -2
- package/src/components/tasks/machine.tsx +10 -6
- package/src/components/tasks/new-task-composer.tsx +19 -11
- package/src/components/tasks/task-list.tsx +1 -1
- package/src/components/tasks/tasks.test.tsx +11 -4
- package/src/palettes.test.ts +30 -0
- package/src/palettes.ts +188 -0
- package/styles.css +9 -5
|
@@ -12,7 +12,7 @@ import type { DraftFile, TaskPendingAction } from "./types"
|
|
|
12
12
|
* Answering a task — the bottom of the cockpit's centre column.
|
|
13
13
|
*
|
|
14
14
|
* What it does is a **new turn, not an interruption**: the harness is resumed with what you wrote,
|
|
15
|
-
*
|
|
15
|
+
* in the same sandbox, on whatever the checkout holds, and its events continue the timeline above. Which is
|
|
16
16
|
* why it only appears while the task is in review — a session that is still talking has no open
|
|
17
17
|
* stdin to interrupt, and a box that pretended otherwise would be the worst kind of lie: one that
|
|
18
18
|
* looks like it worked.
|
|
@@ -250,7 +250,7 @@ export function TaskComposer({
|
|
|
250
250
|
? // Both paths are real and the composer cannot know which one it will take:
|
|
251
251
|
// the session is usually still listening, and is resumed if it has exited.
|
|
252
252
|
"Goes to the live session — or resumes it if it has exited."
|
|
253
|
-
: "Resumes the session with your message — same
|
|
253
|
+
: "Resumes the session with your message — same sandbox, same checkout.")}
|
|
254
254
|
</span>
|
|
255
255
|
{interactive && state === "running" && onInterrupt && (
|
|
256
256
|
<Button
|
|
@@ -317,8 +317,9 @@ export function bootSteps({
|
|
|
317
317
|
detail: setup ? phaseLabel(setup) : worker ? "waiting for the container's first report…" : undefined,
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
//
|
|
321
|
-
//
|
|
320
|
+
// Tasks from before RFC 0056 only: the platform created the task's branch in every repository
|
|
321
|
+
// before the session started — one recorded command per repo, which is where this reads from.
|
|
322
|
+
// A task since has no such command, and no Branch step: the agent branches, if it wants to.
|
|
322
323
|
const branchCommands = commands.filter((c) => (c.label ?? "").startsWith("Branch setup"))
|
|
323
324
|
const branchState: StepState =
|
|
324
325
|
branchCommands.length === 0
|
|
@@ -336,8 +337,9 @@ export function bootSteps({
|
|
|
336
337
|
commands: branchCommands.length > 0 ? branchCommands : undefined,
|
|
337
338
|
}
|
|
338
339
|
|
|
340
|
+
const legacyBranch = branchCommands.length > 0
|
|
339
341
|
const queued = task.state === "queued"
|
|
340
|
-
const ready = branchState === "done"
|
|
342
|
+
const ready = legacyBranch ? branchState === "done" : setupState === "done"
|
|
341
343
|
const session: TaskBootStep = {
|
|
342
344
|
key: "session",
|
|
343
345
|
label: "Agent session",
|
|
@@ -345,15 +347,17 @@ export function bootSteps({
|
|
|
345
347
|
detail: task.startedAt
|
|
346
348
|
? "started"
|
|
347
349
|
: queued
|
|
348
|
-
?
|
|
350
|
+
? legacyBranch
|
|
351
|
+
? "starts as soon as the branch is ready"
|
|
352
|
+
: "starts as soon as the machine is ready"
|
|
349
353
|
: "never started",
|
|
350
354
|
}
|
|
351
355
|
|
|
352
356
|
// A post-mortem drops the container and setup rows on purpose. Their only source is the
|
|
353
357
|
// machine's state *now* — and a task that is over no longer owns its machine, so those two rows
|
|
354
358
|
// would describe someone else's boot. What is left is recorded: which worker it got, whether
|
|
355
|
-
// its branch commands ran, whether a session ever started.
|
|
356
|
-
const rest = [branch, session]
|
|
359
|
+
// its branch commands ran (an old task), whether a session ever started.
|
|
360
|
+
const rest = legacyBranch ? [branch, session] : [session]
|
|
357
361
|
return queued ? [machine, container, setupStep, ...rest] : [machine, ...rest]
|
|
358
362
|
}
|
|
359
363
|
|
|
@@ -49,6 +49,11 @@ export interface NewTaskComposerProps {
|
|
|
49
49
|
/** Branches common to the project's repositories. Any name typed is accepted too. */
|
|
50
50
|
branches?: string[]
|
|
51
51
|
defaultBranch?: string | null
|
|
52
|
+
/**
|
|
53
|
+
* No Base branch chip: the starting point is decided elsewhere — a snapshot, which is cloned from
|
|
54
|
+
* nothing. The value typed so far is not sent either.
|
|
55
|
+
*/
|
|
56
|
+
hideBaseBranch?: boolean
|
|
52
57
|
modelGroups?: NewTaskModelGroup[]
|
|
53
58
|
/** The project's default model — what the chip says when nobody picked one. */
|
|
54
59
|
defaultModel?: string | null
|
|
@@ -226,6 +231,7 @@ export function NewTaskComposer({
|
|
|
226
231
|
onProjectChange,
|
|
227
232
|
branches = [],
|
|
228
233
|
defaultBranch = null,
|
|
234
|
+
hideBaseBranch = false,
|
|
229
235
|
modelGroups = [],
|
|
230
236
|
defaultModel = null,
|
|
231
237
|
fields = [],
|
|
@@ -281,7 +287,7 @@ export function NewTaskComposer({
|
|
|
281
287
|
onSubmit({
|
|
282
288
|
...(asksProject ? { projectId } : {}),
|
|
283
289
|
prompt: prompt.trim(),
|
|
284
|
-
...(baseBranch.trim() ? { baseBranch: baseBranch.trim() } : {}),
|
|
290
|
+
...(baseBranch.trim() && !hideBaseBranch ? { baseBranch: baseBranch.trim() } : {}),
|
|
285
291
|
...(model.trim() ? { model: model.trim() } : {}),
|
|
286
292
|
files: draft.files,
|
|
287
293
|
...(Object.keys(values).length > 0 ? { fields: values } : {}),
|
|
@@ -320,7 +326,7 @@ export function NewTaskComposer({
|
|
|
320
326
|
<p className="mt-3 text-base font-semibold">What should the agent do?</p>
|
|
321
327
|
<p className="mt-1 text-xs leading-relaxed text-muted-foreground">
|
|
322
328
|
{description ??
|
|
323
|
-
"It gets its own machine
|
|
329
|
+
"It gets its own machine. Its session streams right here as soon as it starts — answer it as it works."}
|
|
324
330
|
</p>
|
|
325
331
|
</div>
|
|
326
332
|
</div>
|
|
@@ -392,15 +398,17 @@ export function NewTaskComposer({
|
|
|
392
398
|
</span>
|
|
393
399
|
))}
|
|
394
400
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
{!hideBaseBranch && (
|
|
402
|
+
<FreeTextChip
|
|
403
|
+
label="Base branch"
|
|
404
|
+
icon={<GitBranchIcon />}
|
|
405
|
+
value={baseBranch}
|
|
406
|
+
onChange={setBaseBranch}
|
|
407
|
+
placeholder={defaultBranch ?? "default branch"}
|
|
408
|
+
groups={[{ id: "branches", items: branches.map((b) => ({ value: b })) }]}
|
|
409
|
+
searchPlaceholder="Start from…"
|
|
410
|
+
/>
|
|
411
|
+
)}
|
|
404
412
|
|
|
405
413
|
<FreeTextChip
|
|
406
414
|
label="Model"
|
|
@@ -261,7 +261,7 @@ export function TaskList<T extends TaskItem>({
|
|
|
261
261
|
<div>
|
|
262
262
|
<p className="text-sm font-medium">No tasks yet</p>
|
|
263
263
|
<p className="mt-0.5 text-xs text-muted-foreground">
|
|
264
|
-
Delegate a unit of work — it gets its own
|
|
264
|
+
Delegate a unit of work — it gets its own sandbox and agent session
|
|
265
265
|
</p>
|
|
266
266
|
</div>
|
|
267
267
|
{emptyAction}
|
|
@@ -92,19 +92,26 @@ describe("boot steps", () => {
|
|
|
92
92
|
|
|
93
93
|
it("is looking for a machine while queued without a worker", () => {
|
|
94
94
|
const steps = bootSteps({ task: task({ state: "queued" }), worker: null, commands: [] })
|
|
95
|
-
|
|
95
|
+
// RFC 0056: no Branch step — Spunto creates no branch, the agent does if it wants one.
|
|
96
|
+
expect(steps.map((s) => s.key)).toEqual(["machine", "container", "setup", "session"])
|
|
96
97
|
expect(steps[0].state).toBe("running")
|
|
97
98
|
})
|
|
98
99
|
|
|
100
|
+
it("starts the session step once the machine is set up, with nothing in between", () => {
|
|
101
|
+
const worker = { id: "w1", name: "sbx-1", state: "ready", dockerState: "running", createdAt: "2026-09-20T00:00:00Z" }
|
|
102
|
+
const steps = bootSteps({ task: task({ state: "queued", branch: null }), worker, commands: [] })
|
|
103
|
+
expect(steps.find((s) => s.key === "session")).toMatchObject({ state: "running", detail: "starts as soon as the machine is ready" })
|
|
104
|
+
})
|
|
105
|
+
|
|
99
106
|
it("says the machine was never allocated on a task that died before one", () => {
|
|
100
107
|
const steps = bootSteps({ task: task({ state: "failed" }), worker: null, commands: [] })
|
|
101
108
|
// A post-mortem drops the container/setup rows: the machine is no longer the task's.
|
|
102
|
-
expect(steps.map((s) => s.key)).toEqual(["machine", "
|
|
109
|
+
expect(steps.map((s) => s.key)).toEqual(["machine", "session"])
|
|
103
110
|
expect(steps[0].state).toBe("error")
|
|
104
|
-
expect(steps[
|
|
111
|
+
expect(steps[1].detail).toBe("never started")
|
|
105
112
|
})
|
|
106
113
|
|
|
107
|
-
it("starts the session step once the branch is ready
|
|
114
|
+
it("an older task, branched by the platform: starts the session step once the branch is ready", () => {
|
|
108
115
|
const worker = { id: "w1", name: "pool-1", state: "ready", dockerState: "running", createdAt: "2026-09-20T00:00:00Z" }
|
|
109
116
|
const steps = bootSteps({ task: task({ state: "queued" }), worker, commands: [branchSetup("succeeded")] })
|
|
110
117
|
expect(steps.find((s) => s.key === "machine")?.detail).toBe("recycled from the pool · pool-1")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
import { describe, expect, it } from "vitest"
|
|
3
|
+
import { PALETTES, PALETTE_BY_ID, contrast, hex, palettesStylesheet, type Oklch } from "./palettes"
|
|
4
|
+
import committed from "../palettes.css?raw"
|
|
5
|
+
|
|
6
|
+
// What a palette must hold to be offered: each colour real in sRGB, a logo and a band that read,
|
|
7
|
+
// a button that reads in both themes — and palettes.css being what src/palettes.ts says.
|
|
8
|
+
|
|
9
|
+
const WHITE: Oklch = { l: 0.99, c: 0.006, h: 0 }
|
|
10
|
+
const inSrgb = (c: Oklch) => /^#[0-9a-f]{6}$/.test(hex(c))
|
|
11
|
+
|
|
12
|
+
describe("palettes", () => {
|
|
13
|
+
it("are 50, with unique ids", () => {
|
|
14
|
+
expect(PALETTES).toHaveLength(50)
|
|
15
|
+
expect(Object.keys(PALETTE_BY_ID)).toHaveLength(50)
|
|
16
|
+
for (const p of PALETTES) expect(p.id).toMatch(/^[a-z]+-[a-z]+$/)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it.each(PALETTES.map((p) => [p.id, p] as const))("%s fits sRGB and reads", (_, p) => {
|
|
20
|
+
for (const c of [p.field, p.signal, p.tone]) expect(inSrgb(c)).toBe(true)
|
|
21
|
+
// The logo tile and any text on a band: signal on field (and field on signal, the dark primary).
|
|
22
|
+
expect(contrast(p.signal, p.field)).toBeGreaterThanOrEqual(7)
|
|
23
|
+
// Light primary: near-white text on the tone.
|
|
24
|
+
expect(contrast(WHITE, p.tone)).toBeGreaterThanOrEqual(4.5)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it("palettes.css is up to date (npm run palettes)", () => {
|
|
28
|
+
expect(committed).toBe(palettesStylesheet())
|
|
29
|
+
})
|
|
30
|
+
})
|
package/src/palettes.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// Palettes — 50 field / signal pairs to wear on anything, like a product's pair but without a product.
|
|
2
|
+
//
|
|
3
|
+
// One table (FIELDS) → 50 palettes, each brought into the sRGB gamut, with the tokens a
|
|
4
|
+
// `data-palette` block sets and the paint of its logo. Pure (no DOM): the same module writes
|
|
5
|
+
// `palettes.css` (scripts/generate-palettes.ts), paints static logos (export-logo.ts --palettes),
|
|
6
|
+
// gives the brand kit its hex (a PNG or an MP4 frame can't read a CSS variable) and is tested in
|
|
7
|
+
// palettes.test.ts (gamut, contrast, the CSS being up to date).
|
|
8
|
+
//
|
|
9
|
+
// Same three values as the products in styles.css: field L 0.27 C 0.07, signal L 0.87, tone
|
|
10
|
+
// (the light theme's primary) L 0.49 C 0.16 — so a palette sits in the universe like a product.
|
|
11
|
+
// To change one, edit its line in FIELDS and run `npm run palettes` (the test fails otherwise).
|
|
12
|
+
|
|
13
|
+
export type Oklch = { l: number; c: number; h: number }
|
|
14
|
+
|
|
15
|
+
export interface Palette {
|
|
16
|
+
/** `<field>-<signal>`, the value of `data-palette`. */
|
|
17
|
+
id: string
|
|
18
|
+
/** French display name: « Lagon · ambre ». */
|
|
19
|
+
name: string
|
|
20
|
+
/** The field's hue family (`dusk`, `lagoon`…, or `graphite`). */
|
|
21
|
+
family: string
|
|
22
|
+
field: Oklch
|
|
23
|
+
signal: Oklch
|
|
24
|
+
tone: Oklch
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ─── Colour: OKLCH → sRGB, gamut, contrast ─────────────────────────────────
|
|
28
|
+
|
|
29
|
+
function oklchToLinear({ l, c, h }: Oklch): [number, number, number] {
|
|
30
|
+
const a = c * Math.cos((h * Math.PI) / 180)
|
|
31
|
+
const b = c * Math.sin((h * Math.PI) / 180)
|
|
32
|
+
const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3
|
|
33
|
+
const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3
|
|
34
|
+
const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3
|
|
35
|
+
return [
|
|
36
|
+
4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,
|
|
37
|
+
-1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,
|
|
38
|
+
-0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_,
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const inGamut = (c: Oklch) => oklchToLinear(c).every((v) => v >= -1e-4 && v <= 1 + 1e-4)
|
|
43
|
+
|
|
44
|
+
/** Lowers the chroma until the colour fits in sRGB (hue and lightness kept). */
|
|
45
|
+
export function fit(c: Oklch): Oklch {
|
|
46
|
+
let { l, c: ch, h } = c
|
|
47
|
+
while (ch > 0 && !inGamut({ l, c: ch, h })) ch -= 0.002
|
|
48
|
+
return { l, c: Math.max(0, +ch.toFixed(3)), h }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function hex(c: Oklch): string {
|
|
52
|
+
return (
|
|
53
|
+
"#" +
|
|
54
|
+
oklchToLinear(c)
|
|
55
|
+
.map((v) => Math.min(1, Math.max(0, v)))
|
|
56
|
+
.map((v) => (v <= 0.0031308 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055))
|
|
57
|
+
.map((v) => Math.round(v * 255).toString(16).padStart(2, "0"))
|
|
58
|
+
.join("")
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const luminance = (c: Oklch) => {
|
|
63
|
+
const [r, g, b] = oklchToLinear(c).map((v) => Math.min(1, Math.max(0, v)))
|
|
64
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b
|
|
65
|
+
}
|
|
66
|
+
/** WCAG 2 contrast ratio between two colours. */
|
|
67
|
+
export function contrast(a: Oklch, b: Oklch): number {
|
|
68
|
+
const [x, y] = [luminance(a), luminance(b)].sort((p, q) => q - p)
|
|
69
|
+
return (x + 0.05) / (y + 0.05)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const css = ({ l, c, h }: Oklch) => `oklch(${l} ${c} ${h})`
|
|
73
|
+
|
|
74
|
+
// ─── The table ─────────────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
// 24 field hues (every 15°) + graphite. Each field gets two signals: « ton sur ton » (its own
|
|
77
|
+
// hue, light) and « contraste » (a hue chosen far from it).
|
|
78
|
+
const FIELDS: Array<[id: string, name: string, hue: number, contrastHue: number]> = [
|
|
79
|
+
["garnet", "Grenat", 15, 86],
|
|
80
|
+
["brick", "Brique", 30, 200],
|
|
81
|
+
["rust", "Rouille", 45, 230],
|
|
82
|
+
["copper", "Cuivre", 60, 180],
|
|
83
|
+
["tobacco", "Tabac", 75, 350],
|
|
84
|
+
["bronze", "Bronze", 90, 260],
|
|
85
|
+
["olive", "Olive", 105, 30],
|
|
86
|
+
["moss", "Mousse", 120, 55],
|
|
87
|
+
["fern", "Fougère", 135, 330],
|
|
88
|
+
["pine", "Sapin", 150, 110],
|
|
89
|
+
["emerald", "Émeraude", 165, 15],
|
|
90
|
+
["lagoon", "Lagon", 180, 75],
|
|
91
|
+
["petrol", "Pétrole", 195, 45],
|
|
92
|
+
["abyss", "Abysse", 210, 125],
|
|
93
|
+
["slate", "Ardoise", 225, 60],
|
|
94
|
+
["navy", "Marine", 240, 86],
|
|
95
|
+
["ink", "Encre", 255, 30],
|
|
96
|
+
["indigo", "Indigo", 270, 140],
|
|
97
|
+
["dusk", "Crépuscule", 285, 86], // = Spunto Cloud
|
|
98
|
+
["amethyst", "Améthyste", 300, 160],
|
|
99
|
+
["aubergine", "Aubergine", 315, 100],
|
|
100
|
+
["plum", "Prune", 330, 190],
|
|
101
|
+
["mulberry", "Mûre", 345, 120],
|
|
102
|
+
["wine", "Lie-de-vin", 0, 70],
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
// A signal's name, by its hue.
|
|
106
|
+
const SIGNAL_NAMES: Array<[upTo: number, id: string, name: string]> = [
|
|
107
|
+
[10, "petal", "pétale"], [25, "coral", "corail"], [45, "peach", "pêche"], [70, "apricot", "abricot"],
|
|
108
|
+
[92, "amber", "ambre"], [105, "honey", "miel"], [118, "lemon", "citron"], [135, "lime", "pousse"],
|
|
109
|
+
[155, "mint", "menthe"], [175, "jade", "jade"], [195, "aqua", "eau"], [215, "glacier", "glacier"],
|
|
110
|
+
[240, "sky", "ciel"], [265, "periwinkle", "pervenche"], [290, "lilac", "lilas"], [320, "orchid", "orchidée"],
|
|
111
|
+
[345, "rose", "rose"], [361, "petal", "pétale"],
|
|
112
|
+
]
|
|
113
|
+
const signalName = (h: number) => SIGNAL_NAMES.find(([upTo]) => ((h % 360) + 360) % 360 < upTo)!
|
|
114
|
+
|
|
115
|
+
function palette(fieldId: string, fieldName: string, hue: number, sigHue: number, sigC: number): Palette {
|
|
116
|
+
const field = fit({ l: 0.27, c: 0.07, h: hue })
|
|
117
|
+
// Cyans hold a chroma other hues can't: capped, or they shout.
|
|
118
|
+
const h = ((sigHue % 360) + 360) % 360
|
|
119
|
+
const signal = fit({ l: 0.87, c: h >= 165 && h <= 225 ? Math.min(sigC, 0.1) : sigC, h: sigHue })
|
|
120
|
+
const tone = fit({ l: 0.49, c: 0.16, h: hue })
|
|
121
|
+
const [, sid, sname] = signalName(sigHue)
|
|
122
|
+
return { id: `${fieldId}-${sid}`, name: `${fieldName} · ${sname}`, family: fieldId, field, signal, tone }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const PALETTES: Palette[] = [
|
|
126
|
+
...FIELDS.flatMap(([id, name, hue, contrastHue]) => [
|
|
127
|
+
palette(id, name, hue, hue + 12, 0.11), // ton sur ton
|
|
128
|
+
palette(id, name, hue, contrastHue, 0.14), // contrast
|
|
129
|
+
]),
|
|
130
|
+
// The neutrals: graphite · paper (the design system's own pair) and graphite · amber.
|
|
131
|
+
{
|
|
132
|
+
id: "graphite-paper", name: "Graphite · papier", family: "graphite",
|
|
133
|
+
field: { l: 0.22, c: 0.012, h: 165 }, signal: { l: 0.96, c: 0.01, h: 150 }, tone: { l: 0.42, c: 0.02, h: 165 },
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: "graphite-amber", name: "Graphite · ambre", family: "graphite",
|
|
137
|
+
field: { l: 0.22, c: 0.012, h: 165 }, signal: fit({ l: 0.87, c: 0.14, h: 86 }), tone: { l: 0.42, c: 0.02, h: 165 },
|
|
138
|
+
},
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
// ─── What a palette sets: its CSS block (light + dark) and its logo ────────
|
|
142
|
+
|
|
143
|
+
const WHITE: Oklch = { l: 0.99, c: 0.006, h: 0 }
|
|
144
|
+
|
|
145
|
+
/** The light and dark blocks for `[data-palette="<id>"]` — literal values, like the product blocks.
|
|
146
|
+
`--night`, Build/Ship/Run and the chart ramp derive from them in styles.css. */
|
|
147
|
+
export function paletteCss(p: Palette): string {
|
|
148
|
+
const { field, signal, tone } = p
|
|
149
|
+
const h = field.h
|
|
150
|
+
const light = {
|
|
151
|
+
"--field": css(field), "--signal": css(signal), "--tone": css(tone),
|
|
152
|
+
"--primary": css(tone), "--primary-foreground": css({ ...WHITE, h }), "--ring": css(tone),
|
|
153
|
+
"--accent": css({ l: 0.945, c: 0.03, h }), "--accent-foreground": css({ l: 0.32, c: 0.07, h }),
|
|
154
|
+
"--sidebar-primary": css(tone), "--sidebar-primary-foreground": css({ ...WHITE, h }),
|
|
155
|
+
"--sidebar-accent": css({ l: 0.935, c: 0.03, h }), "--sidebar-accent-foreground": css({ l: 0.3, c: 0.07, h }),
|
|
156
|
+
"--sidebar-ring": css(tone), "--flame": css(tone),
|
|
157
|
+
}
|
|
158
|
+
const dark = {
|
|
159
|
+
"--field": css(field), "--signal": css(signal), "--tone": css(tone),
|
|
160
|
+
"--primary": css(signal), "--primary-foreground": css(field), "--ring": css(signal),
|
|
161
|
+
"--accent": css({ l: 0.28, c: 0.035, h }), "--accent-foreground": css({ l: 0.95, c: 0.01, h }),
|
|
162
|
+
"--sidebar-primary": css(signal), "--sidebar-primary-foreground": css(field),
|
|
163
|
+
"--sidebar-accent": css({ l: 0.26, c: 0.03, h }), "--sidebar-accent-foreground": css({ l: 0.95, c: 0.01, h }),
|
|
164
|
+
"--sidebar-ring": css(signal), "--flame": css(signal),
|
|
165
|
+
}
|
|
166
|
+
const block = (o: Record<string, string>) => Object.entries(o).map(([k, v]) => ` ${k}: ${v};`).join("\n")
|
|
167
|
+
return `[data-palette="${p.id}"] {\n${block(light)}\n}\n.dark [data-palette="${p.id}"],\n.dark[data-palette="${p.id}"] {\n${block(dark)}\n}\n`
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** A palette's logo paint — signal tile, field ink (like `tone="product"`). */
|
|
171
|
+
export const paletteLogo = (p: Palette) => ({ tile: hex(p.signal), ink: hex(p.field) })
|
|
172
|
+
|
|
173
|
+
/** Every palette by id. */
|
|
174
|
+
export const PALETTE_BY_ID: Record<string, Palette> = Object.fromEntries(PALETTES.map((p) => [p.id, p]))
|
|
175
|
+
|
|
176
|
+
/** A palette's three colours in hex — for what can't read CSS (an export, a canvas, an email). */
|
|
177
|
+
export const paletteHex = (p: Palette) => ({ field: hex(p.field), signal: hex(p.signal), tone: hex(p.tone) })
|
|
178
|
+
|
|
179
|
+
/** The whole of `palettes.css` (scripts/generate-palettes.ts writes it, the test compares). */
|
|
180
|
+
export function palettesStylesheet(): string {
|
|
181
|
+
return `/* @spunto/design-system — palettes.css. GENERATED from src/palettes.ts by
|
|
182
|
+
* scripts/generate-palettes.ts (\`npm run palettes\`): don't edit by hand.
|
|
183
|
+
*
|
|
184
|
+
* Opt-in: import it after styles.css, then wear a palette on any subtree with
|
|
185
|
+
* \`data-palette="<id>"\` — the same cascade as \`data-product\`, light and dark. */
|
|
186
|
+
|
|
187
|
+
${PALETTES.map(paletteCss).join("\n")}`
|
|
188
|
+
}
|
package/styles.css
CHANGED
|
@@ -670,7 +670,8 @@
|
|
|
670
670
|
--code-surface: oklch(0.19 0.012 165);
|
|
671
671
|
}
|
|
672
672
|
:root,
|
|
673
|
-
[data-product]
|
|
673
|
+
[data-product],
|
|
674
|
+
[data-palette] {
|
|
674
675
|
--night: var(--field);
|
|
675
676
|
}
|
|
676
677
|
|
|
@@ -678,11 +679,12 @@
|
|
|
678
679
|
* Build / Ship / Run (the dashboard's semantics) and the chart ramp are not
|
|
679
680
|
* colours of their own: they run from the product's signal (Build, the most
|
|
680
681
|
* alive) to its mid tone `--tone` (Run, what settled). Declared on every
|
|
681
|
-
* `[data-product]` so a subtree wearing
|
|
682
|
-
* same reason as `--night` above. Dark lifts the ramp: Run can't sit at the
|
|
682
|
+
* `[data-product]` (and `[data-palette]`, palettes.css) so a subtree wearing
|
|
683
|
+
* another product re-derives them — same reason as `--night` above. Dark lifts the ramp: Run can't sit at the
|
|
683
684
|
* mid tone on a near-black ground. */
|
|
684
685
|
:root,
|
|
685
|
-
[data-product]
|
|
686
|
+
[data-product],
|
|
687
|
+
[data-palette] {
|
|
686
688
|
--build: color-mix(in oklch, var(--signal) 80%, var(--tone));
|
|
687
689
|
--ship: color-mix(in oklch, var(--signal) 40%, var(--tone));
|
|
688
690
|
--run: var(--tone);
|
|
@@ -694,7 +696,9 @@
|
|
|
694
696
|
}
|
|
695
697
|
.dark,
|
|
696
698
|
.dark [data-product],
|
|
697
|
-
.dark[data-product]
|
|
699
|
+
.dark[data-product],
|
|
700
|
+
.dark [data-palette],
|
|
701
|
+
.dark[data-palette] {
|
|
698
702
|
--build: var(--signal);
|
|
699
703
|
--ship: color-mix(in oklch, var(--signal) 70%, var(--tone));
|
|
700
704
|
--run: color-mix(in oklch, var(--signal) 50%, var(--tone));
|