Skip to content

Agent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages

v2.1 (wip): app screens round-4 fixes (a face of its own, data truth, charts)

Leonxlnx3dba5acc82d8
diff --git a/skills/taste-skill/assets/app.css b/skills/taste-skill/assets/app.css
index a95f3f7..865e4ed 100644
--- a/skills/taste-skill/assets/app.css
+++ b/skills/taste-skill/assets/app.css
@@ -20,12 +20,14 @@
--accent: #1f6f5c; /* one hue: data, focus, the selected thing */
--primary: #1d1f20; /* the primary button is near-black unless the style says otherwise */
--primary-ink: #ffffff;
- --positive: #2f8a57; --negative: #c23a26; --warning: #a15c07;
- --pill-positive-bg: #e3f5ea; --pill-positive-ink: #134227;
- --pill-negative-bg: #fdecea; --pill-negative-ink: #7d1d14;
- --pill-warning-bg: #fff6e0; --pill-warning-ink: #6b3d04;
+ --positive: #247b50; --negative: #c4242a; --warning: #92400e; /* references/app-screens.md §9.5; a green accent is also --positive */
+ --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
+ --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
+ --pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e;
--pill-neutral-bg: #eeeeee; --pill-neutral-ink: #3d3d3d;
--chart-1: var(--accent); --chart-2: #8fb8ad; --chart-3: #b08a2e; --chart-muted: #cfd3d6;
+ --chart-mark: var(--text); /* a marked period in Charts.diverging: the second tone */
+ --chart-span: 0.06; /* opacity of a shaded span (a selling window, an outage) */
--grid: var(--rule); /* chart gridlines (charts.js) */
--axis-ink: var(--muted); /* chart tick labels (charts.js) */
--ink: var(--text);
@@ -37,7 +39,7 @@
--pad: 24px; /* canvas padding */
--gap: 16px; /* one gutter, horizontal and vertical */
--card-pad: 20px;
- --radius-card: 12px; /* tight family: 6–8 / soft family: 16–20; decide once */
+ --radius-card: 8px; /* radius is bimodal: tight 4–8 (controls 6) or soft 16–24 (controls full); never 11–12 */
--radius-control: 6px;
--control-height: 32px; /* every control in the title and filter rows */
--row-height: 48px; /* single-line table row */
@@ -46,6 +48,20 @@
--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
--t-press: 120ms; --t-hover: 150ms; --t-ui: 200ms;
}
+/* dark: one true-neutral ground, elevation by lightness; two greys that read apart (not #aaa beside #969696) */
+:root[data-theme="dark"] {
+ --ground: #000000; --surface: #111111; --raised: #222222; --active: #222222;
+ --border: #1a1a1a; --rule: #161616; --control: #444444;
+ --text: #ffffff; --muted: #b4b4b4; --faint: #949494;
+ --primary: #ffffff; --primary-ink: #000000;
+ --positive: #3fc07a; --negative: #e5566f; --warning: #e5a93b; /* a green or yellow-green accent is also --positive */
+ --pill-positive-bg: #172a1d; --pill-positive-ink: #3fc07a;
+ --pill-negative-bg: #2c1a20; --pill-negative-ink: #e5566f;
+ --pill-warning-bg: #2b2414; --pill-warning-ink: #e5a93b;
+ --pill-neutral-bg: #222222; --pill-neutral-ink: #ffffff;
+ --chart-muted: #4a4a4a; --grid: #2b2b2b;
+ --chart-span: 0.12;
+}
/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
@@ -84,6 +100,27 @@ a { color: inherit; text-decoration: none; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel h2 { font-size: var(--fs-section); line-height: 1.3; font-weight: 600; }
.panel .meta { color: var(--faint); font-size: var(--fs-small); }
+/* paired cards in one row: a card stretches to its neighbour only when it has content to fill. Otherwise it keeps
+ its own height (add .top to the row), and only an action or a total may be pinned to a stretched card's bottom */
+.grid.top { align-items: start; }
+
+/* a chart's heading row: its title (and legend or period) with a fixed 8px to the svg */
+.chart-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
+.chart-head h3 { font-size: var(--fs-body); line-height: 20px; font-weight: 500; }
+.chart { position: relative; min-width: 0; }
+
+/* a link at a card's foot or header ("Show all 7", "Sell-out history"): ink, a 12px chevron, an underline on hover,
+ and no inline padding, so its text sits on the card's content edge */
+.card-link { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; color: var(--text); font-weight: 500; cursor: pointer; text-underline-offset: 3px; }
+.card-link::after { content: ""; width: 12px; height: 12px; flex: none; background: currentColor; -webkit-mask: var(--chevron) center / 12px no-repeat; mask: var(--chevron) center / 12px no-repeat; }
+.card-link:hover { text-decoration: underline; }
+:root { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.5 2.5 8 6l-3.5 3.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
+
+/* list rows: a rule between rows and none above the first. A rule on a rounded box curls up at both ends, so a row
+ that carries a rule has square corners */
+.rows { display: grid; }
+.row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 0; }
+.row + .row { border-top: 1px solid var(--rule); border-radius: 0; }
/* KPIs as one divided strip: a label above a number, no icons, no tiles */
.kpis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
@@ -94,14 +131,23 @@ a { color: inherit; text-decoration: none; }
.kpi-value small { font-size: 0.55em; color: var(--muted); font-weight: 400; margin-left: 2px; }
.delta { margin-top: 4px; font-size: var(--fs-small); color: var(--muted); }
.delta .up { color: var(--positive); } .delta .down { color: var(--negative); }
+/* KPIs as the chart's tabs: the selected one carries a 2px rule and an ink label; the others keep a grey label and
+ their value in ink at a lighter weight (a grey value reads as disabled). When the tabs are the per-entity
+ breakdown the brief asks for (takings by shop), add .entities: nothing changes but the rule */
+.kpis[role="tablist"] .kpi { position: relative; cursor: pointer; }
+.kpis[role="tablist"] .kpi[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); }
+.kpis[role="tablist"]:not(.entities) .kpi[aria-selected="true"] .kpi-label { color: var(--text); }
+.kpis[role="tablist"]:not(.entities) .kpi[aria-selected="false"] .kpi-value { color: var(--text); font-weight: 400; }
/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { height: 36px; padding: 0 12px; text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
-td { height: var(--row-height); padding: 0 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
+/* cells share one baseline, so a figure never sits 2px below the name beside it; the row height comes from padding */
+td { padding: calc((var(--row-height) - 20px) / 2) 12px; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
tbody tr:last-child td { border-bottom: 0; }
-tbody tr:hover td { background: var(--raised); }
+/* no hover that changes the fill; a row that drives a detail pane takes the nav pill's fill when selected */
+tbody tr[aria-selected="true"] td { background: var(--active); }
th.n, td.n { text-align: right; }
td .sub { display: block; font-size: var(--fs-small); color: var(--muted); }
.truncate { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -124,26 +170,28 @@ td .sub { display: block; font-size: var(--fs-small); color: var(--muted); }
.input, select.input { height: 38px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); }
.input::placeholder { color: var(--faint); }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); }
-.tabs a { padding: 10px 0; color: var(--muted); box-shadow: inset 0 -2px 0 transparent; transition: color var(--t-hover) ease, box-shadow var(--t-hover) ease; }
-.tabs a[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--text); }
-.segmented { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--raised); }
+.tabs a { position: relative; padding: 10px 0; color: var(--muted); transition: color var(--t-hover) ease; }
+.tabs a[aria-selected="true"] { color: var(--text); }
+.tabs a[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); }
+/* as wide as its options; full width only on a narrow phone */
+.segmented { display: inline-flex; width: max-content; max-width: 100%; padding: 2px; border-radius: 8px; background: var(--raised); }
.segmented button { height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); }
.switch { appearance: none; width: 32px; height: 20px; border-radius: 999px; background: var(--control); position: relative; cursor: pointer; transition: background-color var(--t-ui) ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t-ui) var(--ease-out); }
.switch:checked { background: var(--text); } .switch:checked::after { transform: translateX(12px); }
-/* empty and loading states keep the frame */
+/* empty and loading states keep the frame; a loading value is a flat grey bar at its real size, with no shimmer */
.empty { display: grid; place-items: center; min-height: 96px; padding: 16px; border: 1px dashed var(--control); border-radius: var(--radius-control); color: var(--muted); text-align: center; }
-.skeleton { background: var(--raised); border-radius: 4px; animation: pulse 1.4s ease-in-out infinite; }
-@keyframes pulse { 50% { opacity: 0.55; } }
+.skeleton { background: var(--raised); border-radius: 4px; }
/* ---------- phone: the navigation folds away and the canvas takes the width ---------- */
.menu-toggle { display: none; }
@media (max-width: 860px) {
.app { grid-template-columns: minmax(0, 1fr); }
- .sidebar { position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 20; background: var(--surface); transform: translateX(-100%); transition: transform var(--t-ui) var(--ease-out); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0); }
- .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.32); }
+ /* the menu opens as a full-screen sheet */
+ .sidebar { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 20; background: var(--surface); transform: translateX(-100%); transition: transform var(--t-ui) var(--ease-out); }
+ .sidebar.open { transform: none; }
.menu-toggle { display: inline-flex; }
.canvas { padding: 16px; }
.grid > * { grid-column: 1 / -1 !important; }
@@ -151,8 +199,17 @@ td .sub { display: block; font-size: var(--fs-small); color: var(--muted); }
.kpi + .kpi { border-left: 0; }
.kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
.kpi:nth-child(2n) { border-left: 1px solid var(--border); }
+ /* an odd count leaves no half-empty row: the last cell takes the full width */
+ .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
+ /* KPI tabs in a 2-up grid: the selected cell takes a fill, never an underline floating mid-grid */
+ .kpis[role="tablist"] .kpi[aria-selected="true"] { background: var(--active); }
+ .kpis[role="tablist"] .kpi[aria-selected="true"]::after { content: none; }
.title-row { flex-wrap: wrap; align-items: flex-start; }
}
+@media (max-width: 480px) {
+ .segmented { display: flex; width: 100%; }
+ .segmented button { flex: 1; }
+}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; } }
/* an empty message spans the block it stands in, never one squeezed column */
diff --git a/skills/taste-skill/assets/charts.js b/skills/taste-skill/assets/charts.js
index 218c2a3..fa0f459 100644
--- a/skills/taste-skill/assets/charts.js
+++ b/skills/taste-skill/assets/charts.js
@@ -2,23 +2,39 @@
// They follow references/app-screens.md: one question per chart, one series that matters, 3–5 quiet
// horizontal gridlines, round ticks that top out above the largest value, 2px straight lines with no
// markers, square bars, no gradients, a bare tooltip, tabular figures. Colours come from CSS variables:
-// --chart-1 … --chart-4 (series), --chart-muted (other series), --grid, --axis-ink, --ink, --surface
+// --chart-1 … --chart-4 (series), --chart-muted (other series), --chart-mark (a marked period; ink by default),
+// --chart-span (the opacity of a shaded span: about .06 on light, .12 on dark), --chart-track (a time strip's track),
+// --grid, --axis-ink, --ink, --surface, --raised, --rule, --negative
// Usage (after this file loads):
// Charts.line(el, { labels: ['1 Oct', …], series: [{ name: 'Requests', values: [...] }], format: Charts.fmt.compact })
-// Charts.bars(el, { labels, values, highlight: 6, format }) one bar may carry the accent
+// Charts.bars(el, { labels, values, highlight: 6, format }) one bar (or [indices]) may carry the accent; dim: [indices]
+// Charts.diverging(el, { labels, up, down, above: 'Sold', below: 'Bought', mark: [3, 9], markLabel: 'Car charged' })
// Charts.ring(el, { value: 0.72, label: '72%', sub: 'of capacity' }) a progress ring with its total inside
-// Charts.barList(el, [{ label: 'Berlin', value: 412 }, …], { format }) a ranked list where the row is the bar
+// Charts.barList(el, [{ label: 'Berlin', value: 412 }, …], { format, thin }) a ranked list where the row is the bar
// Charts.plan(el, [{ label: 'Groceries', planned: 600, spent: 412, committed: 60 }, …], { scale: 'row' | 'plan' }) planned against spent
// Charts.bullet(el, [{ label: 'Bonds', value: 0.31, target: 0.25 }, …]) share against a target
-// line/bars also take annotations: [{ at: index, label: 'Deploy a3f09c1' }] or spans [{ from, to, label: 'Cloud' }],
-// and reference: { value, label, at: 'left' | 'right' } (put the label where no series passes)
-// line takes step: true for a balance that only changes on given days; today: index (the forecast after it is dashed);
-// endLabel: true (the last value at the line's end); max: caps a flat series with one spike (the peak is labelled)
-// Every chart gets role="img" and an aria-label that states what it shows.
+// Charts.timeline(el, rows, kinds, { days, today, weekends }) who is away when, each kind of booking its own mark
+// Charts.matrix(el, rows, { cols, comfort: 2, today }) slack against a minimum, team by day
+// Charts.timeStrip(el, rows, { open: '08:00', close: '15:00', compareLabel: 'Last Sunday' }) when, within the day
+// line, bars and diverging take annotations: [{ at: index, label: 'Deploy a3f09c1', short: 'a3f09c1' }] or spans
+// [{ from, to, label: 'Cloud' }]. Their labels sit in rows above the plot, measured once the fonts have loaded, and no
+// leader line crosses another label; the rows are reserved only when a label exists. reference: { value, label }, its
+// label set where no series passes.
+// line takes step: true for a balance that only changes on given days; today: index (the forecast after it is dashed)
+// with todayLabel: 'Now 20:34' (set clear of the line); endLabel: true (the last value at the line's end); max: caps a
+// flat series with one spike (the peak is labelled); yTicks: fixed ticks for a bounded quantity (0–100%); tickFormat:
+// axis labels apart from the tooltip format; xAt: the indices to label. Without xAt the x labels keep one step.
+// diverging, timeline, matrix and timeStrip return { svg, legend }, and line returns { legend } for two series or more:
+// the legend is drawn from the same style objects as the marks, so a swatch is always the mark scaled down. Put it in
+// the card's header, or pass legend: element (or a selector) to have it filled.
+// Numbers follow the page's language (<html lang>). Every chart gets role="img" and an aria-label that states what it shows.
(() => {
- const NS = 'http://www.w3.org/2000/svg';
+ const NS = 'http://www.w3.org/2000/svg', MINUS = '\u2212', ROW = 14, LANE = (rows) => 8 + rows * ROW + (rows ? 4 : 0);
const css = (el, name, fb) => getComputedStyle(el).getPropertyValue(name).trim() || fb;
- const svg = (tag, attrs = {}, parent) => { const n = document.createElementNS(NS, tag); for (const [k, v] of Object.entries(attrs)) n.setAttribute(k, v); if (parent) parent.appendChild(n); return n; };
+ const cssNum = (el, name, fb) => { const v = parseFloat(css(el, name, '')); return Number.isFinite(v) ? v : fb; };
+ const svg = (tag, attrs = {}, parent) => { const n = document.createElementNS(NS, tag); for (const [k, v] of Object.entries(attrs)) if (v != null) n.setAttribute(k, v); if (parent) parent.appendChild(n); return n; };
+ const text = (parent, str, attrs) => { const t = svg('text', attrs, parent); t.textContent = str; return t; };
+ const titled = (parent, str) => { svg('title', {}, parent).textContent = str; return parent; };
// numbers follow the page's language (<html lang>), so separators match the rest of the screen
const nf = (o) => new Intl.NumberFormat(document.documentElement.lang || 'en', o);
const fmt = {
@@ -28,7 +44,12 @@
money: (cur = 'EUR', d = 0) => (v) => nf({ style: 'currency', currency: cur, minimumFractionDigits: d, maximumFractionDigits: d }).format(v),
compact: (v) => nf({ notation: 'compact', maximumFractionDigits: 1 }).format(v),
ms: (v) => `${nf({ maximumFractionDigits: 0 }).format(v)} ms`,
+ // a sign on every change, with a true minus: fmt.signed() → '+2', '0', '−1'; fmt.signed(fmt.dec(1)) → '+0.4'
+ signed: (f = (v) => nf({ maximumFractionDigits: 0 }).format(v)) => (v) => (v > 0 ? '+' : v < 0 ? MINUS : '') + f(Math.abs(v)),
+ // minutes since midnight as a 24-hour time: 680 → '11:20'
+ clock: (m) => `${String(Math.floor(m / 60) % 24).padStart(2, '0')}:${String(Math.round(m % 60)).padStart(2, '0')}`, // taste-skill-ignore: a clock, not a counter
};
+ const minutes = (t) => (t == null || t === '' ? null : typeof t === 'number' ? t : (([hh, mm]) => hh * 60 + (mm || 0))(String(t).split(':').map(Number)));
// Round ticks (steps of 1, 2, 2.5 or 5 × 10^n) whose top sits above the largest value.
function ticks(min, max, count = 4) {
if (max === min) max = min + 1;
@@ -38,6 +59,46 @@
const out = []; for (let v = lo; v <= hi + step / 2; v += step) out.push(+v.toFixed(10));
return out;
}
+ // x labels keep one step all the way: every k-th label, with k chosen so the labels fit the width, and a step that
+ // lands on the last label when one gives enough labels. Never a forced end label that breaks the step. Clock labels
+ // ('08:30') step in whole hours (or halves and quarters) from a round time, so a half-hourly axis reads 06:00, 09:00.
+ function xPicks(labels, span, at) {
+ const n = labels.length;
+ if (at) return at.filter((i) => i >= 0 && i < n);
+ if (n <= 1) return n ? [0] : [];
+ const longest = Math.max(...labels.map((l) => String(l).length));
+ const cap = Math.max(2, Math.min(8, Math.floor(span / (longest * 7 + 18))));
+ if (n <= cap) return [...Array(n).keys()];
+ const mins = labels.every((l) => /^\d{1,2}:\d{2}$/.test(String(l))) ? labels.map(minutes) : null;
+ const d = mins ? mins[1] - mins[0] : 0;
+ let first = null, land = null;
+ for (let k = 1; k < n; k++) {
+ const stepM = k * d, clock = mins && d > 0;
+ if (clock && (stepM >= 60 ? ![1, 2, 3, 4, 6, 12].includes(stepM / 60) : 60 % stepM !== 0)) continue;
+ // start on a round time: a multiple of the step (09:00 for three hours), or a whole hour for shorter steps
+ let s = clock ? mins.findIndex((m) => m % Math.max(60, stepM) === 0) : 0;
+ if (s < 0) s = Math.max(0, mins.findIndex((m) => m % 60 === 0));
+ const count = Math.floor((n - 1 - s) / k) + 1;
+ if (count > cap) continue;
+ if (first == null) first = { k, s };
+ if ((n - 1 - s) % k === 0) { land = { k, s, count }; break; }
+ }
+ const pick = land && land.count >= Math.max(3, Math.ceil(cap * 0.6)) ? land : first || { k: n - 1, s: 0 };
+ const out = []; for (let i = pick.s; i < n; i += pick.k) out.push(i);
+ return out;
+ }
+ // colours: tokens resolved to rgb, so a mark can be mixed with the surface (a pale fill, a darker step)
+ const swatchProbe = document.createElement('span'); swatchProbe.style.display = 'none';
+ const rgb = (el, value) => {
+ el.appendChild(swatchProbe); swatchProbe.style.color = ''; swatchProbe.style.color = value;
+ const c = getComputedStyle(swatchProbe).color; swatchProbe.remove();
+ const m = c.match(/-?[\d.]+/g); if (!m || m.length < 3) return null;
+ return c.startsWith('color(') ? m.slice(0, 3).map((v) => Math.round(+v * 255)) : m.slice(0, 3).map(Number);
+ };
+ const mix = (el, a, b, t) => { const p = rgb(el, a), q = rgb(el, b); return p && q ? `rgb(${p.map((v, i) => Math.round(v * t + q[i] * (1 - t))).join(',')})` : a; };
+ // text width, measured in the chart's own face (falls back to an estimate when the chart is hidden)
+ const measure = (s, str, size = 11, weight = 400) => { const t = text(s, str, { x: -999, y: -999, 'font-size': size, 'font-weight': weight, visibility: 'hidden' }); let wd = 0; try { wd = t.getComputedTextLength(); } catch {} t.remove(); return wd > 0 ? wd : String(str).length * size * 0.56; };
+ const fit = (s, str, max, size, weight) => { str = String(str); if (measure(s, str, size, weight) <= max) return str; while (str.length > 1 && measure(s, str + '\u2026', size, weight) > max) str = str.slice(0, -1); return str.trimEnd() + '\u2026'; };
function frame(el, h) {
el.innerHTML = '';
const w = Math.max(240, el.clientWidth || 600);
@@ -49,52 +110,172 @@
if (!t) { t = document.createElement('div'); t.className = 'chart-tip'; t.style.cssText = 'position:absolute;pointer-events:none;padding:6px 8px;font:inherit;font-size:12px;line-height:1.35;border-radius:6px;white-space:nowrap;opacity:0;transition:opacity 120ms ease;background:var(--surface,#fff);color:var(--ink,#111);border:1px solid var(--grid,#e5e7eb)'; if (getComputedStyle(el).position === 'static') el.style.position = 'relative'; el.appendChild(t); }
return t;
}
- function axes(g, { w, h, padL, padB, padT, yt, y, xLabels, x, el, band = false }) {
- const grid = css(el, '--grid', '#e8e8e8'), ink = css(el, '--axis-ink', '#6b6b6b');
+ function axes(g, el, { w, h, padL, padB, yt, y, labels, x, band = false, at = null, tick, avoid = null }) {
+ const grid = css(el, '--grid', '#e8e8e8'), ink = css(el, '--axis-ink', '#6b6b6b'), s = g.ownerSVGElement;
for (const v of yt) {
const yy = y(v);
svg('line', { x1: padL, x2: w, y1: yy, y2: yy, stroke: grid, 'stroke-width': 1, 'shape-rendering': 'crispEdges' }, g);
- const t = svg('text', { x: padL - 8, y: yy + 4, 'text-anchor': 'end', 'font-size': 12, fill: ink }, g); t.textContent = el._fmt(v);
+ text(g, tick(v), { x: padL - 8, y: yy + 4, 'text-anchor': 'end', 'font-size': 12, fill: ink });
+ }
+ const n = labels.length;
+ for (const i of xPicks(labels, w - padL, at)) {
+ const lab = String(labels[i]), tw = measure(s, lab, 12), xx = x(i);
+ // the first and last labels are pulled inside the plot; none runs past either edge
+ let left = band ? xx - tw / 2 : i === 0 ? xx : i === n - 1 ? xx - tw : xx - tw / 2;
+ left = Math.max(band ? 0 : padL, Math.min(w - tw, left));
+ if (avoid && left < avoid[1] + 8 && left + tw > avoid[0] - 8) continue;
+ text(g, lab, { x: left, y: h - padB + 18, 'font-size': 12, fill: ink });
+ }
+ }
+ // Annotation labels sit in rows above the plot, never on the data. A label sits beside the top of its own leader
+ // line, right of it or left of it, in one of three rows. A place is free when no other label in that row overlaps
+ // it, no leader line passes through it, and its own leader passes through no label below it. The layout is searched
+ // (close markers often need the first label on the left so the next leader runs clear): full labels first, then
+ // short forms (`short`), and only then is a label dropped to its marker's tooltip, with a note in the console.
+ function lane(s, items, w, maxRows = 3) {
+ const gap = 6, rank = (it) => (it.fixed != null ? 0 : it.span ? 1 : 2);
+ // fixed captions first, then spans, then markers from left to right
+ const order = [...items].sort((a, b) => rank(a) - rank(b) || (a.x ?? a.x0) - (b.x ?? b.x0));
+ const opts = order.map((it) => {
+ const out = [];
+ for (const str of [it.label, it.short].filter(Boolean)) {
+ const tw = measure(s, str, 11) + (it.glyph ? 9 : 0), mid = it.span ? (it.x0 + it.x1) / 2 : 0;
+ const cands = it.fixed != null ? [[it.fixed, it.fixed + tw]] : it.span ? [[mid - tw / 2, mid + tw / 2], [it.x0, it.x0 + tw], [it.x1 - tw, it.x1]] : [[it.x + 4, it.x + 4 + tw], [it.x - 4 - tw, it.x - 4]];
+ for (let row = 0; row < maxRows; row++) for (const [x0, x1] of cands) if (x0 >= 0 && x1 <= w) out.push({ ...it, text: str, isShort: str !== it.label, row, x0, x1 });
+ }
+ return out;
+ });
+ const free = (c, placed) => placed.every((p) => p.dropped || (!(p.row === c.row && c.x0 < p.x1 + gap && c.x1 > p.x0 - gap)
+ && !(p.leader != null && p.row >= c.row && p.leader > c.x0 - 3 && p.leader < c.x1 + 3)
+ && !(c.leader != null && p.row <= c.row && c.leader > p.x0 - 3 && c.leader < p.x1 + 3)));
+ let best = null, steps = 0;
+ const solve = (i, placed, allowShort, allowDrop) => {
+ if (++steps > 20000) return false;
+ if (i === order.length) { best = placed.slice(); return true; }
+ for (const c of opts[i]) { if ((c.isShort && !allowShort) || !free(c, placed)) continue; placed.push(c); if (solve(i + 1, placed, allowShort, allowDrop)) return true; placed.pop(); }
+ if (allowDrop) { placed.push({ ...order[i], dropped: true }); if (solve(i + 1, placed, allowShort, allowDrop)) return true; placed.pop(); }
+ return false;
+ };
+ for (const [sh, dr] of [[false, false], [true, false], [true, true]]) { steps = 0; if (solve(0, [], sh, dr)) break; }
+ const placed = (best || []).filter((p) => !p.dropped), dropped = (best || order.map((it) => ({ ...it, dropped: true }))).filter((p) => p.dropped);
+ return { placed, dropped, rows: placed.length ? Math.max(...placed.map((p) => p.row)) + 1 : 0 };
+ }
+ function prepNotes(s, annotations = [], x, w, extra = []) {
+ const items = [];
+ for (const a of annotations || []) {
+ if (a.from != null) items.push({ span: true, x0: Math.min(x(a.from), x(a.to)), x1: Math.max(x(a.from), x(a.to)), label: a.label, short: a.short, colour: a.colour });
+ else if (a.at != null) items.push({ x: x(a.at), at: a.at, leader: x(a.at), label: a.label, short: a.short, colour: a.colour });
}
- const n = xLabels.length, every = n <= 8 ? 1 : Math.max(1, Math.ceil(n / 6));
- xLabels.forEach((lab, i) => { if (i % every && i !== n - 1) return; if (i === n - 1 && (n - 1) % every && (n - 1) % every < every / 2) return; const t = svg('text', { x: x(i), y: h - padB + 18, 'text-anchor': band ? 'middle' : i === 0 ? 'start' : i === n - 1 ? 'end' : 'middle', 'font-size': 12, fill: ink }, g); t.textContent = lab; });
+ items.push(...extra);
+ return { items, ...lane(s, items.filter((it) => it.label), w) };
}
- // Marks that explain the data: a 1px tick with a short label at an index (a deploy, a campaign), and a
- // dashed reference line with its label at the right end (a budget, an SLO, a start time).
- function notes(g, el, { annotations = [], reference = null, x, y, padT, h, padB, w, padL }) {
+ // shaded spans go under the data; marker lines and the label rows over it
+ function notesUnder(g, el, N, { padT, h, padB }) {
+ const ink = css(el, '--axis-ink', '#6b6b6b'), op = cssNum(el, '--chart-span', 0.07);
+ for (const it of N.items) if (it.span) svg('rect', { x: it.x0, y: padT, width: it.x1 - it.x0, height: h - padT - padB, fill: ink, opacity: op }, g);
+ }
+ function notesOver(g, el, N, { padT, h, padB }) {
const ink = css(el, '--axis-ink', '#6b6b6b');
- for (const a of annotations.filter((a) => a.from != null)) {
- const x0 = x(a.from), x1 = x(a.to);
- svg('rect', { x: Math.min(x0, x1), y: padT, width: Math.abs(x1 - x0), height: h - padT - padB, fill: ink, opacity: 0.07 }, g);
- if (a.label) { const t = svg('text', { x: (x0 + x1) / 2, y: padT + 10, 'text-anchor': 'middle', 'font-size': 11, fill: ink }, g); t.textContent = a.label; }
+ // a marker line runs to the plot's foot, or stops above the bar it points at (it.end)
+ for (const it of N.items) if (it.leader != null && !it.drawn) svg('line', { x1: it.leader, x2: it.leader, y1: padT, y2: Math.max(padT, it.end ?? h - padB), stroke: ink, 'stroke-width': 1, opacity: 0.45, 'shape-rendering': 'crispEdges' }, g);
+ for (const p of N.placed) {
+ const base = padT - 9 - p.row * ROW;
+ if (p.leader != null) svg('line', { x1: p.leader, x2: p.leader, y1: base - 8, y2: padT, stroke: ink, 'stroke-width': 1, opacity: 0.45, 'shape-rendering': 'crispEdges' }, g);
+ if (p.glyph) svg('path', { d: p.glyph === 'up' ? `M${p.x0} ${base - 1}l3 -6l3 6z` : `M${p.x0} ${base - 7}l3 6l3 -6z`, fill: ink }, g);
+ text(g, p.text, { x: p.x0 + (p.glyph ? 9 : 0), y: base, 'font-size': 11, fill: p.colour || ink });
+ }
+ const el2 = g.ownerSVGElement.parentNode; el2._warned = el2._warned || new Set();
+ for (const d of N.dropped) {
+ if (d.leader != null) { const hit = svg('line', { x1: d.leader, x2: d.leader, y1: padT, y2: h - padB, stroke: 'transparent', 'stroke-width': 8 }, g); titled(hit, d.label, {}); }
+ if (!el2._warned.has(d.label)) { el2._warned.add(d.label); console.warn(`Charts: no room above the plot for "${d.label}". Give it a short form (short) or label fewer markers.`); }
}
- for (const a of annotations.filter((a) => a.at != null)) {
- const xx = x(a.at);
- svg('line', { x1: xx, x2: xx, y1: padT, y2: h - padB, stroke: ink, 'stroke-width': 1, opacity: 0.45, 'shape-rendering': 'crispEdges' }, g);
- if (a.label) { const t = svg('text', { x: xx + 4, y: padT + 10, 'font-size': 11, fill: ink }, g); t.textContent = a.label; }
+ }
+ // does a label box touch a drawn line? polylines are [[x, y], …]; a box is { x0, x1, y0, y1 }
+ function hits(b, lines) {
+ for (const pts of lines) for (let k = 1; k < pts.length; k++) {
+ const a = pts[k - 1], c = pts[k]; if (!a || !c) continue;
+ if (a[0] === c[0]) { if (a[0] >= b.x0 - 3 && a[0] <= b.x1 + 3 && Math.max(a[1], c[1]) >= b.y0 - 3 && Math.min(a[1], c[1]) <= b.y1 + 3) return true; continue; }
+ const lo = Math.max(b.x0 - 3, Math.min(a[0], c[0])), hi = Math.min(b.x1 + 3, Math.max(a[0], c[0]));
+ for (let xx = lo; xx <= hi; xx += 2) { const yy = a[1] + ((xx - a[0]) / (c[0] - a[0])) * (c[1] - a[1]); if (yy >= b.y0 - 3 && yy <= b.y1 + 3) return true; }
}
- for (const r of [].concat(reference || [])) {
+ return false;
+ }
+ const boxHits = (b, boxes) => boxes.some((r) => b.x0 < r.x1 + 3 && b.x1 > r.x0 - 3 && b.y0 < r.y1 + 3 && b.y1 > r.y0 - 3);
+ // a reference line (a budget, an SLO) with its label at an end where no series passes
+ function references(g, el, refs, { y, padL, w, lines = [], boxes = [] }) {
+ const ink = css(el, '--axis-ink', '#6b6b6b'), s = g.ownerSVGElement;
+ for (const r of [].concat(refs || [])) {
const yy = y(r.value);
svg('line', { x1: padL, x2: w, y1: yy, y2: yy, stroke: ink, 'stroke-width': 1, 'stroke-dasharray': '4 4', opacity: 0.7 }, g);
- if (r.label) { const left = r.at === 'left'; const t = svg('text', { x: left ? padL + 4 : w, y: yy - 5, 'text-anchor': left ? 'start' : 'end', 'font-size': 11, fill: ink }, g); t.textContent = r.label; }
+ if (!r.label) continue;
+ const tw = measure(s, r.label, 11), right = r.at !== 'left';
+ const cand = [[right, -5], [right, 13], [!right, -5], [!right, 13]].map(([rt, dy]) => ({ x0: rt ? w - tw : padL + 4, x1: rt ? w : padL + 4 + tw, y0: yy + dy - 9, y1: yy + dy + 2, base: yy + dy }));
+ const b = cand.find((c) => !hits(c, lines) && !boxHits(c, boxes)) || cand[0];
+ text(g, r.label, { x: b.x0, y: b.base, 'font-size': 11, fill: ink });
+ }
+ }
+ // One style object per kind of mark draws both the mark and its legend swatch, so the two cannot drift apart.
+ function paintRect(parent, st, x, y, w, h, r = 0) {
+ let fill = st.fill || 'none';
+ if (st.hatch) {
+ const s = parent.ownerSVGElement || parent, id = 'h' + Math.random().toString(36).slice(2, 8);
+ const p = svg('pattern', { id, width: 5, height: 5, patternUnits: 'userSpaceOnUse', patternTransform: 'rotate(45)' }, svg('defs', {}, s));
+ svg('rect', { width: 5, height: 5, fill: st.fill }, p); svg('line', { x1: 0, y1: 0, x2: 0, y2: 5, stroke: st.hatch, 'stroke-width': 1.2 }, p);
+ fill = `url(#${id})`;
}
+ const inset = st.stroke ? (st.width || 1) / 2 : 0;
+ const n = svg('rect', { x: x + inset, y: y + inset, width: Math.max(0, w - inset * 2), height: Math.max(0, h - inset * 2), rx: r, fill, stroke: st.stroke, 'stroke-width': st.stroke ? st.width || 1 : null, 'stroke-dasharray': st.dash, opacity: st.opacity, 'shape-rendering': r ? null : 'crispEdges' }, parent);
+ if (st.edge) svg('rect', { x, y, width: 3, height: h, rx: Math.min(r, 1.5), fill: st.edge }, parent);
+ return n;
}
- function line(el, { labels, series, format = fmt.int, height = 220, fill = false, min, max, step = false, annotations, reference, today = null, endLabel = false }) {
+ const legendCss = ':where(.chart-legend){list-style:none;margin:0;padding:0;display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12px;line-height:16px;color:var(--muted,#5f6368)}:where(.chart-legend li){display:inline-flex;align-items:center;gap:6px;white-space:nowrap}:where(.chart-legend svg){flex:none;overflow:visible}@media (max-width:480px){:where(.chart-legend){display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}}';
+ function legendEl(items, target) {
+ if (!document.getElementById('charts-legend-css')) { const st = document.createElement('style'); st.id = 'charts-legend-css'; st.textContent = legendCss; document.head.appendChild(st); }
+ const ul = document.createElement('ul'); ul.className = 'chart-legend';
+ for (const it of items) {
+ const li = document.createElement('li'), sw = svg('svg', { width: it.w || 14, height: 12, 'aria-hidden': 'true' });
+ it.draw(sw); li.append(sw, document.createTextNode(it.label)); ul.appendChild(li);
+ }
+ const t = typeof target === 'string' ? document.querySelector(target) : target;
+ if (t) t.replaceChildren(ul);
+ return ul;
+ }
+ const rectSwatch = (st, w = 14, h = 10, r = 2) => (sw) => paintRect(sw, st, 0, (12 - h) / 2, w, h, r);
+ // charts are laid out with measured text: draw again once the page's fonts have arrived
+ function settle(draw) { if (document.fonts) { document.fonts.ready.then(draw); document.fonts.addEventListener?.('loadingdone', draw, { once: true }); } }
+ const heightOf = (h) => (typeof h === 'function' ? h() : h);
+
+ function line(el, { labels, series, format = fmt.int, tickFormat = null, height = 220, fill = false, min, max, step = false, annotations, reference, today = null, todayLabel = 'Today', endLabel = false, yTicks = null, xAt = null, legend = null }) {
el._fmt = format;
+ const colourOf = (sr, k) => sr.colour || (k === 0 ? css(el, '--chart-1', '#2f6fdf') : css(el, `--chart-${k + 1}`, css(el, '--chart-muted', '#a3a3a3')));
const draw = () => {
- const { s, w, h } = frame(el, height);
+ const { s, w, h } = frame(el, heightOf(height));
const all = series.flatMap((x) => x.values.filter((v) => v != null)).concat([].concat(reference || []).map((r) => r.value));
// max caps the range (a flat series with one spike): values above it are clipped and their peak labelled
const top = max ?? Math.max(...all);
- const yt = ticks(min ?? Math.min(0, ...all), top, 4);
+ const yt = yTicks || ticks(min ?? Math.min(0, ...all), top, 4);
+ const tick = tickFormat || format;
const lastVal = series[0].values.filter((v) => v != null).at(-1);
- const padL = 12 + Math.max(...yt.map((v) => String(format(v)).length)) * 7, padB = 26, padT = 8, padR = endLabel ? 8 + String(format(lastVal)).length * 7 : 0;
+ const padL = 12 + Math.max(...yt.map((v) => measure(s, tick(v), 12))), padB = 26, padR = endLabel ? 10 + measure(s, format(lastVal), 12, 600) : 0;
const x = (i) => padL + (i * (w - padL - padR)) / Math.max(1, labels.length - 1);
- const y = (v) => padT + (h - padT - padB) * (1 - (v - yt[0]) / (yt.at(-1) - yt[0]));
+ // the peaks clipped by max are labelled in the rows above the plot, where the line leaves it
+ const peaks = [];
+ series.forEach((sr, k) => sr.values.forEach((v, i) => { if (v != null && v > yt.at(-1) && (i === 0 || sr.values[i - 1] == null || sr.values[i - 1] <= yt.at(-1))) { let j = i, peak = v; while (j < sr.values.length && sr.values[j] != null && sr.values[j] > yt.at(-1)) { peak = Math.max(peak, sr.values[j]); j++; } peaks.push({ x: x(i), label: format(peak) + ' at ' + labels[i], colour: colourOf(sr, k) }); } }));
+ const scale = (N) => { const padT = LANE(N.rows); return { padT, y: (v) => padT + (h - padT - padB) * (1 - (v - yt[0]) / (yt.at(-1) - yt[0])) }; };
+ const linesAt = (y) => series.map((sr) => { const out = []; sr.values.forEach((v, i) => { if (v == null) { out.push(null); return; } const p = [x(i), y(Math.min(v, yt.at(-1)))]; const prev = out.at(-1); if (step && prev) out.push([p[0], prev[1]]); out.push(p); }); return out; }).concat([].concat(reference || []).map((r) => [[padL, y(r.value)], [w, y(r.value)]]));
+ let N = prepNotes(s, annotations, x, w, peaks), { padT, y } = scale(N), todayBox = null;
+ // the today label goes inside the plot on whichever side of its line no series crosses; failing that, above
+ if (today != null && todayLabel) {
+ const cut = x(today), tw = measure(s, todayLabel, 11), lines = linesAt(y);
+ const cand = [[cut + 4, h - padB - 6], [cut - 4 - tw, h - padB - 6], [cut + 4, padT + 11], [cut - 4 - tw, padT + 11]].map(([x0, b]) => ({ x0, x1: x0 + tw, y0: b - 9, y1: b + 2, base: b }));
+ todayBox = cand.find((b) => b.x0 >= padL && b.x1 <= w && !hits(b, lines)) || null;
+ if (!todayBox) { N = prepNotes(s, annotations, x, w, [...peaks, { x: cut, leader: cut, drawn: true, label: todayLabel }]); ({ padT, y } = scale(N)); }
+ }
const g = svg('g', {}, s);
- axes(g, { w, h, padL, padB, padT, yt, y, xLabels: labels, x, el });
+ axes(g, el, { w, h, padL, padB, yt, y, labels, x, at: xAt, tick });
+ notesUnder(g, el, N, { padT, h, padB });
series.forEach((sr, k) => {
- const col = sr.colour || (k === 0 ? css(el, '--chart-1', '#2f6fdf') : css(el, `--chart-${k + 1}`, css(el, '--chart-muted', '#a3a3a3')));
+ const col = colourOf(sr, k);
const pts = sr.values.map((v, i) => (v == null ? null : [x(i), y(Math.min(v, yt.at(-1)))]));
// step: a balance that only changes on given days holds its value until the next one
const d = pts.reduce((acc, p, i) => (p ? acc + (acc && pts[i - 1] ? (step ? `L${p[0].toFixed(1)} ${pts[i - 1][1].toFixed(1)}L` : 'L') : 'M') + p[0].toFixed(1) + ' ' + p[1].toFixed(1) : acc), '');
@@ -108,41 +289,89 @@
const b = svg('clipPath', { id: id + 'b' }, defs); svg('rect', { x: cut, y: 0, width: w, height: h }, b);
svg('path', { d, fill: 'none', stroke: col, 'stroke-width': 2, 'stroke-linejoin': 'round', 'clip-path': 'url(#' + id + 'a)' }, g);
svg('path', { d, fill: 'none', stroke: col, 'stroke-width': 2, 'stroke-dasharray': '5 4', opacity: 0.8, 'clip-path': 'url(#' + id + 'b)' }, g);
- if (k === 0) { svg('line', { x1: cut, x2: cut, y1: padT, y2: h - padB, stroke: css(el, '--axis-ink', '#6b6b6b'), 'stroke-width': 1, opacity: 0.4 }, g); const t = svg('text', { x: cut + 4, y: h - padB - 6, 'font-size': 11, fill: css(el, '--axis-ink', '#6b6b6b') }, g); t.textContent = 'Today'; }
+ if (k === 0) { svg('line', { x1: cut, x2: cut, y1: padT, y2: h - padB, stroke: css(el, '--axis-ink', '#6b6b6b'), 'stroke-width': 1, opacity: 0.4 }, g); if (todayBox) text(g, todayLabel, { x: todayBox.x0, y: todayBox.base, 'font-size': 11, fill: css(el, '--axis-ink', '#6b6b6b') }); }
}
- // values clipped by max: label the peak where it leaves the plot
- sr.values.forEach((v, i) => { if (v != null && v > yt.at(-1) && (i === 0 || sr.values[i - 1] == null || sr.values[i - 1] <= yt.at(-1))) { let j = i, peak = v; while (j < sr.values.length && sr.values[j] != null && sr.values[j] > yt.at(-1)) { peak = Math.max(peak, sr.values[j]); j++; } const t = svg('text', { x: x(i) + 4, y: padT + 10, 'font-size': 11, fill: col }, g); t.textContent = format(peak) + ' at ' + labels[i]; } });
- if (endLabel && k === 0) { const li = sr.values.map((v, i) => (v == null ? -1 : i)).filter((i) => i >= 0).at(-1); const t = svg('text', { x: x(li) + 6, y: y(Math.min(sr.values[li], yt.at(-1))) + 4, 'font-size': 12, 'font-weight': 600, fill: css(el, '--ink', '#111') }, g); t.textContent = format(sr.values[li]); }
+ if (endLabel && k === 0) { const li = sr.values.map((v, i) => (v == null ? -1 : i)).filter((i) => i >= 0).at(-1); text(g, format(sr.values[li]), { x: x(li) + 6, y: y(Math.min(sr.values[li], yt.at(-1))) + 4, 'font-size': 12, 'font-weight': 600, fill: css(el, '--ink', '#111') }); }
});
- notes(g, el, { annotations, reference, x, y, padT, h, padB, w, padL });
+ references(g, el, reference, { y, padL, w, lines: linesAt(y).slice(0, series.length) });
+ notesOver(g, el, N, { padT, h, padB });
// hover: a rule, a dot per series and a bare tooltip
const tip = tooltip(el), rule = svg('line', { y1: padT, y2: h - padB, stroke: css(el, '--axis-ink', '#6b6b6b'), 'stroke-width': 1, opacity: 0 }, g);
- const dots = series.map((sr, k) => svg('circle', { r: 3.5, fill: css(el, '--surface', '#fff'), stroke: sr.colour || css(el, `--chart-${k + 1}`, '#2f6fdf'), 'stroke-width': 2, opacity: 0 }, g));
+ const dots = series.map((sr, k) => svg('circle', { r: 3.5, fill: css(el, '--surface', '#fff'), stroke: colourOf(sr, k), 'stroke-width': 2, opacity: 0 }, g));
const hit = svg('rect', { x: padL, y: padT, width: w - padL, height: h - padT - padB, fill: 'transparent' }, s);
- const move = (ev) => { const r = s.getBoundingClientRect(); const px = ((ev.clientX - r.left) / r.width) * w; const i = Math.max(0, Math.min(labels.length - 1, Math.round(((px - padL) / (w - padL)) * (labels.length - 1)))); rule.setAttribute('x1', x(i)); rule.setAttribute('x2', x(i)); rule.setAttribute('opacity', 0.35); series.forEach((sr, k) => { const v = sr.values[i]; dots[k].setAttribute('cx', x(i)); dots[k].setAttribute('cy', v == null ? -99 : y(v)); dots[k].setAttribute('opacity', v == null ? 0 : 1); }); tip.innerHTML = `<div style="opacity:.7">${labels[i]}</div>` + series.map((sr) => `<div><b style="font-weight:600">${sr.values[i] == null ? '–' : format(sr.values[i])}</b> ${series.length > 1 ? sr.name : ''}</div>`).join(''); const left = Math.min((x(i) / w) * r.width + 12, r.width - tip.offsetWidth - 4); tip.style.left = `${Math.max(0, left)}px`; tip.style.top = '0px'; tip.style.opacity = 1; };
+ const move = (ev) => { const r = s.getBoundingClientRect(); const px = ((ev.clientX - r.left) / r.width) * w; const i = Math.max(0, Math.min(labels.length - 1, Math.round(((px - padL) / (w - padL - padR)) * (labels.length - 1)))); rule.setAttribute('x1', x(i)); rule.setAttribute('x2', x(i)); rule.setAttribute('opacity', 0.35); series.forEach((sr, k) => { const v = sr.values[i]; dots[k].setAttribute('cx', x(i)); dots[k].setAttribute('cy', v == null ? -99 : y(Math.min(v, yt.at(-1)))); dots[k].setAttribute('opacity', v == null ? 0 : 1); }); tip.innerHTML = `<div style="opacity:.7">${labels[i]}</div>` + series.map((sr) => `<div><b style="font-weight:600">${sr.values[i] == null ? '–' : format(sr.values[i])}</b> ${series.length > 1 ? sr.name : ''}</div>`).join(''); const left = Math.min((x(i) / w) * r.width + 12, r.width - tip.offsetWidth - 4); tip.style.left = `${Math.max(0, left)}px`; tip.style.top = '0px'; tip.style.opacity = 1; };
hit.addEventListener('pointermove', move); hit.addEventListener('pointerleave', () => { tip.style.opacity = 0; rule.setAttribute('opacity', 0); dots.forEach((d) => d.setAttribute('opacity', 0)); });
const last = series[0].values.filter((v) => v != null).at(-1);
s.setAttribute('aria-label', `${series.map((x) => x.name).join(', ')}, ${labels[0]} to ${labels.at(-1)}; latest ${last == null ? 'no data' : format(last)}`);
};
- draw(); watch(el, draw);
+ draw(); watch(el, draw); settle(draw);
+ const lg = series.length > 1 ? legendEl(series.map((sr, k) => ({ label: sr.name, w: 16, draw: (sw) => svg('line', { x1: 0, x2: 16, y1: 6, y2: 6, stroke: colourOf(sr, k), 'stroke-width': 2, 'stroke-dasharray': sr.dash ? '4 3' : null }, sw) })), legend) : null;
+ return { legend: lg };
}
- function bars(el, { labels, values, format = fmt.int, height = 200, highlight = null, colour, annotations, reference }) {
+ function bars(el, { labels, values, format = fmt.int, tickFormat = null, height = 200, highlight = null, dim = [], colour, mutedColour, annotations, reference, xAt = null }) {
el._fmt = format;
+ const lit = (i) => highlight == null || (Array.isArray(highlight) ? highlight.includes(i) : highlight === i);
const draw = () => {
- const { s, w, h } = frame(el, height);
- const yt = ticks(0, Math.max(...values, ...[].concat(reference || []).map((r) => r.value)), 4);
- const padL = 12 + Math.max(...yt.map((v) => String(format(v)).length)) * 7, padB = 26, padT = 8;
+ const { s, w, h } = frame(el, heightOf(height));
+ const yt = ticks(0, Math.max(...values, ...[].concat(reference || []).map((r) => r.value)), 4), tick = tickFormat || format;
+ const padL = 12 + Math.max(...yt.map((v) => measure(s, tick(v), 12))), padB = 26;
const band = (w - padL) / values.length, bw = Math.max(2, band * 0.62);
const x = (i) => padL + band * i + band / 2;
+ const N = prepNotes(s, annotations, x, w), padT = LANE(N.rows);
const y = (v) => padT + (h - padT - padB) * (1 - v / yt.at(-1));
const g = svg('g', {}, s);
- axes(g, { w, h, padL, padB, padT, yt, y, xLabels: labels, x, el, band: true });
- const main = colour || css(el, '--chart-1', '#2f6fdf'), muted = css(el, '--chart-muted', '#c9c9c9');
- values.forEach((v, i) => { const r = svg('rect', { x: x(i) - bw / 2, y: y(v), width: bw, height: Math.max(0, y(0) - y(v)), fill: highlight == null || highlight === i ? main : muted, 'shape-rendering': 'crispEdges' }, g); const t = svg('title', {}, r); t.textContent = `${labels[i]}: ${format(v)}`; });
- notes(g, el, { annotations, reference, x, y, padT, h, padB, w, padL });
+ axes(g, el, { w, h, padL, padB, yt, y, labels, x, band: true, at: xAt, tick });
+ notesUnder(g, el, N, { padT, h, padB });
+ for (const it of N.items) if (it.at != null && values[it.at] != null) it.end = y(values[it.at]) - 4;
+ const main = colour || css(el, '--chart-1', '#2f6fdf'), muted = mutedColour || css(el, '--chart-muted', '#c9c9c9');
+ values.forEach((v, i) => { const r = svg('rect', { x: x(i) - bw / 2, y: y(v), width: bw, height: Math.max(0, y(0) - y(v)), fill: lit(i) ? main : muted, opacity: dim.includes(i) ? 0.45 : null, 'shape-rendering': 'crispEdges' }, g); titled(r, `${labels[i]}: ${format(v)}`, {}); });
+ references(g, el, reference, { y, padL, w, boxes: values.map((v, i) => ({ x0: x(i) - bw / 2, x1: x(i) + bw / 2, y0: y(v), y1: y(0) })) });
+ notesOver(g, el, N, { padT, h, padB });
s.setAttribute('aria-label', `${labels.length} bars from ${labels[0]} to ${labels.at(-1)}; highest ${format(Math.max(...values))}`);
};
- draw(); watch(el, draw);
+ draw(); watch(el, draw); settle(draw);
+ }
+ // Two directions on one scale: what went out above the zero line and what came in below it (sold and bought,
+ // income and spend). The axis says which is which, with signed ticks and a caption on each side of zero.
+ // mark: [indices] draws those periods in a second tone with their own legend entry (the nights the car charged).
+ function diverging(el, { labels, up, down, values, above = 'Above', below = 'Below', mark = [], markLabel = null, markSide = 'below', partial = null, format = fmt.int, tickFormat = null, height = 200, annotations, reference, xAt = null, legend = null }) {
+ if (values) { up = values.map((v) => Math.max(0, v || 0)); down = values.map((v) => Math.max(0, -(v || 0))); }
+ up = up || labels.map(() => 0); down = down || labels.map(() => 0);
+ const st = { above: { fill: css(el, '--chart-1', '#2f6fdf') }, below: { fill: css(el, '--chart-muted', '#c9c9c9') }, mark: { fill: css(el, '--chart-mark', css(el, '--ink', '#111')) } };
+ const marked = (i, side) => mark.includes(i) && (markSide === 'both' || markSide === side);
+ const tick = (v) => (v > 0 ? '+' : v < 0 ? MINUS : '') + (tickFormat || format)(Math.abs(v));
+ const draw = () => {
+ const { s, w, h } = frame(el, heightOf(height));
+ const hiUp = Math.max(0, ...up), hiDown = Math.max(0, ...down);
+ const yt = ticks(-hiDown, hiUp || 1, 4); const stp = yt[1] - yt[0]; if (hiDown > 0 && yt[0] >= -hiDown) yt.unshift(+(yt[0] - stp).toFixed(10));
+ const padL = 12 + Math.max(...yt.map((v) => measure(s, tick(v), 12))), padB = 26;
+ const band = (w - padL) / labels.length, bw = Math.max(2, band * 0.62);
+ const x = (i) => padL + band * i + band / 2;
+ // the caption for the upper side opens the label rows above the plot; the lower one sits under the plot, at left
+ const N = prepNotes(s, annotations, x, w, [{ fixed: padL, glyph: 'up', label: above }]), padT = LANE(N.rows);
+ const y = (v) => padT + (h - padT - padB) * (1 - (v - yt[0]) / (yt.at(-1) - yt[0]));
+ const g = svg('g', {}, s), ink = css(el, '--axis-ink', '#6b6b6b');
+ const bwid = measure(s, below, 11) + 9;
+ axes(g, el, { w, h, padL, padB, yt, y, labels, x, band: true, at: xAt, tick, avoid: [padL, padL + bwid] });
+ svg('path', { d: `M${padL} ${h - padB + 11}l3 6l3 -6z`, fill: ink }, g); text(g, below, { x: padL + 9, y: h - padB + 18, 'font-size': 11, fill: ink });
+ notesUnder(g, el, N, { padT, h, padB });
+ for (const it of N.items) if (it.at != null) it.end = y(up[it.at] || 0) - 4;
+ labels.forEach((lab, i) => {
+ const o = partial === i ? 0.5 : null;
+ if (up[i] > 0) { const r = paintRect(g, { ...(marked(i, 'above') ? st.mark : st.above), opacity: o }, x(i) - bw / 2, y(up[i]), bw, Math.max(0, y(0) - y(up[i]) - 1)); titled(r, `${lab}: ${above} ${format(up[i])}`, {}); }
+ if (down[i] > 0) { const r = paintRect(g, { ...(marked(i, 'below') ? st.mark : st.below), opacity: o }, x(i) - bw / 2, y(0) + 1, bw, Math.max(0, y(-down[i]) - y(0) - 1)); titled(r, `${lab}: ${below} ${format(down[i])}`, {}); }
+ });
+ svg('line', { x1: padL, x2: w, y1: y(0), y2: y(0), stroke: ink, 'stroke-width': 1, opacity: 0.8, 'shape-rendering': 'crispEdges' }, g);
+ references(g, el, reference, { y, padL, w, boxes: labels.map((_, i) => ({ x0: x(i) - bw / 2, x1: x(i) + bw / 2, y0: y(up[i]), y1: y(-down[i]) })) });
+ notesOver(g, el, N, { padT, h, padB });
+ s.setAttribute('aria-label', `${above} above the line and ${below} below it, ${labels[0]} to ${labels.at(-1)}`);
+ };
+ draw(); watch(el, draw); settle(draw);
+ const items = [];
+ if (up.some((v) => v > 0)) items.push({ label: above, draw: rectSwatch(st.above) });
+ if (down.some((v) => v > 0)) items.push({ label: below, draw: rectSwatch(st.below) });
+ if (mark.length && markLabel) items.push({ label: markLabel, draw: rectSwatch(st.mark) });
+ return { get svg() { return el.querySelector(':scope > svg'); }, legend: legendEl(items, legend) };
}
function ring(el, { value, label, sub, size = 132, stroke = 8, colour }) {
el.innerHTML = '';
@@ -155,19 +384,27 @@
t.innerHTML = `<div style="font-size:${Math.round(size / 5.5)}px;font-weight:600;line-height:1">${label}</div>${sub ? `<div style="font-size:12px;opacity:.7;margin-top:4px">${sub}</div>` : ''}`;
wrap.appendChild(t); el.appendChild(wrap);
}
- function barList(el, rows, { format = fmt.int, colour } = {}) {
+ // A ranked list. By default the row's fill is the bar (a one-figure list); thin: true puts a 2px grey bar under each
+ // label instead, ink for the top item, for a ranked list of money in a narrow card.
+ function barList(el, rows, { format = fmt.int, colour, thin = false } = {}) {
el.innerHTML = '';
const max = Math.max(...rows.map((r) => r.value)) || 1;
- const list = document.createElement('ol'); list.style.cssText = 'list-style:none;margin:0;padding:0;display:grid;gap:2px;font-variant-numeric:tabular-nums';
+ const list = document.createElement('ol'); list.style.cssText = `list-style:none;margin:0;padding:0;display:grid;gap:${thin ? 10 : 2}px;font-variant-numeric:tabular-nums`;
const valueCol = Math.max(...rows.map((r) => String(format(r.value)).length)) + 1;
- for (const r of rows) {
- const li = document.createElement('li'); li.style.cssText = 'display:grid;grid-template-columns:minmax(0,1fr) ' + valueCol + 'ch;align-items:center;gap:12px';
- const track = document.createElement('span'); track.style.cssText = 'position:relative;padding:10px 12px;border-radius:6px;isolation:isolate;min-width:0';
- const bar = document.createElement('span'); bar.style.cssText = `position:absolute;inset:0 auto 0 0;width:${(r.value / max) * 100}%;background:${colour || 'var(--bar-fill, color-mix(in srgb, var(--chart-1, #2f6fdf) 12%, transparent))'};border-radius:inherit;z-index:-1`;
- track.append(bar); const a = document.createElement('span'); a.textContent = r.label; a.style.cssText = 'position:relative;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis'; track.append(a);
+ rows.forEach((r, k) => {
+ const li = document.createElement('li'); li.style.cssText = 'display:grid;grid-template-columns:minmax(0,1fr) ' + valueCol + 'ch;align-items:center;column-gap:12px';
+ const a = document.createElement('span'); a.textContent = r.label; a.style.cssText = 'position:relative;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis';
const b = document.createElement('span'); b.textContent = format(r.value); b.style.cssText = 'font-weight:500;text-align:right';
- li.append(track, b); list.appendChild(li);
- }
+ if (thin) {
+ const bar = document.createElement('span'); bar.style.cssText = `grid-column:1 / -1;height:2px;margin-top:4px;width:${(r.value / max) * 100}%;background:${k === 0 ? colour || 'var(--ink,#111)' : 'var(--chart-muted,#c9c9c9)'}`;
+ li.append(a, b, bar);
+ } else {
+ const track = document.createElement('span'); track.style.cssText = 'position:relative;padding:10px 12px;border-radius:6px;isolation:isolate;min-width:0';
+ const bar = document.createElement('span'); bar.style.cssText = `position:absolute;inset:0 auto 0 0;width:${(r.value / max) * 100}%;background:${colour || 'var(--bar-fill, color-mix(in srgb, var(--chart-1, #2f6fdf) 12%, transparent))'};border-radius:inherit;z-index:-1`;
+ track.append(bar, a); li.append(track, b);
+ }
+ list.appendChild(li);
+ });
el.appendChild(list);
}
// Planned against spent: the track is the plan, the fill what is spent, a lighter segment what is
@@ -209,6 +446,172 @@
}
el.appendChild(list);
}
+ // shared by the row charts (timeline, matrix, time strip): a label column with an optional grey subline.
+ // A subline needs a 40-44px row pitch; one-line labels sit on 32px.
+ function rowLabel(g, s, el, r, { y0, pitch, lw }) {
+ const ink = css(el, '--ink', '#111'), muted = css(el, '--axis-ink', '#6b6b6b');
+ if (r.sub) { text(g, fit(s, r.label, lw - 12, 14), { x: 0, y: y0 + pitch / 2 - 3, 'font-size': 14, fill: ink }); text(g, fit(s, r.sub, lw - 12, 12), { x: 0, y: y0 + pitch / 2 + 13, 'font-size': 12, fill: muted }); }
+ else text(g, fit(s, r.label, lw - 12, 14), { x: 0, y: y0 + pitch / 2 + 5, 'font-size': 14, fill: ink });
+ }
+ const dayText = (d) => (typeof d === 'object' && d ? d.label : String(d));
+ // day headers: the full label when every one fits its column, else the short form ('19'), else every k-th short
+ // label with today always shown and its neighbours left out, so no two headers ever touch
+ function dayHeads(g, s, el, days, { x0, cw, y, today }) {
+ const ink = css(el, '--ink', '#111'), muted = css(el, '--axis-ink', '#6b6b6b');
+ const full = days.map(dayText), short = days.map((d) => (typeof d === 'object' && d ? d.short || dayText(d) : dayText(d).split(' ').at(-1)));
+ const wide = (labs) => Math.max(...labs.map((t) => measure(s, t, 12))) + 6;
+ const labs = wide(full) <= cw ? full : short, k = Math.max(1, Math.ceil(wide(labs) / cw));
+ labs.forEach((t, i) => {
+ if (i !== today && (i % k || (today != null && k > 1 && Math.abs(i - today) < k))) return;
+ text(g, t, { x: x0 + i * cw + cw / 2, y, 'text-anchor': 'middle', 'font-size': 12, 'font-weight': i === today ? 600 : 400, fill: i === today ? ink : muted });
+ });
+ }
+ // The style of each kind of booking: a pale fill, a 1px diagonal hatch, a darker grey step, an outline, or the one
+ // chart hue for the screen's main data element. tone: 'negative' turns the edge and the label red (it needs a decision).
+ function kindStyle(el, k = {}) {
+ const ink = css(el, '--ink', '#111'), surface = css(el, '--surface', '#fff'), neg = css(el, '--negative', '#c4242a'), hue = k.colour || css(el, '--chart-1', '#2f6fdf');
+ const tone = k.tone === 'negative' ? { stroke: neg, width: 1.5 } : {};
+ const dash = k.dash ? { dash: '3 2' } : {};
+ if (k.mark === 'hatch') return { fill: mix(el, ink, surface, 0.04), hatch: mix(el, ink, surface, 0.32), ...tone, ...dash };
+ if (k.mark === 'step') return { fill: mix(el, ink, surface, 0.24), ...tone, ...dash };
+ if (k.mark === 'outline') return { fill: surface, stroke: mix(el, ink, surface, 0.55), width: 1, ...tone, ...dash };
+ if (k.mark === 'hue') return { fill: mix(el, hue, surface, 0.18), edge: hue, ...tone, ...dash };
+ return { fill: mix(el, ink, surface, 0.12), ...tone, ...dash };
+ }
+ // Who is away when: people (or rooms, vans) down the left, days across, a bar per booking told apart by its kind.
+ // rows: [{ label: 'Lena Hoffmann', sub: 'Product design · Berlin', bars: [{ from: 3, to: 7, kind: 'holiday', label, note }] }]
+ // and { group: 'Brand' } rows for a team subheader
+ // kinds: { holiday: { label: 'Holiday', mark: 'fill' | 'hatch' | 'step' | 'outline' | 'hue', code: 'H', tone, dash } }
+ // days: ['Mon 19', …] or [{ label: 'Mon 19', short: '19' }]; weekends: [indices]; today: index;
+ // holidays: [{ day: index, label: 'All Saints’ Day (Lisbon)' }]; onSelect(bar, row) makes the bars buttons.
+ // A label that does not fit its bar becomes the kind's code inside it, then goes after the bar's end (never into the
+ // days before it), and is always in the bar's tooltip.
+ function timeline(el, rows, kinds = {}, { days = [], weekends = [], today = null, holidays = [], labelWidth = null, rowHeight = null, barHeight = 22, onSelect = null, legend = null, extras = true } = {}) {
+ const draw = () => {
+ const pitch = rowHeight || (rows.some((r) => r.sub) ? 44 : 32), head = 30, groupH = 30;
+ const height = head + rows.reduce((a, r) => a + (r.group ? groupH : pitch), 0) + 2;
+ const { s, w, h } = frame(el, height);
+ const lw = labelWidth || Math.round(Math.min(220, Math.max(w < 480 ? 96 : 120, w * 0.2)));
+ const cw = (w - lw) / Math.max(1, days.length), col = (i) => lw + i * cw;
+ const ink = css(el, '--ink', '#111'), muted = css(el, '--axis-ink', '#6b6b6b'), rule = css(el, '--rule', '#f0f0f0'), raised = css(el, '--raised', '#f4f5f6'), hue = css(el, '--chart-1', '#2f6fdf');
+ const g = svg('g', {}, s);
+ // weekends one tone step darker, faint day lines, the day header (today in ink)
+ for (const i of weekends) svg('rect', { x: col(i), y: head, width: cw, height: h - head, fill: raised }, g);
+ for (let i = 0; i <= days.length; i++) svg('line', { x1: col(i), x2: col(i), y1: head, y2: h, stroke: rule, 'stroke-width': 1, 'shape-rendering': 'crispEdges' }, g);
+ dayHeads(g, s, el, days, { x0: lw, cw, y: head - 10, today });
+ for (const hd of holidays) { const c = svg('circle', { cx: col(hd.day) + cw / 2, cy: head - 3, r: 2, fill: muted }, g); titled(c, hd.label, {}); }
+ if (today != null) svg('line', { x1: col(today) + cw / 2, x2: col(today) + cw / 2, y1: head, y2: h, stroke: hue, 'stroke-width': 1, 'shape-rendering': 'crispEdges' }, g);
+ let y0 = head;
+ for (const r of rows) {
+ if (r.group) { svg('line', { x1: 0, x2: w, y1: y0 + 0.5, y2: y0 + 0.5, stroke: rule, 'stroke-width': 1 }, g); text(g, r.group, { x: 0, y: y0 + 20, 'font-size': 12, 'font-weight': 500, fill: muted }); y0 += groupH; continue; }
+ rowLabel(g, s, el, r, { y0, pitch, lw });
+ const bs = (r.bars || []).filter((b) => b.to >= 0 && b.from < days.length).sort((a, b) => a.from - b.from);
+ bs.forEach((b, k) => {
+ const kind = kinds[b.kind] || {}, st = kindStyle(el, kind);
+ const x0 = col(Math.max(0, b.from)) + 2, x1 = col(Math.min(days.length - 1, b.to) + 1) - 2, by = y0 + (pitch - barHeight) / 2;
+ const grp = svg('g', onSelect ? { tabindex: 0, role: 'button', style: 'cursor:pointer' } : {}, g);
+ paintRect(grp, st, x0, by, x1 - x0, barHeight, 4);
+ const label = b.label ?? kind.label ?? '', code = b.code ?? kind.code, tw = measure(s, label, 12), labInk = kind.tone === 'negative' ? css(el, '--negative', '#c4242a') : ink;
+ const next = bs[k + 1] ? col(Math.max(0, bs[k + 1].from)) : w;
+ // over a hatch the label keeps a halo of the bar's own fill, so the lines never run through the words
+ const halo = st.hatch ? { stroke: st.fill, 'stroke-width': 4, 'stroke-linejoin': 'round', 'paint-order': 'stroke' } : {};
+ if (label && tw + 16 <= x1 - x0) text(grp, label, { x: x0 + 8 + (st.edge ? 2 : 0), y: by + barHeight / 2 + 4, 'font-size': 12, fill: labInk, ...halo });
+ else if (code && measure(s, code, 12) + 8 <= x1 - x0) text(grp, code, { x: (x0 + x1) / 2, y: by + barHeight / 2 + 4, 'text-anchor': 'middle', 'font-size': 12, fill: labInk, ...halo });
+ else if (label && x1 + 6 + tw <= Math.min(next - 6, w)) text(grp, label, { x: x1 + 6, y: by + barHeight / 2 + 4, 'font-size': 12, fill: kind.tone === 'negative' ? labInk : muted });
+ titled(grp, `${r.label}: ${label}${b.note ? ' \u00b7 ' + b.note : ''}`, {});
+ if (onSelect) { grp.addEventListener('click', () => onSelect(b, r)); grp.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onSelect(b, r); } }); }
+ });
+ y0 += pitch;
+ }
+ s.setAttribute('aria-label', `${rows.filter((r) => !r.group).length} rows across ${days.length} days, ${dayText(days[0])} to ${dayText(days.at(-1))}`);
+ };
+ draw(); watch(el, draw); settle(draw);
+ const used = new Set(rows.flatMap((r) => (r.bars || []).map((b) => b.kind)));
+ const items = Object.entries(kinds).filter(([id]) => used.has(id)).map(([, k]) => ({ label: k.label, w: 22, draw: (sw) => { const st = kindStyle(el, k); paintRect(sw, st, 0, 0, 22, 12, 3); } }));
+ if (extras && today != null) items.push({ label: 'Today', w: 8, draw: (sw) => svg('line', { x1: 4, x2: 4, y1: 0, y2: 12, stroke: css(el, '--chart-1', '#2f6fdf'), 'stroke-width': 1.5 }, sw) });
+ return { get svg() { return el.querySelector(':scope > svg'); }, legend: legendEl(items, legend) };
+ }
+ // Is there enough cover? A team-by-day grid of slack against the minimum (+2, +1, 0, −1). Cells with room to spare
+ // stay plain, and one hue ramps toward the negative colour as the slack runs out; the headcount is in the tooltip.
+ // rows: [{ label: 'Product design', sub: 'needs 7 of 10', values: [2, 1, 0, -1, null, …], titles: ['8 in', …] }]
+ // cols: ['Mon 19', …]; comfort: the slack that needs no attention (2); null is a day with no cover to count (a dash)
+ function matrix(el, rows, { cols = [], comfort = 2, today = null, format = fmt.signed(), labelWidth = null, rowHeight = null, levels = ['Room to spare', 'Tight', 'At the minimum', 'Short'], legend = null } = {}) {
+ const level = (v) => (v >= comfort ? 0 : v > 0 ? 1 : v === 0 ? 2 : 3);
+ const styles = () => { const neg = css(el, '--negative', '#c4242a'), surface = css(el, '--surface', '#fff'), ink = css(el, '--ink', '#111'); return [{ fill: surface, ink: css(el, '--axis-ink', '#6b6b6b'), stroke: css(el, '--grid', '#e5e5e5') }, { fill: mix(el, neg, surface, 0.1), ink }, { fill: mix(el, neg, surface, 0.26), ink }, { fill: neg, ink: surface }]; };
+ const draw = () => {
+ const pitch = rowHeight || (rows.some((r) => r.sub) ? 44 : 32), head = 26;
+ const { s, w, h } = frame(el, head + rows.length * pitch);
+ const lw = labelWidth || Math.round(Math.min(220, Math.max(w < 480 ? 96 : 120, w * 0.22)));
+ const cw = (w - lw) / Math.max(1, cols.length), ST = styles(), muted = css(el, '--axis-ink', '#6b6b6b'), ink = css(el, '--ink', '#111');
+ const g = svg('g', {}, s);
+ dayHeads(g, s, el, cols, { x0: lw, cw, y: head - 10, today });
+ rows.forEach((r, k) => {
+ const y0 = head + k * pitch; rowLabel(g, s, el, r, { y0, pitch, lw });
+ const ch = Math.min(pitch - 6, 28), cy = y0 + (pitch - ch) / 2;
+ r.values.forEach((v, i) => {
+ const cx = lw + i * cw + 1;
+ if (v == null) { svg('rect', { x: cx + cw / 2 - 4, y: cy + ch / 2 - 1, width: 6, height: 2, fill: muted }, g); return; }
+ const st = ST[level(v)], cell = paintRect(g, { fill: st.fill }, cx, cy, cw - 2, ch, 3);
+ text(g, format(v), { x: cx + (cw - 2) / 2, y: cy + ch / 2 + 4, 'text-anchor': 'middle', 'font-size': 12, 'font-weight': level(v) === 3 ? 600 : 400, fill: st.ink });
+ titled(cell, `${r.label}, ${dayText(cols[i])}: ${r.titles?.[i] || format(v) + ' against the minimum'}`, {});
+ });
+ });
+ s.setAttribute('aria-label', `Cover against the minimum for ${rows.length} rows across ${cols.length} days`);
+ };
+ draw(); watch(el, draw); settle(draw);
+ const seen = new Set(rows.flatMap((r) => r.values.filter((v) => v != null).map(level)));
+ const ST = styles();
+ const items = [0, 1, 2, 3].filter((l) => seen.has(l)).map((l) => ({ label: levels[l], w: 14, draw: rectSwatch(l === 0 ? { fill: ST[0].fill, stroke: ST[0].stroke } : { fill: ST[l].fill }, 14, 12, 3) }));
+ return { get svg() { return el.querySelector(':scope > svg'); }, legend: legendEl(items, legend) };
+ }
+ // When, within the day: one row per item on a shared open–close axis. A 2px grey track, an ink dot at today's time and
+ // a hollow tick at the comparison day's, so "earlier than last Sunday" is drawn and not only written.
+ // rows: [{ label: 'White sourdough', sub: 'Headingley', at: '11:20', compare: '12:05', value: '11:20', note: '3 h 40 m before close' }]
+ // at or compare may be null (it did not sell out); step: minutes between axis labels (60).
+ function timeStrip(el, rows, { open = '08:00', close = '18:00', step = 60, todayLabel = 'Today', compareLabel = null, labelWidth = null, valueWidth = null, rowHeight = null, legend = null } = {}) {
+ const o = minutes(open), c = minutes(close);
+ const st = { today: { r: 4.5 }, compare: { w: 5, h: 12 } };
+ const dot = (parent, cx, cy) => svg('circle', { cx, cy, r: st.today.r, fill: css(el, '--ink', '#111') }, parent);
+ const tick = (parent, cx, cy) => svg('rect', { x: cx - st.compare.w / 2, y: cy - st.compare.h / 2, width: st.compare.w, height: st.compare.h, rx: 2.5, fill: css(el, '--surface', '#fff'), stroke: css(el, '--axis-ink', '#6b6b6b'), 'stroke-width': 1.5 }, parent);
+ const draw = () => {
+ const narrow = (el.clientWidth || 600) < 560, axisH = 24;
+ const pitch = rowHeight || (narrow ? 62 : rows.some((r) => r.sub || r.note) ? 44 : 32);
+ const { s, w, h } = frame(el, rows.length * pitch + axisH);
+ const lw = narrow ? 0 : labelWidth || Math.round(Math.min(200, Math.max(110, w * 0.26)));
+ const vw = narrow ? 0 : valueWidth ?? Math.min(w * 0.32, Math.max(0, ...rows.map((r) => Math.max(r.value ? measure(s, r.value, 13, 500) : 0, r.note ? measure(s, r.note, 12) : 0))) + (rows.some((r) => r.value || r.note) ? 16 : 0));
+ const x0 = narrow ? 18 : lw + 6, x1 = narrow ? w - 18 : w - vw - 6, tx = (m) => x0 + ((m - o) / Math.max(1, c - o)) * (x1 - x0);
+ const ink = css(el, '--ink', '#111'), muted = css(el, '--axis-ink', '#6b6b6b'), rule = css(el, '--rule', '#f0f0f0');
+ const track = css(el, '--chart-track', mix(el, ink, css(el, '--surface', '#fff'), 0.16));
+ const g = svg('g', {}, s), plotH = rows.length * pitch;
+ // the axis: one step from the opening, the labels thinned by the same rule as the charts
+ const marks = []; for (let m = Math.ceil(o / step) * step; m <= c; m += step) marks.push(m);
+ const picks = xPicks(marks.map(fmt.clock), x1 - x0);
+ for (const i of picks) { const xx = tx(marks[i]); if (!narrow) svg('line', { x1: xx, x2: xx, y1: 0, y2: plotH, stroke: rule, 'stroke-width': 1, 'shape-rendering': 'crispEdges' }, g); const lab = fmt.clock(marks[i]), tw = measure(s, lab, 12); text(g, lab, { x: Math.max(x0 - 2, Math.min(x1 + 6 - tw, xx - tw / 2)), y: plotH + 17, 'font-size': 12, fill: muted }); }
+ rows.forEach((r, k) => {
+ const y0 = k * pitch, cy = narrow ? y0 + pitch - 12 : y0 + pitch / 2;
+ if (narrow) {
+ const vwid = r.value ? measure(s, r.value, 13, 500) + 12 : 0;
+ text(g, fit(s, r.label, w - vwid, 14), { x: 0, y: y0 + 16, 'font-size': 14, fill: ink });
+ if (r.value) text(g, r.value, { x: w, y: y0 + 16, 'text-anchor': 'end', 'font-size': 13, 'font-weight': 500, fill: ink });
+ const second = [r.sub, r.note].filter(Boolean).join(' \u00b7 ');
+ if (second) text(g, fit(s, second, w, 12), { x: 0, y: y0 + 33, 'font-size': 12, fill: muted });
+ } else rowLabel(g, s, el, r, { y0, pitch, lw });
+ svg('line', { x1: x0, x2: x1, y1: cy, y2: cy, stroke: track, 'stroke-width': 2, 'stroke-linecap': 'round' }, g);
+ const cm = minutes(r.compare), am = minutes(r.at);
+ if (cm != null) titled(tick(g, tx(cm), cy), `${compareLabel || 'Comparison'}: ${fmt.clock(cm)}`, {});
+ if (am != null) titled(dot(g, tx(am), cy), `${todayLabel}: ${fmt.clock(am)}`, {});
+ if (narrow) return;
+ if (r.note) { if (r.value) text(g, r.value, { x: w, y: cy - 3, 'text-anchor': 'end', 'font-size': 13, 'font-weight': 500, fill: ink }); text(g, fit(s, r.note, vw - 8, 12), { x: w, y: r.value ? cy + 13 : cy + 4, 'text-anchor': 'end', 'font-size': 12, fill: muted }); }
+ else if (r.value) text(g, r.value, { x: w, y: cy + 5, 'text-anchor': 'end', 'font-size': 13, 'font-weight': 500, fill: ink });
+ });
+ s.setAttribute('aria-label', `${rows.length} rows between ${fmt.clock(o)} and ${fmt.clock(c)}`);
+ };
+ draw(); watch(el, draw); settle(draw);
+ const items = [];
+ if (rows.some((r) => minutes(r.at) != null)) items.push({ label: todayLabel, w: 10, draw: (sw) => dot(sw, 5, 6) });
+ if (compareLabel && rows.some((r) => minutes(r.compare) != null)) items.push({ label: compareLabel, w: 8, draw: (sw) => tick(sw, 4, 6) });
+ return { get svg() { return el.querySelector(':scope > svg'); }, legend: legendEl(items, legend) };
+ }
function watch(el, draw) { if (!('ResizeObserver' in window)) return; let w = el.clientWidth; new ResizeObserver(() => { if (Math.abs(el.clientWidth - w) > 4) { w = el.clientWidth; draw(); } }).observe(el); }
- window.Charts = { line, bars, ring, barList, plan, bullet, ticks, fmt };
+ window.Charts = { line, bars, diverging, ring, barList, plan, bullet, timeline, matrix, timeStrip, ticks, fmt };
})();
diff --git a/skills/taste-skill/library/app.json b/skills/taste-skill/library/app.json
index a1347ef..c06fb45 100644
--- a/skills/taste-skill/library/app.json
+++ b/skills/taste-skill/library/app.json
@@ -16,8 +16,8 @@
"workspace",
"builder"
],
- "idea": "The chrome holds no colour at all; money and counts are set in ink, and a single hue appears only where a figure changed.",
- "colourBudget": "under 1% coloured pixels; the chart is ink, the only hue is a small change signal",
+ "idea": "The chrome holds no colour at all; money and counts are set in ink, the one chart hue marks the screen's main data element, and the only other hue is a small signal where a figure changed.",
+ "colourBudget": "under 1% coloured pixels; the chrome is ink, the one chart hue goes on the main data element, and the only other hue is a small change signal",
"tokens": {
"ground": "#f8f8f8",
"surface": "#ffffff",
@@ -55,8 +55,8 @@
]
},
"radius": {
- "card": 12,
- "control": 8
+ "card": 8,
+ "control": 6
},
"font": {
"family": "Geist",
@@ -88,7 +88,12 @@
"icon-rail",
"no-sidebar"
],
- "signature": "No brand colour anywhere in the chrome: the one primary action is near-black (a grey pill, #e5e5e5, is the secondary), the main series is drawn in ink with the comparison or the part after the cursor in grey, zero balances are set in grey, and the only hue on the screen is a small triangle or a short coloured number where a figure changed.",
+ "signature": "No brand colour anywhere in the chrome: the one primary action is near-black (a grey pill, #e5e5e5, is the secondary), the main data element (today's series, the booked bars, the current period) takes the one chart hue, #1d5fbf, and everything else is drawn in ink with the comparison or the part after the cursor in grey, zero balances are set in grey, and the only hue on the screen is a small triangle or a short coloured number where a figure changed.",
+ "identity": [
+ "A ground from the product's world in place of #f8f8f8, one level off white and low in chroma: a stone (#f4f3f1) for a bakery or a shop, a sage (#f2f5f2) for a garden or a greenhouse, a blue-grey (#f2f4f7) for a ledger or a meter. Cards stay white; a warm tint stays under the cream check (saturation under about 15%).",
+ "The one chart hue (#1d5fbf, or the brand's own hue at 3:1 or more on white) on the screen's main data element: today's line, the booked bars, the current period's column, the margin that breaks. The chrome stays ink and the hue stays under 1% of the screen.",
+ "Every figure in Geist Mono, as the style's decision, so money and counts read as a ledger's columns while the text stays Geist. Lint and the inspector flag mono; give the reason in the report."
+ ],
"avoid": [
"a brand-coloured primary button",
"tinted cards or tinted KPI tiles",
@@ -96,7 +101,8 @@
"bold on anything but money",
"a chart with no y-scale (the study's one example of this look hid magnitude behind hover and was flagged)",
"a grey pill as the only button for the screen's main job: in testing an Approve repeated in grey on every row left the screen without a primary"
- ]
+ ],
+ "notes": "The studied screens of this kind used 11-12px card radii, which §9.4 counts among the rare middle values; the library sets the tight pair (8 and 6) so the style lands on the bimodal rule. After testing, the chart hue moved from an unused third series colour onto the main data element: a screen whose only hue was a delta read as a kit."
},
{
"id": "framed-sheet",
@@ -185,6 +191,11 @@
"shell": "framed-sheet",
"shellAlternatives": [],
"signature": "One tinted frame holds the sidebar and the 48px top bar with no rule between them; the page is a white sheet inset 8px from the window's right and bottom edges, with a 1px edge, 16px corners and no shadow. The active tab is a 2px underline in ink or the accent; everything else in the chrome is grey.",
+ "identity": [
+ "The frame tinted from the product's colour in place of #f9fbfc: one low-chroma step of its hue (a green-grey for a climate or farm tool, a blue-grey for an observability tool, a stone for a print shop). The sheet stays white.",
+ "The brand's own hue from the brief as --chart-1 in place of the dealt teal, on the main series and the one selected state, at 3:1 or more on white, never violet or indigo.",
+ "IBM Plex Mono for IDs, keys and the figures in tables (one job): its figures have their own drawing, and a developer reads them as the product's."
+ ],
"avoid": [
"a border between the sidebar and the top bar",
"a shadow under the sheet",
@@ -285,6 +296,11 @@
"ruled-t-frame"
],
"signature": "The full hue goes only on small marks: the one filled-button style, the data series and the active nav icon. Its 50-200 tints carry every area: the active nav row (tint fill with the dark ink of the hue), the plan or trial card, badges and progress tracks. The primary action may instead be near-black, as on the study's newsletter home.",
+ "identity": [
+ "The ladder built from the brand's own hue (its logo, the brief's object) in place of the dealt raspberry: the full hue on small marks, its pale tints on areas, never violet or indigo.",
+ "The product's objects in the lead block: the newsletter's latest issue as its cover, the shop's products as 40px thumbnails, the course's lessons with their own art.",
+ "A ground one level toward the hue's palest tint (#fbf7f8 for the raspberry) in place of #f9fafb, so the page and the tints read as one family."
+ ],
"avoid": [
"the full hue on large areas",
"a second accent family (four families on one screen was flagged in the study)",
@@ -375,6 +391,11 @@
"framed-sheet"
],
"signature": "The greeting is the h1, in a centred 1100px column on a real 12-column grid (77px columns, 16px gutters), with spans that change by row but share column lines (3/3/3/3, then 9/3, then 6/6, so every internal edge meets one above it). Every figure below is set at regular weight on tonal panels, one layer each: a panel one step off white holds its title and its content directly; a white inner card is used once, for the main chart.",
+ "identity": [
+ "The greeting names this team or household and today's one fact, set from the data (\"Morning, Okoro house. The car is ready by 06:10.\"), never \"Welcome back\".",
+ "Each person's stable hue as a pale tint on their avatar and their own lane or column (a couple and their joint account as three lanes): identity, not data, so it stays out of the chart legends.",
+ "A surface from the product's world in place of #f9f9f9, one level toward its material (a sage for a garden, a stone for a kitchen, a blue-grey for a studio), with the page white kept."
+ ],
"avoid": [
"an emoji in the greeting",
"a tracked uppercase date above the greeting (put the date after it or in the grey line below)",
@@ -471,6 +492,11 @@
"icon-rail"
],
"signature": "Pale category tiles with the dark of their own hue as ink (#dcf1ff with #0a3a80), one large radius (20px on cards, stepping down to 10, 8 and 5 inside), and quiet money polarity: income green with a plus sign, spending in ink, no red on ordinary outgoings. Tints go on small tiles, avatars and chips; a panel that holds a list stays white. When the product has people (two partners, a family), each gets one hue, at least 60 degrees from the next.",
+ "identity": [
+ "The tile hues from the account's own colours (the card's colour, each pot's colour in the app) in place of the dealt cobalt, each tile pale with the dark of its own hue as ink.",
+ "The money's own objects: the card art at its real ratio, merchant marks at 24px in the rows, the goal's picture on its pot.",
+ "Manrope's figures carry the balance: 30-36px at 600 with tabular figures and the pence in a smaller grey, so the number itself is the face."
+ ],
"avoid": [
"a gradient balance card",
"two data palettes on one page (flagged in the study)",
@@ -501,10 +527,10 @@
"rule": "#161616",
"control": "#444444",
"text": "#ffffff",
- "muted": "#aaaaaa",
- "faint": "#969696",
+ "muted": "#b4b4b4",
+ "faint": "#949494",
"accent": "#c6f24e",
- "positive": "#3fc07a",
+ "positive": "#c6f24e",
"negative": "#e5484d",
"warning": "#e5a93b",
"chart": [
@@ -514,8 +540,8 @@
],
"pills": {
"positive": [
- "#172a1d",
- "#3fc07a"
+ "#222a10",
+ "#c6f24e"
],
"negative": [
"#2c1a20",
@@ -564,6 +590,11 @@
"no-sidebar"
],
"signature": "Elevation by lightness alone (#000 ground, #111 card, #2a2a2a nested panel) with no borders or shadows on cards; the active nav item is marked only by its label going from #bbb to #fff; the primary control is made primary by inversion, a white 36px pill with black text.",
+ "identity": [
+ "The one data hue from the product's world in place of the dealt lime: a solar amber (#f2b33d) for an energy home, a sky blue (#4cb3f0) for water or weather, a lime only for sport. It is still the only hue on data and never touches buttons, tabs or nav. A green or yellow-green hue is also --positive; an amber that sits beside --warning leaves the warning to its pill pair.",
+ "A ground with the product's temperature: the studied #000 for media and events, a warm near-black (#0e0d0c) for a home, a cool one (#0c0d0f) for a monitor, with cards one lightness step above it (#181716, #15171a). Never navy or slate.",
+ "A signature element from the product's world as the lead: the energy home's power flow (sun, house, battery and grid with their live kW), an event's doors against capacity, an artist's release with its cover."
+ ],
"avoid": [
"a navy or slate dark theme",
"glow, neon borders or shadows",
@@ -571,7 +602,7 @@
"the accent on buttons, tabs or nav",
"a 64px top bar left empty across most of its width (flagged twice)"
],
- "notes": "The studied screens of this kind used a violet-magenta (#dd6cff) and an orange (#ff5500) as their one data hue. The library deals a lime, which keeps the move and stays clear of the violet ban and of the positive green. The tertiary grey is lifted from the measured #888 to #969696 so it still reads at 4.5:1 on the #2a2a2a nested panel."
+ "notes": "The studied screens of this kind used a violet-magenta (#dd6cff) and an orange (#ff5500) as their one data hue. The library deals a lime, which keeps the move and stays clear of the violet ban; because the lime is a yellow-green, it is also the positive colour (a second, mint green beside it read as two greens). The greys are #b4b4b4 for secondary text and #949494 for meta, 32 levels apart rather than the 20 of the measured #aaa and #969696, which read as one grey; #949494 still holds 4.5:1 on the #2a2a2a nested panel."
},
{
"id": "data-terminal",
@@ -654,6 +685,11 @@
"shell": "icon-rail",
"shellAlternatives": [],
"signature": "Every selection (tab, toggle, range, nav item) is a 1px accent line exactly as wide as its label, placed on the nearest existing edge; numbers stay white or grey and carry their sign in the text ('+$24,000,000').",
+ "identity": [
+ "Every figure in a monospace as the style's decision (IBM Plex Mono or JetBrains Mono for each price, count and time, digits that stack), with the text in Public Sans. Lint and the inspector flag mono; give the reason in the report.",
+ "The one accent line from the product's world in place of the dealt blue (the exchange's or the team's hue): still the only selection mark, never violet or indigo.",
+ "A signature of the market or the system as the lead: an order book's depth as two mirrored bar lists, an incident as a minute-by-minute strip, a region map with the list beside it."
+ ],
"avoid": [
"filled pill tabs or a coloured segmented control",
"a chart with no scale and no dates (the studied screen had none and was flagged)",
@@ -799,8 +835,8 @@
"commerce"
],
"basis": "a seller home",
- "blueprint": "One card per subject, 8-16px apart: the main chart card runs full width, and any card holding a table of five columns or fewer, or a short list, pairs with its neighbour in two columns, the page header indented by the card padding so the title, the card titles, the numbers and the plot share one left edge. Balances that do not change during the day go first, in one container split by 1px dividers into equal columns; a zero balance is grey and its caption becomes the next step. In the main card, 2-4 KPIs sit in a row and act as the chart's series tabs: the selected one in ink, the others grey with their label and value; choosing one swaps the series. Under them, one line chart as wide as the card's content (about 1136x220 in the study): 3-4 solid 1px gridlines, 4-6 round y ticks at 12px, a 2-3px line in ink with straight segments and no fill, an 8px hover dot with a 1px dashed guide and the line after the cursor in pale grey. Close with a 2-3 row comparison table on a 36px pitch, value and change columns right-aligned under a 14px grey header such as 'vs prior Monday'.",
- "phone": "KPI tabs become a 2-up row above the chart; the chart is full width, 160-200px tall, with 4 x labels; the comparison table keeps its two right-aligned columns."
+ "blueprint": "One card per subject, 8-16px apart: the main chart card runs full width, and any card holding a table of five columns or fewer, or a short list, pairs with its neighbour in two columns, the page header indented by the card padding so the title, the card titles, the numbers and the plot share one left edge. Balances that do not change during the day go first, in one container split by 1px dividers into equal columns; a zero balance is grey and its caption becomes the next step. In the main card, 2-4 KPIs sit in a row and act as the chart's series tabs: the selected one carries a 2px rule and an ink label, the others keep a grey label and their value in ink at a lighter weight (a grey value reads as disabled); when the tabs are the per-entity breakdown the brief asks for (takings by shop), nothing is greyed and the rule alone marks the selection. Choosing one swaps the series. Under them, one line chart as wide as the card's content (about 1136x220 in the study): 3-4 solid 1px gridlines, 4-6 round y ticks at 12px, a 2-3px line in ink with straight segments and no fill, an 8px hover dot with a 1px dashed guide and the line after the cursor in pale grey. Close with a 2-3 row comparison table on a 36px pitch, value and change columns right-aligned under a 14px grey header such as 'vs prior Monday'.",
+ "phone": "KPI tabs become a 2-up grid above the chart, with the selected cell marked by a fill (never an underline floating inside the grid) or a row of tabs that scrolls sideways; the chart is full width, 160-200px tall, with 4 x labels; the comparison table keeps its two right-aligned columns."
},
{
"id": "chart-pairs",
@@ -1048,6 +1084,85 @@
"basis": "house pattern from testing: built after a flat 24-hour chart filled a whole first screen and lost to a richer layout",
"blueprint": "Title row: the project's name as the h1 with a status pill (Healthy, Degraded) and a breadcrumb of team and product above it; repository, branch and a freshness stamp in a 14px grey line under it; the one primary action (Redeploy, or View logs when the latest deploy failed) on the right. Then a full-width card for what is live now: the production deployment's commit message at 16/600, its branch, short SHA in mono, author and age on the left, and three or four facts in divided cells on the right (domain, live since, build time, regions). Then the health strip: three or four KPIs in one divided container, each with its change in words and in the polarity colour when it moved the wrong way. Then a two-column row: the 24-hour chart at two-thirds (deploy markers as 1px ticks with their short SHA, the budget or SLO as a dashed reference line) and, at one-third, the block that explains the worst number (the spike and what reverted it, the status codes behind the error rate). Then the deployments table capped at 6 rows, a failed row carrying its failing step and a View logs action, a building row its elapsed time.",
"phone": "The live deployment card becomes a stack of label-value rows; the KPIs a 2x2 grid; the chart full width with its markers; the explanation under it; deployments as two-line rows with region and duration on line 2."
+ },
+ {
+ "id": "power-flow",
+ "name": "Power flow summary",
+ "signature": true,
+ "cues": [
+ "energy",
+ "solar",
+ "battery",
+ "kwh",
+ "tariff",
+ "heat pump",
+ "electric car",
+ "ev charger",
+ "home charger"
+ ],
+ "basis": "house pattern from round-4 testing: a home-energy overview without it read as the stock dark dashboard; real energy apps lead with this flow",
+ "blueprint": "A strip under the title row that answers \"where is the power going now?\": four nodes in one row (Sun, House, Battery, Grid), each a 14px label over its live figure at 20-24px with the unit as a grey suffix (2.4 kW), the battery's charge under its figure (88%). Between neighbours, a 2px connector only where power flows now, with its direction and amount in words above it (\"to battery 1.7 kW\"); an idle link is a 1px dashed rule in the grid colour. Solar and export carry the one data hue, import from the grid is grey, the house is ink. The flows balance and are built from one live-state object that also feeds the top bar and the charts: sun + grid import + battery out = house + battery in + export. A freshness stamp at the strip's right (\"Live · 20:34\").",
+ "phone": "The four nodes become a 2x2 grid in the same order (Sun, House / Battery, Grid) with the flow sentence under it (\"Sun 2.4 kW: house 0.7, battery 1.7\"), no connectors."
+ },
+ {
+ "id": "leave-timeline",
+ "name": "Team timeline with kind encoding",
+ "signature": true,
+ "cues": [
+ "leave",
+ "holiday",
+ "time off",
+ "absence",
+ "pto",
+ "vacation",
+ "rota",
+ "roster",
+ "shift",
+ "booking"
+ ],
+ "basis": "house pattern from round-4 testing: a leave calendar that drew every booking in the same pale grey read as a loading state",
+ "blueprint": "People down the left on a 160-220px column, grouped under 12px team subheaders; days across with weekends one tone step darker, faint 1px day lines, and today as a 1px line in the one data hue with its date in ink in the header. Each kind of booking has its own mark, drawn with `Charts.timeline(el, rows, kinds)`: holiday a pale fill, off sick a 1px diagonal hatch, long leave a darker grey step, working away an outline, a pending request a dashed outline. Full colour only for what needs a decision: a request that breaks cover is outlined and labelled in the negative colour. Bars 20-24px tall at radius 4; the label inside the bar, the kind's code when the bar is too short, then the label after the bar's end, never over the days before it. One-line names on a 32px pitch; a name with a subline (team, office) on 40-44px. A public holiday is a small dot under its date whose tooltip names the office. The legend is the one the helper returns, so each swatch is its mark scaled down and only kinds on screen are listed.",
+ "phone": "One week at a time, with the week switch in the same control row as any office filter; names shorten to first name and initial; the legend sits in a 2-column grid."
+ },
+ {
+ "id": "cover-matrix",
+ "name": "Cover against the minimum",
+ "signature": true,
+ "cues": [
+ "team cover",
+ "cover by",
+ "staffing",
+ "rota",
+ "roster",
+ "shift",
+ "coverage",
+ "on call",
+ "leave"
+ ],
+ "basis": "house pattern from round-4 testing: a grid of 120 absolute headcounts made the reader subtract each team's minimum in their head",
+ "blueprint": "A team-by-day matrix of slack against each team's minimum (+2, +1, 0, −1) rather than headcounts, drawn with `Charts.matrix(el, rows, { cols, comfort })`: the team and its rule (\"needs 7 of 10\") in a 160-220px label column on a 40-44px pitch, one cell per working day with the signed slack in 12px tabular figures. Cells with room to spare stay plain; one hue ramps toward the negative colour as the slack runs out (tight a pale tint, at the minimum a stronger tint, short the full negative with white figures), and the headcount sits in the tooltip (\"6 in of 9, needs 7\"). Today's column has its date in ink. The days that go short are the finding in the title row, beside the request that causes them.",
+ "phone": "The lowest slack per team for each week (four columns), with the days behind a tap; or one team at a time."
+ },
+ {
+ "id": "sell-out-strip",
+ "name": "Sell-out time strip",
+ "signature": true,
+ "cues": [
+ "bakery",
+ "cafe",
+ "café",
+ "kitchen",
+ "restaurant",
+ "sell-out",
+ "sell out",
+ "sold out",
+ "deli",
+ "menu",
+ "bake"
+ ],
+ "basis": "house pattern from round-4 testing: six 4px black bars for sell-out times were the loudest marks on a bakery screen and drew no comparison",
+ "blueprint": "One row per line that sold out, earliest first: the line and its shop on the left; a 2px grey track on a shared opening-to-closing axis with an ink dot at today's sell-out time and a hollow tick at the comparison day's (last Sunday), drawn with `Charts.timeStrip(el, rows, { open, close, compareLabel })`; the time on the right in ink with the gap under it in 12px grey, its baseline named (\"3 h 40 m before close\", \"45 m earlier than last Sunday\"). The lines that did not sell out are counted in one closing sentence, not drawn. Axis labels on one hourly step from opening; the legend (Today, Last Sunday) is the one the helper returns.",
+ "phone": "The rows keep the full width with axis labels every two hours; the gap moves under the line's name."
}
],
"kinds": {
diff --git a/skills/taste-skill/references/app-screens.md b/skills/taste-skill/references/app-screens.md
index 37f25b5..784439e 100644
--- a/skills/taste-skill/references/app-screens.md
+++ b/skills/taste-skill/references/app-screens.md
@@ -53,28 +53,48 @@ the same every time, and each is now a rule below:
Quiet is the starting point, not the goal. A screen that a person would trust shows more of the
product than a template does: its people, its objects, its numbers and the one thing to do next.
-**Give the product a face.** After three rounds the judges' last complaint was the same on most
-screens: "a well-applied kit, not a product with its own identity". The style's tokens make a screen
-correct; these make it this product's:
-
+**Give the product a face.** After four rounds the judges' top complaint was the same on most
+screens: "a well-applied kit, not a product with its own identity" (stock Geist or Inter, a #f8f8f8
+ground, white 12px cards, lime on black). The style's tokens make a screen correct; these make it
+this product's, and choosing them is a step of the run, not a finish (§2.3):
+
+- **One face from the sheet, chosen before you build.** Each style lists two or three ways it takes a
+ face from the brief: a ground tinted from the product's world, a figure face with character, the
+ brand's hue on the main data element. Choose one, write it in your notes next to the screen's
+ question, and check that it shows on the first screenshot.
- **The dealt typeface, really loaded.** A build that fell back to the default face landed on the
default look; the inspector now fails it.
- **The product's mark and name** at the top of the shell, drawn for this product (a simple
monogram or symbol in the accent, from its name or its object), never a black square with a letter.
-- **One element only this product has**, built from its own things: the pace groups of a running
- club as a unit chart, the couple as three lanes, a deploy's commit as the hero of the overview, the
- family's car on tonight's charging window. Name it in your notes next to the screen's question.
-- **Its people and objects as themselves**: each person gets a stable initial and hue (at least 60
- degrees from the next), products show their thumbnails, cover art shows the cover.
+- **One element only this product has**, built from its own things: an energy home's power flow, a
+ bakery's sell-out strip, a leave planner's cover against the minimum, the pace groups of a running
+ club as a unit chart, the couple as three lanes, a deploy's commit as the hero of the overview. The
+ sheet lists the library's signature elements whose words appear in the brief; otherwise invent one.
+ Name it in your notes next to the screen's question.
+- **The one chart hue on the main data element**: today's line, the booked bars, the current period,
+ the margin that breaks. A screen whose only hue is a delta reads as a kit, and the inspector warns
+ when a screen with charts carries no hue on its data (`no-data-hue`).
+- **Its people and objects as themselves**: each person gets a stable initial and a pale tint of their
+ own hue, with people listed next to each other at least 60 degrees apart. These tints are identity,
+ not data: they stay pale and out of the chart legends. Products show their thumbnails, cover art
+ shows the cover.
- **Words of the trade** in labels and empty states ("Waiting on the customer", "Off sick", "Due
on the 28th"), never the generic noun of a template ("Items", "Records", "Status").
**Calendars and timelines** (house rule, from testing; the study has none). People down the left on a
-fixed 160-220px column, days across with today marked by a 1px accent line and weekends one tone
-step darker; bars 20-24px tall on a 32-40px row pitch with radius 4; routine bookings in a pale
-neutral fill with ink text, the kind of leave or work told apart by a 3px left edge in its hue or a
-glyph, and colour at full strength only for what needs a decision (a request breaking cover). Every
-colour drawn is in the legend.
+fixed 160-220px column, grouped under a team subheader rather than repeating the team on every row;
+days across with faint 1px day lines, weekends one tone step darker, and today marked by a 1px line
+in the one data hue with its date in ink. Bars are 20-24px tall at radius 4. One-line names sit on a
+32px pitch; a name with a subline (team, office) needs 40-44px, or the subline touches the next name.
+**Every kind of booking has its own mark**, so sickness reads apart from a holiday at a glance:
+holiday a pale fill, off sick a 1px diagonal hatch, long leave a darker grey step, working away an
+outline, a pending request a dashed outline. A style with a hue budget may add a 3px left edge in the
+hue for the kind the screen is about. Full colour is only for what needs a decision (a request that
+breaks cover). A label sits inside its bar; a bar too short for it shows the kind's code inside and
+the full label in its tooltip, or the label after the bar's end, never over the days before it.
+Holiday markers name their office in a multi-office product. Every swatch in the legend is the mark
+itself, scaled down, and lists only kinds on screen: `Charts.timeline(el, rows, kinds)` draws the bars
+and returns that legend from the same kinds map.
## Contents
@@ -142,7 +162,26 @@ Totals are computed from the rows, never typed in separately. Small numbers stay
screens show new accounts with 1, 6 or 9 of something, drawn honestly at their real size. Write the
figures that must agree as assertions in the data file (`console.assert(sold - cancelled === rsvps)`,
the bins sum to the total, the parts to the whole) and read the console: in testing, a ticket table
-that did not reconcile with its own KPI cost a judge's trust in the whole screen.
+that did not reconcile with its own KPI cost a judge's trust in the whole screen. Checks that need
+computed values (allowance after a request, cover per day) go in the script that computes them.
+
+**Data that tells the truth** (house rules, from testing; judges checked every one of these):
+
+- **A fact shown twice is one variable.** A time window, a total or a state that appears in two cards
+ (the battery full 13:30-16:30 in the KPI label, the shaded span and the battery card) is one value in
+ the data file, and the copy and the chart annotation are both built from it. Two cards that
+ disagree by half an hour cost more trust than a missing card.
+- **Totals and deltas come from the parts as shown.** Sum the rounded pennies the screen displays,
+ never round the unrounded total separately: £21.68 + £8.34 − £3.81 is £26.21, and a screen that
+ says £26.22 is caught. A change is the difference of the two values on screen (£5.28 against
+ £5.22 is +£0.06, not +£0.07).
+- **Every relative figure names its baseline** in the same phrase: "3 h 40 m before close", "45 m
+ earlier than last Sunday", "+5 on the usual Monday". "Early", "up" or a bare "+5" next to another
+ time or figure reads as measured against that one.
+- **One name per time.** Shops close at 15:00 and the tills are cashed up at 15:12; the header and
+ the card use the same words for the same moment, and an error state rewrites the status line.
+- **If a caption has to say which bars are which, encode it in the chart instead**: a marked period in
+ a second tone with its own legend entry, a signed axis, a label on the mark.
### 2.2 Name the screen's one question
@@ -151,7 +190,9 @@ waiting for a reply?", "How much of this month's plan is left?". Write it in one
three things:
- **what is biggest.** In the study the largest block is always the one that carries the screen's
- question, whatever form it takes (a chart, a plan, a ring, a list);
+ question, whatever form it takes (a chart, a plan, a ring, a list). The same holds for figures:
+ the largest figure on the screen answers the question the title row's sentence answers. In testing,
+ an 88% sun ratio at 32px out-shouted the 24px charging window the title led with;
- **what comes first** in the reading order;
- **what is left out.** The studied settings page shows three usage numbers and links to the
analytics screen instead of drawing a chart; four screens draw no chart at all because a few
@@ -194,8 +235,9 @@ node <skill>/scripts/draw.mjs --app --kind <kind> --brief "<one line about the p
--screens <screens> [--theme light|dark] [--keep palette,type] --options 3
```
-This deals three styles from `library/app.json`. `draw.mjs --app --list kinds` (or `styles`, or
-`screens`) prints the choices; the screens are `overview`, `analytics`, `list`, `detail`, `settings`, `wallet`,
+This deals up to three styles from `library/app.json` (fewer when only two suit the kind and the
+theme). `draw.mjs --app --list kinds` (or `styles`, `screens` or `signatures`) prints the choices; the
+screens are `overview`, `analytics`, `list`, `detail`, `settings`, `wallet`,
`builder`, `inbox`, `home` and `report`. The library holds seven styles, each distilled from the
studied screens that share its move:
@@ -222,6 +264,14 @@ Keep the style's one move intact and take every other value from the defaults in
or the product is used in a way the style does not suit. With an existing brand, pass
`--keep palette,type`, map its colours onto the roles in §9 and keep the style's colour budget.
+**Then choose its face, before any markup.** The sheet's "Its face" list gives two or three ways this
+style takes a face from the brief, and "Signature elements" lists the library's elements whose words
+appear in the brief (a power flow for an energy home, a sell-out strip for a bakery, a cover matrix
+and a kind-encoded timeline for a leave planner). Write in your notes, next to the screen's question:
+the face you chose, the signature element (from the sheet, or your own built from the product's
+things), and where each appears on the first screen. A style dealt to two products must not give them
+the same face: in four rounds, the screens that skipped this step were scored as the same kit.
+
### 2.4 Build the shell
Build the frame first, empty: the sidebar or rail, the top bar if the shell has one, the canvas with
@@ -233,8 +283,11 @@ the cards land on the canvas edges.
### 2.5 Put in the data
Render every block from the dataset; draw the charts from it too, with `<skill>/assets/charts.js`
-(`Charts.line`, `Charts.bars`, `Charts.ring`, `Charts.barList`) or your own SVG to the rules of §6,
-never a chart library's defaults and never a picture of a chart. Format every figure by §7.4: separators, fixed decimals per
+(`Charts.line`, `Charts.bars`, `Charts.diverging`, `Charts.ring`, `Charts.barList`, `Charts.plan`,
+`Charts.bullet`, `Charts.timeline`, `Charts.matrix`, `Charts.timeStrip`; the file's header lists their
+options) or your own SVG to the rules of §6, never a chart library's defaults and never a picture of a
+chart. The newer helpers return `{ svg, legend }`: put that legend in the card's header rather than
+drawing your own, so each swatch is the mark it explains. Format every figure by §7.4: separators, fixed decimals per
metric, a sign on every change, units as smaller grey suffixes, tabular figures, right alignment in
columns. Use the product's own words for labels. No placeholder data: the inspector fails lorem ipsum,
Acme, John Doe and their kind. Proof is not invented here either: no vanity totals, no "+12%" on an
@@ -254,30 +307,42 @@ node <skill>/scripts/inspect.mjs --app <url or path/to/index.html>
```
A sheet dealt with `--app` switches both tools to the app rules by itself. The inspector opens the
-screen at 1440, 768 and 390 and measures what this chapter asks for: an h1; a sidebar that folds on
-the phone; the canvas used to its right edge; panel shadows and borders; the number of corner radii;
-icons in tinted squares; numeric alignment and tabular figures; chart hues; colour share; placeholder
-data; text under 11px; and the page rules that still hold (contrast, gradients, the banned palettes,
-emoji). Fix every `FAIL`. Treat each `WARN` as wrong unless you can defend it to a designer in one
-sentence.
-
-Then look at the screenshots, every width, and answer these in writing:
-
-1. Is the screen's question answered by the biggest thing on it, and is that read first?
+screen at 1440, 768 and 390 and measures what this chapter asks for: an h1 (and reports it as the
+screen's hero); a sidebar that folds on the phone; the canvas used to its right edge; panel shadows
+and borders; the number of corner radii; cards in one row that end apart, where a column of cards
+stacked with the gutter counts as one block (`ragged-row`); a blank band inside a card of over 40px,
+or over 64px before a new section's heading (`panel-void`); icons in tinted squares; numeric alignment and tabular figures; chart hues; colour
+share, and a screen with charts but no hue on its data (`no-data-hue`); placeholder data; text under
+11px; and the page rules that still hold (contrast, gradients, the banned palettes, emoji). Fix every
+`FAIL`. Treat each `WARN` as wrong unless you can defend it to a designer in one sentence.
+
+Then look at the screenshots, every width, and answer these in writing. This is the critique for an
+app screen: the caps in `critique.md` for pictures, motion and the page's live element are page rules
+and do not apply here.
+
+1. Is the screen's question answered by the biggest thing on it, and is that read first? Is the
+ largest figure the one that answers the title row's sentence?
2. Does every block share the screen's edges? Is there a dead strip on one side, a card stopping
- short, an orphan cell?
-3. Is colour only on data, on status and on the one primary action?
-4. Do the numbers add up, and do they line up digit for digit?
-5. Does every zero look like a zero and every missing value like a dash?
-6. On the phone, is the navigation folded away, and does each block still answer its question?
+ short, an orphan cell, a stretched card with a blank band (a legend pinned to its foot, four rows
+ in a card kept at its neighbour's height)?
+3. Is colour only on data, on status and on the one primary action, and does the main data element
+ carry the one hue? Does the face you chose show on the first screen?
+4. Do the numbers add up, and do they line up digit for digit? List every fact that appears twice
+ and check that the copies agree; recompute each total and change from the values as displayed;
+ check that every relative figure names what it is against.
+5. Does every zero look like a zero and every missing value like a dash? Does every count badge sit
+ on a queue that needs action, with its noun clear from the label?
+6. Does every legend swatch match the mark it explains, and does any caption have to say which bars
+ are which (then encode it in the chart)? Does any label collide with a line or another label?
+7. On the phone, is the navigation folded away, and does each block still answer its question?
Fix the worst three, inspect again, look again. Three rounds at most. Judge the pictures: if a problem
shows in a screenshot, it is real, whatever the code says.
### 2.8 Report
-Tell the user, briefly: the style dealt (name and seed) and any redraws with their reasons; each
-screen's one question; any check you allowed and why (for example `--allow icon-chips` for node-type
+Tell the user, briefly: the style dealt (name and seed) and any redraws with their reasons; the face
+you chose and the signature element; each screen's one question; any check you allowed and why (for example `--allow icon-chips` for node-type
tiles in a builder); and the sample data that must be replaced with real data, listed so it can be
found.
@@ -321,6 +386,9 @@ No screen in the study puts a dark or saturated sidebar against a light canvas (
- **The product is named** (house rule, from testing). The product's mark and name sit at the top of
the sidebar or rail, and the scope (workspace, team, project, account) is shown as a switcher or a
breadcrumb. A screen whose product cannot be named from the screenshot reads as a template.
+- **Counts on nav items** (house rule, from testing). A count appears only on a queue that needs
+ action, and its noun is clear from the label: "Requests 5", "Price changes 3". A bare "Range and
+ prices 9" left the judge asking nine of what.
- **Labels by default.** A labelled sidebar unless the product has five destinations or fewer and the
screen needs the width (a research or monitoring view); an icon rail always carries the product's
mark at the top, a tooltip and an accessible name on every icon. Nav items are other screens, never
@@ -384,9 +452,19 @@ do not stretch a card's frame over empty space.
**Cards that share a row share a bottom edge.** In testing, rows whose cards stopped 26-190px apart
were marked down every time, by judges and by the inspector (`ragged-row`). Balance the row by its
content first: move a list's rows so the two columns hold the same number, cap both lists at the same
-count, or pair blocks of similar height. Only when the contents cannot balance, stack the two blocks,
-or let the shorter card fill the row height with its content top-aligned and the footer action (a
-"View all", a total) pinned to its bottom so the extra height is not a hole.
+count, or pair blocks of similar height. Two cards stacked in one column beside a tall card count as
+one block: they balance when the column ends level. Only when the contents cannot balance, stack the
+two blocks, or let the shorter card fill the row height with its content top-aligned and the footer
+action (a "View all", a total) pinned to its bottom so the extra height is not a hole.
+
+**A stretched card stretches only when it has content to fill.** Only an action or a total may be
+pinned to a stretched card's foot; a legend or a note stays directly under its chart. In testing, a
+cover card stretched to its neighbour with its legend pinned to the bottom left 60px of blank under
+the last row, and a sell-out card left 45px above its links. When the content is short, let the card
+keep its own height (`align-items: start` on the row), move its footer link into its header, or give
+the row a block of similar height. A filtered block shrinks to its rows, or keeps a fixed number of
+rows with one sentence in the empty ones; four rows over 270px of empty card is a hole. The inspector
+warns on a blank band of over 40px inside a card (`panel-void`).
**Narrow blocks do not span the canvas.** A table of five columns or fewer, or a list of six rows or
fewer, runs to about 760px at 1440 and pairs with the next block; stretched to 1300px it leaves
@@ -416,7 +494,8 @@ fewer, runs to about 760px at 1440 and pairs with the next block; stretched to 1
- **Underline tabs** (8 screens) always sit on a full-width 1px rule; the indicator is 1-4px (median
2), as wide as the label or running 8-11px past it.
- **A segmented track** once: 48px, #f3f4f6, a white 36px active pill, and the date select inside its
- right end, so tabs and range read as one row.
+ right end, so tabs and range read as one row. A segmented control is as wide as its options, and full
+ width only below about 480px: three options spread across a 680px tablet card read as a progress bar.
- **Control height** in title and filter rows: 28-40px, median 34, clustering at 32 and 36.
- **Order**: scope on the left (the date first, then the filters), utility and refresh on the right.
- **Compound filters** that read as a sentence ("Date | Jun 14 - Jul 13 | Daily"), 28px tall and 8px
@@ -442,13 +521,20 @@ fewer, runs to about 760px at 1440 and pairs with the next block; stretched to 1
over 14, "2 m 24 s", "5 /10".
- **The answer figure leads.** When one figure is the screen's answer (a balance, net worth, the
portfolio's value), it is 30-36px and at least 1.3 times its sibling figures (those at 18-24px). In
- testing, a 24px portfolio value beside two 24px figures left the screen without a lead.
+ testing, a 24px portfolio value beside two 24px figures left the screen without a lead. No other
+ figure on the screen is larger: the biggest number answers the title row's sentence, so a
+ secondary ratio in another card stays at the siblings' size.
- **One figure, one place.** A figure shown in the strip is not repeated in a legend beside it, and a
KPI strip whose every cell names a panel below (RSVPs, then an RSVPs panel) is dropped: lead each
panel with its own number instead.
-- **A second job.** KPIs may be the chart's series tabs (the selected one carries a 2px rule or the
- active fill, the others a hover state; grey values with no marker read as disabled) or the list's
- type filter (the selected card takes a 1.5px border).
+- **A second job.** KPIs may be the chart's series tabs or the list's type filter (the selected card
+ takes a 1.5px border). As tabs, the selected one carries a 2px rule or the active fill and an ink
+ label; the others keep a grey label and their value in ink, at 400 against the selected one's 500.
+ A grey value reads as disabled: in testing, three shops' takings set in grey because they were tabs
+ read as secondary, though they were the brief's first ask. When the tabs are the per-entity
+ breakdown the brief asks for, grey nothing and let the rule alone mark the selection. On a phone the
+ tabs become a 2-up grid with the selected cell filled, or a row that scrolls sideways; never an
+ underline floating inside the grid (`app.css` does both).
### Deltas
@@ -484,6 +570,10 @@ fewer, runs to about 760px at 1440 and pairs with the next block; stretched to 1
| Has it drifted from its target? | One row per part: the current share as a bar with a 1px tick at the target (`Charts.bullet`); never two stacked bars to compare | house rule |
| Where? | A map with a list beside it; the list carries the magnitudes | 1 |
| Per period, and the running total? | The two side by side at equal width, with the same dates | 1 |
+| Which way did it flow, and how much? | Columns above and below one zero line on one scale, the axis signed and captioned on each side ("Sold" above, "Bought" below), a marked period in a second tone with its own legend entry (`Charts.diverging`) | house rule |
+| Who is away when? | A timeline of people by day, each kind of booking its own mark (`Charts.timeline`) | house rule |
+| Is there enough cover? | A team-by-day matrix of slack against the minimum (+2, +1, 0, −1), one hue ramping toward the negative colour, the headcount on hover (`Charts.matrix`) | house rule |
+| When in the day, against last time? | One row per item on a shared opening-to-closing axis: a 2px grey track, an ink dot for today, a hollow tick for the comparison day (`Charts.timeStrip`) | house rule |
Three more, from testing:
@@ -526,7 +616,9 @@ to 5.2.
- **Axis text no larger than the data.** 15-16px ticks beside 14px values are flagged as louder than
the numbers.
- **X labels**: 4-8 per chart, flat, never rotated (40 degrees is flagged), the first and last pulled
- inside the plot. Labelling only the two ends hides when things happened. Irregular dates on a
+ inside the plot, on one step all the way: a forced closing label after 14:00 on a 90-minute step
+ left a short last gap that a judge measured. Choose a step that lands on the end (hourly from 08:00
+ to 15:00) or leave the end unlabelled. Labelling only the two ends hides when things happened. Irregular dates on a
categorical axis are flagged: time goes on a time scale.
### 6.4 Marks
@@ -541,13 +633,19 @@ to 5.2.
- **Colour.** One hue per chart. The accent touches only data on 8 screens, and data ink is under 3%
of the pixels on most. Neutral series are fine and often better: a near-black line that turns pale
grey after the cursor; a white line against a red one; signs instead of colour ("+$24,000,000").
+ But the one hue, when the style has one, goes on the screen's main data element (today's series,
+ the booked bars, the current period, the margin that breaks), not on a secondary chart or a delta:
+ in testing, an all-ink screen with no hue on any of its data read as a kit.
One subject keeps one hue across the screen: the same subscribers drawn pink in one chart and indigo
in the next is flagged. Unrelated hues on one screen (three, five) are flagged every time. Status
colours are for status. The inspector warns over four hues and fails over six.
- **Legends.** None for a single series (9 charts): the title or the dropdown names it. Otherwise five
items at most, as a 5-8px dot with a 12-14px grey label in the card's header, or as a small table
(dot, name, value, change) that makes the legend carry data. Never list a series that has no data
- (flagged). The legend dot is the line's colour.
+ (flagged). Every swatch is the mark it explains, scaled down: the legend dot is the line's colour,
+ a hatched bar's swatch is hatched. A swatch drawn separately from the mark drifted from it in testing
+ (a black outline with a red edge explaining a red outline); the helpers return the legend built from
+ the same style object as the marks.
- **Rings** only for three to five parts of a whole that are not already listed beside them (a ring
redrawing the spent, due and left figures of the tile next to it was marked redundant). Never
labelled on the slices; the total sits in the centre or beside the ring. The
@@ -560,8 +658,14 @@ to 5.2.
- **Annotate the event that matters.** A step or a spike more than about three times the usual change
gets a 1px marker and a 12px label naming its cause ("Deploy a3f09c1", "Newsletter featured");
reference lines (a budget, an SLO, a start time) are 1px dashed with their label at the end. In
- testing, an unexplained jump was the first thing a judge asked about. `Charts.line` and
- `Charts.bars` take `annotations` and `reference`.
+ testing, an unexplained jump was the first thing a judge asked about. `Charts.line`,
+ `Charts.bars` and `Charts.diverging` take `annotations` and `reference`.
+- **Labels never collide.** Annotation labels sit in rows above the plot, each beside the top of its
+ own leader line, and no leader line runs through another label; the rows are reserved only when a
+ label exists, so a chart without one has no dead band above it. The "Now" label of a forecast goes
+ on whichever side of its line the series does not cross. Lay labels out after the fonts load, or
+ the label set changes between loads (it did in testing). The helpers do all of this; give a label
+ that may not fit a `short` form.
- **Use the helper, then extend it.** Draw charts with `assets/charts.js` and add what a chart needs to
it, rather than writing new axis code: in testing, every chart written from scratch on a phone put
its y labels on top of its line.
@@ -578,7 +682,8 @@ to 5.2.
(48 + 24, 48 + 32, 50 + 30).
- Key-value and legend rows inside cards: 21-32px.
- In a two-line cell, line 2 sits about 21px below line 1 (19-23), one size smaller (12-14px) and
- grey.
+ grey. Two-line labels need a 40-44px pitch at least: on a 32px pitch a subline nearly touched the
+ next row's name and the list ran together (house rule, from testing).
- Overview lists show 2-5 rows.
### 7.2 Header
@@ -589,7 +694,9 @@ to 5.2.
strongest line in the table (#e5e7eb over #f3f4f6 row rules).
- Header row 36-40px.
- Numeric headers are right-aligned and flush with their values; a header that stops 15px short of
- its column is flagged.
+ its column is flagged. A header over a control aligns with the control it labels (centred over a
+ column of steppers), and a delta beside a stepper gets its own narrow unlabelled column; three
+ alignments in one header row were flagged.
- A sort glyph on the active column only.
### 7.3 Dividers
@@ -624,6 +731,12 @@ to 5.2.
- **IDs** in a monospace at body size, truncated to about 8 characters with an ellipsis and a copy
icon 12px after.
- Truncate to one line with an ellipsis; never break inside a word.
+- **A breakdown in a narrow card** ("Headingley 6 · Chapel Allerton 5 · Meanwood 3") goes in fixed
+ mini-columns, or each item is `nowrap` with its separator attached to the next item, so no line ends
+ on a dangling "·".
+- **An edited cell shows that it changed** (house rule, from testing). In an editable grid a changed
+ value carries a mark (a dot, a tinted border), and the column header or a caption names the
+ baseline ("vs the usual Monday"); a bare grey "+5" beside a stepper was read as noise.
### 7.5 Ink inside rows
@@ -685,6 +798,13 @@ list so the text starts on one edge (a 50px slot with the text 16px after it). M
Planned against spent is a separate 6-8px track under the label (`Charts.plan`).
- **Bar list**: a 64px pitch, a label line, then a 10px pill bar with the value 5px after its end; the
longest bar about 88% of the width; one colour, no track.
+- **Inline bars in a list are thin and grey** unless they are the screen's main series: 2-3px at
+ most. A ranked list of money in a narrow card carries a 2px proportional bar under each label, grey
+ with the top item in ink (`Charts.barList(el, rows, { thin: true })`), so "most costly first" is
+ seen and not only read. In testing, six 4px black bars were the loudest marks on the screen.
+- **A timeline draws its comparison.** When the brief asks "against last Sunday", the comparison is a
+ mark on the same axis (`Charts.timeStrip`: an ink dot for today, a hollow tick for the comparison
+ day), not only a line of text.
- **Legend as table**: dot, name, pill, value and change on a 57px pitch.
- **Key-value well**: a tinted well, radius 8, 32px rows, label left, figure right.
- **Feed as row cards**: 63px tall, 8px gaps, radius 14, a fill one step lighter and a border one step
@@ -815,10 +935,15 @@ white with a 1px border; a tertiary is text. The controls in one row share one h
#222224 on #171719); interactive outlines brighter, #373737-#4c4c4c, so an outlined button reads as
clickable without a fill.
- **Text**: #fff; secondary about #aaa (#82848a-#bbb); tertiary about #888. #4c4c4f (about 2:1) is
- flagged. The house floor of 4.5:1 holds here too.
+ flagged. The house floor of 4.5:1 holds here too. Two greys at most, and far enough apart to read
+ as two: about #b4b4b4 for secondary text and #949494 for meta (in testing, #aaaaaa, #969696 and
+ #bbbbbb on one screen read as one grey used three ways).
- **Accent** on data only, or on one selected state. Active nav by brightness. Emphasis without
colour: an inverted white pill, a grey-filled button (#212121), an outline.
-- **Status** as a hue on a dark tint of itself: #3fc07a on #172a1d; #44a282 on #1b2828.
+- **Status** as a hue on a dark tint of itself: #3fc07a on #172a1d; #44a282 on #1b2828. **When the
+ accent is green or yellow-green, `--positive` is the accent** (a lime accent: lime on a dark lime
+ tint), or the sign carries the meaning in neutral ink; a mint "+£3.81" beside a lime "Sold" read as
+ two greens. The same holds on light screens.
- **Colour share** at or under 3% on all six.
### 9.4 Surfaces, radius, icons, spacing
@@ -846,8 +971,9 @@ style does not set, with the greys moved to pass 4.5:1.
The names match the sheet `draw.mjs --app` prints and `assets/app.css`, a neutral start set to these
defaults (shell, title row, panels, the divided KPI strip, tables, pills, controls, tabs, empty states
-and the phone fold). `assets/charts.js` draws the line, bar, ring and bar-list charts of §6 in SVG from
-your data, with these rules built in.
+and the phone fold). `assets/charts.js` draws the charts of §6 in SVG from your data (line, bars,
+diverging columns, ring, bar list, plan, bullet, timeline, cover matrix and time strip), with these
+rules built in and its colours read from these tokens.
```css
:root {
@@ -860,7 +986,7 @@ your data, with these rules built in.
--positive: #247b50; --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
--negative: #c4242a; --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
--pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e; /* notice border #fde68a */
- --grid: #e5e5e5;
+ --grid: #e5e5e5; --chart-span: 0.06; /* the opacity of a shaded span in a chart */
--radius-card: 8px; --radius-control: 6px; --radius-chip: 4px; /* soft styles: 20 / 14 / 999 */
--gap: 16px; --card-pad: 20px; --pad: 24px;
@@ -871,11 +997,11 @@ your data, with these rules built in.
:root[data-theme="dark"] {
--ground: #000000; --surface: #111111; --raised: #222222; --active: #222222;
--border: #1a1a1a; --rule: #161616; --control: #444444; /* on a #111 ground the border is #2e2e2e */
- --text: #ffffff; --muted: #aaaaaa; --faint: #969696;
+ --text: #ffffff; --muted: #b4b4b4; --faint: #949494; /* two greys that read apart */
--primary: #ffffff; /* inverted: white fill, black label */
- --positive: #3fc07a; --pill-positive-bg: #172a1d; --pill-positive-ink: #3fc07a;
+ --positive: #3fc07a; --pill-positive-bg: #172a1d; --pill-positive-ink: #3fc07a; /* a green accent replaces these */
--negative: #e5566f; --pill-negative-bg: #2c1a20; --pill-negative-ink: #e5566f; /* the study's #d4405d, lifted for 4.5:1 */
- --grid: #2b2b2b;
+ --grid: #2b2b2b; --chart-span: 0.12;
}
.num { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }
@@ -909,8 +1035,13 @@ td.num, th.num { text-align: right; }
"Automate your savings with up to 3.50% APY").
- **Missing or not applicable** is a grey dash: an em dash, a "-", a 6x2px mark. Never a dash at full
value size: "--" at 24px reads as loading (flagged).
-- **Counts follow the view.** Counts shown in scope (tabs, KPI tiles, "12 open") are computed from
- the rows in the current view or filter and recomputed on every switch.
+- **Counts follow the view, and so does the frame.** Counts shown in scope (tabs, KPI tiles, "12
+ open") are computed from the rows in the current view or filter and recomputed on every switch. A
+ filtered block shrinks to its rows and its row-mate aligns to the top, or the block keeps a fixed
+ number of rows with one empty-state sentence; each view's subline is computed for that view.
+- **An empty side card fills with the reference data**, not one dashed box in 400px of white: before
+ anything has sold out, last Sunday's sell-out times as a quiet list under "Nothing has sold out yet
+ today".
- **Red is a signal, not a texture**: one red mark per object at most, on the overdue or failing fact;
thirteen red strings on one board read as noise, and a list of deals needing attention does not
repeat the same flags on the board beside it.
@@ -953,9 +1084,20 @@ takes more than 30% of a phone's width.
row, never the page. The first list row starts in the top 60% of the phone screen: three rows of
filter controls above it pushed the list off the first screen in testing.
- **KPIs**: a divided container becomes a 2-column grid, or a list with the label on the left and the
- value on the right. Never four squeezed columns.
-- **Charts** go full width, 160-200px tall, with 3-4 x labels and a legend of dots above. The y ticks
- keep their own lane at the left (or move to the right edge); a tick label never sits on the line.
+ value on the right. Never four squeezed columns. In a 2-column grid the count after any full-width
+ lead is even; otherwise use three narrow columns or a divided list, or let the last cell take the
+ full width (`app.css` does that for an odd count). A lone "Sold 3.18 kWh" beside an empty half-row
+ was flagged.
+- **At most one row of controls above a chart**: an office select and a week switch share one row.
+ Two stacked full-width segmented controls pushed the data down in testing.
+- **Charts** go full width, 160-200px tall, with 3-4 x labels and a legend of dots above, set in a
+ 2-column grid (or behind a "Key" disclosure) when it would wrap to three lines. The y ticks keep
+ their own lane at the left (or move to the right edge); a tick label never sits on the line.
+- **Row actions on a phone** are text actions or one compact trailing button, with one filled bulk
+ action for the list ("Approve 3 that fit"); five 44px grey Approve blocks turned a list into a stack
+ of buttons.
+- **When a strip collapses, drop the item least relevant to the screen's main action**, not the last
+ in source order: the live price stays on an energy screen whose plan depends on it.
- **Tables become lists of two-line rows below about 640px**: the identity and the key number on line
1, the other fields the brief names in 13px grey on line 2 ("fra1 · 1m 38s"), the one action at the
right. Fields move to line 2; they are never dropped. A table that must stay a table scrolls inside
@@ -1048,6 +1190,7 @@ Each line sets a habit of generated dashboards against what the 23 screens do in
| Pagination under a short list | Capped rows and "View all". |
| An equal four-up grid whatever the data, with orphan cells and stretched cards | A column count chosen by the item count; spans that change by row and land on the same lines. |
| Neon on dark, glowing borders, glass | True neutral darks, lightness steps, colour on the data. |
+| The kit's own face: Geist or Inter on #f8f8f8 with white 12px cards and no hue on the data, or lime on black | One face taken from the brief (a ground from the product's world, a figure face with character, the brand's hue on the main data element) and one element only this product has. |
| A coloured icon per category in a list | One grey icon set; colour, if any, on the numbers. |
| An illustration and "No data yet" in an empty chart | The zero line drawn, and one sentence in the frame. |
diff --git a/skills/taste-skill/scripts/inspect.mjs b/skills/taste-skill/scripts/inspect.mjs
index 07d7ff2..a8f0b6e 100644
--- a/skills/taste-skill/scripts/inspect.mjs
+++ b/skills/taste-skill/scripts/inspect.mjs
@@ -36,7 +36,7 @@ if (!target || target === '-h' || target.startsWith('--')) {
}
// Allowances granted by the drawn direction (written by draw.mjs) apply automatically.
for (const p of ['.taste-skill/direction.json', join(outDir, '..', 'direction.json')]) {
- if (existsSync(p)) { try { const d = JSON.parse(readFileSync(p, 'utf8')); allow = [...new Set([...allow, ...(d.allow || [])])]; if (d.kind === 'app') appMode = true; if (Array.isArray(d.scenes) && d.scenes.length) film = true; dealtFonts = d.kind === 'app' ? [d.style?.tokens?.font?.family].filter(Boolean) : (d.input?.keep || []).includes('type') ? [] : [d.type?.display?.family, d.type?.text?.family].filter(Boolean); } catch {} break; }
+ if (existsSync(p)) { try { const d = JSON.parse(readFileSync(p, 'utf8')); allow = [...new Set([...allow, ...(d.allow || [])])]; if (d.kind === 'app') appMode = true; if (Array.isArray(d.scenes) && d.scenes.length) film = true; dealtFonts = (d.input?.keep || []).includes('type') ? [] : d.kind === 'app' ? [d.style?.tokens?.font?.family].filter(Boolean) : [d.type?.display?.family, d.type?.text?.family].filter(Boolean); } catch {} break; }
}
// A local file is served over http from a throwaway server on 127.0.0.1, so the browser never has to
// open a file path (some sandboxes show Node and the browser different views of the disk) and relative
diff --git a/skills/taste-skill/scripts/lib/app-draw.mjs b/skills/taste-skill/scripts/lib/app-draw.mjs
index 279f4d3..e246a38 100644
--- a/skills/taste-skill/scripts/lib/app-draw.mjs
+++ b/skills/taste-skill/scripts/lib/app-draw.mjs
@@ -25,12 +25,16 @@ const outDir = resolve(String(opt('out', '.taste-skill')));
const sheetPath = join(outDir, 'direction.json');
const KINDS = Object.keys(LIB.kinds);
-const SCREENS = [...new Set(LIB.patterns.map((p) => p.screen))];
+// signature patterns are elements of one kind of product (a power flow, a sell-out strip), not whole screens
+const SCREENS = [...new Set(LIB.patterns.filter((p) => p.screen).map((p) => p.screen))];
+const SIGNATURES = LIB.patterns.filter((p) => p.signature);
+const signaturesFor = (brief = '') => { const b = brief.toLowerCase(); return SIGNATURES.filter((p) => (p.cues || []).some((c) => new RegExp('(^|[^a-z])' + c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i').test(b))); };
if (opt('list')) {
const what = opt('list');
if (what === 'kinds') for (const [k, v] of Object.entries(LIB.kinds)) console.log(`${k.padEnd(14)} ${v.note}`);
else if (what === 'screens') for (const s of SCREENS) console.log(`${s.padEnd(12)} ${LIB.patterns.filter((p) => p.screen === s).map((p) => p.id).join(', ')}`);
+ else if (what === 'signatures') for (const p of SIGNATURES) console.log(`${p.id.padEnd(16)} ${p.name} — ${(p.cues || []).slice(0, 5).join(', ')}`);
else for (const s of LIB.styles) console.log(`${s.id.padEnd(22)} ${s.name} — ${s.theme}, ${s.suits.join(', ')}`);
process.exit(0);
}
@@ -142,6 +146,19 @@ function render(s) {
if (st.avoid?.length) p('**Off-style here:** ' + st.avoid.join('; ') + '.');
if (st.basis) p(`Distilled from ${st.basis}.${st.notes ? ' ' + st.notes : ''}`);
p();
+ // the style makes a screen correct; its face makes it this product's (references/app-screens.md, §2.3)
+ if (st.identity?.length) {
+ p('**Its face.** Choose one of these (or one of your own of the same weight) before you build, write it in your notes next to');
+ p('the screen\'s question, and check that it shows on the first screen. Without one the screen reads as a well-applied kit.');
+ for (const x of st.identity) p('- ' + x);
+ p();
+ }
+ const sigs = signaturesFor(s.input.brief);
+ if (sigs.length) {
+ p('**Signature elements this brief names** (an element only this kind of product has; build one of them as part of a screen):');
+ for (const g of sigs) p(`- **${g.name}** (\`${g.id}\`). ${g.blueprint}${g.phone ? ' On a phone: ' + g.phone : ''}`);
+ p();
+ }
const f = t.font || {};
if (!s.input.keep.includes('palette')) {
p('## 2. Tokens'); p('```css'); p(':root {');
diff --git a/skills/taste-skill/scripts/lib/probe.mjs b/skills/taste-skill/scripts/lib/probe.mjs
index 3aa8d7a..ceb714b 100644
--- a/skills/taste-skill/scripts/lib/probe.mjs
+++ b/skills/taste-skill/scripts/lib/probe.mjs
@@ -747,13 +747,51 @@ export function app() {
// panels start on the first screen
const panelEls = new Set(panels.map((p) => p.el));
const tops = panels.filter((p) => { for (let a = p.el.parentElement; a && a !== B; a = a.parentElement) if (panelEls.has(a)) return false; return p.w < W * 0.97 || p.h < H * 2; });
+ // a column of cards stacked with a gutter of 24px or less is one block: two cards on the left that end level with
+ // one tall card on the right are not ragged. A pair is ragged only when the cards and their columns both end apart.
+ const below = (p) => tops.find((q) => q !== p && Math.abs(q.left - p.left) <= 4 && Math.abs(q.w - p.w) <= 4 && q.top >= p.bottom - 2 && q.top - p.bottom <= 24);
+ const columnBottom = (p) => { let b = p.bottom; for (let q = below(p), n = 0; q && n < 12; q = below(q), n++) b = q.bottom; return b; };
const ragged = [];
for (let i = 0; i < tops.length; i++) for (let k = i + 1; k < tops.length; k++) {
const a = tops[i], b = tops[k];
if (Math.abs(a.top - b.top) > 4 || a.w < 200 || b.w < 200 || (a.right > b.left - 4 && b.right > a.left - 4)) continue; // side by side, same row
- const diff = Math.abs(a.bottom - b.bottom), tall = Math.max(a.h, b.h);
+ const diff = Math.min(Math.abs(a.bottom - b.bottom), Math.abs(columnBottom(a) - columnBottom(b))), tall = Math.max(a.h, b.h);
if (diff > Math.max(24, tall * 0.12)) ragged.push({ diff, top: a.top });
}
+ // the largest blank band inside a card: the vertical gap between consecutive pieces of its content (text, charts,
+ // pictures, controls, rules, fills), or from the last piece to the card's padding edge. A legend pinned to the foot
+ // of a stretched card, or four rows in a card kept at its neighbour's height, leave one.
+ const voids = [];
+ const seen = new Map();
+ const visibleIn = (el, root) => { if (seen.has(el)) return seen.get(el); let ok = true; for (let p = el; p && p !== root.parentElement; p = p.parentElement) { const cs = getComputedStyle(p); if (cs.display === 'none' || cs.visibility === 'hidden' || +cs.opacity < 0.05 || cs.position === 'fixed') { ok = false; break; } } seen.set(el, ok); return ok; };
+ for (const p of tops) {
+ if (p.el.matches('nav, aside, header, footer, dialog, [role="navigation"], [role="dialog"]') || p.el.querySelector('nav') || (sidebar && p.left < sidebar.w - 4) || p.h < 120) continue;
+ if (panels.filter((q) => q.el !== p.el && p.el.contains(q.el)).length >= 2) continue; // a frame of cards, not a card
+ const cs = getComputedStyle(p.el), pr = p.el.getBoundingClientRect();
+ const inTop = pr.top + (parseFloat(cs.borderTopWidth) || 0) + (parseFloat(cs.paddingTop) || 0), inBottom = pr.bottom - (parseFloat(cs.borderBottomWidth) || 0) - (parseFloat(cs.paddingBottom) || 0);
+ const bg = rgba(cs.backgroundColor), spans = [];
+ const tw2 = document.createTreeWalker(p.el, NodeFilter.SHOW_TEXT), rg = document.createRange();
+ // text that opens a section (a heading, a summary, or text at 14px/600 or 15px/500 and up) may follow a wider, placed gap
+ for (let n = tw2.nextNode(); n; n = tw2.nextNode()) { if (!n.nodeValue.trim() || !n.parentElement || n.parentElement.closest('svg') || !visibleIn(n.parentElement, p.el)) continue; rg.selectNodeContents(n); const r = rg.getBoundingClientRect(); if (r.height > 0 && r.width > 0) { const pcs = getComputedStyle(n.parentElement); const fs = parseFloat(pcs.fontSize), fw = +pcs.fontWeight; spans.push([r.top, r.bottom, !!n.parentElement.closest('h1, h2, h3, h4, h5, h6, [role="heading"], summary, legend, caption') || (fw >= 600 && fs >= 14) || (fw >= 500 && fs >= 15)]); } }
+ for (const el of p.el.querySelectorAll('*')) {
+ if (el.parentElement && el.parentElement.closest('svg')) continue;
+ const r = el.getBoundingClientRect(); if (r.width < 2 || r.height < 1 || !visibleIn(el, p.el)) continue;
+ if (/^(svg|canvas|img|video|input|select|textarea|button|hr|progress|meter|iframe)$/i.test(el.tagName)) { spans.push([r.top, r.bottom]); continue; }
+ const ecs = getComputedStyle(el), fillC = rgba(ecs.backgroundColor);
+ if (fillC.a >= 0.1 && (bg.a < 0.9 || contrast({ ...fillC, a: 1 }, bg) >= 1.03) && r.height >= 2) spans.push([r.top, r.bottom]);
+ if ((parseFloat(ecs.borderTopWidth) || 0) >= 0.5 && ecs.borderTopStyle !== 'none' && rgba(ecs.borderTopColor).a > 0.05) spans.push([r.top, r.top + 1]);
+ if ((parseFloat(ecs.borderBottomWidth) || 0) >= 0.5 && ecs.borderBottomStyle !== 'none' && rgba(ecs.borderBottomColor).a > 0.05) spans.push([r.bottom - 1, r.bottom]);
+ }
+ const ys = spans.filter(([a, b]) => b > inTop - 2 && a < inBottom + 2).sort((a, b) => a[0] - b[0]);
+ if (!ys.length) continue;
+ // a band counts when it is over 40px, or over 64px when the content after it opens a new section
+ let end = ys[0][1], gap = 0, at = null;
+ for (const [a, b] of ys.slice(1)) { const g = a - end, section = ys.some(([t, , hd]) => hd && Math.abs(t - a) < 6); if (g > (section ? 64 : 40) && g > gap) { gap = g; at = end; } end = Math.max(end, b); }
+ if (inBottom - end > 40 && inBottom - end > gap) { gap = inBottom - end; at = end; }
+ const head = (p.el.querySelector('h1, h2, h3, h4, [role="heading"], header') || p.el).innerText || '';
+ if (gap > 40) voids.push({ gap: Math.round(gap), at: Math.round(at + SY), panel: head.trim().split('\n')[0].slice(0, 40) });
+ }
+ voids.sort((a, b) => b.gap - a.gap);
const firstScreen = tops.filter((p) => p.top < H - 48).length;
// the icon-in-a-tinted-square habit: small boxes with a coloured fill holding one icon, repeated
const chips = []; let tiles = 0;
@@ -793,10 +831,37 @@ export function app() {
const total = [...sizes.values()].reduce((a, b) => a + b, 0) || 1;
const under13 = Math.round(([...sizes.entries()].filter(([s]) => s < 13).reduce((a, [, c]) => a + c, 0) / total) * 100) / 100;
const h1 = document.querySelector('h1'); const h1r = h1 && h1.getBoundingClientRect();
+ // the screen's hero: its h1 when that is on the first screen, else the largest text there. Text is read with a
+ // space between element children, so a figure and its unit ("£55.94" and "at cost") do not run together.
+ const spaced = (el) => { const out = []; const w = document.createTreeWalker(el, NodeFilter.SHOW_TEXT); for (let n = w.nextNode(); n; n = w.nextNode()) { const t = n.nodeValue.replace(/\s+/g, ' ').trim(); if (t && n.parentElement && !n.parentElement.closest('svg, script, style') && getComputedStyle(n.parentElement).display !== 'none') out.push(t); } return out.join(' ').replace(/\s+([,.;:!?%])/g, '$1').trim(); };
+ let heroEl = h1 && h1r && h1r.width > 0 && h1r.top + SY < H * 0.95 ? h1 : null;
+ if (!heroEl) {
+ let best = null; const hw = document.createTreeWalker(B, NodeFilter.SHOW_TEXT);
+ for (let n = hw.nextNode(); n; n = hw.nextNode()) {
+ const el = n.parentElement; if (!el || n.nodeValue.trim().length < 2 || el.closest('svg, nav, aside, [role="navigation"]')) continue;
+ const r = el.getBoundingClientRect(); if (r.top + SY > H * 0.95 || r.width < 1 || (sidebar && r.left < sidebar.w - 2)) continue;
+ const cs = getComputedStyle(el); if (cs.visibility === 'hidden' || +cs.opacity < 0.05) continue;
+ const size = parseFloat(cs.fontSize); if (!best || size > best.size) best = { el, size };
+ }
+ if (best) { heroEl = best.el; for (let p = heroEl; p && p !== B; p = p.parentElement) if (!/^inline/.test(getComputedStyle(p).display)) { heroEl = p; break; } }
+ }
+ let hero = null;
+ if (heroEl) {
+ const big = [...heroEl.querySelectorAll('*'), heroEl].map((e) => ({ e, s: parseFloat(getComputedStyle(e).fontSize) })).filter((o) => [...o.e.childNodes].some((c) => c.nodeType === 3 && c.nodeValue.trim())).sort((a, b) => b.s - a.s)[0]?.e || heroEl;
+ const cs = getComputedStyle(big), size = parseFloat(cs.fontSize), txt = spaced(heroEl), r = heroEl.getBoundingClientRect();
+ const tops2 = []; const lw = document.createTreeWalker(heroEl, NodeFilter.SHOW_TEXT); const lr = document.createRange();
+ for (let n = lw.nextNode(); n; n = lw.nextNode()) { if (!n.nodeValue.trim()) continue; lr.selectNodeContents(n); for (const rc of lr.getClientRects()) { const mid = rc.top + rc.height / 2; if (rc.width >= 1 && !tops2.some((t) => Math.abs(t - mid) < size * 0.55)) tops2.push(mid); } }
+ const lh = parseFloat(cs.lineHeight);
+ hero = { text: txt.slice(0, 200), words: txt.split(' ').filter(Boolean).length, chars: txt.length, lines: Math.max(1, tops2.length), size: Math.round(size), vw: Math.round((size / W) * 1000) / 10, font: cs.fontFamily.split(',')[0].replace(/["']/g, '').trim(), weight: +cs.fontWeight, tracking: Math.round(((parseFloat(cs.letterSpacing) || 0) / size) * 100) / 100, leading: Number.isFinite(lh) ? Math.round((lh / size) * 100) / 100 : 1.2, top: Math.round(r.top + SY), tag: heroEl.tagName.toLowerCase(), kind: 'heading', align: 'left', position: 'left' };
+ }
+ // charts and timelines on the screen (for the data-hue check): sizeable SVGs with marks, or blocks named as one
+ const chartRe = /(^|[\s_-])(chart|plot|graph|timeline|calendar|cal|gantt|heatmap|matrix|strip)([\s_-]|$)/i;
+ const chartCount = [...B.querySelectorAll('svg')].filter((s) => { if (s.parentElement && s.parentElement.closest('svg')) return false; const r = s.getBoundingClientRect(); return r.width >= 200 && r.height >= 80 && s.querySelectorAll('path, rect, line, polyline, circle').length >= 6 && shown(s); }).length
+ + [...B.querySelectorAll('[class]')].filter((e) => typeof e.className === 'string' && chartRe.test(e.className) && !e.closest('svg') && (() => { const r = e.getBoundingClientRect(); return r.width >= 200 && r.height >= 80 && shown(e); })()).length;
return {
viewport: { w: W, h: H }, dark: lum(pageBg) < 0.2, ground: hex(pageBg),
- sidebar, topbar, canvas,
- layout: { panels: tops.length, firstScreen, ragged: ragged.slice(0, 6) },
+ sidebar, topbar, canvas, hero, charts: chartCount,
+ layout: { panels: tops.length, firstScreen, ragged: ragged.slice(0, 6), voids: voids.slice(0, 4) },
tiles,
panels: { count: panels.length, radii: [...radii.entries()].sort((a, b) => b[1] - a[1]).slice(0, 6), heavyBorders, borderSamples, heavyShadows, softShadows, shadowSamples, glass },
chips: { count: chips.length, hues: chipHues.size, samples: chips.slice(0, 4) },
diff --git a/skills/taste-skill/scripts/lib/rules.mjs b/skills/taste-skill/scripts/lib/rules.mjs
index 3cd2d79..e2a5473 100644
--- a/skills/taste-skill/scripts/lib/rules.mjs
+++ b/skills/taste-skill/scripts/lib/rules.mjs
@@ -223,7 +223,14 @@ export function judgeApp(A, m, { width = A.viewport.w, allow = [] } = {}) {
if (!mobile && A.layout) {
if (A.layout.ragged.length) add('WARN', 'ragged-row', `${A.layout.ragged.length} pair(s) of cards in one row end at different heights (by ${A.layout.ragged.map((r) => r.diff + 'px').slice(0, 3).join(', ')}).`, 'Cards that share a row share a bottom edge: balance them by their content (the same number of rows, a block of similar height beside it), or stack them. In testing, ragged rows were marked down every time.');
if (width >= 1100 && A.layout.panels >= 4 && A.layout.firstScreen / A.layout.panels < 0.5) add('WARN', 'below-fold', `Only ${A.layout.firstScreen} of ${A.layout.panels} blocks start on the first ${width}px screen.`, 'Every block the brief names shows its header and first rows on the first desktop screen: size the headline block to its question, cap long lists with "View all", and put time-sensitive blocks before long tables.');
+ if (width >= 1100 && A.layout.voids?.length) add('WARN', 'panel-void', `${A.layout.voids.length} card(s) hold a blank band inside: ${A.layout.voids.slice(0, 3).map((v) => `${v.gap}px in "${v.panel}"`).join(', ')}.`, 'A card stretches to its neighbour only when it has content to fill. Keep a legend or a note directly under its chart (only an action or a total may sit at a stretched card\'s foot), let a short card keep its own height (align-items: start), and let a filtered block shrink to its rows.');
}
+ // an achromatic screen with a chart or a timeline and no hue on any data reads as a kit: the one chart hue goes on
+ // the main data element (today's line, the booked bars, the margin that breaks)
+ if (!mobile && A.charts > 0 && A.chartHues === 0 && A.colourShare != null && A.colourShare < 0.002) add('WARN', 'no-data-hue', `The screen has ${A.charts === 1 ? 'a chart' : A.charts + ' charts or timelines'} but no hue on any of its data (${(A.colourShare * 100).toFixed(1)}% coloured pixels).`, 'Put the style\'s one chart hue (or the brand\'s) on the screen\'s main data element: today\'s line, the booked bars, the current period, the cover margin. Keep the chrome neutral; the hue still stays under the style\'s colour budget.');
+ // in app mode the screen's hero is its h1 or the largest text on the first screen, not the page probe's guess
+ // (which can be a figure below the fold read without its spaces); the report and the MEASURED line use this one
+ if (A.hero && m) m.hero = A.hero;
if (A.title && A.title.size > (mobile ? 28 : 34)) add('WARN', 'app-title-size', `The h1 is ${A.title.size}px ("${A.title.text.slice(0, 40)}").`, 'An app screen is not a landing page: the title is 18-32px (20-24px on a phone).');
if (A.numbers.kpiMax && A.numbers.kpiMax >= 48) add('WARN', 'kpi-size', `A figure is set at ${Math.round(A.numbers.kpiMax)}px.`, 'Figures run 16-40px on app screens; none of the studied screens reaches 48px. Size and isolation make a number loud, not display type.');
if (A.type.sizes.length > 10) add('WARN', 'size-count', `${A.type.sizes.length} font sizes (${A.type.sizes.join(', ')}).`, 'App screens use 4-9 sizes (median 6): a scale such as 12/14/16/24 with one figure size.');
@@ -233,4 +240,4 @@ export function judgeApp(A, m, { width = A.viewport.w, allow = [] } = {}) {
return out;
}
-export const RULE_IDS = ['headline-lines', 'statement-length', 'focal-point', 'hero-words', 'mixed-font-headline', 'eyebrow', 'mono', 'numbering', 'micro-label', 'emoji', 'gradient', 'gradient-text', 'shadow', 'text-shadow', 'button-fx', 'hairline', 'outlined-box', 'dashed', 'glass', 'icon-cards', 'card-rows', 'pill-nav', 'palette-claude', 'palette-terracotta', 'palette-cream', 'palette-purple', 'default-link', 'contrast', 'font-count', 'font-fallback', 'size-count', 'body-size', 'measure', 'small-text', 'all-centred', 'ui-wrapper', 'overflow', 'broken-image', 'no-hero', 'first-action', 'grey-body', 'blend-text', 'covered-text', 'clipped-text', 'pinned-over-picture', 'empty-screens', 'long-pin', 'side-scroll', 'few-pictures', 'no-real-pictures', 'no-footage', 'still-page', 'off-centre', 'lopsided', 'blank-gap', 'no-title', 'small-title', 'many-h1', 'name-only-title', 'empty-middle', 'untitled-section', 'edge-text', 'ragged-edges', 'sidebar-phone', 'unused-canvas', 'heavy-shadow', 'heavy-borders', 'radius-mix', 'icon-chips', 'numeric-align', 'tabular', 'rainbow-chart', 'placeholder-data', 'tiny-text', 'colour-sprawl', 'ragged-row', 'below-fold', 'app-title-size', 'kpi-size', 'icon-tiles', 'late-title', 'reduced-hidden', 'no-poster', 'hero-void', 'one-sided-bleed', 'font-not-dealt'];
+export const RULE_IDS = ['headline-lines', 'statement-length', 'focal-point', 'hero-words', 'mixed-font-headline', 'eyebrow', 'mono', 'numbering', 'micro-label', 'emoji', 'gradient', 'gradient-text', 'shadow', 'text-shadow', 'button-fx', 'hairline', 'outlined-box', 'dashed', 'glass', 'icon-cards', 'card-rows', 'pill-nav', 'palette-claude', 'palette-terracotta', 'palette-cream', 'palette-purple', 'default-link', 'contrast', 'font-count', 'font-fallback', 'size-count', 'body-size', 'measure', 'small-text', 'all-centred', 'ui-wrapper', 'overflow', 'broken-image', 'no-hero', 'first-action', 'grey-body', 'blend-text', 'covered-text', 'clipped-text', 'pinned-over-picture', 'empty-screens', 'long-pin', 'side-scroll', 'few-pictures', 'no-real-pictures', 'no-footage', 'still-page', 'off-centre', 'lopsided', 'blank-gap', 'no-title', 'small-title', 'many-h1', 'name-only-title', 'empty-middle', 'untitled-section', 'edge-text', 'ragged-edges', 'sidebar-phone', 'unused-canvas', 'heavy-shadow', 'heavy-borders', 'radius-mix', 'icon-chips', 'numeric-align', 'tabular', 'rainbow-chart', 'placeholder-data', 'tiny-text', 'colour-sprawl', 'ragged-row', 'below-fold', 'app-title-size', 'kpi-size', 'icon-tiles', 'late-title', 'reduced-hidden', 'no-poster', 'hero-void', 'one-sided-bleed', 'font-not-dealt', 'panel-void', 'no-data-hue'];