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>
This commit is contained in:
2026-11-19 21:50:02 +02:00
co-authored by Claude Opus 5.5
parent cc18b7b514
commit 70c471666b
20 changed files with 482 additions and 40 deletions
@@ -93,6 +93,29 @@
"type": "null"
}
]
},
"accentColour": {
"anyOf": [
{
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
{
"type": "null"
}
]
},
"logoUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
}
},
"required": [
@@ -1096,6 +1119,102 @@
"actor",
"type"
]
},
{
"type": "object",
"properties": {
"schema": {
"type": "string",
"const": "crosscode.identity-request/1"
},
"requestId": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"actor": {
"anyOf": [
{
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
{
"type": "null"
}
]
},
"type": {
"type": "string",
"const": "church.branding"
},
"church": {
"type": "object",
"properties": {
"name": {
"anyOf": [
{
"type": "string",
"minLength": 1,
"maxLength": 200
},
{
"type": "null"
}
]
},
"primaryColour": {
"anyOf": [
{
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
{
"type": "null"
}
]
},
"accentColour": {
"anyOf": [
{
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
{
"type": "null"
}
]
},
"logoUrl": {
"anyOf": [
{
"type": "string",
"maxLength": 2048,
"format": "uri"
},
{
"type": "null"
}
]
}
},
"required": [
"name",
"primaryColour"
]
},
"overwrite": {
"type": "boolean"
}
},
"required": [
"schema",
"requestId",
"actor",
"type",
"church",
"overwrite"
]
}
]
}
+20 -2
View File
@@ -43,6 +43,18 @@ const base = z.object({
// ─── import.* ────────────────────────────────────────────────────────────────
/**
* The church's look as a product has it, for Accounts' sign-in pages: its name, logo (an https
* address) and colours. 1.9.0 adds the logo and accent colour (optional, so 1.8.0 senders still fit).
*/
export const churchLookSchema = z.object({
name: z.string().trim().min(1).max(200).nullable(),
primaryColour: z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable(),
accentColour: z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional(),
logoUrl: z.url({ protocol: /^https?$/ }).max(2048).nullable().optional(),
});
export type ChurchLook = z.infer<typeof churchLookSchema>;
/** A privacy notice version, numbers kept (EVENTS-3.0-PLAN decision 5). */
export const importNoticeSchema = z.object({
version: z.int().positive(),
@@ -90,7 +102,7 @@ export const importBeginSchema = base.extend({
/** The product's privacy notice versions. Taken only when Accounts has published none of its own. */
notices: z.array(importNoticeSchema).max(100),
/** Fills the church profile's empty fields, so the sign-in page looks like the church at once. */
church: z.object({ name: z.string().trim().min(1).max(200).nullable(), primaryColour: z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable() }),
church: churchLookSchema,
});
export const importBatchSchema = base.extend({
@@ -179,10 +191,16 @@ export const messagingTestSchema = base.extend({
/** Tests the settings given as messaging.test does, and saves each part only if its test worked. */
export const messagingSetSchema = messagingTestSchema.extend({ type: z.literal("messaging.set") });
/**
* 1.9.0: use the product's look (name, logo, colours) on Accounts' pages. `overwrite: false` only
* fills what Accounts doesn't have yet; `true` replaces it (an admin pressing the button).
*/
export const churchBrandingSchema = base.extend({ type: z.literal("church.branding"), church: churchLookSchema, overwrite: z.boolean() });
export const identityRequestSchema = z.discriminatedUnion("type", [
importBeginSchema, importBatchSchema, importFinishSchema, importAbortSchema,
peopleEnsureSchema, peopleUpdateSchema, peopleResetTwoFactorSchema, peopleUnlockSchema, peopleSetActiveSchema, peopleNewsOffSchema,
messagingStatusSchema, messagingTestSchema, messagingSetSchema,
messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema,
]);
export type IdentityRequest = z.infer<typeof identityRequestSchema>;
export type IdentityRequestType = IdentityRequest["type"];
+30 -11
View File
@@ -9,30 +9,49 @@ const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).jo
export type Branding = { name: string; shortName?: string | null; logoUrl?: string | null };
/** The page frame: the church's logo and name, then the content in a centred column. */
/** The church's logo, or its first letter on its colour while it has none. */
export function ChurchMark({ branding, size = "md" }: { branding: Branding; size?: "md" | "lg" }) {
const box = size === "lg" ? "h-14 w-14 text-2xl" : "h-10 w-10 text-lg";
if (branding.logoUrl) return <img src={branding.logoUrl} alt="" className={cx(size === "lg" ? "h-14" : "h-10", "w-auto max-w-[12rem] rounded-xl object-contain")} />;
return <span className={cx(box, "flex shrink-0 items-center justify-center rounded-xl bg-brand font-semibold text-white")} aria-hidden>{(branding.shortName || branding.name || "?").trim().charAt(0).toUpperCase()}</span>;
}
/**
* The page frame (as the church's other sites): a soft wash of the church's colour, its logo and
* name across the top, the content in a centred column, and a quiet footer. `wide` for the account
* and admin pages; otherwise a sign-in column.
*/
export function Shell({ branding, children, wide = false, aside }: { branding: Branding; children: React.ReactNode; wide?: boolean; aside?: React.ReactNode }) {
return (
<div className="min-h-screen flex flex-col">
<header className="bg-white border-b">
<div className={cx("mx-auto flex items-center gap-3 px-4 py-3", wide ? "max-w-5xl" : "max-w-md")}>
{branding.logoUrl ? <img src={branding.logoUrl} alt="" className="h-9 w-auto rounded" /> : <span className="h-9 w-9 rounded-lg bg-brand" aria-hidden />}
<span className="font-semibold text-gray-900">{branding.name}</span>
<div className="min-h-screen flex flex-col bg-gradient-to-br from-brand/10 via-white to-brand/5">
<header className="border-b border-brand/10 bg-white/90 backdrop-blur">
<div className="mx-auto flex max-w-5xl items-center gap-3 px-4 py-3">
<ChurchMark branding={branding} />
<span className="text-lg font-semibold text-brand-dark">{branding.name}</span>
{aside && <div className="ml-auto">{aside}</div>}
</div>
</header>
<main className={cx("mx-auto w-full flex-1 px-4 py-8", wide ? "max-w-5xl" : "max-w-md")}>{children}</main>
<main className={cx("mx-auto w-full flex-1 px-4", wide ? "max-w-5xl py-8" : "max-w-md py-10 sm:py-16")}>{children}</main>
<footer className="px-4 py-6 text-center text-xs text-gray-500">
{branding.name} · your church account, for all its sites and apps
</footer>
</div>
);
}
export function Card({ children, className }: { children: React.ReactNode; className?: string }) {
return <div className={cx("rounded-2xl border bg-white p-6 shadow-sm", className)}>{children}</div>;
return <div className={cx("rounded-2xl border border-gray-200 border-t-4 border-t-brand bg-white p-6 shadow-sm sm:p-8", className)}>{children}</div>;
}
export function Heading({ children, sub }: { children: React.ReactNode; sub?: React.ReactNode }) {
/** A page's title, with an optional icon in a tile of the church's colour (as on the church's other sites). */
export function Heading({ children, sub, icon }: { children: React.ReactNode; sub?: React.ReactNode; icon?: React.ReactNode }) {
return (
<div className="mb-5">
<h1 className="text-xl font-semibold text-gray-900">{children}</h1>
{sub && <p className="mt-1 text-sm text-gray-600">{sub}</p>}
<div className="mb-6 flex items-start gap-3">
{icon && <span className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-brand/10 text-brand" aria-hidden>{icon}</span>}
<div>
<h1 className="text-xl font-semibold text-gray-900">{children}</h1>
{sub && <p className="mt-1 text-sm text-gray-600">{sub}</p>}
</div>
</div>
);
}