No hand-written SVG: visx charts, lucide icons, Mermaid journey diagram

- desktop: Growth chart, Health and portfolio sparklines and the rollout bar drawn with visx (responsive width,
  crosshair tooltip with real values, arrow keys, theme tokens, no animation); icons from lucide-react behind the
  existing Icon names; empty states are lucide icons on token tiles; store marks are generic lucide icons; stars are
  lucide; the brand mark moves to ui/brand.tsx as the one allowed inline SVG
- fixtures: app icons and store art stand-ins are PNGs rendered by tools/fixture-art.ts (lucide on gradients)
- site: icons are lucide's own files in site/img/icons (tools/site-icons.ts, with the ISC licence) shown as CSS masks;
  the journey diagram is rendered from docs/diagrams/journey.mmd by tools/diagrams.ts (Mermaid CLI), with a tall
  variant for phones
- tests/no-handmade-svg.test.ts fails on new inline SVG drawing in apps/desktop/src and site/*.html
- desktop bundle: 598.7 -> 695.5 kB minified, 174.6 -> 206.0 kB gzip
This commit is contained in:
CRTkafa 2026-10-11 00:49:30 +00:00
parent c2b0a0d8a3
commit 82066de5ed
62 changed files with 840 additions and 661 deletions

View file

@ -1,11 +1,20 @@
// A small line chart for daily store analytics. Reach (impressions, visitors), installs and conversion differ by one
// to three orders of magnitude, so on one count axis installs lay flat at the bottom. The chart therefore plots each
// line as an index (100 = that line's own average over the days shown, views.ts indexSeries) on one shared axis: every
// line uses the full height and a listing change shows as lines moving apart. Hover (or arrow keys when focused) shows
// the real values of one day; store changes from git are dashed markers.
import { type KeyboardEvent, useId, useState } from 'react';
// Daily store analytics as lines, drawn with visx (scales, axes, shapes, gradient, tooltip, responsive width). Reach
// (impressions, visitors), installs and conversion differ by one to three orders of magnitude, so on one count axis
// installs lay flat at the bottom. The chart therefore plots each line as an index (100 = that line's own average over
// the days shown, views.ts indexSeries) on one shared axis with a dashed 100 baseline: every line uses the full height
// and a listing change shows as lines moving apart. A crosshair tooltip (pointer, or arrow keys when focused) shows the
// real values of one day and the store changes from git made that day; changes are dashed markers.
import { AxisBottom, AxisLeft } from '@visx/axis';
import { curveMonotoneX } from '@visx/curve';
import { LinearGradient } from '@visx/gradient';
import { Group } from '@visx/group';
import { useParentSize } from '@visx/responsive';
import { scaleLinear } from '@visx/scale';
import { AreaClosed, Bar, Circle, Line, LinePath } from '@visx/shape';
import { useId } from 'react';
import { date, num, pct } from '../lib/format';
import { indexSeries } from '../lib/views';
import { ChartTip, useIndexHover } from './charts';
export interface ChartLine {
label: string;
@ -15,7 +24,7 @@ export interface ChartLine {
unit: 'count' | 'rate';
}
const W = 800, H = 230, L = 46, R = 18, T = 14, B = 26;
const M = { top: 14, right: 18, bottom: 26, left: 46 };
/** Index axis: a round top above the highest point (at least 150 so 100 sits in the lower two thirds) and 4 ticks. */
export function indexAxis(lines: (number | null)[][]): { max: number; ticks: number[] } {
@ -25,54 +34,79 @@ export function indexAxis(lines: (number | null)[][]): { max: number; ticks: num
return { max, ticks: Array.from({ length: max / step + 1 }, (_, i) => i * step) };
}
/** Up to `most` evenly spread day indexes, always the first and the last. */
export function dateTicks(n: number, most: number): number[] {
if (n <= 1) return [0];
const k = Math.max(2, Math.min(n, most));
return [...new Set(Array.from({ length: k }, (_, i) => Math.round((i * (n - 1)) / (k - 1))))];
}
export function LineChart({ dates, lines, events, label, eventsLabel, indexLabel }: {
dates: string[]; lines: ChartLine[]; events: { date: string; subject: string }[]; label: string; eventsLabel: string; indexLabel: string;
}) {
const gid = useId().replace(/:/g, '');
const [hover, setHover] = useState<number | null>(null);
const gid = `lg${useId().replace(/:/g, '')}`;
const { parentRef, width } = useParentSize({ debounceTime: 50 });
const n = dates.length;
const h = useIndexHover(n, width, M.left, M.right);
if (n < 2) return null;
// responsive: the height follows the width between 180 and 260 px
const height = Math.round(Math.max(180, Math.min(260, width * 0.3)));
const plotted = lines.map(l => indexSeries(l.values));
const { max, ticks } = indexAxis(plotted);
const x = (i: number) => L + (i / (n - 1)) * (W - L - R);
const y = (v: number) => H - B - (v / max) * (H - T - B);
const path = (vs: (number | null)[]) => vs.map((v, i) => (v === null ? '' : `${i && vs[i - 1] !== null ? 'L' : 'M'}${x(i).toFixed(1)} ${y(v).toFixed(1)}`)).join(' ');
const onMove = (ev: React.MouseEvent<SVGSVGElement>) => {
const r = ev.currentTarget.getBoundingClientRect();
const px = ((ev.clientX - r.left) / r.width) * W;
setHover(Math.max(0, Math.min(n - 1, Math.round(((px - L) / (W - L - R)) * (n - 1)))));
};
const onKey = (ev: KeyboardEvent) => {
if (ev.key === 'ArrowRight') { ev.preventDefault(); setHover(h => Math.min(n - 1, (h ?? -1) + 1)); }
if (ev.key === 'ArrowLeft') { ev.preventDefault(); setHover(h => Math.max(0, (h ?? n) - 1)); }
};
const x = scaleLinear({ domain: [0, n - 1], range: [M.left, Math.max(M.left + 1, width - M.right)] });
const y = scaleLinear({ domain: [0, max], range: [height - M.bottom, M.top] });
const pts = (vs: (number | null)[]) => vs.map((v, i) => [i, v] as const);
const defined = (d: readonly [number, number | null]) => d[1] !== null;
const xs = dateTicks(n, Math.max(2, Math.floor(width / 110)));
const onDay = (i: number) => events.filter(e => e.date === dates[i]);
const fmt = (l: ChartLine, v: number | null) => (v === null ? '–' : l.unit === 'rate' ? pct(v, 1) : num(v));
const hv = h.hover;
return (
<div className="lchart">
<svg viewBox={`0 0 ${W} ${H}`} role="img" aria-label={`${label} (${indexLabel})`} tabIndex={0} onMouseMove={onMove} onMouseLeave={() => setHover(null)} onKeyDown={onKey} onBlur={() => setHover(null)}>
<defs><linearGradient id={`lg${gid}`} x1="0" y1="0" x2="0" y2="1"><stop offset="0" className="stop-a" /><stop offset="1" className="stop-b" /></linearGradient></defs>
{ticks.map(v => (
<g key={v} className="grid-l">
<line x1={L} x2={W - R} y1={y(v)} y2={y(v)} />
<text x={L - 6} y={y(v) + 4} textAnchor="end">{v}</text>
</g>
))}
<line className="base" x1={L} x2={W - R} y1={y(100)} y2={y(100)} />
{events.map((e, i) => {
const k = dates.indexOf(e.date);
if (k < 0) return null;
return <g key={i} className="ev"><line x1={x(k)} x2={x(k)} y1={T} y2={H - B} /><circle cx={x(k)} cy={T + 4} r={4}><title>{`${date(e.date)} · ${e.subject}`}</title></circle></g>;
})}
{plotted[0] && <path className="area" d={`${path(plotted[0])} L${x(n - 1)} ${H - B} L${x(0)} ${H - B} Z`} fill={`url(#lg${gid})`} />}
{lines.map((l, k) => <path key={l.label} className={`ln ${l.cls}`} d={path(plotted[k]!)} />)}
{hover !== null && <g className="hov"><line x1={x(hover)} x2={x(hover)} y1={T} y2={H - B} />{lines.map((l, k) => (plotted[k]![hover] === null ? null : <circle key={l.label} className={l.cls} cx={x(hover)} cy={y(plotted[k]![hover]!)} r={3.5} />))}</g>}
<text className="ax" x={L} y={H - 6}>{date(dates[0])}</text>
<text className="ax" x={W - R} y={H - 6} textAnchor="end">{date(dates[n - 1])}</text>
</svg>
<div ref={parentRef} className="lchart-plot" style={{ height }}>
{width > 0 && (
<svg width={width} height={height} role="img" aria-label={`${label} (${indexLabel})`} tabIndex={0} {...h.handlers}>
<LinearGradient id={gid} vertical from="var(--accent-solid)" to="var(--accent-solid)" fromOpacity={0.18} toOpacity={0} />
<Group className="grid-l">
{ticks.map(v => <Line key={v} from={{ x: M.left, y: y(v) }} to={{ x: width - M.right, y: y(v) }} />)}
</Group>
<AxisLeft scale={y} left={M.left} tickValues={ticks} hideAxisLine hideTicks tickClassName="ax" tickLabelProps={{ className: 'ax', textAnchor: 'end', dx: -4, dy: 4 }} />
<AxisBottom scale={x} top={height - M.bottom} tickValues={xs} tickFormat={v => date(dates[Number(v)])} hideAxisLine hideTicks
tickLabelProps={(_, i) => ({ className: 'ax', textAnchor: i === 0 ? 'start' : i === xs.length - 1 ? 'end' : 'middle', dy: 4 })} />
<Line className="base" from={{ x: M.left, y: y(100) }} to={{ x: width - M.right, y: y(100) }} />
{events.map((e, i) => {
const k = dates.indexOf(e.date);
if (k < 0) return null;
return (
<Group key={i} className="ev">
<Line from={{ x: x(k), y: M.top }} to={{ x: x(k), y: height - M.bottom }} />
<Circle cx={x(k)} cy={M.top + 4} r={4}><title>{`${date(e.date)} · ${e.subject}`}</title></Circle>
</Group>
);
})}
{plotted[0] && <AreaClosed data={pts(plotted[0])} defined={defined} x={d => x(d[0])} y={d => y(d[1] ?? 0)} yScale={y} curve={curveMonotoneX} fill={`url(#${gid})`} className="area" />}
{lines.map((l, k) => <LinePath key={l.label} className={`ln ${l.cls}`} data={pts(plotted[k]!)} defined={defined} x={d => x(d[0])} y={d => y(d[1] ?? 0)} curve={curveMonotoneX} />)}
{hv !== null && (
<Group className="hov">
<Line from={{ x: x(hv), y: M.top }} to={{ x: x(hv), y: height - M.bottom }} />
{lines.map((l, k) => (plotted[k]![hv] === null ? null : <Circle key={l.label} className={l.cls} cx={x(hv)} cy={y(plotted[k]![hv]!)} r={3.5} />))}
</Group>
)}
<Bar x={M.left} y={M.top} width={Math.max(0, width - M.left - M.right)} height={height - M.top - M.bottom} fill="transparent" />
</svg>
)}
{hv !== null && width > 0 && (
<ChartTip left={x(hv)} top={h.tooltipTop ?? M.top}>
<b>{date(dates[hv])}</b>
{lines.map(l => <span key={l.label} className="vx-row"><i className={`sw ${l.cls}`} />{l.label}<b className="num">{fmt(l, l.values[hv] ?? null)}</b></span>)}
{onDay(hv).map((e, i) => <span key={i} className="vx-row ev"><i className="sw ev" />{e.subject}</span>)}
</ChartTip>
)}
</div>
<div className="lchart-legend" aria-live="polite">
<span className="lg idx">{indexLabel}</span>
{hover !== null && <b className="num">{date(dates[hover])}</b>}
{lines.map(l => <span key={l.label} className="lg"><span className={`sw ${l.cls}`} />{l.label}{hover !== null && <b className="num">{fmt(l, l.values[hover] ?? null)}</b>}</span>)}
{hv !== null && <b className="num">{date(dates[hv])}</b>}
{lines.map(l => <span key={l.label} className="lg"><span className={`sw ${l.cls}`} />{l.label}{hv !== null && <b className="num">{fmt(l, l.values[hv] ?? null)}</b>}</span>)}
{events.length > 0 && <span className="lg"><span className="sw ev" />{eventsLabel}</span>}
</div>
</div>

View file

@ -0,0 +1,16 @@
// The storebound brand mark (an arrow out of a tray, like site/favicon.svg). A brand asset, kept as the owner made it:
// the one file in apps/desktop/src where the CI guard (tests/no-handmade-svg.test.ts) allows inline SVG.
export function Mark({ className }: { className?: string }) {
return (
<svg viewBox="0 0 32 32" className={className} aria-hidden="true">
<defs>
<linearGradient id="sb-mark" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stopColor="#6d67f0" />
<stop offset="1" stopColor="#4338ca" />
</linearGradient>
</defs>
<rect width="32" height="32" rx="8" fill="url(#sb-mark)" />
<path d="M16 7.5v11M11 12.5l5-5 5 5M8.5 18v5.5h15V18" fill="none" stroke="#fff" strokeWidth="2.6" strokeLinecap="round" strokeLinejoin="round" />
</svg>
);
}

View file

@ -0,0 +1,99 @@
// Small charts drawn with visx (@visx/*, MIT): scales, shapes, curves, gradients, responsive sizing and tooltips come
// from the library; this file only maps data to them. Colours are the design tokens (styles.css .spark, .rbar,
// .vx-tip). Nothing animates, so reduced motion needs no extra case.
import { localPoint } from '@visx/event';
import { curveMonotoneX } from '@visx/curve';
import { LinearGradient } from '@visx/gradient';
import { useParentSize } from '@visx/responsive';
import { scaleLinear } from '@visx/scale';
import { Group } from '@visx/group';
import { AreaClosed, Bar, Circle, Line, LinePath } from '@visx/shape';
import { TooltipWithBounds, useTooltip } from '@visx/tooltip';
import { type KeyboardEvent, type PointerEvent, type ReactNode, useId } from 'react';
import { date, pct } from '../lib/format';
import type { Tone } from '../lib/model';
/** A hovered (or keyboard-picked) index along x, with pointer and arrow-key handlers for an svg of `width`. */
export function useIndexHover(n: number, width: number, left: number, right: number) {
const tip = useTooltip<number>();
const at = (i: number, top = 0) => tip.showTooltip({ tooltipData: i, tooltipLeft: left + (n < 2 ? 0 : (i / (n - 1)) * (width - left - right)), tooltipTop: top });
const onPointerMove = (ev: PointerEvent<SVGElement>) => {
const p = localPoint(ev);
if (!p || n < 1) return;
const span = Math.max(1, width - left - right);
at(Math.max(0, Math.min(n - 1, Math.round(((p.x - left) / span) * (n - 1)))), p.y);
};
const onKeyDown = (ev: KeyboardEvent) => {
const cur = tip.tooltipOpen ? tip.tooltipData ?? null : null;
if (ev.key === 'ArrowRight') { ev.preventDefault(); at(Math.min(n - 1, (cur ?? -1) + 1), 12); }
if (ev.key === 'ArrowLeft') { ev.preventDefault(); at(Math.max(0, (cur ?? n) - 1), 12); }
if (ev.key === 'Escape') tip.hideTooltip();
};
return { ...tip, hover: tip.tooltipOpen ? tip.tooltipData ?? null : null, handlers: { onPointerMove, onPointerLeave: tip.hideTooltip, onKeyDown, onBlur: tip.hideTooltip } };
}
/** The chart tooltip: visx positions it inside the chart's box (flips at the edges); styles.css .vx-tip draws it. */
export function ChartTip({ left, top, children }: { left: number; top: number; children: ReactNode }) {
return <TooltipWithBounds left={left + 12} top={top + 8} unstyled applyPositionStyle className="vx-tip">{children}</TooltipWithBounds>;
}
/** Daily rate (crash, ANR) as a line + area with a dashed threshold. The y range always shows the threshold. With
* `dates` the chart has a crosshair and a one-line tooltip with the day's real value (the threshold is in the card's
* legend); `compact` (portfolio rows) has none. */
export function Sparkline({ values, dates, threshold, tone = 'neutral', label, compact }: {
values: number[]; dates?: string[]; threshold?: number; tone?: Tone; label: string; compact?: boolean;
}) {
const { parentRef, width, height } = useParentSize({ debounceTime: 50 });
const gid = `sg${useId().replace(/:/g, '')}`;
const interactive = !compact && !!dates && dates.length === values.length;
const pad = compact ? 2 : 4;
const h = hover(useIndexHover(values.length, width, 0, 0), interactive);
if (!values.length) return <div className={`spark ${tone}`} />;
const max = Math.max(...values, (threshold ?? 0) * 1.25) * 1.08 || 1;
const x = scaleLinear({ domain: [0, Math.max(1, values.length - 1)], range: values.length === 1 ? [width / 2, width / 2] : [0, width] });
const y = scaleLinear({ domain: [0, max], range: [height - pad, pad] });
const pts = values.map((v, i) => [i, v] as const);
return (
<div ref={parentRef} className={`spark ${tone}${compact ? ' compact' : ''}`}>
{width > 0 && height > 0 && (
<svg width={width} height={height} role="img" aria-label={label} tabIndex={interactive ? 0 : undefined} {...(interactive ? h.handlers : {})}>
<LinearGradient id={gid} from="var(--spark)" to="var(--spark)" fromOpacity={0.28} toOpacity={0} vertical />
<AreaClosed data={pts} x={d => x(d[0])} y={d => y(d[1])} yScale={y} curve={curveMonotoneX} fill={`url(#${gid})`} className="area" />
{threshold !== undefined && <Line className="thr" from={{ x: 0, y: y(threshold) }} to={{ x: width, y: y(threshold) }} />}
<LinePath data={pts} x={d => x(d[0])} y={d => y(d[1])} curve={curveMonotoneX} className="line" />
{h.hover !== null && (
<Group className="hov">
<Line from={{ x: x(h.hover), y: 0 }} to={{ x: x(h.hover), y: height }} />
<Circle cx={x(h.hover)} cy={y(values[h.hover]!)} r={3.5} />
</Group>
)}
{interactive && <Bar x={0} y={0} width={width} height={height} fill="transparent" />}
</svg>
)}
{h.hover !== null && dates && (
<ChartTip left={x(h.hover)} top={y(values[h.hover]!)}>
<span className="vx-row"><i className={`sw ${tone}`} />{date(dates[h.hover])}<b className="num">{pct(values[h.hover]!)}</b></span>
</ChartTip>
)}
</div>
);
}
const hover = (h: ReturnType<typeof useIndexHover>, on: boolean) => (on ? h : { ...h, hover: null });
/** Staged rollout (Play) or phased release (App Store) share as a visx bar on a track, with the meter semantics. */
export function RolloutBar({ value, tone = 'accent', label }: { value: number; tone?: Tone; label: string }) {
const { parentRef, width, height } = useParentSize({ debounceTime: 50 });
const v = Math.max(0, Math.min(1, value));
const x = scaleLinear({ domain: [0, 1], range: [0, width] });
return (
<div ref={parentRef} className={`rbar ${tone}`} role="meter" aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(v * 100)} aria-label={label}>
{width > 0 && height > 0 && (
<svg width={width} height={height} aria-hidden="true">
<Bar className="track" x={0} y={0} width={width} height={height} rx={height / 2} />
{v > 0 && <Bar className="fill" x={0} y={0} width={Math.max(height, x(v))} height={height} rx={height / 2} />}
</svg>
)}
</div>
);
}

View file

@ -1,114 +1,44 @@
// One stroke icon set (24 x 24 grid, 1.75 stroke, round caps), drawn for this app. Decorative: aria-hidden.
const P = {
portfolio: 'M4 4h6.5v6.5H4zM13.5 4H20v6.5h-6.5zM4 13.5h6.5V20H4zM13.5 13.5H20V20h-6.5z',
folder: 'M3.5 7A1.5 1.5 0 0 1 5 5.5h4l2 2h8A1.5 1.5 0 0 1 20.5 9v8.5A1.5 1.5 0 0 1 19 19H5a1.5 1.5 0 0 1-1.5-1.5z',
folderPlus: 'M3.5 7A1.5 1.5 0 0 1 5 5.5h4l2 2h8A1.5 1.5 0 0 1 20.5 9v8.5A1.5 1.5 0 0 1 19 19H5a1.5 1.5 0 0 1-1.5-1.5zM12 10.5v5M9.5 13h5',
key: 'M8 20a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9zM11.2 12.3 20 3.5M16.5 7l2.5 2.5M14.2 9.3l2 2',
package: 'M12 3 20 7.5v9L12 21l-8-4.5v-9zM4 7.5l8 4.5 8-4.5M12 12v9',
settings: 'M12 15.2a3.2 3.2 0 1 0 0-6.4 3.2 3.2 0 0 0 0 6.4zM19.1 13.6l1.4 1.1-1.8 3.1-1.7-.6a7 7 0 0 1-1.9 1.1l-.3 1.8h-3.6l-.3-1.8a7 7 0 0 1-1.9-1.1l-1.7.6-1.8-3.1 1.4-1.1a7 7 0 0 1 0-2.2L3.5 9.3l1.8-3.1 1.7.6A7 7 0 0 1 8.9 5.7l.3-1.8h3.6l.3 1.8a7 7 0 0 1 1.9 1.1l1.7-.6 1.8 3.1-1.4 1.1a7 7 0 0 1 0 2.2z',
search: 'M10.5 17a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13zM15.3 15.3 20 20',
refresh: 'M20 11a8 8 0 0 0-14.3-4.9L4 8M4 4v4h4M4 13a8 8 0 0 0 14.3 4.9L20 16M20 20v-4h-4',
chevronRight: 'M9.5 6l6 6-6 6',
chevronDown: 'M6 9.5l6 6 6-6',
plus: 'M12 5v14M5 12h14',
x: 'M6 6l12 12M18 6 6 18',
check: 'M5 12.5l4.5 4.5L19 7.5',
alert: 'M12 4 21 19.5H3zM12 10v4.5M12 17.2v.1',
alertCircle: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7.5v5.5M12 16.3v.1',
info: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 11v5.5M12 7.7v.1',
external: 'M14 4h6v6M20 4l-8.5 8.5M18 14v4.5A1.5 1.5 0 0 1 16.5 20h-11A1.5 1.5 0 0 1 4 18.5v-11A1.5 1.5 0 0 1 5.5 6H10',
download: 'M12 4v11M7.5 10.5 12 15l4.5-4.5M4.5 19.5h15',
trash: 'M4.5 7h15M9.5 7V4.5h5V7M6.5 7l1 12.5h9l1-12.5M10.5 11v5M13.5 11v5',
star: 'M12 3.8l2.5 5.1 5.6.8-4 4 1 5.5-5.1-2.7-5 2.7 1-5.5-4.1-4 5.7-.8z',
message: 'M5 5.5h14A1.5 1.5 0 0 1 20.5 7v9a1.5 1.5 0 0 1-1.5 1.5h-7l-4.5 3v-3H5A1.5 1.5 0 0 1 3.5 16V7A1.5 1.5 0 0 1 5 5.5z',
activity: 'M3.5 12h4l2.5-6.5 4 13 2.5-6.5h4',
tag: 'M3.5 12.3V4.5a1 1 0 0 1 1-1h7.8l8.2 8.2a1.4 1.4 0 0 1 0 2L13.7 20.5a1.4 1.4 0 0 1-2 0zM8 8.2v.1',
text: 'M6 3.5h8.5L19 8v12.5H6zM14 3.5V8.5h5M9 12.5h7M9 16h5',
plane: 'M21 3.5 10.5 14M21 3.5l-6.5 17-4-6.5-6.5-4z',
rocket: 'M14 4.5c3-1 5.5-1 5.5-1s0 2.5-1 5.5L12 15.5 8.5 12zM8.5 12l-3 .5-2 2 4 1M12 15.5l-.5 3-2 2-1-4M15.5 8.5v.1',
shield: 'M12 3.5 19 6v5.5c0 4.5-3 7.5-7 9-4-1.5-7-4.5-7-9V6zM8.8 12l2.2 2.2 4.4-4.4',
clock: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3.5 2',
command: 'M9 6.5A2.5 2.5 0 1 0 6.5 9H9zm0 0v11m0-11h6m-6 11a2.5 2.5 0 1 1-2.5-2.5H9zm6-11A2.5 2.5 0 1 1 17.5 9H15zm0 0v11m0 0a2.5 2.5 0 1 0 2.5-2.5H15zM9 9h6M9 15h6',
globe: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM3.5 12h17M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9c-2.5-2.5-3.5-5.5-3.5-9S9.5 5.5 12 3z',
moon: 'M19.5 14.5A7.5 7.5 0 0 1 9.5 4.5a7.5 7.5 0 1 0 10 10z',
sun: 'M12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM12 2.5v2M12 19.5v2M4.6 4.6l1.4 1.4M18 18l1.4 1.4M2.5 12h2M19.5 12h2M4.6 19.4 6 18M18 6l1.4-1.4',
terminal: 'M4.5 5h15A1.5 1.5 0 0 1 21 6.5v11a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5v-11A1.5 1.5 0 0 1 4.5 5zM7 9.5l3 2.5-3 2.5M12.5 15h4',
copy: 'M9 9h10.5v10.5H9zM15 9V4.5H4.5V15H9',
image: 'M5 4.5h14A1.5 1.5 0 0 1 20.5 6v12a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 18V6A1.5 1.5 0 0 1 5 4.5zM3.5 16l5-5 4 4 2.5-2.5 5.5 5.5M15.5 9.5v.1',
users: 'M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM2.5 20a6.5 6.5 0 0 1 13 0M16 4.3a3.5 3.5 0 0 1 0 6.4M18 14a6.5 6.5 0 0 1 3.5 6',
layers: 'M12 3.5 21 8l-9 4.5L3 8zM3 12.5l9 4.5 9-4.5M3 16.5l9 4.5 9-4.5',
sparkle: 'M12 3.5c.6 4 2.4 5.9 6.5 6.5-4.1.6-5.9 2.5-6.5 6.5-.6-4-2.4-5.9-6.5-6.5 4.1-.6 5.9-2.5 6.5-6.5zM18.5 15.5c.3 1.6 1 2.3 2.5 2.5-1.5.2-2.2.9-2.5 2.5-.3-1.6-1-2.3-2.5-2.5 1.5-.2 2.2-.9 2.5-2.5z',
pause: 'M8.5 5.5v13M15.5 5.5v13',
cube: 'M12 3.5 20 8v8l-8 4.5L4 16V8zM12 12.5V20.5M12 12.5 20 8M12 12.5 4 8',
arrowRight: 'M5 12h14M13 6l6 6-6 6',
arrowLeft: 'M19 12H5M11 6l-6 6 6 6',
dot: 'M12 12.5a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1z',
phone: 'M7.5 3h9A1.5 1.5 0 0 1 18 4.5v15a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 6 19.5v-15A1.5 1.5 0 0 1 7.5 3zM10.5 18h3',
keyboard: 'M3.5 6.5h17A1 1 0 0 1 21.5 7.5v9a1 1 0 0 1-1 1h-17a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zM6.5 10h.1M10 10h.1M13.5 10h.1M17 10h.1M7.5 14h9',
database: 'M12 8c4.4 0 8-1.3 8-3s-3.6-3-8-3-8 1.3-8 3 3.6 3 8 3zM4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3',
wand: 'M14.5 6.5l3 3M4 20 17.5 6.5l-3-3L1 17zM19 2.5v3M20.5 4h-3M21 10v2M22 11h-2',
building: 'M4.5 20.5V5A1.5 1.5 0 0 1 6 3.5h7A1.5 1.5 0 0 1 14.5 5v15.5M14.5 9.5H18a1.5 1.5 0 0 1 1.5 1.5v9.5M3 20.5h18M8 7.5h3M8 11h3M8 14.5h3',
eye: 'M2.5 12c1-1.5 4.5-6 9.5-6s8.5 4.5 9.5 6c-1 1.5-4.5 6-9.5 6s-8.5-4.5-9.5-6zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z',
eyeOff: 'M3 3l18 18M10.6 6.1c.5-.1.9-.1 1.4-.1 5 0 8.5 4.5 9.5 6-.5.8-1.6 2.3-3.2 3.6M6.4 7.9C4.7 9.2 3.5 10.9 2.5 12c1 1.5 4.5 6 9.5 6 1.5 0 2.9-.4 4.1-1M9.9 9.9a3 3 0 0 0 4.2 4.2',
link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
unlink: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1M4 4l16 16',
bell: 'M6 16.5V11a6 6 0 1 1 12 0v5.5l1.5 2h-15zM10 20.5a2 2 0 0 0 4 0',
filter: 'M4 5.5h16l-6 7.5v5.5l-4 1.5v-7z',
play: 'M8 5.5v13l10.5-6.5z',
send: 'M4 11.5 20 4l-6 16-3-6.5zM11 13.5 20 4',
edit: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4',
upload: 'M12 20V9M7.5 13.5 12 9l4.5 4.5M4.5 4.5h15',
sliders: 'M4 6.5h9M17 6.5h3M4 12h3M11 12h9M4 17.5h11M19 17.5h1M15 4.5v4M9 10v4M17 15.5v4',
rotate: 'M4 12a8 8 0 1 0 2.4-5.7L4 8.5M4 4v4.5h4.5',
cloud: 'M7 18.5h10.5a4 4 0 0 0 .6-8 6 6 0 0 0-11.6 1.6A3.3 3.3 0 0 0 7 18.5z',
coins: 'M9 10c3.3 0 6-1.1 6-2.5S12.3 5 9 5 3 6.1 3 7.5 5.7 10 9 10zM3 7.5v4C3 12.9 5.7 14 9 14s6-1.1 6-2.5v-4M9 18c3.3 0 6-1.1 6-2.5v-4M3 11.5v4C3 16.9 5.7 18 9 18M15.5 10.2c3 .2 5.5 1.2 5.5 2.3v4c0 1.4-2.7 2.5-6 2.5-1.3 0-2.5-.2-3.5-.5',
chart: 'M4 19.5h16M6.5 16l4-5 3 3 5-7M15.5 7h3v3',
flask: 'M9.5 3.5h5M10.5 3.5v5.2L5 18.2a1.5 1.5 0 0 0 1.3 2.3h11.4a1.5 1.5 0 0 0 1.3-2.3l-5.5-9.5V3.5M7.5 14.5h9',
grid: 'M4 4h4.5v6H4zM9.75 4h4.5v6h-4.5zM15.5 4H20v6h-4.5zM4 14h4.5v6H4zM9.75 14h4.5v6h-4.5zM15.5 14H20v6h-4.5z',
clipboard: 'M9 4.5H6.5A1.5 1.5 0 0 0 5 6v13.5A1.5 1.5 0 0 0 6.5 21h11a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H15M9 3h6v3H9zM8.5 11.5l2 2 4-4M8.5 17h7',
share: 'M12 15V3.5M7.5 8 12 3.5 16.5 8M5 12.5v6A1.5 1.5 0 0 0 6.5 20h11a1.5 1.5 0 0 0 1.5-1.5v-6',
lock: 'M6.5 10.5h11A1.5 1.5 0 0 1 19 12v7a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 5 19v-7a1.5 1.5 0 0 1 1.5-1.5zM8.5 10.5V7.5a3.5 3.5 0 0 1 7 0v3',
question: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9.6 9.3a2.5 2.5 0 0 1 4.8.9c0 1.7-2.4 2.2-2.4 3.8M12 17v.1',
} as const;
// Icons come from lucide (lucide-react, ISC licence, https://lucide.dev): one named import per icon so Vite
// tree-shakes the rest. The names below are the app's own (call sites use <Icon name="..." />); each maps to its
// closest lucide icon. Decorative unless a title is given. No hand-drawn SVG in the app: see docs/desktop.md.
import {
Activity, Apple, ArrowLeft, ArrowRight, Bell, Box, Building2, Check, ChevronDown, ChevronRight, CircleAlert, CircleHelp,
ClipboardCheck, Clock, Cloud, Coins, Command, Copy, Database, Dot, Download, ExternalLink, Eye, EyeOff, FileText,
FlaskConical, Folder, FolderPlus, Funnel, Globe, Grid3x2, Image, Info, Key, Keyboard, Layers, LayoutGrid, Link, Lock,
type LucideIcon, MessageSquare, Moon, Package, Pause, Pencil, Play, Plus, RefreshCw, Rocket, RotateCcw, Search, Send,
SendHorizontal, Settings, Share, ShieldCheck, SlidersHorizontal, Smartphone, Sparkles, SquareTerminal, Star, Sun, Tag,
Trash2, TrendingUp, TriangleAlert, Unlink, Upload, Users, WandSparkles, X,
} from 'lucide-react';
export type IconName = keyof typeof P;
const ICONS = {
portfolio: LayoutGrid, folder: Folder, folderPlus: FolderPlus, key: Key, package: Package, settings: Settings,
search: Search, refresh: RefreshCw, chevronRight: ChevronRight, chevronDown: ChevronDown, plus: Plus, x: X, check: Check,
alert: TriangleAlert, alertCircle: CircleAlert, info: Info, external: ExternalLink, download: Download, trash: Trash2,
star: Star, message: MessageSquare, activity: Activity, tag: Tag, text: FileText, plane: Send, rocket: Rocket,
shield: ShieldCheck, clock: Clock, command: Command, globe: Globe, moon: Moon, sun: Sun, terminal: SquareTerminal,
copy: Copy, image: Image, users: Users, layers: Layers, sparkle: Sparkles, pause: Pause, cube: Box,
arrowRight: ArrowRight, arrowLeft: ArrowLeft, dot: Dot, phone: Smartphone, keyboard: Keyboard, database: Database,
wand: WandSparkles, building: Building2, eye: Eye, eyeOff: EyeOff, link: Link, unlink: Unlink, bell: Bell,
filter: Funnel, play: Play, send: SendHorizontal, edit: Pencil, upload: Upload, sliders: SlidersHorizontal,
rotate: RotateCcw, cloud: Cloud, coins: Coins, chart: TrendingUp, flask: FlaskConical, grid: Grid3x2,
clipboard: ClipboardCheck, share: Share, lock: Lock, question: CircleHelp,
} satisfies Record<string, LucideIcon>;
export type IconName = keyof typeof ICONS;
export function Icon({ name, className, title }: { name: IconName; className?: string; title?: string }) {
return (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" className={className} aria-hidden={title ? undefined : true} role={title ? 'img' : undefined}>
{title && <title>{title}</title>}
<path d={P[name]} />
</svg>
);
const C = ICONS[name];
return title
? <C className={className} strokeWidth={1.75} role="img" aria-label={title}><title>{title}</title></C>
: <C className={className} strokeWidth={1.75} aria-hidden="true" />;
}
/** Generic store glyphs (not the stores' logos): a rounded "A" tile for the App Store, a play triangle for Google Play. */
/** Store marks without the stores' logos (Apple publishes no licence for its App Store icon in third-party tools, and
* Google's Play guidelines cover badges): lucide's generic apple (a fruit, not Apple's logo) for the App Store and
* lucide's play triangle for Google Play. Text next to them always names the store. */
export function StoreGlyph({ store, className }: { store: 'ios' | 'android'; className?: string }) {
return store === 'ios' ? (
<svg viewBox="0 0 24 24" className={className} aria-hidden="true" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
<rect x="3" y="3" width="18" height="18" rx="5" />
<path d="M9 16.5 12.6 7.5M15 16.5l-2.2-5.4M8 13.5h8" />
</svg>
) : (
<svg viewBox="0 0 24 24" className={className} aria-hidden="true" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinejoin="round">
<path d="M6 3.8v16.4a.8.8 0 0 0 1.2.7l13.6-8.2a.8.8 0 0 0 0-1.4L7.2 3.1A.8.8 0 0 0 6 3.8z" />
<path d="M6.3 3.4 14.5 12l-8.2 8.6" strokeLinecap="round" />
</svg>
);
const C = store === 'ios' ? Apple : Play;
return <C className={className} strokeWidth={1.75} aria-hidden="true" />;
}
/** The storebound mark (an arrow out of a tray, like the site's favicon). */
export function Mark({ className }: { className?: string }) {
return (
<svg viewBox="0 0 32 32" className={className} aria-hidden="true">
<defs>
<linearGradient id="sb-mark" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stopColor="#6d67f0" />
<stop offset="1" stopColor="#4338ca" />
</linearGradient>
</defs>
<rect width="32" height="32" rx="8" fill="url(#sb-mark)" />
<path d="M16 7.5v11M11 12.5l5-5 5 5M8.5 18v5.5h15V18" fill="none" stroke="#fff" strokeWidth="2.6" strokeLinecap="round" strokeLinejoin="round" />
</svg>
);
}
export { Mark } from './brand';

View file

@ -1,103 +1,34 @@
// Empty state illustrations: inline SVG in the theme's tokens (no external assets, both themes). Decorative.
import type { ReactNode } from 'react';
const Frame = ({ children }: { children: ReactNode }) => (
<svg className="illo" viewBox="0 0 168 112" aria-hidden="true" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<ellipse cx="84" cy="100" rx="58" ry="6" className="f1" />
{children}
</svg>
);
// Empty state art: a lucide icon (lucide-react, ISC) on a soft tile with an optional small badge icon, in the theme's
// tokens (styles.css .illo), the empty-state style of Linear and Vercel. No drawn artwork. Decorative.
import {
Activity, Box, CircleHelp, CloudDownload, FileText, KeyRound, type LucideIcon, MessageSquareText, Package, Plus, Send,
ShieldCheck, Smartphone, Star, Check, Wrench,
} from 'lucide-react';
export type IlloName = 'apps' | 'cloud' | 'reviews' | 'shield' | 'key' | 'plane' | 'pulse' | 'catalog' | 'text' | 'tools' | 'unknown';
const ART: Record<IlloName, [LucideIcon, LucideIcon?]> = {
apps: [Smartphone, Plus],
cloud: [CloudDownload],
reviews: [MessageSquareText, Star],
shield: [ShieldCheck],
key: [KeyRound],
plane: [Send],
pulse: [Activity],
catalog: [Package, Check],
text: [FileText, Check],
tools: [Box, Wrench],
unknown: [CircleHelp],
};
export function Illo({ name }: { name: IlloName }) {
switch (name) {
case 'apps': return (
<Frame>
<rect x="40" y="22" width="40" height="70" rx="9" className="f2" />
<rect x="64" y="14" width="44" height="78" rx="10" className="fs s1" />
<rect x="72" y="26" width="28" height="28" rx="7" className="f1" />
<path d="M80 72h12M80 79h8" className="s2" />
<circle cx="118" cy="28" r="13" className="fl" />
<path d="M118 22v12M112 28h12" stroke="#fff" />
</Frame>
);
case 'cloud': return (
<Frame>
<path d="M54 66a16 16 0 0 1 3-31.7A22 22 0 0 1 99 30a17 17 0 0 1 14 36z" className="f2" />
<path d="M60 62a14 14 0 0 1 2.6-27.7A19 19 0 0 1 98.5 32 15 15 0 0 1 110 62" className="s1" />
<path d="M84 50v32M75 73l9 9 9-9" className="s1" />
<path d="M60 92h48" className="s2" strokeDasharray="3 5" />
</Frame>
);
case 'reviews': return (
<Frame>
<path d="M38 24h70a8 8 0 0 1 8 8v30a8 8 0 0 1-8 8H66l-14 12V70H38a8 8 0 0 1-8-8V32a8 8 0 0 1 8-8z" className="f2" />
<path d="M60 36h66a8 8 0 0 1 8 8v28a8 8 0 0 1-8 8h-12v12l-14-12H60a8 8 0 0 1-8-8V44a8 8 0 0 1 8-8z" className="fs s1" />
{[72, 86, 100, 114].map((x, i) => <path key={x} d={`M${x} 52l2.2 4.6 5 .7-3.6 3.5.9 5-4.5-2.4-4.5 2.4.9-5-3.6-3.5 5-.7z`} className={i < 3 ? 'fl' : 'f2'} strokeWidth="0" />)}
</Frame>
);
case 'shield': return (
<Frame>
<path d="M84 12 116 24v26c0 22-14 36-32 44-18-8-32-22-32-44V24z" className="f2" />
<path d="M84 20 110 30v20c0 18-11 30-26 37-15-7-26-19-26-37V30z" className="fs s1" />
<path d="M71 52l9 9 18-18" className="s1" strokeWidth="3" />
</Frame>
);
case 'key': return (
<Frame>
<rect x="34" y="30" width="100" height="58" rx="10" className="f2" />
<rect x="42" y="22" width="84" height="58" rx="10" className="fs s1" />
<circle cx="70" cy="51" r="11" className="s1" />
<path d="M81 51h30M103 51v8M111 51v6" className="s1" />
<path d="M54 70h20" className="s2" />
</Frame>
);
case 'plane': return (
<Frame>
<path d="M30 80c20-6 44-6 64-22" className="s2" strokeDasharray="3 6" />
<path d="M136 18 58 50l28 10 10 28z" className="f2" />
<path d="M136 18 58 50l28 10 10 28zM136 18 86 60" className="s1" />
</Frame>
);
case 'pulse': return (
<Frame>
<rect x="26" y="20" width="116" height="68" rx="12" className="f2" />
<rect x="34" y="14" width="100" height="68" rx="11" className="fs s1" />
<path d="M44 56h16l7-18 12 34 8-22 6 6h21" className="s1" strokeWidth="2.5" />
<path d="M44 40h80" className="s2" strokeDasharray="4 5" />
</Frame>
);
case 'catalog': return (
<Frame>
<rect x="36" y="26" width="44" height="54" rx="9" className="f2" />
<rect x="88" y="26" width="44" height="54" rx="9" className="f2" />
<rect x="44" y="18" width="80" height="60" rx="10" className="fs s1" />
<path d="M56 36h14M56 48h14M56 60h14" className="s2" />
<path d="M86 34l4 4 7-7M86 46l4 4 7-7M86 58l4 4 7-7" className="s1" />
<path d="M106 34l8 0M106 46l8 0M106 58l8 0" className="s2" />
</Frame>
);
case 'text': return (
<Frame>
<rect x="46" y="18" width="70" height="78" rx="9" className="f2" />
<rect x="54" y="10" width="70" height="78" rx="9" className="fs s1" />
<path d="M66 28h46M66 40h40M66 52h46M66 64h28" className="s2" />
<circle cx="122" cy="76" r="12" className="fl" />
<path d="M117 76l4 4 7-8" stroke="#fff" />
</Frame>
);
case 'tools': return (
<Frame>
<path d="M84 14 118 32v38L84 88 50 70V32z" className="f2" />
<path d="M84 22 112 37v31L84 83 56 68V37zM56 37l28 15 28-15M84 52v31" className="s1" />
</Frame>
);
default: return (
<Frame>
<circle cx="84" cy="52" r="34" className="f2" />
<circle cx="84" cy="52" r="26" className="s1" strokeDasharray="5 6" />
<path d="M76 45a8 8 0 1 1 11 7.5c-2 .8-3 2-3 4v2M84 66v.1" className="s1" strokeWidth="3" />
</Frame>
);
}
const [Main, Badge] = ART[name] ?? ART.unknown;
return (
<div className="illo" aria-hidden="true" data-illo={name}>
<span className="illo-tile">
<Main strokeWidth={1.6} />
{Badge && <span className="illo-badge"><Badge strokeWidth={2.4} /></span>}
</span>
</div>
);
}

View file

@ -1,6 +1,7 @@
// Shared UI pieces of the design system (styles.css): chips, store badges, app icons, KPI tiles, bars, sparklines,
// stars, notices, skeletons, empty states, segmented controls, cards.
import { type ReactNode, useId } from 'react';
// Shared UI pieces of the design system (styles.css): chips, store badges, app icons, KPI tiles, bars, sparklines
// (visx, charts.tsx), stars (lucide), notices, skeletons, empty states, segmented controls, cards.
import { Star } from 'lucide-react';
import type { ReactNode } from 'react';
import type { ReleasePhase, StoreRelease } from '../api';
import { t } from '../i18n';
import { share } from '../lib/format';
@ -75,32 +76,13 @@ export function Bar({ value, tone, thin, label }: { value: number; tone?: Tone;
);
}
/** Line + area sparkline with a dashed threshold line. Values are fractions; the y range always shows the threshold. */
export function Sparkline({ values, threshold, tone = 'neutral', label }: { values: number[]; threshold?: number; tone?: Tone; label: string }) {
const W = 300, H = 72, pad = 4;
const gid = useId().replace(/:/g, '');
if (!values.length) return <div className="spark" />;
const max = Math.max(...values, (threshold ?? 0) * 1.25) * 1.08 || 1;
const x = (i: number) => (values.length === 1 ? W / 2 : (i / (values.length - 1)) * W);
const y = (v: number) => H - pad - (v / max) * (H - pad * 2);
const line = values.map((v, i) => `${i ? 'L' : 'M'}${x(i).toFixed(1)} ${y(v).toFixed(1)}`).join(' ');
const area = `${line} L${W} ${H} L0 ${H} Z`;
return (
<svg className={`spark ${tone}`} viewBox={`0 0 ${W} ${H}`} preserveAspectRatio="none" role="img" aria-label={label}>
<defs><linearGradient id={`sg${gid}`} x1="0" y1="0" x2="0" y2="1"><stop offset="0" className="stop-a" /><stop offset="1" className="stop-b" /></linearGradient></defs>
<path className="area" d={area} fill={`url(#sg${gid})`} />
{threshold !== undefined && <line className="thr" x1="0" x2={W} y1={y(threshold)} y2={y(threshold)} />}
<path className="line" d={line} />
</svg>
);
}
/** Crash / ANR sparkline (visx): see charts.tsx. */
export { Sparkline } from './charts';
export function Stars({ n, label }: { n: number; label?: string }) {
return (
<span className="stars" role="img" aria-label={label ?? t('reviews.starsAria', { count: n })}>
{[1, 2, 3, 4, 5].map(i => (
<svg key={i} viewBox="0 0 24 24" className={i <= n ? '' : 'off'} aria-hidden="true"><path fill="currentColor" d="M12 3.8l2.5 5.1 5.6.8-4 4 1 5.5-5.1-2.7-5 2.7 1-5.5-4.1-4 5.7-.8z" /></svg>
))}
{[1, 2, 3, 4, 5].map(i => <Star key={i} className={i <= n ? '' : 'off'} fill="currentColor" strokeWidth={0} aria-hidden="true" />)}
</span>
);
}