Files
crosscode-platform/packages/demo/src/logo.ts
T
joshuaandClaude Opus 5.5 ad488c3280 Accounts 1.9.0, @crosscode/demo 1.0.0: messaging.get, WhatsApp opt-out, demo scenarios
Accounts 1.9.0 (one migration):
- messaging.get (sealed settings) and the messaging.changed hint to products
  that asked, on admin or product changes
- the WhatsApp opt-out for every product: whatsapp.optout, Accounts' own WAWP
  webhook, WhatsAppOptOut kept per number, whatsapp_opted_out in user.updated,
  no WhatsApp from Accounts to an opted-out person, "Turn WhatsApp back on"
- demo scenarios: npm run demo -- --profile <scenario> --force replaces the
  church profile (with an SVG logo and icon at /api/demo-assets/) and the demo
  people, ids kept across loads

@crosscode/demo 1.0.0 (new): the eight scenarios' churches, people and logos.

crosscode script: crosscode demo <church> accounts, --scenario on every demo,
Accounts installs and builds packages/demo.

Checked on PostgreSQL 18: migrations, scenario loads, opt-out, npm run demo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 11:05:22 +02:00

48 lines
4.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { FONT_PAIRINGS, type agent } from "@crosscode/contracts";
import { demoChurch, type DemoMark } from "./churches";
/**
* Each demo church's logo and icon, drawn for the demo (never a real church's): a simple mark in
* white on the church's colour, and the mark beside the church's name. SVG, so they're crisp at
* any size; Accounts serves them (`/api/demo-assets/<scenario>/icon.svg`, `logo.svg`).
*/
/** The marks, drawn in white on a 512 × 512 square. */
const MARKS: Record<DemoMark, string> = {
// A church window: a pointed arch with a sill.
arch: '<path d="M176 400V236c0-56 36-100 80-124 44 24 80 68 80 124v164z" fill="none" stroke="#fff" stroke-width="28" stroke-linejoin="round"/><path d="M256 168v232M176 272h160" stroke="#fff" stroke-width="20"/>',
cross: '<rect x="232" y="96" width="48" height="320" rx="6" fill="#fff"/><rect x="152" y="176" width="208" height="48" rx="6" fill="#fff"/>',
flame: '<path d="M256 88c24 72 104 112 104 200a104 104 0 0 1-208 0c0-48 24-80 48-104 0 40 16 64 40 72-8-64 0-112 16-168z" fill="#fff"/>',
wave: '<path d="M96 300c40-40 80-40 120 0s80 40 120 0 80-40 80 0M96 372c40-40 80-40 120 0s80 40 120 0 80-40 80 0" fill="none" stroke="#fff" stroke-width="28" stroke-linecap="round"/><path d="M256 108v120M216 148h80" stroke="#fff" stroke-width="24" stroke-linecap="round"/>',
// An acacia: a flat crown on a thin trunk.
tree: '<path d="M112 220c0-36 64-64 144-64s144 28 144 64-64 44-144 44-144-8-144-44z" fill="#fff"/><path d="M256 260v156M256 316l-56-52M256 300l52-40" stroke="#fff" stroke-width="22" stroke-linecap="round"/>',
sun: '<circle cx="256" cy="300" r="72" fill="#fff"/><path d="M256 156v-48M156 204l-34-34M356 204l34-34M120 300H72M392 300h48" stroke="#fff" stroke-width="24" stroke-linecap="round"/><path d="M96 404h320" stroke="#fff" stroke-width="24" stroke-linecap="round"/>',
// A compass point.
north: '<path d="M256 88l88 296-88-56-88 56z" fill="#fff"/><circle cx="256" cy="420" r="16" fill="#fff"/>',
// A river through three points (three campuses).
river: '<path d="M120 120c120 40 40 140 136 168s48 112 136 104" fill="none" stroke="#fff" stroke-width="32" stroke-linecap="round"/><circle cx="148" cy="360" r="28" fill="#fff"/><circle cx="380" cy="160" r="28" fill="#fff"/><circle cx="256" cy="200" r="20" fill="#fff"/>',
};
const escapeXml = (s: string) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
/** The square icon (app icon, favicon): the mark on the church's primary colour. */
export function demoIconSvg(scenario: agent.DemoScenarioKey): string {
const c = demoChurch(scenario);
const radius = c.profile.style.corners === "sharp" ? 48 : c.profile.style.corners === "round" ? 160 : 96;
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512" role="img" aria-label="${escapeXml(c.profile.name)}"><rect width="512" height="512" rx="${radius}" fill="${c.profile.colours.primary}"/>${MARKS[c.mark]}</svg>`;
}
/** The logo: the icon and the church's name in its heading font (a font stack, with a fallback). */
export function demoLogoSvg(scenario: agent.DemoScenarioKey): string {
const c = demoChurch(scenario);
const pairing = FONT_PAIRINGS[c.profile.style.fontPairing];
const font = `${pairing.heading.family}, ${pairing.heading.category === "serif" ? "Georgia, serif" : "Helvetica, Arial, sans-serif"}`;
const name = c.profile.name;
const size = name.length > 20 ? 64 : 76;
const width = Math.round(240 + name.length * size * 0.56);
const icon = demoIconSvg(scenario).replace(/^<svg[^>]*>/, "").replace(/<\/svg>$/, "");
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} 200" width="${width}" height="200" role="img" aria-label="${escapeXml(name)}">`
+ `<svg x="16" y="16" width="168" height="168" viewBox="0 0 512 512">${icon}</svg>`
+ `<text x="208" y="${100 + size * 0.35}" font-family="${escapeXml(font)}" font-size="${size}" font-weight="700" fill="${c.profile.colours.primary}">${escapeXml(name)}</text></svg>`;
}