diff --git a/.opencodereview/rule.json b/.opencodereview/rule.json
index 047ce99..c08b925 100644
--- a/.opencodereview/rule.json
+++ b/.opencodereview/rule.json
@@ -2,6 +2,7 @@
"exclude": [
"frontend/wailsjs/**",
"frontend/src/i18n/domains/*.gen.ts",
+ "frontend/src/components/*.gen.ts",
"go.sum",
"**/package-lock.json",
"**/pnpm-lock.yaml"
diff --git a/assets/wordmark-dark.svg b/assets/wordmark-dark.svg
deleted file mode 100644
index 39b21fb..0000000
--- a/assets/wordmark-dark.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/assets/wordmark-light.svg b/assets/wordmark-light.svg
deleted file mode 100644
index b2a051e..0000000
--- a/assets/wordmark-light.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/frontend/scripts/test-brand.mjs b/frontend/scripts/test-brand.mjs
new file mode 100644
index 0000000..67a0bc5
--- /dev/null
+++ b/frontend/scripts/test-brand.mjs
@@ -0,0 +1,21 @@
+// scripts/brand/wordmark.py is the single source of the icon and the wordmark
+// geometry: it copies assets/logo.svg into public/ and generates
+// wordmark.gen.ts. Neither copy may be edited by hand.
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import fs from 'node:fs'
+import path from 'node:path'
+
+const repoRoot = path.resolve(import.meta.dirname, '..', '..')
+
+test('frontend/public/logo.svg is the copy of assets/logo.svg', () => {
+ const source = fs.readFileSync(path.join(repoRoot, 'assets', 'logo.svg'))
+ const served = fs.readFileSync(path.join(repoRoot, 'frontend', 'public', 'logo.svg'))
+ assert.ok(source.equals(served), 'run python scripts/brand/wordmark.py to refresh frontend/public/logo.svg')
+})
+
+test('the frontend wordmark geometry is generated', () => {
+ const generated = fs.readFileSync(path.join(repoRoot, 'frontend', 'src', 'components', 'wordmark.gen.ts'), 'utf8')
+ assert.match(generated, /^\/\/ Code generated by scripts\/brand\/wordmark\.py; DO NOT EDIT\./)
+ assert.match(generated, /export const WORDMARK_STROKES: WordmarkStroke\[\] = \[/)
+})
diff --git a/frontend/src/components/WordmarkLoader.tsx b/frontend/src/components/WordmarkLoader.tsx
index 571eec4..4711f62 100644
--- a/frontend/src/components/WordmarkLoader.tsx
+++ b/frontend/src/components/WordmarkLoader.tsx
@@ -1,23 +1,14 @@
import React, { useEffect, useId, useRef } from 'react'
+import {
+ WORDMARK_GRADIENT,
+ WORDMARK_ORIGIN,
+ WORDMARK_STROKES,
+ WORDMARK_STROKE_WIDTH,
+ WORDMARK_VIEWBOX,
+} from './wordmark.gen'
-// Strokes of the Reims-Go wordmark (scripts/brand/wordmark.py), in pen order.
-// Coordinates sit in the generator's baseline frame (translate 4 107).
-type Stroke =
- | { kind: 'path'; d: string; ink: 'ink' | 'dash' | 'brand' }
- | { kind: 'dot'; cx: number; cy: number; r: number }
-
-const STROKES: Stroke[] = [
- { kind: 'path', ink: 'ink', d: 'M7.5 -7.5V-36A24 28.5 0 0 1 31.5 -64.5' },
- { kind: 'path', ink: 'ink', d: 'M50.5 -36H107.5A28.5 28.5 0 1 0 100.18 -16.93' },
- { kind: 'path', ink: 'ink', d: 'M133.5 -64.5V-7.5' },
- { kind: 'dot', cx: 133.5, cy: -94, r: 9 },
- { kind: 'path', ink: 'ink', d: 'M159.5 -7.5V-36A22 28.5 0 0 1 203.5 -36V-7.5M203.5 -36A22 28.5 0 0 1 247.5 -36V-7.5' },
- { kind: 'path', ink: 'ink', d: 'M311.05 -59.02A21 14.25 0 0 0 273.5 -50.25A21 14.25 0 0 0 294.5 -36A21 14.25 0 0 1 315.5 -21.75A21 14.25 0 0 1 277.95 -12.98' },
- { kind: 'path', ink: 'dash', d: 'M340.5 -36H358.5' },
- { kind: 'path', ink: 'brand', d: 'M440.5 -36A28.5 28.5 0 1 1 440.5 -36.01' },
- { kind: 'path', ink: 'brand', d: 'M440.5 -64.5V0A28.5 22.5 0 0 1 387.32 11.25' },
- { kind: 'path', ink: 'brand', d: 'M523.5 -36A28.5 28.5 0 1 1 523.5 -36.01' },
-]
+// Geometry comes from scripts/brand/wordmark.py through wordmark.gen.ts: the
+// strokes are in pen order, in the generator's baseline frame.
// Pen timing, in ms. Writing speed is constant, so long strokes take longer.
const PX_PER_MS = 0.62
@@ -101,20 +92,20 @@ export const WordmarkLoader: React.FC = ({ width = 168, label, className
\n')
+
+
+def ts_strokes(strokes):
+ """Turns the unpainted (role, element) strokes into TypeScript literals."""
+ lines = []
+ for role, el in strokes:
+ circle = CIRCLE_ELEMENT.match(el)
+ if circle:
+ cx, cy, r = circle.groups()
+ lines.append(f" {{ kind: 'dot', cx: {cx}, cy: {cy}, r: {r} }},")
+ continue
+ path = PATH_ELEMENT.match(el)
+ if path is None or role not in TS_INK:
+ raise ValueError(f"the frontend loader cannot paint stroke {el!r} with role {role!r}")
+ lines.append(f" {{ kind: 'path', ink: '{TS_INK[role]}', d: '{path.group(1)}' }},")
+ return "\n".join(lines)
+
+
+def ts_module(style=STYLE):
+ """Writes the geometry the frontend WordmarkLoader animates.
+
+ The loader paints strokes with CSS classes and one gradient, so it needs
+ the geometry and the gradient extent, not the per-theme colours.
+ """
+ wm = wordmark("light", style)
+ width, height = wm["width"] + 2 * PAD, wm["ascent"] + wm["descent"] + 2 * PAD
+ gradient_x1 = wm["go_start"] - (14 if wm["pill"] else 0)
+ stops = ", ".join(f"'{c}'" for c in GRADIENT)
+ return (
+ "// Code generated by scripts/brand/wordmark.py; DO NOT EDIT.\n"
+ "// Run \"python scripts/brand/wordmark.py\" after changing the wordmark.\n"
+ "\n"
+ "export type WordmarkInk = 'ink' | 'dash' | 'brand'\n"
+ "\n"
+ "export type WordmarkStroke =\n"
+ " | { kind: 'path'; ink: WordmarkInk; d: string }\n"
+ " | { kind: 'dot'; cx: number; cy: number; r: number }\n"
+ "\n"
+ "/** viewBox of the wordmark, in generator units. */\n"
+ f"export const WORDMARK_VIEWBOX = {{ width: {f(width)}, height: {f(height)} }}\n"
+ "\n"
+ "/** Translation that puts the generator's baseline frame into the viewBox. */\n"
+ f"export const WORDMARK_ORIGIN = {{ x: {PAD}, y: {f(PAD + wm['ascent'])} }}\n"
+ "\n"
+ f"export const WORDMARK_STROKE_WIDTH = {f(style['stroke'])}\n"
+ "\n"
+ "/** Horizontal extent of the brand gradient on the baseline. */\n"
+ f"export const WORDMARK_GRADIENT = {{ x1: {f(gradient_x1)}, x2: {f(wm['width'])}, stops: [{stops}] }}\n"
+ "\n"
+ "/** Strokes in pen order, in the generator's baseline frame. */\n"
+ "export const WORDMARK_STROKES: WordmarkStroke[] = [\n"
+ f"{ts_strokes(wm['strokes'])}\n"
+ "]\n"
+ )
def main():
+ # Text outputs use the platform line endings so a rerun leaves the working
+ # tree clean under core.autocrlf=true as well as on Linux.
for theme in ("light", "dark"):
- (ROOT / f"assets/wordmark-{theme}.svg").write_text(standalone(theme), encoding="utf-8", newline="\n")
- (ROOT / f".github/readme/banner-{theme}.svg").write_text(banner(theme), encoding="utf-8", newline="\n")
+ (ROOT / f".github/readme/banner-{theme}.svg").write_text(banner(theme), encoding="utf-8")
+ (ROOT / "frontend/src/components/wordmark.gen.ts").write_text(ts_module(), encoding="utf-8")
+ # The frontend serves the icon from public/, so keep that copy byte-identical.
+ (ROOT / "frontend/public/logo.svg").write_bytes((ROOT / "assets/logo.svg").read_bytes())
if __name__ == "__main__":