Files
crosscode-platform/apps/events/backend/src/accounts/look.ts
T
joshuaandClaude Opus 5.5 70c471666b Accounts sign-in looks like the church's site; Events sends its logo and colours
- @crosscode/ui: Shell with the church's colour wash, logo (or its initial)
  and name, footer; Card edged in the church's colour; Heading with an
  icon tile. Icons on every sign-in step.
- contracts 1.9.0: churchLookSchema (logo, accent colour) in import.begin;
  church.branding request. Accounts fills (move) or replaces (button) the
  church profile's name, logo and colours.
- Events 3.1.0: src/accounts/look.ts (logo as a full address), sent with a
  move; Settings -> Sign-in "Use this site's logo and colours".
Tests: Accounts 55, contracts 218, Events 774, test:accounts 16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:50:02 +02:00

32 lines
1.6 KiB
TypeScript

/**
* This site's look (3.1.0) for the church's Accounts sign-in pages: its name, logo and colours, so
* signing in looks like the church's own site. Sent with a move (filling what Accounts doesn't have
* yet) and by Settings → Sign-in → "Use this site's logo and colours" (replacing it).
*/
import type { ChurchLook } from '@crosscode/contracts';
import { siteUrl } from '../feed/context';
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
const { getSetting } = require('../utils/settingsCache') as { getSetting(k: string, f?: string): Promise<string> };
/* eslint-enable @typescript-eslint/no-require-imports */
const hex = (v: string) => (/^#[0-9a-fA-F]{6}$/.test(v) ? v : null);
export async function churchLook(): Promise<ChurchLook> {
const name = (await getSetting('org_name', '')) || (await getSetting('site_name', '')) || null;
const primary = hex(await getSetting('primary_color', '')) || hex(await getSetting('brand_color', ''));
const accent = hex(await getSetting('accent_color', '')) || hex(await getSetting('secondary_color', ''));
// The logo as an address anyone can load: an uploaded one is a path on this site.
const raw = String(await getSetting('logo_url', '')).trim();
let logoUrl: string | null = null;
if (raw) {
try {
const u = new URL(raw, `${(await siteUrl()).replace(/\/+$/, '')}/`);
if (/^https?:$/.test(u.protocol)) logoUrl = u.toString();
} catch {
logoUrl = null;
}
}
return { name: name ? name.slice(0, 200) : null, primaryColour: primary, accentColour: accent, logoUrl };
}