Accessibility, event photo and analytics (v1.12.0-accessibility) #25

Merged
ngu-git-admin merged 3 commits from accessibility into main 2026-10-03 09:03:20 +01:00
14 changed files with 69 additions and 15 deletions
Showing only changes of commit e324422f32 - Show all commits

View file

@ -61,6 +61,8 @@ export const events = {
text("event_logo"), text("event_logo"),
text("color"), text("color"),
text("card_image"), text("card_image"),
text("photo"),
text("photo_alt"),
bool("is_published"), bool("is_published"),
bool("is_listed"), bool("is_listed"),
bool("in_timeline"), bool("in_timeline"),

View file

@ -0,0 +1,20 @@
-- ═══════════════════════════════════════════════════════════════
-- 061 EVENTS: EVENT PHOTO
--
-- An event's own 16:9 photo, shown whole: at the top of its page, as
-- the front page's featured event, on featured cards, in newsletter
-- picks and as its page's share preview. photo_alt says what it
-- shows, for screen readers (blank: decoration).
--
-- card_image (029) goes back to being only the faded background of
-- the event's card, which crops it to the card's shape. Until now it
-- did both jobs, so each event's photo starts as its card
-- background, to keep the front page and previews as they were.
--
-- v_events selects e.*, so it carries the new columns as it is.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE events ADD COLUMN photo TEXT;
ALTER TABLE events ADD COLUMN photo_alt TEXT;
UPDATE events SET photo = card_image WHERE card_image IS NOT NULL;

View file

@ -199,7 +199,7 @@ function eventMeta(site, db, id, meta) {
const when = [row.date_label, row.location_label].filter(Boolean).join(" · "); const when = [row.date_label, row.location_label].filter(Boolean).join(" · ");
const image = const image =
imageUrl(site, row.card_image, "eventBackground") ?? imageUrl(site, row.photo, "eventPhoto") ??
imageUrl(site, row.event_logo, "eventLogo") ?? imageUrl(site, row.event_logo, "eventLogo") ??
imageUrl(site, row.effective_org_logo, "organization") ?? imageUrl(site, row.effective_org_logo, "organization") ??
meta.image; meta.image;

View file

@ -150,6 +150,8 @@ function shapeEvent(row, links, cardBlocks, hosts = []) {
event_logo: row.event_logo, event_logo: row.event_logo,
color: row.effective_color, color: row.effective_color,
card_image: row.card_image, card_image: row.card_image,
photo: row.photo,
photo_alt: row.photo_alt,
hosts: hosts.map(shapeHost), hosts: hosts.map(shapeHost),

View file

@ -87,14 +87,15 @@ function statValue(db, row) {
} }
/* The countdown's fields plus what the hero's event card also draws: /* The countdown's fields plus what the hero's event card also draws:
its tagline, place, card background and buttons. */ its tagline, place, photo and buttons. */
function shapeHeroEvent(db, row) { function shapeHeroEvent(db, row) {
if (!row) return null; if (!row) return null;
const { actions } = splitLinks(loadLinks(db, "event", [row.id]).get(row.id) ?? []); const { actions } = splitLinks(loadLinks(db, "event", [row.id]).get(row.id) ?? []);
return { return {
...shapeCountdown(row), ...shapeCountdown(row),
tagline: row.tagline, tagline: row.tagline,
card_image: row.card_image, photo: row.photo,
photo_alt: row.photo_alt,
org_logo: row.effective_org_logo, org_logo: row.effective_org_logo,
links: actions, links: actions,
}; };

View file

@ -369,6 +369,8 @@ tx(db, () => {
event_logo: IMAGE, event_logo: IMAGE,
color: "#d62976", color: "#d62976",
card_image: IMAGE, card_image: IMAGE,
photo: IMAGE,
photo_alt: "The showcase test image",
is_published: 1, is_published: 1,
is_listed: LISTED, is_listed: LISTED,
in_timeline: LISTED, in_timeline: LISTED,

View file

@ -203,7 +203,7 @@ export function shapeSeries(row) {
`image` is { file, kind }, like the timeline's logo: the record `image` is { file, kind }, like the timeline's logo: the record
tables keep bare filenames in different public/ directories, tables keep bare filenames in different public/ directories,
and logoForKind in media.ts knows which is which. The kinds are and logoForKind in media.ts knows which is which. The kinds are
the ref kinds, plus 'event-background' and 'featured' (the the ref kinds, plus 'event-photo' and 'featured' (the
card's own image). An unpublished card's own image). An unpublished
record's card is dropped; an unlisted one's stays, since record's card is dropped; an unlisted one's stays, since
featuring it is attaching it by hand. featuring it is attaching it by hand.
@ -213,11 +213,11 @@ const FEATURED_REFS = {
event: { event: {
sql: (marks) => sql: (marks) =>
`SELECT id, title, tagline AS blurb, date_label AS eyebrow, `SELECT id, title, tagline AS blurb, date_label AS eyebrow,
card_image, event_logo photo, event_logo
FROM events WHERE is_published = 1 AND id IN (${marks})`, FROM events WHERE is_published = 1 AND id IN (${marks})`,
image: (row) => image: (row) =>
row.card_image row.photo
? { file: row.card_image, kind: "event-background" } ? { file: row.photo, kind: "event-photo" }
: row.event_logo : row.event_logo
? { file: row.event_logo, kind: "event" } ? { file: row.event_logo, kind: "event" }
: null, : null,

View file

@ -35,7 +35,7 @@ import { useSmallImage } from '../lib/useSmallImage.ts'
/* Image kinds that are photographs, drawn edge to edge. Anything /* Image kinds that are photographs, drawn edge to edge. Anything
else is a logo, drawn whole. */ else is a logo, drawn whole. */
const PHOTO_KINDS = new Set(['event-background', 'featured', 'person']) const PHOTO_KINDS = new Set(['event-photo', 'featured', 'person'])
function hrefFor(card: FeaturedCard): string | null { function hrefFor(card: FeaturedCard): string | null {
if (card.kind === 'record' && card.ref) { if (card.kind === 'record' && card.ref) {

View file

@ -147,13 +147,27 @@ export const events = {
{ path: "event_logo", label: "Event logo", widget: "image", folder: "logos", resolve: mediaUrl, full: true }, { path: "event_logo", label: "Event logo", widget: "image", folder: "logos", resolve: mediaUrl, full: true },
{ path: "org_logo", label: "Org logo override", widget: "image", folder: "logos", resolve: mediaUrl, full: true }, { path: "org_logo", label: "Org logo override", widget: "image", folder: "logos", resolve: mediaUrl, full: true },
{ path: "color", label: "Color", widget: "color" }, { path: "color", label: "Color", widget: "color" },
{
path: "photo",
label: "Event photo",
widget: "image",
resolve: mediaUrl,
full: true,
help: "16:9, eg. 1920 x 1080, shown whole: at the top of the event's page, as the front page's featured event, on featured cards, in the newsletter and when the page is shared.",
},
{
path: "photo_alt",
label: "Photo description",
full: true,
help: "What the photo shows, for people who can't see it, eg. Campers around the fire at the 2025 retreat. Default: none (read as decoration).",
},
{ {
path: "card_image", path: "card_image",
label: "Card background", label: "Card background",
widget: "image", widget: "image",
resolve: mediaUrl, resolve: mediaUrl,
full: true, full: true,
help: "A photo behind the event's card, faded so the text stays readable.", help: "Only behind the event's card, faded so the text stays readable and cropped to the card's shape (about square). Keep the subject centered and leave words out.",
}, },
], ],
}, },

View file

@ -133,8 +133,11 @@ export type EventRecord = {
org_logo?: string | null org_logo?: string | null
event_logo?: string | null event_logo?: string | null
color?: string | null color?: string | null
/** Behind the card. See 029_event_card_image.sql. */ /** Behind the card only, cropped. See 029_event_card_image.sql. */
card_image?: string | null card_image?: string | null
/** The event's own 16:9 photo, shown whole. See 061_event_photo.sql. */
photo?: string | null
photo_alt?: string | null
/* In billing order. The first is the one `color` and `org_logo` /* In billing order. The first is the one `color` and `org_logo`
fell back to when the event set neither. */ fell back to when the event set neither. */
hosts: EventHost[] hosts: EventHost[]

View file

@ -111,7 +111,8 @@ export type FeaturedCard = {
/** The countdown's event plus what the hero's event card draws. */ /** The countdown's event plus what the hero's event card draws. */
export type HeroEvent = CountdownEvent & { export type HeroEvent = CountdownEvent & {
tagline?: string | null tagline?: string | null
card_image?: string | null photo?: string | null
photo_alt?: string | null
org_logo?: string | null org_logo?: string | null
links: Link[] links: Link[]
} }

View file

@ -98,6 +98,15 @@ export default function EventDetail() {
<div className="max-w-6xl mx-auto px-6 space-y-8"> <div className="max-w-6xl mx-auto px-6 space-y-8">
<Facts event={event} accent={accent} /> <Facts event={event} accent={accent} />
{/* The event's own 16:9 photo (not the card's background). */}
{event.photo && (
<img
src={mediaUrl(event.photo) ?? ''}
alt={event.photo_alt ?? ''}
className="aspect-video w-full max-w-3xl object-cover"
/>
)}
{event.description.map((paragraph, index) => ( {event.description.map((paragraph, index) => (
<p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}> <p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}>
{paragraph} {paragraph}

View file

@ -361,7 +361,7 @@ export default function AdminNewsletter() {
.filter(Boolean) .filter(Boolean)
.join(', '), .join(', '),
text: event.tagline ?? event.description?.[0] ?? null, text: event.tagline ?? event.description?.[0] ?? null,
image: imageFor(event.card_image), image: imageFor(event.photo),
href: siteUrl(eventHref(event.id)), href: siteUrl(eventHref(event.id)),
cta: PICK_DEFAULTS.events.cta, cta: PICK_DEFAULTS.events.cta,
}) })

View file

@ -463,7 +463,7 @@ function VideoFrame({
it's usually Register. */ it's usually Register. */
function EventPanel({ event }: { event: HeroEvent }) { function EventPanel({ event }: { event: HeroEvent }) {
const color = event.color || 'var(--color-action)' const color = event.color || 'var(--color-action)'
const photo = mediaUrl(event.card_image) const photo = mediaUrl(event.photo)
const when = seriesLabel(event.series, event.starts_on) ?? event.date_label const when = seriesLabel(event.series, event.starts_on) ?? event.date_label
const where = event.is_online && !event.location_label ? 'Online' : event.location_label const where = event.is_online && !event.location_label ? 'Online' : event.location_label
@ -473,11 +473,11 @@ function EventPanel({ event }: { event: HeroEvent }) {
style={{ boxShadow: '0 24px 48px -24px rgba(0, 16, 17, 0.6)' }} style={{ boxShadow: '0 24px 48px -24px rgba(0, 16, 17, 0.6)' }}
> >
{photo ? ( {photo ? (
<img src={photo} alt="" className="aspect-[16/7] w-full object-cover" /> <img src={photo} alt={event.photo_alt ?? ''} className="aspect-video w-full object-cover" />
) : ( ) : (
<div <div
aria-hidden="true" aria-hidden="true"
className="aspect-[16/7] w-full" className="aspect-video w-full"
style={{ background: `color-mix(in srgb, ${color} 35%, #001011)` }} style={{ background: `color-mix(in srgb, ${color} 35%, #001011)` }}
/> />
)} )}