Website 1.7.1: move and zoom for ministries', leaders' and events' photos

1.7.0 had Move and zoom in page sections only. Ministries, Leadership
and Events now have it on their photo, in the frame the site uses for
the current template and layouts. Saved with the row as `framing`
({ x, y, zoom }, null for centred; cleared when the photo changes).
Ministries and leaders are drafts until Publish (snapshot, Discard and
Restore carry it); an event's shows once the event is published.
Versions published before this compare unchanged.

One migration: a nullable JSONB `framing` column on Ministry, Leader
and SimpleEvent.

Also: the 1.7.0 e2e test waits for the media library to load before
counting it (it could count an empty list).

Checked: Website backend tests (136) and typecheck, frontend typecheck
and lint, production build, admin e2e suite in Chromium (12).
Lighthouse not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 00:27:54 +02:00
co-authored by Claude Opus 5.5
parent 4897489fb1
commit 0c521ff614
23 changed files with 212 additions and 40 deletions
+6
View File
@@ -2,6 +2,12 @@
Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …).
## website@1.7.1 - 2026-11-28
Move and zoom for ministries', leaders' and events' photos (1.7.0 had it in page sections only).
One migration: a nullable `framing` column on `Ministry`, `Leader` and `SimpleEvent`. Details in
`apps/website/CHANGELOG.md`.
## website@1.7.0 - 2026-11-27
Photos can be moved and zoomed in their frame, and unused photos deleted. Details in
+17
View File
@@ -1,5 +1,22 @@
# Changelog — Church Website
## [1.7.1] — 2026-11-28
One migration (`20261128000000_photo_framing`: a nullable `framing` column on `Ministry`,
`Leader` and `SimpleEvent`), run by `crosscode deploy`. No new environment settings.
### Fixed
- **Move and zoom everywhere a photo is framed, not only in page sections.** 1.7.0 had it in the
page editor only. Ministries, Leadership and Events now have the same **Move and zoom** on their
photo, shown in the frame the site uses for the current template and layouts (`frameFor` types
`ministry`, `leader`, `event`; `RowFraming` in `admin/framing.tsx`). It's saved with the row as
`framing` (`{ x, y, zoom }`, null for centred) and cleared when the photo is removed or changed.
Ministries and leaders are drafts until Publish (in the snapshot, Discard and Restore, as
`image.focus` / `photo.focus`); an event's shows once the event is published, like the rest of
it. Versions published before this compare unchanged (no framing key), so nothing shows as a
pending change after the update.
## [1.7.0] — 2026-11-27
No migration, no new environment settings.
+7
View File
@@ -3,6 +3,13 @@
What each version changes for the church, in plain language (read by the Hub like Cross Events'
WHATS-NEW.md; a section shows once its version is tagged).
## 1.7.1
- **Move and zoom now works for ministries, your team and events too**, not only for page
sections. Edit a ministry, a person or an event, and press **Move and zoom** on its photo.
Ministries and people show it on your site once you publish; an event shows it once the event
is published.
## 1.7.0
- **Move and zoom your photos.** When you choose a photo for a section, you now see it in the
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/website-backend",
"version": "1.7.0",
"version": "1.7.1",
"description": "Church Website: the public site's content API, the admin API, publishing and uploads",
"private": true,
"type": "module",
@@ -0,0 +1,4 @@
-- Move and zoom for ministries', leaders' and events' photos (Website 1.7.1).
ALTER TABLE "Ministry" ADD COLUMN "framing" JSONB;
ALTER TABLE "Leader" ADD COLUMN "framing" JSONB;
ALTER TABLE "SimpleEvent" ADD COLUMN "framing" JSONB;
@@ -104,6 +104,8 @@ model Ministry {
summary String?
body String?
imageId String?
/// How the photo sits in its frame on the site: { x, y, zoom } (Move and zoom); null is centred.
framing Json?
position Int @default(0)
archivedAt DateTime?
updatedAt DateTime @updatedAt
@@ -117,6 +119,8 @@ model Leader {
role String?
bio String?
photoId String?
/// How the photo sits in its frame on the site: { x, y, zoom } (Move and zoom); null is centred.
framing Json?
position Int @default(0)
archivedAt DateTime?
updatedAt DateTime @updatedAt
@@ -170,6 +174,8 @@ model SimpleEvent {
location String?
description String?
imageId String?
/// How the photo sits in its frame on the site: { x, y, zoom } (Move and zoom); null is centred.
framing Json?
link String?
/// A ministry's event: its Ministry leader can add and edit it; an Editor publishes it (§10).
ministryId String?
+9 -3
View File
@@ -9,13 +9,17 @@
import { z } from 'zod';
import { websiteTemplateSchema } from '@crosscode/contracts';
import type { Ctx } from '../context.js';
import { Prisma } from '../generated/prisma/client.js';
import { ApiError } from '../http.js';
import { BLOCK_SCHEMAS, isBlockType, SECTION_SCHEMAS } from '../site/sections.js';
import { BLOCK_SCHEMAS, isBlockType, rowFraming, SECTION_SCHEMAS } from '../site/sections.js';
import { cleanDesign } from '../site/snapshot.js';
import { BUTTONS, IMAGE_TREATMENTS, isVariant, SECTION_COLOURS, SECTION_TYPES, sectionTypeSchema, SPACINGS, switchTemplate, TEMPLATE_HEADERS, type SectionType } from '../site/variants.js';
type Who = { id: string; role: string };
/** A row's photo framing to save: kept only while it has a photo (a new photo starts centred). */
export const framingFor = (photo: string | null, f: { x: number; y: number; zoom: number } | null) => (photo && f ? f : Prisma.DbNull);
/** zod issues as `{ field: message }`, for the form. */
function fieldsOf(e: z.ZodError): Record<string, string> {
const out: Record<string, string> = {};
@@ -231,6 +235,7 @@ const ministrySchema = z.object({
summary: z.string().trim().max(300).nullable().default(null),
body: z.string().trim().max(8000).nullable().default(null),
imageId: z.string().uuid().nullable().default(null),
framing: rowFraming,
position: z.int().min(0).max(1000).optional(),
});
@@ -239,6 +244,7 @@ const leaderSchema = z.object({
role: z.string().trim().max(120).nullable().default(null),
bio: z.string().trim().max(4000).nullable().default(null),
photoId: z.string().uuid().nullable().default(null),
framing: rowFraming,
position: z.int().min(0).max(1000).optional(),
});
@@ -253,7 +259,7 @@ export async function saveMinistry(ctx: Ctx, id: string | null, body: unknown, b
const slug = m.slug ?? slugify(m.name);
const clash = await ctx.db.ministry.findFirst({ where: { slug, ...(id ? { NOT: { id } } : {}) } });
if (clash) throw new ApiError(409, 'SLUG_TAKEN', 'Another ministry already has that name.', { name: 'Another ministry has it' });
const data = { name: m.name, slug, summary: m.summary, body: m.body, imageId: m.imageId, ...(m.position !== undefined ? { position: m.position } : {}), updatedBy: by.id };
const data = { name: m.name, slug, summary: m.summary, body: m.body, imageId: m.imageId, framing: framingFor(m.imageId, m.framing), ...(m.position !== undefined ? { position: m.position } : {}), updatedBy: by.id };
if (id) {
const row = await ctx.db.ministry.findUnique({ where: { id } });
if (!row || row.archivedAt) throw new ApiError(404, 'NOT_FOUND', 'That ministry doesn\'t exist.');
@@ -274,7 +280,7 @@ export async function listLeaders(ctx: Ctx) {
export async function saveLeader(ctx: Ctx, id: string | null, body: unknown, by: Who) {
const l = check(leaderSchema, body);
const data = { name: l.name, role: l.role, bio: l.bio, photoId: l.photoId, ...(l.position !== undefined ? { position: l.position } : {}), updatedBy: by.id };
const data = { name: l.name, role: l.role, bio: l.bio, photoId: l.photoId, framing: framingFor(l.photoId, l.framing), ...(l.position !== undefined ? { position: l.position } : {}), updatedBy: by.id };
if (id) {
const row = await ctx.db.leader.findUnique({ where: { id } });
if (!row || row.archivedAt) throw new ApiError(404, 'NOT_FOUND', 'That person isn\'t on the team.');
+5 -3
View File
@@ -9,10 +9,11 @@ import type { Ctx } from '../context.js';
import { ApiError } from '../http.js';
import { audit } from '../lib/audit.js';
import { youtubeId, spotifyEmbed, messageThumbnail } from '../site/content.js';
import { rowFraming } from '../site/sections.js';
import { mediaUrl } from '../site/snapshot.js';
import { getSource, setSource, syncYoutube, uniqueSlug } from '../site/youtube.js';
import { markRemoved, notifyLinks } from '../feed/feed.js';
import { notChangedSince } from './content.js';
import { framingFor, notChangedSince } from './content.js';
type Who = { id: string; role: string };
@@ -121,6 +122,7 @@ const eventSchema = z.object({
location: optional(500),
description: optional(8000),
imageId: z.string().uuid().nullable().default(null),
framing: rowFraming,
ministryId: z.string().uuid().nullable().default(null),
link: z.string().trim().max(500).nullable().default(null).refine((v) => !v || /^https:\/\//.test(v), 'An https:// address').transform((v) => v || null),
}).refine((e) => !e.endsAt || new Date(e.endsAt) >= new Date(e.startsAt), { message: 'It ends before it starts', path: ['endsAt'] });
@@ -130,7 +132,7 @@ export async function listEvents(ctx: Ctx) {
const urls = new Map(media.map((m) => [m.id, mediaUrl(m.filename)]));
return rows.map((e) => ({
id: e.id, slug: e.slug, title: e.title, startsAt: e.startsAt.toISOString(), endsAt: e.endsAt?.toISOString() ?? null, allDay: e.allDay, location: e.location,
description: e.description, imageId: e.imageId, image: e.imageId ? urls.get(e.imageId) ?? null : null, link: e.link, ministryId: e.ministryId,
description: e.description, imageId: e.imageId, image: e.imageId ? urls.get(e.imageId) ?? null : null, framing: e.framing, link: e.link, ministryId: e.ministryId,
cancelled: e.cancelled, published: e.publishedAt !== null, updatedAt: e.updatedAt.toISOString(),
}));
}
@@ -144,7 +146,7 @@ export async function saveEvent(ctx: Ctx, id: string | null, body: unknown, by:
if (leader && (!leader.ministryId || e.ministryId !== leader.ministryId)) throw new ApiError(403, 'FORBIDDEN', OWN_ONLY);
const data = {
title: e.title, startsAt: new Date(e.startsAt), endsAt: e.endsAt ? new Date(e.endsAt) : null, allDay: e.allDay, location: e.location, description: e.description,
imageId: e.imageId, link: e.link, ministryId: e.ministryId, timezone: ctx.config.timezone, updatedBy: by.id,
imageId: e.imageId, framing: framingFor(e.imageId, e.framing), link: e.link, ministryId: e.ministryId, timezone: ctx.config.timezone, updatedBy: by.id,
};
if (id) {
const row = await ctx.db.simpleEvent.findUnique({ where: { id } });
+2 -2
View File
@@ -8,7 +8,7 @@ import { TEMPLATE_FONT_PAIRINGS, type Church, type CrosscodeEvent, type WebsiteT
import type { Ctx } from '../context.js';
import { churchProfile } from '../church/profile.js';
import { buildPalette, type Palette } from './palette.js';
import { buildSnapshot, imageOf, mediaUrl, publishedSnapshot, type Image, type Snapshot } from './snapshot.js';
import { buildSnapshot, framed, imageOf, mediaUrl, publishedSnapshot, type Image, type Snapshot } from './snapshot.js';
import { headerIsTransparent, TEMPLATE_STYLE, type Variant } from './variants.js';
export type SiteEvent = {
@@ -139,7 +139,7 @@ async function liveEvents(ctx: Ctx): Promise<SiteEvent[]> {
};
const own: SiteEvent[] = simple.map((e) => ({
title: e.title, summary: e.description ? e.description.slice(0, 200) : null, startsAt: e.startsAt.toISOString(), endsAt: e.endsAt?.toISOString() ?? null,
allDay: e.allDay, location: e.location, image: image(e.imageId), url: e.link || `/events/${e.slug}`, slug: e.slug, link: e.link, from: 'website', registration: null,
allDay: e.allDay, location: e.location, image: framed(image(e.imageId), e.framing), url: e.link || `/events/${e.slug}`, slug: e.slug, link: e.link, from: 'website', registration: null,
}));
const copies: SiteEvent[] = imported.flatMap((row) => {
const e = row.data as unknown as CrosscodeEvent;
+4 -1
View File
@@ -16,7 +16,10 @@ const mediaId = z.string().uuid();
* How each photo sits in its frame, by media id: the point kept in view (`x`, `y`, 0 to 100 from
* the left and top, as CSS `object-position`) and how far it's zoomed in (1 fills the frame).
*/
const framing = z.record(z.string().uuid(), z.object({ x: z.number().min(0).max(100), y: z.number().min(0).max(100), zoom: z.number().min(1).max(4) })).optional();
export const focusSchema = z.object({ x: z.number().min(0).max(100), y: z.number().min(0).max(100), zoom: z.number().min(1).max(4) });
/** A ministry's, leader's or event's one photo: how it sits in its frame, or null (centred). */
export const rowFraming = focusSchema.nullable().default(null);
const framing = z.record(z.string().uuid(), focusSchema).optional();
/** Keeps framing only for the photos the section still shows (a removed photo's would hold it "in use"). */
function pruneFraming<T extends { framing?: Record<string, unknown> }>(d: T): T {
if (!d.framing) return d;
+24 -7
View File
@@ -16,7 +16,21 @@ import { defaultDesign, isVariant, SECTION_TYPES, switchTemplate, type SectionTy
export const SNAPSHOT_VERSION = 1;
/** An image to show: the photo, and its responsive sizes as `srcset`s when it has them (§3). */
export type Image = { url: string; alt: string; width: number | null; height: number | null; srcset?: { webp: string; jpg: string } };
export type Image = { url: string; alt: string; width: number | null; height: number | null; srcset?: { webp: string; jpg: string }; focus?: Focus };
/** How a photo sits in its frame (Move and zoom): the point kept in view and the zoom. */
export type Focus = { x: number; y: number; zoom: number };
/** A row's saved framing, if it is one (a Json column: anything else is ignored). */
export function focusOf(f: unknown): Focus | undefined {
const x = f as Partial<Focus> | null | undefined;
return x && typeof x.x === 'number' && typeof x.y === 'number' && typeof x.zoom === 'number' ? { x: x.x, y: x.y, zoom: x.zoom } : undefined;
}
/** The image with its framing, when it has one. */
export const framed = (img: Image | null, f: unknown): Image | null => {
const focus = img ? focusOf(f) : undefined;
return img && focus ? { ...img, focus } : img;
};
type MediaRow = { id: string; filename: string; alt: string; width: number | null; height: number | null; sizes?: unknown };
@@ -89,8 +103,8 @@ export type Source = {
inNav: boolean; position: number; imageId: string | null;
sections: { id: string; type: string; variant: string | null; position: number; hidden: boolean; data: unknown }[];
}[];
ministries: { id: string; slug: string; name: string; summary: string | null; body: string | null; imageId: string | null; position: number }[];
leaders: { id: string; name: string; role: string | null; bio: string | null; photoId: string | null; position: number }[];
ministries: { id: string; slug: string; name: string; summary: string | null; body: string | null; imageId: string | null; framing?: unknown; position: number }[];
leaders: { id: string; name: string; role: string | null; bio: string | null; photoId: string | null; framing?: unknown; position: number }[];
};
/** Every page, section, ministry and leader that isn't archived, with who last changed it. */
@@ -105,6 +119,9 @@ export async function readWorkingCopy(ctx: Ctx) {
return { design, pages, ministries, leaders };
}
/** Framing in a source row only when there is some: versions published before it compare equal. */
const withFraming = (f: unknown) => (focusOf(f) ? { framing: focusOf(f) } : {});
export function toSource(w: Awaited<ReturnType<typeof readWorkingCopy>>): Source {
return {
design: w.design ? { template: w.design.template, variants: w.design.variants, home: w.design.home, style: w.design.style } : null,
@@ -113,8 +130,8 @@ export function toSource(w: Awaited<ReturnType<typeof readWorkingCopy>>): Source
position: p.position, imageId: p.imageId,
sections: p.sections.map((x) => ({ id: x.id, type: x.type, variant: x.variant, position: x.position, hidden: x.hidden, data: x.data })),
})),
ministries: w.ministries.map((m) => ({ id: m.id, slug: m.slug, name: m.name, summary: m.summary, body: m.body, imageId: m.imageId, position: m.position })),
leaders: w.leaders.map((l) => ({ id: l.id, name: l.name, role: l.role, bio: l.bio, photoId: l.photoId, position: l.position })),
ministries: w.ministries.map((m) => ({ id: m.id, slug: m.slug, name: m.name, summary: m.summary, body: m.body, imageId: m.imageId, ...withFraming(m.framing), position: m.position })),
leaders: w.leaders.map((l) => ({ id: l.id, name: l.name, role: l.role, bio: l.bio, photoId: l.photoId, ...withFraming(l.framing), position: l.position })),
};
}
@@ -179,8 +196,8 @@ export function snapshotFrom(source: Source, media: MediaRow[]): Snapshot {
v: SNAPSHOT_VERSION,
design: d,
pages: snapshotPages,
ministries: source.ministries.map((m) => ({ slug: m.slug, name: m.name, summary: m.summary, body: m.body, image: image(m.imageId) })),
leaders: source.leaders.map((l) => ({ name: l.name, role: l.role, bio: l.bio, photo: image(l.photoId) })),
ministries: source.ministries.map((m) => ({ slug: m.slug, name: m.name, summary: m.summary, body: m.body, image: framed(image(m.imageId), m.framing) })),
leaders: source.leaders.map((l) => ({ name: l.name, role: l.role, bio: l.bio, photo: framed(image(l.photoId), l.framing) })),
media: used,
redirects: {},
source,
+3 -2
View File
@@ -12,6 +12,7 @@
*/
import type { Ctx } from '../context.js';
import { ApiError } from '../http.js';
import { Prisma } from '../generated/prisma/client.js';
import { audit } from '../lib/audit.js';
import { publishedSnapshot, readWorkingCopy, toSource, type Source } from './snapshot.js';
@@ -103,14 +104,14 @@ async function apply(ctx: Ctx, key: string, source: Source | null, by: Who) {
if (what === 'ministry') {
const m = source?.ministries.find((x) => x.id === id);
if (!m) return void (await db.ministry.update({ where: { id }, data: { archivedAt: ctx.now(), ...stamp } }));
const data = { slug: m.slug, name: m.name, summary: m.summary, body: m.body, imageId: m.imageId, position: m.position, archivedAt: null, ...stamp };
const data = { slug: m.slug, name: m.name, summary: m.summary, body: m.body, imageId: m.imageId, framing: (m.framing ?? Prisma.DbNull) as never, position: m.position, archivedAt: null, ...stamp };
await db.ministry.upsert({ where: { id }, create: { id, ...data }, update: data });
return;
}
if (what === 'leader') {
const l = source?.leaders.find((x) => x.id === id);
if (!l) return void (await db.leader.update({ where: { id }, data: { archivedAt: ctx.now(), ...stamp } }));
const data = { name: l.name, role: l.role, bio: l.bio, photoId: l.photoId, position: l.position, archivedAt: null, ...stamp };
const data = { name: l.name, role: l.role, bio: l.bio, photoId: l.photoId, framing: (l.framing ?? Prisma.DbNull) as never, position: l.position, archivedAt: null, ...stamp };
await db.leader.upsert({ where: { id }, create: { id, ...data }, update: data });
return;
}
+36
View File
@@ -226,3 +226,39 @@ describe('uploads and storage (§10, decision 12)', () => {
assert.equal((await as.get('/media')).body.storage.full, true);
});
});
describe('move and zoom for ministries, leaders and events', () => {
it('saves framing with the row, publishes it onto the photo, drops it with the photo, and leaves old versions unchanged', async () => {
const { as, app } = await signedIn('editor');
// Published before framing existed: nothing shows as changed.
assert.deepEqual((await as.get('/changes')).body, []);
const focus = { x: 20, y: 70, zoom: 1.6 };
const m = ((await as.get('/ministries')).body as { id: string; name: string; imageId: string; updatedAt: string }[])[0]!;
assert.ok(m.imageId);
assert.equal((await as.put(`/ministries/${m.id}`, { name: m.name, imageId: m.imageId, framing: focus })).status, 200);
assert.equal((await as.put(`/ministries/${m.id}`, { name: m.name, imageId: m.imageId, framing: { x: 200, y: 0, zoom: 1 } })).status, 400);
const l = ((await as.get('/leaders')).body as { id: string; name: string; photoId: string }[])[0]!;
assert.equal((await as.put(`/leaders/${l.id}`, { name: l.name, photoId: l.photoId, framing: focus })).status, 200);
assert.deepEqual(((await as.get('/leaders')).body as { id: string; framing: unknown }[]).find((x) => x.id === l.id)!.framing, focus);
assert.deepEqual((await as.get('/changes')).body.map((c: { what: string }) => c.what).sort(), ['leader', 'ministry']);
assert.equal((await as.post('/publish')).status, 200);
const site = (await request(app).get('/api/v1/site/content')).body;
assert.deepEqual(site.snapshot.ministries.find((x: { name: string }) => x.name === m.name).image.focus, focus);
assert.deepEqual(site.snapshot.leaders.find((x: { name: string }) => x.name === l.name).photo.focus, focus);
// Discard puts the published framing back; a photo removed takes its framing with it.
await as.put(`/leaders/${l.id}`, { name: l.name, photoId: null, framing: focus });
assert.equal(((await as.get('/leaders')).body as { id: string; framing: unknown }[]).find((x) => x.id === l.id)!.framing, null);
assert.equal((await as.post('/discard', { key: `leader:${l.id}` })).status, 200);
assert.deepEqual(((await as.get('/leaders')).body as { id: string; framing: unknown }[]).find((x) => x.id === l.id)!.framing, focus);
// Events: saved with the event, shown on the live site straight away once published.
const e = ((await as.get('/events')).body as { id: string; title: string; startsAt: string; endsAt: string | null; imageId: string | null }[]).find((x) => x.imageId)!;
assert.equal((await as.put(`/events/${e.id}`, { title: e.title, startsAt: e.startsAt, endsAt: e.endsAt, imageId: e.imageId, framing: focus })).status, 200);
assert.deepEqual(((await as.get('/events')).body as { id: string; framing: unknown }[]).find((x) => x.id === e.id)!.framing, focus);
const live = (await request(app).get('/api/v1/site/content')).body;
assert.deepEqual(live.events.find((x: { title: string }) => x.title === e.title).image.focus, focus);
});
});
@@ -9,13 +9,13 @@ import crypto from 'node:crypto';
type Row = Record<string, unknown>;
const DEFAULTS: Record<string, () => Row> = {
ministry: () => ({ summary: null, body: null, imageId: null, position: 0, archivedAt: null, updatedBy: null }),
leader: () => ({ role: null, bio: null, photoId: null, position: 0, archivedAt: null, updatedBy: null }),
ministry: () => ({ summary: null, body: null, imageId: null, framing: null, position: 0, archivedAt: null, updatedBy: null }),
leader: () => ({ role: null, bio: null, photoId: null, framing: null, position: 0, archivedAt: null, updatedBy: null }),
messageSeries: () => ({ summary: null, imageId: null }),
page: () => ({ seoTitle: null, description: null, navLabel: null, inNav: true, position: 0, imageId: null, archivedAt: null, updatedBy: null }),
section: () => ({ variant: null, position: 0, hidden: false, updatedBy: null }),
message: () => ({ externalId: null, thumbnailUrl: null, speaker: null, passage: null, notes: null, seriesId: null, hidden: false, publishedAt: null, updatedBy: null }),
simpleEvent: () => ({ endsAt: null, allDay: false, timezone: 'Africa/Johannesburg', location: null, description: null, imageId: null, link: null, cancelled: false, publishedAt: null, updatedBy: null }),
simpleEvent: () => ({ endsAt: null, allDay: false, timezone: 'Africa/Johannesburg', location: null, description: null, imageId: null, framing: null, link: null, cancelled: false, publishedAt: null, updatedBy: null }),
mediaAsset: () => ({ width: null, height: null, alt: '', sizes: null, uploadedBy: null }),
siteVersion: () => ({ note: null }),
websiteUser: () => ({ ministryId: null, lastSignInAt: null }),
@@ -66,7 +66,9 @@ export function matches(row: Row, where: Row = {}): boolean {
});
}
const clone = <T>(x: T): T => structuredClone(x);
/** Prisma.DbNull / JsonNull (a nullable Json field set to null) are stored as null, as Postgres does. */
const nulls = (x: unknown) => (x && typeof x === 'object' && /^(Db|Json)Null$/.test(x.constructor?.name ?? '') ? null : x);
const clone = <T>(x: T): T => structuredClone(x && typeof x === 'object' && !Array.isArray(x) && !(x instanceof Date) ? Object.fromEntries(Object.entries(x).map(([k, y]) => [k, nulls(y)])) as T : x);
const pick = (row: Row, select?: Row) => (select ? Object.fromEntries(Object.keys(select).filter((k) => select[k]).map((k) => [k, row[k]])) : row);
function order(rows: Row[], orderBy?: Row | Row[]) {
+21
View File
@@ -212,6 +212,8 @@ test("move and zoom a photo in its frame, then delete a photo nothing uses", asy
// Upload one nothing uses, then delete it; one in use says where instead.
await page.goto("/admin/media");
// Count once the library has loaded (it can still be empty for a moment).
await expect(page.locator("main li").first()).toBeVisible();
const before = await page.locator("main li").count();
const png = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==", "base64");
await page.locator('input[type="file"]').setInputFiles({ name: "dot.png", mimeType: "image/png", buffer: png });
@@ -224,3 +226,22 @@ test("move and zoom a photo in its frame, then delete a photo nothing uses", asy
await expect(page.getByText("Deleted.")).toBeVisible();
await expect(page.locator("main li")).toHaveCount(before);
});
test("move and zoom a ministry's, a leader's and an event's photo", async ({ page, context }) => {
await signIn(context);
for (const [path, saved] of [["/admin/ministries", "Saved as a draft."], ["/admin/leaders", "Saved as a draft."], ["/admin/events", null]] as const) {
await page.goto(path);
await page.getByRole("button", { name: "Edit", exact: true }).first().click();
await page.getByRole("button", { name: "Move and zoom" }).first().click();
const dialog = page.getByRole("dialog", { name: "Move and zoom the photo" });
await dialog.getByRole("slider").fill("2");
await dialog.getByRole("button", { name: "Done" }).click();
await expect(page.getByText("Moved and zoomed to 200%")).toBeVisible();
await page.getByRole("button", { name: "Save", exact: true }).click();
if (saved) await expect(page.getByText(saved)).toBeVisible();
else await expect(page.getByRole("button", { name: "Save", exact: true })).toHaveCount(0);
// Saved with the row: it's there when the form opens again.
await page.getByRole("button", { name: "Edit", exact: true }).first().click();
await expect(page.getByText("Moved and zoomed to 200%")).toBeVisible();
}
});
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/website-frontend",
"version": "1.7.0",
"version": "1.7.1",
"private": true,
"description": "Church Website: the church's public site in its template, and the admin",
"scripts": {
+15 -3
View File
@@ -3,10 +3,15 @@
/** A list of things the church keeps (ministries, its team): add, edit, remove. Drafts until Publish. */
import { useState } from "react";
import { api } from "./api";
import type { Focus } from "@/site/types";
import { RowFraming } from "./framing";
import { ImagePicker } from "./media";
import { Btn, Field, inputClass, Loading, Notice, Panel, useAction, useAdmin } from "./ui";
export type ListField = { key: string; label: string; kind: "text" | "textarea" | "image"; max?: number; hint?: string };
export type ListField = { key: string; label: string; kind: "text" | "textarea" | "image"; max?: number; hint?: string;
/** An image field: its photo can be moved and zoomed in this frame (saved as the row's `framing`). */
frame?: "ministry" | "leader";
};
type Row = Record<string, unknown> & { id: string };
@@ -14,7 +19,14 @@ function Editor({ fields, initial, onSave, onCancel, busy, errors }: { fields: L
const [v, setV] = useState<Record<string, unknown>>(initial);
return (
<div className="space-y-3">
{fields.map((f) => f.kind === "image"
{fields.map((f) => f.kind === "image" && f.frame
? (
<RowFraming key={f.key} type={f.frame} value={v.framing as Focus | null} onChange={(framing) => setV({ ...v, framing })}>
{/* Another photo starts centred. */}
<ImagePicker label={f.label} slot={{ key: f.key }} value={(v[f.key] as string) ?? null} onChange={(id) => setV({ ...v, [f.key]: id, framing: null })} />
</RowFraming>
)
: f.kind === "image"
? <ImagePicker key={f.key} label={f.label} value={(v[f.key] as string) ?? null} onChange={(id) => setV({ ...v, [f.key]: id })} />
: (
<Field key={f.key} label={f.label} hint={f.hint} error={errors[f.key]}>
@@ -36,7 +48,7 @@ export function ListEditor({ path, fields, nameKey, subKey, addLabel, canAdd }:
const save = (id: string | null, v: Record<string, unknown>) => run(async () => {
const row = id ? data.find((r) => r.id === id) : null;
// When the form was loaded: someone else's save in between isn't overwritten (§4).
const body = { ...Object.fromEntries(fields.map((f) => [f.key, v[f.key] ?? null])), ...(row?.updatedAt ? { ifUpdatedAt: row.updatedAt } : {}) };
const body = { ...Object.fromEntries(fields.map((f) => [f.key, v[f.key] ?? null])), ...(fields.some((f) => f.frame) ? { framing: v.framing ?? null } : {}), ...(row?.updatedAt ? { ifUpdatedAt: row.updatedAt } : {}) };
await api(id ? `${path}/${id}` : path, { method: id ? "PUT" : "POST", body });
setEditing(null);
await reload();
+23 -1
View File
@@ -8,7 +8,7 @@
import { createContext, useContext, useEffect, useRef, useState } from "react";
import { focusStyle } from "@/site/parts";
import type { Focus } from "@/site/types";
import { Btn, cx } from "./ui";
import { Btn, cx, useAdmin } from "./ui";
export type Frame = { ratio: number; round?: boolean; label: string };
@@ -40,6 +40,18 @@ export function frameFor(design: Design, type: string, key: string, index = 0):
if (key === "photoId") return { ratio: 4 / 5, label: "The pastor's photo" };
return t === "bold" ? { ratio: 1, label: "Beside the welcome" } : { ratio: 4 / 3, label: "Beside the welcome" };
}
// A ministry's, leader's or event's photo: the home page section's frame for the layout chosen.
if (type === "ministry") {
const vm = design?.variants?.ministries;
if (vm === "bands") return t === "bold" ? { ratio: 4 / 3, label: "Beside its name on the home page (4:3 on the Ministries page)" } : { ratio: 16 / 10, label: "Beside its name on the home page (4:3 on the Ministries page)" };
return { ratio: 4 / 3, label: "On its card on the home page and beside it on the Ministries page" };
}
if (type === "leader") {
const round = t === "heritage" || t === "community";
if (t === "bold") return { ratio: 3 / 4, label: "Their photo on the home page (square on the Leadership page)" };
return { ratio: 1, round, label: round ? "Their photo, in a circle" : "Their photo" };
}
if (type === "event") return { ratio: 16 / 10, label: "On the event's card (a little taller on its own page)" };
if (type === "invitation") return { ratio: 3, label: "Behind the invitation, darkened (the Image background layout)" };
return { ratio: 4 / 3, label: "Beside the text" };
}
@@ -54,6 +66,16 @@ export type Framing = {
export const FramingContext = createContext<Framing | null>(null);
export const useFraming = () => useContext(FramingContext);
/**
* Framing for a row with one photo (a ministry, a leader, an event): saved as the row's `framing`,
* in the frame of `type` (frameFor) for the site's current template and layouts.
*/
export function RowFraming({ type, value, onChange, children }: { type: "ministry" | "leader" | "event"; value: Focus | null | undefined; onChange: (f: Focus | null) => void; children: React.ReactNode }) {
const design = useAdmin<{ design: Design }>("/design");
const ctx: Framing = { get: () => value ?? undefined, set: (_, f) => onChange(f), frame: (key, i) => frameFor(design.data?.design, type, key, i) };
return <FramingContext.Provider value={ctx}>{children}</FramingContext.Provider>;
}
/** The photo drawn in its frame, as the site draws it (object-cover, point kept in view, zoom). */
export function Framed({ url, frame, focus, className, imgRef }: { url: string; frame: Frame; focus: Focus | undefined; className?: string; imgRef?: React.Ref<HTMLImageElement> }) {
return (
@@ -8,15 +8,17 @@
*/
import { useState } from "react";
import { api, canEdit } from "@/admin/api";
import { RowFraming } from "@/admin/framing";
import { ImagePicker } from "@/admin/media";
import type { Focus } from "@/site/types";
import { Btn, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin, when } from "@/admin/ui";
import { CalendarDays } from "lucide-react";
type Ev = {
id: string; slug: string; title: string; startsAt: string; endsAt: string | null; allDay: boolean; location: string | null; description: string | null;
imageId: string | null; image: string | null; link: string | null; ministryId: string | null; cancelled: boolean; published: boolean; updatedAt: string;
imageId: string | null; image: string | null; framing: Focus | null; link: string | null; ministryId: string | null; cancelled: boolean; published: boolean; updatedAt: string;
};
type Form = { title: string; date: string; time: string; endDate: string; endTime: string; allDay: boolean; location: string; description: string; imageId: string | null; link: string; ministryId: string | null };
type Form = { title: string; date: string; time: string; endDate: string; endTime: string; allDay: boolean; location: string; description: string; imageId: string | null; framing: Focus | null; link: string; ministryId: string | null };
type Me = { user: { role: string; ministryId: string | null } };
/** "2026-12-05" + "18:30" in the browser's time zone (the church's, for its admins) → ISO with offset. */
@@ -53,11 +55,14 @@ function EventForm({ initial, ministries, fixedMinistry, onSave, onCancel }: { i
</select>
</Field>
)}
<ImagePicker label="Photo" value={v.imageId} onChange={(id) => set("imageId", id)} />
<RowFraming type="event" value={v.framing} onChange={(f) => set("framing", f)}>
{/* Another photo starts centred. */}
<ImagePicker label="Photo" slot={{ key: "imageId" }} value={v.imageId} onChange={(id) => setV({ ...v, imageId: id, framing: null })} />
</RowFraming>
<div className="flex gap-2">
<Btn kind="primary" busy={busy} onClick={() => run(() => onSave({
title: v.title, startsAt: iso(v.date, v.allDay ? "00:00" : v.time), endsAt: v.endDate ? iso(v.endDate, v.allDay ? "23:59" : v.endTime) : null,
allDay: v.allDay, location: v.location || null, description: v.description || null, imageId: v.imageId, link: v.link || null, ministryId: fixedMinistry ?? v.ministryId,
allDay: v.allDay, location: v.location || null, description: v.description || null, imageId: v.imageId, framing: v.framing, link: v.link || null, ministryId: fixedMinistry ?? v.ministryId,
}))}>Save</Btn>
<Btn onClick={onCancel}>Cancel</Btn>
</div>
@@ -66,7 +71,7 @@ function EventForm({ initial, ministries, fixedMinistry, onSave, onCancel }: { i
);
}
const empty: Form = { title: "", date: "", time: "10:00", endDate: "", endTime: "", allDay: false, location: "", description: "", imageId: null, link: "", ministryId: null };
const empty: Form = { title: "", date: "", time: "10:00", endDate: "", endTime: "", allDay: false, location: "", description: "", imageId: null, framing: null, link: "", ministryId: null };
export default function Events() {
const me = useAdmin<Me>("/me");
@@ -82,7 +87,7 @@ export default function Events() {
const toForm = (e: Ev): Form => {
const s = local(e.startsAt);
const f = local(e.endsAt);
return { title: e.title, date: s.d, time: s.t, endDate: f.d, endTime: f.t, allDay: e.allDay, location: e.location ?? "", description: e.description ?? "", imageId: e.imageId, link: e.link ?? "", ministryId: e.ministryId };
return { title: e.title, date: s.d, time: s.t, endDate: f.d, endTime: f.t, allDay: e.allDay, location: e.location ?? "", description: e.description ?? "", imageId: e.imageId, framing: e.framing ?? null, link: e.link ?? "", ministryId: e.ministryId };
};
const state = (e: Ev, change: object, done: string) => run(async () => { await api(`/events/${e.id}/state`, { body: change }); await reload(); }, done);
const form = (e: Ev | null) => (
@@ -15,7 +15,7 @@ export default function Leaders() {
{ key: "name", label: "Name", kind: "text", max: 120 },
{ key: "role", label: "Role", kind: "text", max: 120, hint: "E.g. “Lead pastor”." },
{ key: "bio", label: "About them", kind: "textarea", max: 4000 },
{ key: "photoId", label: "Photo", kind: "image" },
{ key: "photoId", label: "Photo", kind: "image", frame: "leader" },
]} />
</>
);
@@ -15,7 +15,7 @@ export default function Ministries() {
{ key: "name", label: "Name", kind: "text", max: 120 },
{ key: "summary", label: "In one line", kind: "text", max: 300, hint: "E.g. “Ages 3 to 12, every Sunday at 10:00.”" },
{ key: "body", label: "More about it", kind: "textarea", max: 8000 },
{ key: "imageId", label: "Photo", kind: "image" },
{ key: "imageId", label: "Photo", kind: "image", frame: "ministry" },
]} />
</>
);
+7 -2
View File
@@ -11,7 +11,7 @@ separately below; the two often differ.
| What | Repo | Latest | Tag | Released |
|------|------|--------|-----|----------|
| Cross Events | `crosscode-platform` (`apps/events`) | **3.7.2** | `events@3.7.2` | 2026-11-27 |
| Church Website | `crosscode-platform` (`apps/website`) | **1.7.0** | `website@1.7.0` | 2026-11-27 |
| Church Website | `crosscode-platform` (`apps/website`) | **1.7.1** | `website@1.7.1` | 2026-11-28 |
| Accounts | `crosscode-platform` (`apps/accounts`) | **1.8.0** | `accounts@1.8.0` | 2026-11-26 |
| Server agent | `crosscode-platform` (`apps/agent`) | **1.6.0** | `agent@1.6.0` | 2026-11-27 |
| Contracts | `crosscode-platform` (`packages/contracts`) | **1.19.0** | `contracts@1.19.0` | 2026-11-27 |
@@ -30,7 +30,7 @@ on each run, so merging to `main` and pushing releases it. Its changes are liste
| `@crosscode/auth-client` | `packages/auth-client` | 1.1.0 (released with Events 3.0.0 and Accounts 1.1.0) |
| `@crosscode/seo` | `packages/seo` | 1.0.0 (released with Events 2.4.0) |
| `@crosscode/ui` | `packages/ui` | 0.3.0 (fonts, `ChurchFooter`; 0.2.0 with Accounts 1.7.0, 0.3.0 with Events 3.7.0) |
| Website | `apps/website` | 1.7.0 (1.0.0–1.1.0 released 2026-11-26, 1.2.0–1.7.0 on 2026-11-27; installed for the demo church cross-demo2 (1.7.0) only, Hope Family Church next) |
| Website | `apps/website` | 1.7.1 (1.0.0–1.1.0 released 2026-11-26, 1.2.0–1.7.0 on 2026-11-27, 1.7.1 on 2026-11-28; installed for the demo church cross-demo2 (1.7.0) only, Hope Family Church next) |
| App | `apps/app` | 0.0.0 (not started, phase 6) |
These shared packages ship inside the apps that use them, from the same checkout, so they don't
@@ -38,6 +38,11 @@ need their own tags until something outside this repo depends on them.
## What each latest release was for
- **Church Website 1.7.1 (2026-11-28):** Move and zoom for ministries', leaders' and events'
photos too (1.7.0 had it in page sections only), saved with the row (`framing`). One migration
(a nullable column on three tables). Checked: backend tests (136) and typecheck, frontend
typecheck and lint, and the admin e2e suite in Chromium (12). Lighthouse not run. **Not deployed
yet.**
- **Hub 2.25.1 (2026-11-27):** Jobs → Product filter lists every product. It offered only Cross
Events and Accounts, so the Church Website's jobs couldn't be picked out; the list now comes from
the frontend's products list (Events, Accounts, the Church Website, the App). Frontend only. No
+2 -2
View File
@@ -360,7 +360,7 @@
},
"apps/website/backend": {
"name": "@crosscode/website-backend",
"version": "1.7.0",
"version": "1.7.1",
"hasInstallScript": true,
"dependencies": {
"@crosscode/auth-client": "*",
@@ -389,7 +389,7 @@
},
"apps/website/frontend": {
"name": "@crosscode/website-frontend",
"version": "1.7.0",
"version": "1.7.1",
"dependencies": {
"@crosscode/contracts": "*",
"@crosscode/seo": "*",