diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3575d684..ab25f630 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,6 +29,12 @@ Try the screenshot and video pipeline on the demo game without any store account by hand. Frontmatter is `name` + `description` only. - **No secrets, no real ids, no personal data** in code, tests, fixtures or examples: use `com.example.*`, `example.com` and obviously fake values. `bun run ci` runs the scrub. +- **No hand-written SVG.** Charts come from visx, icons from lucide (`lucide-react` in the desktop app; the site's + icons are lucide's own files, vendored by `bun tools/site-icons.ts` into `site/img/icons/` with the licence), + diagrams from Mermaid (`docs/diagrams/*.mmd`, rendered by `bun tools/diagrams.ts`), the desktop fixtures' art from + `bun tools/fixture-art.ts`. The brand mark and `site/favicon.svg` are brand assets. `tests/no-handmade-svg.test.ts` + fails on new inline `` / `` drawing in `apps/desktop/src` and `site/*.html`. These libraries are desktop + dependencies (bundled by Vite) or devDependencies; the CLI package keeps zero runtime dependencies. - Plain English in docs and messages, short sentences, no marketing words. ## Pull requests diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 32554386..be59cff1 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -17,6 +17,16 @@ }, "dependencies": { "@tauri-apps/api": "^2.12.0", + "@visx/axis": "^4.0.0", + "@visx/curve": "^4.0.0", + "@visx/event": "^4.0.0", + "@visx/gradient": "^4.0.0", + "@visx/group": "^4.0.0", + "@visx/responsive": "^4.0.0", + "@visx/scale": "^4.0.0", + "@visx/shape": "^4.0.0", + "@visx/tooltip": "^4.0.0", + "lucide-react": "^1.55.0", "react": "^19.2.0", "react-dom": "^19.2.0" }, diff --git a/apps/desktop/src/dev/art/icon-block.png b/apps/desktop/src/dev/art/icon-block.png new file mode 100644 index 00000000..17b5b8a7 Binary files /dev/null and b/apps/desktop/src/dev/art/icon-block.png differ diff --git a/apps/desktop/src/dev/art/icon-focus.png b/apps/desktop/src/dev/art/icon-focus.png new file mode 100644 index 00000000..413a14af Binary files /dev/null and b/apps/desktop/src/dev/art/icon-focus.png differ diff --git a/apps/desktop/src/dev/art/icon-habit.png b/apps/desktop/src/dev/art/icon-habit.png new file mode 100644 index 00000000..d4190381 Binary files /dev/null and b/apps/desktop/src/dev/art/icon-habit.png differ diff --git a/apps/desktop/src/dev/art/icon-lantern.png b/apps/desktop/src/dev/art/icon-lantern.png new file mode 100644 index 00000000..d521b2ce Binary files /dev/null and b/apps/desktop/src/dev/art/icon-lantern.png differ diff --git a/apps/desktop/src/dev/art/icon-mood.png b/apps/desktop/src/dev/art/icon-mood.png new file mode 100644 index 00000000..3ca05add Binary files /dev/null and b/apps/desktop/src/dev/art/icon-mood.png differ diff --git a/apps/desktop/src/dev/art/icon-night.png b/apps/desktop/src/dev/art/icon-night.png new file mode 100644 index 00000000..5a7ee031 Binary files /dev/null and b/apps/desktop/src/dev/art/icon-night.png differ diff --git a/apps/desktop/src/dev/art/icon-orbit.png b/apps/desktop/src/dev/art/icon-orbit.png new file mode 100644 index 00000000..675dcee7 Binary files /dev/null and b/apps/desktop/src/dev/art/icon-orbit.png differ diff --git a/apps/desktop/src/dev/art/icon-prism.png b/apps/desktop/src/dev/art/icon-prism.png new file mode 100644 index 00000000..163df5e2 Binary files /dev/null and b/apps/desktop/src/dev/art/icon-prism.png differ diff --git a/apps/desktop/src/dev/art/icon-racer.png b/apps/desktop/src/dev/art/icon-racer.png new file mode 100644 index 00000000..96ce9360 Binary files /dev/null and b/apps/desktop/src/dev/art/icon-racer.png differ diff --git a/apps/desktop/src/dev/art/icon-sketch.png b/apps/desktop/src/dev/art/icon-sketch.png new file mode 100644 index 00000000..64d6d5dc Binary files /dev/null and b/apps/desktop/src/dev/art/icon-sketch.png differ diff --git a/apps/desktop/src/dev/art/icon-tidy.png b/apps/desktop/src/dev/art/icon-tidy.png new file mode 100644 index 00000000..f439aa32 Binary files /dev/null and b/apps/desktop/src/dev/art/icon-tidy.png differ diff --git a/apps/desktop/src/dev/art/icon-tycoon.png b/apps/desktop/src/dev/art/icon-tycoon.png new file mode 100644 index 00000000..e36925fa Binary files /dev/null and b/apps/desktop/src/dev/art/icon-tycoon.png differ diff --git a/apps/desktop/src/dev/art/scene1-feature.png b/apps/desktop/src/dev/art/scene1-feature.png new file mode 100644 index 00000000..6cdacd79 Binary files /dev/null and b/apps/desktop/src/dev/art/scene1-feature.png differ diff --git a/apps/desktop/src/dev/art/scene1-ipad.png b/apps/desktop/src/dev/art/scene1-ipad.png new file mode 100644 index 00000000..0b4f1276 Binary files /dev/null and b/apps/desktop/src/dev/art/scene1-ipad.png differ diff --git a/apps/desktop/src/dev/art/scene1-phone.png b/apps/desktop/src/dev/art/scene1-phone.png new file mode 100644 index 00000000..5c7a37ad Binary files /dev/null and b/apps/desktop/src/dev/art/scene1-phone.png differ diff --git a/apps/desktop/src/dev/art/scene1-play.png b/apps/desktop/src/dev/art/scene1-play.png new file mode 100644 index 00000000..e2081016 Binary files /dev/null and b/apps/desktop/src/dev/art/scene1-play.png differ diff --git a/apps/desktop/src/dev/art/scene2-feature.png b/apps/desktop/src/dev/art/scene2-feature.png new file mode 100644 index 00000000..45fb596f Binary files /dev/null and b/apps/desktop/src/dev/art/scene2-feature.png differ diff --git a/apps/desktop/src/dev/art/scene2-ipad.png b/apps/desktop/src/dev/art/scene2-ipad.png new file mode 100644 index 00000000..ee843c47 Binary files /dev/null and b/apps/desktop/src/dev/art/scene2-ipad.png differ diff --git a/apps/desktop/src/dev/art/scene2-phone.png b/apps/desktop/src/dev/art/scene2-phone.png new file mode 100644 index 00000000..2a67fe1f Binary files /dev/null and b/apps/desktop/src/dev/art/scene2-phone.png differ diff --git a/apps/desktop/src/dev/art/scene2-play.png b/apps/desktop/src/dev/art/scene2-play.png new file mode 100644 index 00000000..7edadee9 Binary files /dev/null and b/apps/desktop/src/dev/art/scene2-play.png differ diff --git a/apps/desktop/src/dev/art/scene3-feature.png b/apps/desktop/src/dev/art/scene3-feature.png new file mode 100644 index 00000000..18ea9b37 Binary files /dev/null and b/apps/desktop/src/dev/art/scene3-feature.png differ diff --git a/apps/desktop/src/dev/art/scene3-ipad.png b/apps/desktop/src/dev/art/scene3-ipad.png new file mode 100644 index 00000000..e0fa35a5 Binary files /dev/null and b/apps/desktop/src/dev/art/scene3-ipad.png differ diff --git a/apps/desktop/src/dev/art/scene3-phone.png b/apps/desktop/src/dev/art/scene3-phone.png new file mode 100644 index 00000000..f3bf9fac Binary files /dev/null and b/apps/desktop/src/dev/art/scene3-phone.png differ diff --git a/apps/desktop/src/dev/art/scene3-play.png b/apps/desktop/src/dev/art/scene3-play.png new file mode 100644 index 00000000..c4fd1df2 Binary files /dev/null and b/apps/desktop/src/dev/art/scene3-play.png differ diff --git a/apps/desktop/src/dev/art/scene4-feature.png b/apps/desktop/src/dev/art/scene4-feature.png new file mode 100644 index 00000000..84ad8676 Binary files /dev/null and b/apps/desktop/src/dev/art/scene4-feature.png differ diff --git a/apps/desktop/src/dev/art/scene4-ipad.png b/apps/desktop/src/dev/art/scene4-ipad.png new file mode 100644 index 00000000..222ac37a Binary files /dev/null and b/apps/desktop/src/dev/art/scene4-ipad.png differ diff --git a/apps/desktop/src/dev/art/scene4-phone.png b/apps/desktop/src/dev/art/scene4-phone.png new file mode 100644 index 00000000..68119a17 Binary files /dev/null and b/apps/desktop/src/dev/art/scene4-phone.png differ diff --git a/apps/desktop/src/dev/art/scene4-play.png b/apps/desktop/src/dev/art/scene4-play.png new file mode 100644 index 00000000..d9d55973 Binary files /dev/null and b/apps/desktop/src/dev/art/scene4-play.png differ diff --git a/apps/desktop/src/dev/fixtures-more.ts b/apps/desktop/src/dev/fixtures-more.ts index a84952d3..ed9ed93c 100644 --- a/apps/desktop/src/dev/fixtures-more.ts +++ b/apps/desktop/src/dev/fixtures-more.ts @@ -116,26 +116,11 @@ export const LISTING_TEXT: Record = { 'p-tidy': { play: { path: `${HOME}/apps/tidy-lists/store/listing.md`, text: '## en-US\n' }, apple: { path: `${HOME}/apps/tidy-lists/store/appstore.md`, text: '## en-US\n' } }, }; -// ---- store art: drawn stand-ins for the renders ---- -const COPY: Record = { - en: [['Catch every', 'color drop!'], ['Chain splashes,', 'stack combos'], ['A new challenge', 'every day'], ['Clear levels,', 'earn 3 stars']], - tr: [['Renkli damlaları', 'yakala!'], ['Sıçrat, eşleştir,', 'komboyu büyüt'], ['Her gün', 'yeni bir görev'], ['Bölümleri geç,', '3 yıldız topla']], - ja: [['カラフルなしずくを', 'キャッチ!'], ['しずくをそろえて', 'コンボをつなげ'], ['毎日あたらしい', 'チャレンジ'], ['ステージクリアで', '星を3つゲット']], - ar: [['التقط كل', 'قطرة ملوّنة!'], ['طابق القطرات', 'وضاعف الكومبو'], ['تحدٍّ جديد', 'كل يوم'], ['أنهِ المراحل', 'واجمع 3 نجوم']], -}; -const PAL = [['#7c5cff', '#ff5fa2', '#ffd36e'], ['#ff7a59', '#ff3d7f', '#ffe08a'], ['#2fb5ff', '#5b6cff', '#b8f3ff'], ['#ffb03b', '#ff7a1a', '#fff1b8']]; -const esc = (s: string) => s.replace(/&/g, '&').replace(/ = { ios69: 'phone', ios65: 'phone', ipad13: 'ipad', play: 'play', feature: 'feature', poster: 'phone' }; +function shot(scene: number, size: string, variant: string): string { const order = variant === 'b' ? [1, 0, 3, 2] : [0, 1, 2, 3]; - const sc = order[scene % 4]!; - const [a, b, c] = PAL[variant === 'b' && sc === 1 ? 2 : sc]!; - const t = COPY[lang]?.[sc] ?? COPY.en![sc]!; - const land = w > h; - const fs = Math.round((land ? h : w) * 0.085); - const pw = land ? h * 0.42 : w * 0.62, ph = pw * 2.05, px = land ? w * 0.62 : (w - pw) / 2, py = land ? h * 0.18 : h * 0.3; - const drops = Array.from({ length: 7 }, (_, i) => ``).join(''); - const tx = land ? w * 0.08 : w / 2, anchor = land ? 'start' : 'middle'; - return `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(`${esc(t[0]!)}${esc(t[1]!)}${drops}`)))}`; + return new URL(`./art/scene${order[scene % 4]! + 1}-${SHAPE[size] ?? 'phone'}.png`, import.meta.url).href; } const SIZES: [string, string, 'apple' | 'play', number, number][] = [ ['ios69', 'App Store iPhone 6.9"', 'apple', 1320, 2868], ['ios65', 'App Store iPhone 6.5"', 'apple', 1284, 2778], ['ipad13', 'App Store iPad 13"', 'apple', 2064, 2752], @@ -152,7 +137,7 @@ function renders(langs: string[], variants: string[]): RendersResult { const n = size === 'feature' ? 1 : lang === 'ar' && size === 'ipad13' ? 0 : 4; const tiles: RenderTile[] = Array.from({ length: n }, (_, i) => { const src = `${v ? `${v}/` : ''}${lang}/${size}/${size === 'feature' ? '1024x500' : String(i + 1).padStart(2, '0')}.png`; - ART[src] = shot(i, lang, w, h, v); + ART[src] = shot(i, size, v); const issues = lang === 'ja' && size === 'play' && i === 1 ? [{ level: 'warn' as const, code: 'overflow', msg: 'title line 2 shrunk to 72 %: consider shorter words' }] : lang === 'tr' && size === 'feature' ? [{ level: 'warn' as const, code: 'bytes', msg: 'PNG is 1.4 MB: the JPEG copy uploads 4x faster (storebound shots jpeg)' }] : []; images++; warnings += issues.length; @@ -163,7 +148,7 @@ function renders(langs: string[], variants: string[]): RendersResult { return { size, label, store, tiles, issues: rowIssues }; }), ...(!v && lang !== 'ar' ? [{ size: 'preview/iphone', label: 'App preview iPhone', store: 'apple' as const, issues: [], tiles: [(() => { const src = `${lang}/preview/iphone/01.mp4`, poster = `${lang}/preview/iphone/01-poster.png`; - ART[poster] = shot(1, lang, 886, 1920, ''); + ART[poster] = shot(1, 'poster', ''); videos++; return { src, kind: 'video' as const, poster, name: '01.mp4', w: 886, h: 1920, bytes: 18_400_000, issues: [] }; })()] }] : [])], diff --git a/apps/desktop/src/dev/fixtures.ts b/apps/desktop/src/dev/fixtures.ts index 5d0c3442..1474c880 100644 --- a/apps/desktop/src/dev/fixtures.ts +++ b/apps/desktop/src/dev/fixtures.ts @@ -28,12 +28,9 @@ export async function mockListen(event: string, cb: Cb): Promise<() => void> { const emit = (event: string, payload: unknown) => { for (const cb of listeners.get(event) ?? []) cb(payload); }; const cancelled = new Set(); -// ---- icons (fixture art, drawn for the demo apps) ---- -const svg = (s: string) => `data:image/svg+xml;base64,${btoa(s)}`; -const ICONS: Record = { - 'p-prism': svg(``), - 'p-tidy': svg(``), -}; +// ---- icons: PNGs rendered by tools/fixture-art.ts (lucide icons on gradients), served by Vite in dev ---- +const art = (name: string) => new URL(`./art/${name}.png`, import.meta.url).href; +const ICONS: Record = { 'p-prism': art('icon-prism'), 'p-tidy': art('icon-tidy') }; // ---- workspace: 3 studios, 2 Play service accounts + 3 App Store Connect teams, 2 app folders, store-only apps ---- // Placeholder names only (example.com style): no real studio, person, team or id. @@ -57,19 +54,10 @@ let accounts: Account[] = [ ]; if (import.meta.env.VITE_FIXTURES === 'empty') { projects = []; accounts = []; studios = []; } -/** Small drawn icons for the store apps (fixture art). */ -const glyph = (a: string, b: string, inner: string) => `data:image/svg+xml;base64,${btoa(`${inner}`)}`; +/** Store app icons (tools/fixture-art.ts). */ const G = { - orbit: glyph('#0ea5e9', '#6366f1', ''), - block: glyph('#22c55e', '#15803d', ''), - lantern: glyph('#f59e0b', '#b45309', 'W'), - tycoon: glyph('#a855f7', '#6d28d9', '$'), - racer: glyph('#ef4444', '#991b1b', ''), - habit: glyph('#14b8a6', '#0f766e', ''), - focus: glyph('#f43f5e', '#be123c', ''), - sketch: glyph('#fb923c', '#ea580c', ''), - night: glyph('#1e293b', '#4338ca', ''), - mood: glyph('#ec4899', '#8b5cf6', ''), + orbit: art('icon-orbit'), block: art('icon-block'), lantern: art('icon-lantern'), tycoon: art('icon-tycoon'), racer: art('icon-racer'), + habit: art('icon-habit'), focus: art('icon-focus'), sketch: art('icon-sketch'), night: art('icon-night'), mood: art('icon-mood'), }; const ios = (id: string, bundleId: string, name: string, icon: string | null, latest: [string, string] | null): StoreApp => ({ store: 'ios', id, bundleId, name, platforms: ['IOS'], sku: null, primaryLocale: 'en-US', latest: latest ? { version: latest[0], state: latest[1], platform: 'IOS' } : null, icon }); diff --git a/apps/desktop/src/screens/Portfolio.tsx b/apps/desktop/src/screens/Portfolio.tsx index c5adb18a..5a255746 100644 --- a/apps/desktop/src/screens/Portfolio.tsx +++ b/apps/desktop/src/screens/Portfolio.tsx @@ -87,7 +87,7 @@ function HealthCell({ c, android }: { c: { h: HealthSnapshot; at: string } | nul const s = healthSeries(play.crash, 'userPerceivedCrashRate', PLAY_THRESHOLDS.crash); return (
- + {pct(s.current)}
); diff --git a/apps/desktop/src/screens/tabs/Health.tsx b/apps/desktop/src/screens/tabs/Health.tsx index 2feb20a0..86f180f2 100644 --- a/apps/desktop/src/screens/tabs/Health.tsx +++ b/apps/desktop/src/screens/tabs/Health.tsx @@ -25,7 +25,7 @@ function Metric({ title, s }: { title: string; s: Series }) { {t('health.threshold', { value: pct(s.threshold) })} - +
{date(s.dates[0])}{date(s.dates[Math.floor(s.dates.length / 2)])}{date(s.dates.at(-1))}
diff --git a/apps/desktop/src/screens/tabs/Releases.tsx b/apps/desktop/src/screens/tabs/Releases.tsx index c238c1e6..aed22130 100644 --- a/apps/desktop/src/screens/tabs/Releases.tsx +++ b/apps/desktop/src/screens/tabs/Releases.tsx @@ -9,7 +9,8 @@ import { ago, date, share } from '../../lib/format'; import { type Lane, STAGES, type TestFlightStatus, trainLanes, versionHistory } from '../../lib/model'; import { useData, useRead, useWrite } from '../../store'; import { Icon, StoreGlyph } from '../../ui/icons'; -import { Bar, Card, Chip, Empty, Notice, PhaseChip, storeName } from '../../ui/kit'; +import { RolloutBar } from '../../ui/charts'; +import { Card, Chip, Empty, Notice, PhaseChip, storeName } from '../../ui/kit'; import { ascUrl, PLAY_CONSOLE } from '../AppView'; const STAGE_KEY: Record<(typeof STAGES)[number], Key> = { build: 'stage.build', testing: 'stage.testing', review: 'stage.review', live: 'stage.live', rollout: 'stage.rollout' }; @@ -40,7 +41,7 @@ function LaneRow({ lane, version }: { lane: Lane; version: string }) {
{i < lane.at && } {last && i === lane.at && lane.share !== null ? ( -
= 1 ? 'ok' : 'accent'} label={t('tl.rolloutAria')} /> +
= 1 ? 'ok' : 'accent'} label={t('tl.rolloutAria')} /> {lane.share >= 1 ? t('tl.everyone') : `${share(lane.share)}${r?.phased?.day ? ` · ${t('tl.day', { day: r.phased.day })}` : ''}`}
) : {stageCaption(lane, i)}}
diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.css index 6d131c3c..fa5697ec 100644 --- a/apps/desktop/src/styles.css +++ b/apps/desktop/src/styles.css @@ -346,7 +346,7 @@ svg { flex: none; } .tl-cap { position: absolute; top: calc(50% + 4px); font-size: var(--t-micro); color: var(--muted); white-space: nowrap; font-weight: 550; } .tl-step.cur .tl-cap { color: var(--ink); font-weight: 650; } .tl-roll { width: 76%; display: grid; gap: 4px; position: absolute; top: calc(50% + 2px); } -.tl-roll .bar { height: 6px; } +.tl-roll .rbar { height: 6px; } .tl-roll .pct { font-size: var(--t-micro); text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; } .tl-none { grid-column: 2 / -1; color: var(--muted); font-size: var(--t-meta); text-align: center; border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px; } .train-head { display: flex; align-items: center; gap: 10px; } @@ -358,16 +358,34 @@ svg { flex: none; } .bar.thin { height: 4px; } /* ---------- charts ---------- */ -.spark { width: 100%; height: 72px; display: block; overflow: visible; } -.spark .area { opacity: 1; } -.spark .stop-a { stop-color: var(--spark, var(--accent-solid)); stop-opacity: .28; } -.spark .stop-b { stop-color: var(--spark, var(--accent-solid)); stop-opacity: 0; } -.spark .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; } -.spark .thr { stroke: var(--bad-solid); stroke-width: 1.25; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; } -.spark.ok { --spark: var(--ok-solid); } .spark.ok .line { stroke: var(--ok-solid); } -.spark.warn { --spark: var(--warn-solid); } .spark.warn .line { stroke: var(--warn-solid); } -.spark.bad { --spark: var(--bad-solid); } .spark.bad .line { stroke: var(--bad-solid); } -.spark.neutral .line, .spark.accent .line, .spark.info .line { stroke: var(--accent-solid); } +.spark { width: 100%; height: 72px; display: block; position: relative; --spark: var(--accent-solid); } +.spark > svg { display: block; overflow: visible; outline: none; border-radius: 4px; } +.spark > svg:focus-visible { box-shadow: 0 0 0 2px var(--focus); } +.spark linearGradient stop { stop-color: var(--spark); } +.spark .line { fill: none; stroke: var(--spark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; } +.spark.compact .line { stroke-width: 1.5; } +.spark .thr { stroke: var(--bad-solid); stroke-width: 1.25; stroke-dasharray: 4 4; } +.spark .hov line { stroke: var(--line-2); stroke-width: 1; } +.spark .hov circle { fill: var(--spark); stroke: var(--surface); stroke-width: 2; } +.spark.ok { --spark: var(--ok-solid); } .spark.warn { --spark: var(--warn-solid); } .spark.bad { --spark: var(--bad-solid); } +/* chart tooltip (visx TooltipWithBounds, unstyled; charts.tsx ChartTip) */ +.vx-tip { position: absolute; z-index: 5; pointer-events: none; display: grid; gap: 4px; min-width: 150px; padding: 8px 10px; white-space: nowrap; + background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2); font-size: var(--t-meta); } +.vx-tip > b { font-weight: 650; } +.vx-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); } +.vx-row.muted { color: var(--muted); } +.vx-row b { margin-left: auto; padding-left: 14px; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; } +.vx-tip .sw { width: 10px; height: 3px; border-radius: 2px; flex: none; background: var(--accent-solid); } +.vx-tip .sw.ok, .vx-tip .sw.l2 { background: var(--ok-solid); } .vx-tip .sw.warn { background: var(--warn-solid); } .vx-tip .sw.bad { background: var(--bad-solid); } +.vx-tip .sw.l3 { background: repeating-linear-gradient(90deg, var(--warn-solid) 0 4px, transparent 4px 6px); } +.vx-tip .sw.thr { background: repeating-linear-gradient(90deg, var(--bad-solid) 0 3px, transparent 3px 5px); } +.vx-tip .sw.ev { width: 8px; height: 8px; border-radius: 50%; background: var(--info-solid); } +/* rollout / phased release share (visx bar, charts.tsx RolloutBar) */ +.rbar { width: 100%; height: 8px; } +.rbar > svg { display: block; } +.rbar .track { fill: var(--neutral-bg); stroke: var(--line); stroke-width: 1; } +.rbar .fill { fill: var(--accent-solid); } +.rbar.ok .fill { fill: var(--ok-solid); } .rbar.warn .fill { fill: var(--warn-solid); } .rbar.bad .fill { fill: var(--bad-solid); } .rbar.info .fill { fill: var(--info-solid); } .metric { display: grid; gap: 10px; } .metric-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; } .metric-val { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; } @@ -475,14 +493,21 @@ button.li:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; /* ---------- empty states ---------- */ .empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 40px 24px 44px; } -.empty svg.illo { width: 168px; height: 112px; margin-bottom: 6px; } +.empty .illo { margin-bottom: 6px; } .empty h3 { font-size: var(--t-section); font-weight: 650; } .empty p { color: var(--muted); max-width: 52ch; } .empty .actions { margin-top: 10px; justify-content: center; } .empty.compact { padding: 24px 16px; } -.empty.compact svg.illo { width: 120px; height: 80px; } -.illo .f1 { fill: var(--illo-1); } .illo .f2 { fill: var(--illo-2); } .illo .s1 { stroke: var(--illo-line); fill: none; } .illo .s2 { stroke: var(--illo-soft); fill: none; } -.illo .fl { fill: var(--illo-line); } .illo .fs { fill: var(--surface); } .illo .fsoft { fill: var(--illo-soft); } +.empty.compact .illo { --illo-size: 80px; } +/* empty state art (ui/illustrations.tsx): a lucide icon on a soft tile with rings behind it and an optional badge */ +.illo { --illo-size: 112px; width: calc(var(--illo-size) * 1.5); height: var(--illo-size); display: grid; place-items: center; position: relative; + background: radial-gradient(circle at 50% 50%, var(--illo-1) 0 30%, transparent 30.5%), radial-gradient(circle at 50% 50%, transparent 0 41%, var(--illo-2) 41.5% 42.5%, transparent 43%); } +.illo-tile { width: calc(var(--illo-size) * .54); height: calc(var(--illo-size) * .54); border-radius: 28%; display: grid; place-items: center; position: relative; + background: var(--surface); border: 1px solid var(--illo-2); box-shadow: var(--shadow-2); color: var(--illo-line); } +.illo-tile > svg { width: 46%; height: 46%; } +.illo-badge { position: absolute; right: -10%; bottom: -10%; width: 40%; height: 40%; border-radius: 50%; display: grid; place-items: center; + background: var(--illo-line); color: var(--surface); box-shadow: 0 0 0 3px var(--surface); } +.illo-badge > svg { width: 58%; height: 58%; } /* ---------- skeletons ---------- */ .sk { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--neutral-bg) 0%, color-mix(in srgb, var(--neutral-bg) 55%, var(--surface)) 50%, var(--neutral-bg) 100%); background-size: 200% 100%; animation: sk 1.3s ease-in-out infinite; } @@ -620,7 +645,7 @@ select.input { padding-right: 8px; } .fix svg { width: 13px; height: 13px; margin-top: 2px; color: var(--accent-solid); flex: none; } .fix code { font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; } .field > .seg { justify-self: start; } -.wz-body svg.illo { width: 168px; height: 112px; margin-bottom: -6px; } +.wz-body .illo { margin-bottom: -6px; } h2[tabindex="-1"]:focus, h2[tabindex="-1"]:focus-visible { outline: none; } .acc-pick { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 8px; } .acc-pick svg { width: 15px; height: 15px; color: var(--muted); } @@ -852,17 +877,18 @@ textarea.input { height: auto; padding: 8px 10px; line-height: 1.45; resize: ver /* growth chart */ .lchart { display: grid; gap: 8px; } -.lchart svg { width: 100%; height: auto; display: block; overflow: visible; outline: none; border-radius: 8px; } -.lchart svg:focus-visible { box-shadow: 0 0 0 2px var(--focus); } +.lchart-plot { position: relative; width: 100%; } +.lchart-plot > svg { display: block; overflow: visible; outline: none; border-radius: 8px; } +.lchart-plot > svg:focus-visible { box-shadow: 0 0 0 2px var(--focus); } .lchart .grid-l line { stroke: var(--line); stroke-width: 1; } .lchart line.base { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 3; } .lchart text { font-size: 10.5px; fill: var(--muted); font-variant-numeric: tabular-nums; } -.lchart .stop-a { stop-color: var(--accent-solid); stop-opacity: .18; } -.lchart .stop-b { stop-color: var(--accent-solid); stop-opacity: 0; } +.lchart linearGradient stop { stop-color: var(--accent-solid); } .lchart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; } .lchart .ln.l1 { stroke: var(--accent-solid); } .lchart .ln.l2 { stroke: var(--ok-solid); } .lchart .ln.l3 { stroke: var(--warn-solid); stroke-dasharray: 5 4; } +.lchart .hov circle { stroke: var(--surface); stroke-width: 2; } .lchart circle.l1 { fill: var(--accent-solid); } .lchart circle.l2 { fill: var(--ok-solid); } .lchart circle.l3 { fill: var(--warn-solid); } .lchart .ev line { stroke: var(--info-solid); stroke-width: 1.25; stroke-dasharray: 3 4; } .lchart .ev circle { fill: var(--info-solid); stroke: var(--surface); stroke-width: 2; cursor: help; } diff --git a/apps/desktop/src/ui/LineChart.tsx b/apps/desktop/src/ui/LineChart.tsx index ead190d0..1ecc65d4 100644 --- a/apps/desktop/src/ui/LineChart.tsx +++ b/apps/desktop/src/ui/LineChart.tsx @@ -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(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) => { - 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 (
- setHover(null)} onKeyDown={onKey} onBlur={() => setHover(null)}> - - {ticks.map(v => ( - - - {v} - - ))} - - {events.map((e, i) => { - const k = dates.indexOf(e.date); - if (k < 0) return null; - return {`${date(e.date)} · ${e.subject}`}; - })} - {plotted[0] && } - {lines.map((l, k) => )} - {hover !== null && {lines.map((l, k) => (plotted[k]![hover] === null ? null : ))}} - {date(dates[0])} - {date(dates[n - 1])} - +
+ {width > 0 && ( + + + + {ticks.map(v => )} + + + date(dates[Number(v)])} hideAxisLine hideTicks + tickLabelProps={(_, i) => ({ className: 'ax', textAnchor: i === 0 ? 'start' : i === xs.length - 1 ? 'end' : 'middle', dy: 4 })} /> + + {events.map((e, i) => { + const k = dates.indexOf(e.date); + if (k < 0) return null; + return ( + + + {`${date(e.date)} · ${e.subject}`} + + ); + })} + {plotted[0] && x(d[0])} y={d => y(d[1] ?? 0)} yScale={y} curve={curveMonotoneX} fill={`url(#${gid})`} className="area" />} + {lines.map((l, k) => x(d[0])} y={d => y(d[1] ?? 0)} curve={curveMonotoneX} />)} + {hv !== null && ( + + + {lines.map((l, k) => (plotted[k]![hv] === null ? null : ))} + + )} + + + )} + {hv !== null && width > 0 && ( + + {date(dates[hv])} + {lines.map(l => {l.label}{fmt(l, l.values[hv] ?? null)})} + {onDay(hv).map((e, i) => {e.subject})} + + )} +
{indexLabel} - {hover !== null && {date(dates[hover])}} - {lines.map(l => {l.label}{hover !== null && {fmt(l, l.values[hover] ?? null)}})} + {hv !== null && {date(dates[hv])}} + {lines.map(l => {l.label}{hv !== null && {fmt(l, l.values[hv] ?? null)}})} {events.length > 0 && {eventsLabel}}
diff --git a/apps/desktop/src/ui/brand.tsx b/apps/desktop/src/ui/brand.tsx new file mode 100644 index 00000000..88c4e511 --- /dev/null +++ b/apps/desktop/src/ui/brand.tsx @@ -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 ( + + ); +} diff --git a/apps/desktop/src/ui/charts.tsx b/apps/desktop/src/ui/charts.tsx new file mode 100644 index 00000000..a45a7d3f --- /dev/null +++ b/apps/desktop/src/ui/charts.tsx @@ -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(); + 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) => { + 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 {children}; +} + +/** 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
; + 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 ( +
+ {width > 0 && height > 0 && ( + + + x(d[0])} y={d => y(d[1])} yScale={y} curve={curveMonotoneX} fill={`url(#${gid})`} className="area" /> + {threshold !== undefined && } + x(d[0])} y={d => y(d[1])} curve={curveMonotoneX} className="line" /> + {h.hover !== null && ( + + + + + )} + {interactive && } + + )} + {h.hover !== null && dates && ( + + {date(dates[h.hover])}{pct(values[h.hover]!)} + + )} +
+ ); +} + +const hover = (h: ReturnType, 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 ( +
+ {width > 0 && height > 0 && ( + + )} +
+ ); +} diff --git a/apps/desktop/src/ui/icons.tsx b/apps/desktop/src/ui/icons.tsx index 2a27d893..7756fbb4 100644 --- a/apps/desktop/src/ui/icons.tsx +++ b/apps/desktop/src/ui/icons.tsx @@ -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 ); 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; + +export type IconName = keyof typeof ICONS; export function Icon({ name, className, title }: { name: IconName; className?: string; title?: string }) { - return ( - - {title && {title}} - - - ); + const C = ICONS[name]; + return title + ? {title} + :
@@ -347,7 +347,7 @@ }

A Play service account and an App Store Connect API key. Env vars work too. Never your password, never committed.

- + @@ -367,7 +367,7 @@
  • Make store screenshots in 14 languages
  • What still blocks my submission?
  • - + @@ -386,7 +386,7 @@
  • Fix, run again, until zeroread-only, so it is safe to run as often as you like
  • You press Submit for reviewand Send changes for review on Play. Never the agent.
  • - + @@ -395,15 +395,15 @@

    Built for

    • - +
      Indie developers

      One app or a handful: the store chores without a week of console tabs.

    • - +
      Studios shipping many titles

      One config per title, the same checks and store art pipeline every time.

    • - +
      Agencies

      Reviewable config in the client's repo. Their keys, their Submit.

    @@ -456,7 +456,7 @@ - +
    38-second teaser: a scripted terminal run with the demo game, from config to “Submit for review · your click”. Has music.
    @@ -476,7 +476,7 @@

    Everything an app or game needs before review, in order.

    For each step: what storebound does through the store APIs or on your machine, what a skill walks your agent through where the stores have no public API, and what stays your own click.

    - The journey: config, app records, products, listings, questionnaires, privacy and icons, store art, validate, then you press Submit. Each step is tagged API, UI, local or you. + The journey: config, app records, products, listings, questionnaires, privacy and icons, store art, validate, then you press Submit. Each step is tagged API, UI, local or you.
    • API a storebound command (also an MCP tool)
    • diff --git a/site/style.css b/site/style.css index c64b0f0b..a63a7558 100644 --- a/site/style.css +++ b/site/style.css @@ -71,6 +71,13 @@ body { -webkit-font-smoothing: antialiased; } img, video, svg { max-width: 100%; height: auto; display: block; } +/* icons: lucide's own SVG files (site/img/icons, vendored by tools/site-icons.ts) as masks in the text colour */ +.ic { display: inline-block; flex: none; width: 1em; height: 1em; background-color: currentColor; -webkit-mask: none center / contain no-repeat; mask: none center / contain no-repeat; } +.ic-chevron-right { -webkit-mask-image: url(img/icons/chevron-right.svg); mask-image: url(img/icons/chevron-right.svg); } +.ic-play { -webkit-mask-image: url(img/icons/play.svg); mask-image: url(img/icons/play.svg); } +.ic-user-round { -webkit-mask-image: url(img/icons/user-round.svg); mask-image: url(img/icons/user-round.svg); } +.ic-layout-grid { -webkit-mask-image: url(img/icons/layout-grid.svg); mask-image: url(img/icons/layout-grid.svg); } +.ic-briefcase-business { -webkit-mask-image: url(img/icons/briefcase-business.svg); mask-image: url(img/icons/briefcase-business.svg); } a { color: var(--accent); text-underline-offset: 3px; } a:hover { text-decoration-thickness: 2px; } :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; } @@ -215,7 +222,7 @@ html.js .panel[hidden] { display: none; } .see video { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; border: 1px solid var(--line); background: #0b1020; } .player { position: relative; } .play { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px 0 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, #fff 25%, transparent); background: color-mix(in srgb, #0b1020 72%, transparent); color: #fff; font: 650 14.5px var(--font); cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); } -.play svg { width: 20px; height: 20px; } +.play .ic { width: 20px; height: 20px; } .play:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } .play:focus-visible { outline-offset: 3px; border-radius: 999px; } .see figcaption { font-size: 13.5px; color: var(--muted); margin-top: 10px; } @@ -271,8 +278,8 @@ h1 .hl { color: var(--accent); } .lede strong { color: var(--ink); font-weight: 650; } .ctas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; } .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 10px; font-weight: 600; text-decoration: none; font-size: 15px; transition: background-color .15s ease, border-color .15s ease, transform .12s ease; } -.btn svg { width: 16px; height: 16px; margin-right: -4px; transition: transform .15s ease; } -.btn:hover svg { transform: translateX(2px); } +.btn .ic { width: 16px; height: 16px; margin-right: -4px; transition: transform .15s ease; } +.btn:hover .ic { transform: translateX(2px); } .btn:active { transform: translateY(1px); } .btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, 0 6px 16px -8px var(--accent); } .btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); } @@ -591,7 +598,8 @@ h2 { font-size: clamp(28px, 4.2vw, 40px); font-weight: 720; letter-spacing: -.03 .for-list { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 24px; } @media (min-width: 760px) { .for-list { grid-template-columns: repeat(3, 1fr); gap: 32px; } } .for-list li { display: flex; gap: 14px; align-items: flex-start; } -.for-list svg { width: 40px; height: 40px; padding: 9px; flex: none; border-radius: 10px; background: var(--accent-soft); color: var(--accent); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; } +.for-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); } +.for-ic .ic { width: 22px; height: 22px; } .for-list b { display: block; font-size: 16px; color: var(--ink); letter-spacing: -.01em; } .for-list p { margin-top: 4px; font-size: 15px; color: var(--ink-2); } @@ -618,6 +626,6 @@ h2 { font-size: clamp(28px, 4.2vw, 40px); font-weight: 720; letter-spacing: -.03 .st-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); } .st-foot[hidden] { display: none; } .st-next { display: inline-flex; align-items: center; gap: 4px; font: 600 14px var(--font); color: var(--accent); background: none; border: 0; padding: 6px 4px; cursor: pointer; text-decoration: none; border-radius: 6px; } -.st-next svg { width: 15px; height: 15px; transition: transform .15s ease; } -.st-next:hover svg { transform: translateX(2px); } +.st-next .ic { width: 15px; height: 15px; transition: transform .15s ease; } +.st-next:hover .ic { transform: translateX(2px); } @media (min-width: 1024px) { html.js .st-panel:not([hidden]) { display: flex; flex-direction: column; } } diff --git a/tests/no-handmade-svg.test.ts b/tests/no-handmade-svg.test.ts new file mode 100644 index 00000000..5ee7758a --- /dev/null +++ b/tests/no-handmade-svg.test.ts @@ -0,0 +1,69 @@ +// Owner rule: no hand-written SVG. Charts come from visx, icons from lucide, the journey diagram from Mermaid, the +// fixture art from tools/fixture-art.ts. This guard fails on inline SVG drawing in the desktop webview and the site. +// Allowed: the brand mark (apps/desktop/src/ui/brand.tsx, the site's and site/favicon.svg: brand +// assets, owner decision), the root a visx chart renders into (files that import @visx/*), lucide's own files in +// site/img/icons (byte-equal to lucide-static) and the Mermaid output (docs/img, site/img journey*.svg). +import { describe, expect, test } from 'bun:test'; +import { readdirSync, readFileSync, statSync } from 'node:fs'; +import { join, relative } from 'node:path'; +import { checkSiteIcons } from '../tools/site-icons'; + +const ROOT = join(import.meta.dir, '..'); +const walk = (dir: string, keep: (f: string) => boolean): string[] => readdirSync(join(ROOT, dir)).flatMap(n => { + const rel = join(dir, n); + if (n === 'node_modules' || n === 'dist') return []; + return statSync(join(ROOT, rel)).isDirectory() ? walk(rel, keep) : keep(n) ? [rel] : []; +}); +const read = (f: string) => readFileSync(join(ROOT, f), 'utf8'); + +/** SVG drawing elements and inline SVG images. */ +const SHAPES = /<(path|circle|rect|ellipse|line|polyline|polygon)[\s/>]|data:image\/svg\+xml|]/g; +const BRAND_FILES = ['apps/desktop/src/ui/brand.tsx']; +const SITE_MARK = ''; + +/** Every hand-drawn hit in a source text: "file:line { + test('desktop webview: charts through visx, icons through lucide, no inline SVG outside the brand mark', () => { + const files = walk('apps/desktop/src', n => /\.(tsx?|css|html)$/.test(n)); + expect(files.length).toBeGreaterThan(30); + const hits = files.filter(f => !BRAND_FILES.includes(f)).flatMap(f => { + const s = read(f); + return svgHits(f, s, { visxRoot: /from '@visx\//.test(s) }); + }); + expect(hits).toEqual([]); + }); + + test('the guard itself catches a drawn icon and an inline SVG image', () => { + expect(svgHits('x.tsx', 'const a = ;')).toHaveLength(2); + expect(svgHits('x.ts', "const u = 'data:image/svg+xml;base64,AAAA';")).toHaveLength(1); + expect(svgHits('x.tsx', '', { visxRoot: true })).toEqual([]); + expect(svgHits('x.tsx', '', { visxRoot: true })).toHaveLength(1); + }); + + test('site pages: icons are lucide files in site/img/icons; only the brand mark is inline', () => { + const pages = walk('site', n => n.endsWith('.html')); + expect(pages.length).toBeGreaterThanOrEqual(2); + const hits = pages.flatMap(f => svgHits(f, read(f).split(SITE_MARK).join(''))); + expect(hits).toEqual([]); + expect(checkSiteIcons()).toEqual([]); + for (const f of ['site/style.css', 'site/main.js']) expect(svgHits(f, read(f)), f).toEqual([]); + }); + + test('SVG files: brand favicon, vendored lucide icons and Mermaid diagrams only', () => { + const svgs = [...walk('site', n => n.endsWith('.svg')), ...walk('docs', n => n.endsWith('.svg'))].map(f => relative(ROOT, join(ROOT, f))); + for (const f of svgs) { + if (f === 'site/favicon.svg' || f.startsWith('site/img/icons/')) continue; + expect(f, `${f}: not a known asset`).toMatch(/^(docs|site)\/img\/journey(-tall)?\.svg$/); + expect(read(f), `${f}: render it with bun tools/diagrams.ts`).toContain('aria-roledescription="flowchart-v2"'); + } + }); +}); diff --git a/tools/ci.ts b/tools/ci.ts index 44da2693..75b66e33 100644 --- a/tools/ci.ts +++ b/tools/ci.ts @@ -1,6 +1,7 @@ #!/usr/bin/env bun // Everything CI runs, in order; stops at the first failure. bun run ci -// `bun test` covers the CLI and the desktop webview (apps/desktop/tests: model, i18n, theme contrast, webview rules). +// `bun test` covers the CLI and the desktop webview (apps/desktop/tests: model, i18n, theme contrast, webview rules), +// and the no-hand-written-SVG guard (tests/no-handmade-svg.test.ts: visx charts, lucide icons, Mermaid diagrams). // The desktop Rust host (cargo test, clippy // with warnings as errors) runs when cargo is installed; set STOREBOUND_CI_RUST=0 to skip it on a machine without Rust. import { join } from 'node:path'; diff --git a/tools/diagrams.ts b/tools/diagrams.ts new file mode 100644 index 00000000..ab1b6a87 --- /dev/null +++ b/tools/diagrams.ts @@ -0,0 +1,66 @@ +#!/usr/bin/env bun +// Renders the diagrams in docs/diagrams/*.mmd with the Mermaid CLI (@mermaid-js/mermaid-cli, a devDependency; never +// shipped). Plain SVG text (no HTML labels), a fixed dark canvas so it reads the same on light and dark pages. +// bun tools/diagrams.ts +// journey.mmd -> docs/img/journey.svg (README), site/img/journey.svg (wide screens) and site/img/journey-tall.svg +// (phones: every row turned into a column). Chrome: STOREBOUND_CHROME, Playwright's Chromium, or Google Chrome. +import { copyFileSync, existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; + +const root = new URL('..', import.meta.url).pathname; +const BG = '#0f172a'; + +function chrome(): string { + const cands = [process.env.STOREBOUND_CHROME ?? '']; + try { cands.push((require('playwright') as typeof import('playwright')).chromium.executablePath()); } catch { /* not installed */ } + cands.push('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium', 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'); + const home = process.env.HOME ?? ''; + // a newer Playwright Chromium than the installed playwright expects is fine for Mermaid + for (const base of [join(home, 'Library/Caches/ms-playwright'), join(home, '.cache/ms-playwright')]) { + if (!existsSync(base)) continue; + for (const d of Array.from(new Bun.Glob('chromium-*/chrome-*/**/{Google Chrome for Testing,chrome}').scanSync({ cwd: base, onlyFiles: true }))) cands.push(join(base, d)); + } + const hit = cands.find(c => c && existsSync(c)); + if (!hit) throw new Error('diagrams: no Chrome found (set STOREBOUND_CHROME or run `bunx playwright install chromium`)'); + return hit; +} + +const mermaidConfig = { + theme: 'base', + htmlLabels: false, + flowchart: { htmlLabels: false, curve: 'basis', nodeSpacing: 28, rankSpacing: 36, padding: 14, wrappingWidth: 400 }, + themeVariables: { + fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif', fontSize: '15px', + background: BG, primaryColor: '#1e293b', primaryTextColor: '#e2e8f0', primaryBorderColor: '#475569', + lineColor: '#94a3b8', textColor: '#e2e8f0', titleColor: '#f8fafc', clusterBkg: '#111a2e', clusterBorder: '#334155', + }, +}; + +function render(src: string, out: string, tmp: string, exe: string) { + const input = join(tmp, 'in.mmd'); + writeFileSync(input, src); + writeFileSync(join(tmp, 'mermaid.json'), JSON.stringify(mermaidConfig)); + writeFileSync(join(tmp, 'puppeteer.json'), JSON.stringify({ executablePath: exe, args: ['--no-sandbox'] })); + const r = Bun.spawnSync(['node', join(root, 'node_modules/@mermaid-js/mermaid-cli/src/cli.js'), '-q', '-i', input, '-o', out, + '-c', join(tmp, 'mermaid.json'), '-p', join(tmp, 'puppeteer.json'), '-b', BG], { stdout: 'inherit', stderr: 'inherit' }); + if (r.exitCode !== 0) throw new Error(`diagrams: mmdc failed for ${out}`); + // a self-describing image: title for screen readers, the dark canvas filled in (some viewers drop the background style) + let svg = readFileSync(out, 'utf8'); + // Mermaid embeds its default web font; the diagram uses the system font stack instead, so drop the font files + svg = svg.replace(/@font-face\s*\{[^}]*\}/g, ''); + // a fixed intrinsic size (from the viewBox) so and README renderers keep the aspect ratio + const [, , w, h] = (svg.match(/viewBox="([^"]+)"/)?.[1] ?? '0 0 960 560').split(/\s+/).map(Number); + svg = svg.replace(/^]*)>/, (_m, a: string) => `storebound · the journey from zero to Submit for review`); + writeFileSync(out, svg); + console.log(`diagrams: ${out.replace(root, '')} (${(svg.length / 1024).toFixed(1)} KB)`); +} + +const exe = chrome(); +const tmp = mkdtempSync(join(tmpdir(), 'sb-diagrams-')); +try { + const journey = readFileSync(join(root, 'docs/diagrams/journey.mmd'), 'utf8'); + render(journey, join(root, 'docs/img/journey.svg'), tmp, exe); + copyFileSync(join(root, 'docs/img/journey.svg'), join(root, 'site/img/journey.svg')); + render(journey.replace(/direction LR/g, 'direction TB'), join(root, 'site/img/journey-tall.svg'), tmp, exe); +} finally { rmSync(tmp, { recursive: true, force: true }); } diff --git a/tools/fixture-art.ts b/tools/fixture-art.ts new file mode 100644 index 00000000..8693c834 --- /dev/null +++ b/tools/fixture-art.ts @@ -0,0 +1,70 @@ +#!/usr/bin/env bun +// Renders the desktop dev fixtures' art (apps/desktop/src/dev/art/*.png): app icons and store screenshot stand-ins, +// each a lucide icon (lucide-static, ISC) on a CSS gradient, photographed by Playwright's Chromium. No drawn SVG: the +// icons are lucide's own files. Dev only (the fixtures never ship in the release bundle). +// bun tools/fixture-art.ts (Playwright's Chromium, or an installed Google Chrome; same launcher as storebound shots) +import { mkdirSync, readFileSync, renameSync } from 'node:fs'; +import { join } from 'node:path'; +import { launch } from '../cli/shots/browser'; + +const root = new URL('..', import.meta.url).pathname; +const out = join(root, 'apps/desktop/src/dev/art'); +const lucide = (name: string) => readFileSync(join(root, 'node_modules/lucide-static/icons', `${name}.svg`), 'utf8').replace(//s, ''); + +/** [file, lucide icon, gradient from, gradient to] */ +const ICONS: [string, string, string, string][] = [ + ['icon-prism', 'droplets', '#7c5cff', '#ff5fa2'], ['icon-tidy', 'list-checks', '#2fd18b', '#0f9d74'], + ['icon-orbit', 'orbit', '#0ea5e9', '#6366f1'], ['icon-block', 'blocks', '#22c55e', '#15803d'], + ['icon-lantern', 'lamp', '#f59e0b', '#b45309'], ['icon-tycoon', 'coins', '#a855f7', '#6d28d9'], + ['icon-racer', 'car-front', '#ef4444', '#991b1b'], ['icon-habit', 'egg', '#14b8a6', '#0f766e'], + ['icon-focus', 'timer', '#f43f5e', '#be123c'], ['icon-sketch', 'star', '#fb923c', '#ea580c'], + ['icon-night', 'moon', '#1e293b', '#4338ca'], ['icon-mood', 'grid-2x2', '#ec4899', '#8b5cf6'], +]; +/** Four scenes of the demo game: [lucide icon, from, to, accent] */ +const SCENES: [string, string, string, string][] = [ + ['droplets', '#7c5cff', '#ff5fa2', '#ffd36e'], ['zap', '#ff7a59', '#ff3d7f', '#ffe08a'], + ['calendar-days', '#2fb5ff', '#5b6cff', '#b8f3ff'], ['trophy', '#ffb03b', '#ff7a1a', '#fff1b8'], +]; +/** Screenshot shapes at a small preview size, in the stores' aspect ratios. */ +const SHAPES: [string, number, number][] = [['phone', 240, 521], ['play', 240, 427], ['ipad', 300, 400], ['feature', 512, 250]]; + +const page = (w: number, h: number, body: string, css: string) => + `${body}`; + +mkdirSync(out, { recursive: true }); +const browser = await launch(root, {}); +const tab = await browser.newPage({ deviceScaleFactor: 1 }); +async function snap(file: string, w: number, h: number, html: string) { + await tab.setViewportSize({ width: w, height: h }); + await tab.setContent(html); + const png = join(out, `${file}.png`); + await tab.screenshot({ path: png, clip: { x: 0, y: 0, width: w, height: h } }); + // 8-bit palette PNG (ffmpeg, already needed for storebound icons): about a quarter of the bytes; kept as is without it + if (Bun.which('ffmpeg')) { + const tmp = `${png}.q.png`; + const r = Bun.spawnSync(['ffmpeg', '-v', 'error', '-y', '-i', png, '-vf', 'split[a][b];[a]palettegen=max_colors=96:stats_mode=full[p];[b][p]paletteuse=dither=bayer:bayer_scale=3', tmp]); + if (r.exitCode === 0) renameSync(tmp, png); + } + console.log(`fixture-art: ${file}.png ${w}x${h}`); +} +for (const [file, icon, a, b] of ICONS) { + await snap(file, 128, 128, page(128, 128, `
      ${lucide(icon)}
      `, + `.t{width:128px;height:128px;display:grid;place-items:center;background:linear-gradient(135deg,${a},${b});color:#fff}.t svg{width:72px;height:72px;stroke-width:1.8}`)); +} +for (const [i, [icon, a, b, c]] of SCENES.entries()) { + for (const [shape, w, h] of SHAPES) { + const land = w > h; + const phone = land ? { w: h * 0.42, h: h * 0.86 } : { w: w * 0.62, h: Math.min(h * 0.72, w * 0.62 * 2.05) }; + await snap(`scene${i + 1}-${shape}`, w, h, page(w, h, + `
      ${lucide(icon)}
      ${lucide(icon)}
      `, + `.bg{position:relative;width:${w}px;height:${h}px;background:linear-gradient(135deg,${a},${b});color:#fff;overflow:hidden} + .glow{position:absolute;inset:0;background:radial-gradient(circle at 50% 30%,rgba(255,255,255,.35),transparent 70%)} + .big{position:absolute;${land ? `left:${w * 0.1}px;top:${h * 0.22}px` : `left:50%;top:${h * 0.05}px;transform:translateX(-50%)`};color:${c}} + .big svg{width:${land ? h * 0.5 : w * 0.26}px;height:${land ? h * 0.5 : w * 0.26}px;stroke-width:2.2} + .ph{position:absolute;width:${phone.w}px;height:${phone.h}px;${land ? `right:${w * 0.1}px;top:${h * 0.07}px` : `left:50%;bottom:-${phone.w * 0.12}px;transform:translateX(-50%)`}; + border-radius:${phone.w * 0.14}px;background:#10142a;border:${Math.max(2, phone.w * 0.03)}px solid rgba(255,255,255,.85);padding:${phone.w * 0.06}px} + .scr{width:100%;height:100%;border-radius:${phone.w * 0.08}px;background:#1d2350;display:grid;place-items:center;color:${c}} + .scr svg{width:45%;height:45%;stroke-width:1.6}`)); + } +} +await browser.close(); diff --git a/tools/site-icons.ts b/tools/site-icons.ts new file mode 100644 index 00000000..8a611f51 --- /dev/null +++ b/tools/site-icons.ts @@ -0,0 +1,41 @@ +#!/usr/bin/env bun +// Vendors the site's icons from lucide (lucide-static, ISC licence) into site/img/icons/: the official SVG files, +// copied byte for byte, plus lucide's licence. The pages show them as CSS masks (site/style.css .ic-*), so they take +// the text colour in both themes and the site makes no request outside its own folder. +// bun tools/site-icons.ts copy (after a lucide-static bump or a new icon in ICONS) +// bun tools/site-icons.ts --check fail when a vendored file differs from lucide-static (CI, when installed) +import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; + +export const SITE_ICONS = ['chevron-right', 'play', 'user-round', 'layout-grid', 'briefcase-business'] as const; + +const root = new URL('..', import.meta.url).pathname; +const from = join(root, 'node_modules/lucide-static'); +export const ICON_DIR = join(root, 'site/img/icons'); + +/** Problems of the vendored folder against lucide-static ([] when it matches, or when lucide-static is not installed). */ +export function checkSiteIcons(): string[] { + if (!existsSync(from)) return []; + const out: string[] = []; + for (const n of SITE_ICONS) { + const f = join(ICON_DIR, `${n}.svg`); + if (!existsSync(f)) out.push(`site/img/icons/${n}.svg missing (bun tools/site-icons.ts)`); + else if (readFileSync(f, 'utf8') !== readFileSync(join(from, 'icons', `${n}.svg`), 'utf8')) out.push(`site/img/icons/${n}.svg is not lucide-static's file`); + } + for (const f of readdirSync(ICON_DIR)) if (f.endsWith('.svg') && !(SITE_ICONS as readonly string[]).includes(f.slice(0, -4))) out.push(`site/img/icons/${f} is not in SITE_ICONS`); + return out; +} + +if (import.meta.main) { + if (!existsSync(from)) { console.error('site-icons: lucide-static is not installed (bun install)'); process.exit(1); } + if (process.argv.includes('--check')) { + const bad = checkSiteIcons(); + for (const b of bad) console.error(`site-icons: ${b}`); + process.exit(bad.length ? 1 : 0); + } + mkdirSync(ICON_DIR, { recursive: true }); + const version = JSON.parse(readFileSync(join(from, 'package.json'), 'utf8')).version; + for (const n of SITE_ICONS) writeFileSync(join(ICON_DIR, `${n}.svg`), readFileSync(join(from, 'icons', `${n}.svg`))); + writeFileSync(join(ICON_DIR, 'LICENSE.txt'), `Icons in this folder: Lucide ${version} (https://lucide.dev), copied unchanged from the lucide-static\npackage by tools/site-icons.ts.\n\n${readFileSync(join(from, 'LICENSE'), 'utf8')}`); + console.log(`site-icons: ${SITE_ICONS.length} icons from lucide-static ${version} -> site/img/icons/`); +}