The best way to control Claude Code, Codex and more from any computer or phone
| 1 | /** |
| 2 | * Writes the History at scale charts as standalone SVGs (light, or dark when |
| 3 | * the viewer prefers it) to `public/domain/backfill/`, for places that can't |
| 4 | * inline them, like pull requests. The docs page renders them inline. |
| 5 | */ |
| 6 | import { mkdirSync, writeFileSync } from "node:fs"; |
| 7 | import { backfillCharts } from "../src/components/charts/backfillCharts.ts"; |
| 8 | import { chartCss, renderLineChart } from "../src/components/charts/lineChart.ts"; |
| 9 | |
| 10 | const light = chartCss({ |
| 11 | surface: "#fbf6ea", |
| 12 | text: "#2a2620", |
| 13 | muted: "#52442e", |
| 14 | grid: "rgba(42,38,32,0.14)", |
| 15 | series: ["#2a78d6", "#eb6834", "#1baf7a"], |
| 16 | }); |
| 17 | const dark = chartCss({ |
| 18 | surface: "#221e18", |
| 19 | text: "#faf6ec", |
| 20 | muted: "#c0af89", |
| 21 | grid: "rgba(250,246,236,0.14)", |
| 22 | series: ["#3987e5", "#d95926", "#199e70"], |
| 23 | }); |
| 24 | |
| 25 | const dir = new URL("../public/domain/backfill/", import.meta.url); |
| 26 | mkdirSync(dir, { recursive: true }); |
| 27 | for (const [name, spec] of Object.entries(backfillCharts)) { |
| 28 | const file = name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`); |
| 29 | const svg = renderLineChart(spec).replace( |
| 30 | /^(<svg[^>]*>)/, |
| 31 | `$1<style>${light}@media (prefers-color-scheme: dark){${dark}}</style>`, |
| 32 | ); |
| 33 | writeFileSync(new URL(`${file}.svg`, dir), svg); |
| 34 | console.log(`public/domain/backfill/${file}.svg`); |
| 35 | } |