Files
IllusionandClaude Opus 5 19fab4a783 Match the shipped styling to the Claude Design drafts
An audit of all twelve draft files against the build turned up a set of
mismatches, most of them in the tier-2 token layer rather than in any one
component. Tier 1 is untouched throughout - only the meanings moved.

SHAPE. The drafts draw three corners, not five: 2px for a tag, thumbnail,
flag or checkbox, 4px for anything with a box, and fully round for a filter
chip or status pill. Nothing in any draft is 8px or 12px. --radius-card and
--radius-surface therefore come down to radius/sm, a --radius-chip is added
for the 2px tier, and --radius-control-lg - a quirk of the Figma Button
frame's ghost cells - is retired along with its four consumers.

ELEVATION. A shadow is a fraction of the ground it falls on, and the ramp
was tuned for a white page: on the drafts' near-black ground a 12-28% black
is invisible. Tier 1 gains the two deep steps the drafts actually draw
(--shadow-dark-lg/xl), and --elevation-card/-popover/-modal move into the
per-surface blocks so the dark surface can take them while the light one
keeps the soft ramp. A resting card now has no shadow at all - the drafts
separate with a hairline - and the black is spent on what floats.

CARDS. The hover was a white-24% hairline and a faint glow; the drafts turn
the hairline accent green, lift the card 6px and land a deep black under it.
The lift is pointer-only and is dropped under prefers-reduced-motion.

GHOST IS A TEXT LINK. The drafts never fill a ghost control - every
"All updates ->" is plain text that turns green while the label-to-arrow gap
opens. The tokens carry no fill in any state and the variant opts out of the
3px lift, which also retires the WCAG workaround the old Figma hover forced
(green label on a green fill, 1.40:1).

NAVIGATION. A nav label rests in text/secondary and brightens to primary;
the current section stays primary and is marked by the accent rule, not by
green text.

HERO STRIPE. The middle block was painted near-black against a comment
claiming the redesign had dropped white; the drafts paint it #F8F9FA. Back
to background/inverse, and to the drafts' 390 : 495 : 363 split.

styles/README.md is updated to match, including a contrast table that still
described --surface-raised as the retired #2e2e2c.

Not changed, because each is a decision rather than a defect: the drafts set
every eyebrow, tag and meta line in IBM Plex Mono at 10-11px with 1.2-1.4px
tracking (a third typeface, and no Arabic counterpart); draft headings are
weight 800, which needs a font file we do not have; and the EU badge
statement stays at --text-primary, since the visibility lockup is
contractual.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-20 11:14:15 +02:00

433 lines
13 KiB
TypeScript

/* ============================================================================
EVENTS AND OPPORTUNITIES - the pieces these two sections add
----------------------------------------------------------------------------
Everything generic already exists and is imported, not rebuilt:
~/components/ui/Button Button, ArrowIcon
~/components/ui/Card CardShell, CardMedia, CardLink, CardActionHint
- the primitives the card family exports "for
composing new card types"
../_shared/listing-ui PageShell, PageHeader, EmptyState, TabLinks,
Pagination, MetaList, MetaLine, BackLink
What is genuinely new here is the status badge the draft asks for on every
event and every call ("Open / Closed / Full", "Upcoming / Ongoing /
Completed"), the two cards that carry the field set of draft sections 4 and
8, and the notice panel a detail page uses to explain a closed registration.
RULES: tier-2 semantic tokens only, logical properties only, type from the
published roles. Nothing here knows about a hex value or a direction.
========================================================================= */
import type { ReactNode } from "react";
import {
CardActionHint,
CardLink,
CardMedia,
CardShell,
} from "~/components/ui/Card";
import type { CardElement, CardTitleElement } from "~/components/ui/Card";
import { toIsoDate, useTranslation } from "~/i18n";
import { MetaLine } from "../_shared/listing-ui";
import {
eventActionKey,
eventRegistrationLabel,
eventTimeStatusKey,
formatEventWhen,
type EventCardData,
} from "./events";
import { getRouteCopy } from "./copy";
import {
formatOpportunityDate,
opportunityActionKey,
opportunityStatusKey,
type OpportunityCardData,
} from "./opportunities";
function cx(...parts: Array<string | false | null | undefined>): string {
return parts.filter(Boolean).join(" ");
}
/* ---------------------------------------------------------------------------
STATUS BADGE
------------------------------------------------------------------------ */
/** Accent = live and joinable, neutral = informational, danger = full. */
export type BadgeTone = "accent" | "neutral" | "danger";
const BADGE_TONE: Readonly<Record<BadgeTone, string>> = {
accent: "border-border-accent bg-surface-accent-subtle text-text-accent",
neutral: "border-border-subtle bg-surface-sunken text-text-tertiary",
danger: "border-border-danger bg-surface-danger-subtle text-text-danger",
};
/**
* Colour is never the only carrier: the badge always spells the state out, so
* it survives a monochrome print and a colour-blind reader.
*/
export function StatusBadge({
tone = "neutral",
children,
}: {
tone?: BadgeTone;
children: ReactNode;
}) {
return (
<span
className={cx(
"inline-flex items-center gap-2xs rounded-pill border px-xs py-2xs label-md",
BADGE_TONE[tone],
)}
>
{children}
</span>
);
}
/** A row of badges above a card title or a detail heading. */
export function BadgeRow({ children }: { children: ReactNode }) {
return <div className="flex flex-wrap items-center gap-xs">{children}</div>;
}
/* ---------------------------------------------------------------------------
NOTICE
------------------------------------------------------------------------ */
export type NoticeTone = "info" | "accent" | "danger";
const NOTICE_TONE: Readonly<Record<NoticeTone, string>> = {
info: "border-border-default bg-surface-sunken text-text-secondary",
accent: "border-border-accent bg-surface-accent-subtle text-text-primary",
danger: "border-border-danger bg-surface-danger-subtle text-text-primary",
};
/**
* The panel that explains a state: registration closed, the call is not open
* yet, the CMS could not be reached. `role` is left to the caller - a notice
* that appears in response to a submission needs "status", one that is part of
* the page does not.
*/
export function Notice({
tone = "info",
title,
children,
role,
}: {
tone?: NoticeTone;
title?: string;
children?: ReactNode;
role?: "status" | "alert";
}) {
return (
<div
role={role}
className={cx(
"flex flex-col gap-xs rounded-card border p-lg",
NOTICE_TONE[tone],
)}
>
{title ? <p className="body-md-bold text-text-primary">{title}</p> : null}
{children ? <div className="body-md">{children}</div> : null}
</div>
);
}
/* ---------------------------------------------------------------------------
EVENT CARD - draft section 4
title - date and time - format/location - registration status - CTA
------------------------------------------------------------------------ */
export function EventCard({
event,
href,
as = "article",
titleAs = "h3",
className,
}: {
event: EventCardData;
href: string;
as?: CardElement;
titleAs?: CardTitleElement;
className?: string;
}) {
const { locale, t } = useTranslation();
const copy = getRouteCopy(locale);
const Title = titleAs;
const when = formatEventWhen(event, locale);
const formatLabel =
event.format === "online"
? t("events.online")
: event.format === "hybrid"
? copy.events.formatHybrid
: event.format === "in-person"
? t("events.inPerson")
: undefined;
const isPast = event.timeStatus === "completed";
return (
<CardShell
as={as}
linked
className={cx("flex-col overflow-hidden", className)}
>
{event.image ? (
<CardMedia
image={{ src: event.image.src, alt: event.image.alt }}
className="aspect-[9/5] w-full"
/>
) : null}
<div className="flex flex-col gap-md p-lg">
<div className="flex flex-col gap-xs">
<BadgeRow>
<StatusBadge tone={isPast ? "neutral" : "accent"}>
{t(eventTimeStatusKey(event.timeStatus))}
</StatusBadge>
{/* A finished event's registration state is history, not news. */}
{isPast ? null : (
<StatusBadge
tone={
event.registrationStatus === "full"
? "danger"
: event.registrationStatus === "closed"
? "neutral"
: "accent"
}
>
{eventRegistrationLabel(event.registrationStatus, locale)}
</StatusBadge>
)}
</BadgeRow>
<Title className="sh-card-title body-lg-bold text-text-primary">
<CardLink href={href} className="sh-card-link">
{event.title}
</CardLink>
</Title>
<p className="body-sm-bold text-text-secondary">
<time dateTime={toIsoDate(event.start)}>{when}</time>
</p>
<MetaLine items={[formatLabel, event.place, event.region].filter(
(item): item is string => Boolean(item),
)} />
{event.summary ? (
<p className="body-sm text-text-secondary line-clamp-3">
{event.summary}
</p>
) : null}
</div>
<CardActionHint label={t(eventActionKey(event))} />
</div>
</CardShell>
);
}
/* ---------------------------------------------------------------------------
OPPORTUNITY CARD - draft section 8
title - status tag - deadline - CTA
------------------------------------------------------------------------ */
export function OpportunityCard({
opportunity,
href,
as = "article",
titleAs = "h3",
className,
}: {
opportunity: OpportunityCardData;
href: string;
as?: CardElement;
titleAs?: CardTitleElement;
className?: string;
}) {
const { locale, t } = useTranslation();
const Title = titleAs;
const isOpen = opportunity.status === "open";
/* An open or closed call is defined by its deadline; a call that has not
opened yet is defined by its opening date. */
const dateLine =
opportunity.status === "upcoming" && opportunity.openDate
? formatOpportunityDate(opportunity.openDate, locale)
: opportunity.deadline
? t("opportunities.deadline", {
date: formatOpportunityDate(opportunity.deadline, locale),
})
: undefined;
const dateValue =
opportunity.status === "upcoming" && opportunity.openDate
? opportunity.openDate
: opportunity.deadline;
return (
<CardShell
as={as}
linked
className={cx("flex-col overflow-hidden", className)}
>
{opportunity.image ? (
<CardMedia
image={{ src: opportunity.image.src, alt: opportunity.image.alt }}
className="aspect-[9/5] w-full"
/>
) : null}
<div className="flex flex-col gap-md p-lg">
<div className="flex flex-col gap-xs">
<BadgeRow>
<StatusBadge tone={isOpen ? "accent" : "neutral"}>
{t(opportunityStatusKey(opportunity.status))}
</StatusBadge>
{opportunity.opportunityType ? (
<StatusBadge>
{getRouteCopy(locale).opportunityTypes[
opportunity.opportunityType
]}
</StatusBadge>
) : null}
</BadgeRow>
<Title className="sh-card-title body-lg-bold text-text-primary">
<CardLink href={href} className="sh-card-link">
{opportunity.title}
</CardLink>
</Title>
{dateLine ? (
<p className="body-sm-bold text-text-secondary">
<time dateTime={toIsoDate(dateValue)}>{dateLine}</time>
</p>
) : null}
{opportunity.summary ? (
<p className="body-sm text-text-secondary line-clamp-3">
{opportunity.summary}
</p>
) : null}
</div>
<CardActionHint label={t(opportunityActionKey(opportunity.status))} />
</div>
</CardShell>
);
}
/* ---------------------------------------------------------------------------
DEFINITION GRID - the "Event details" block
------------------------------------------------------------------------ */
export interface DetailItem {
readonly label: string;
readonly value: ReactNode;
}
/**
* A description list rather than a table: the pairs are a key/value set, they
* reflow to one column on a phone, and a screen reader announces the label
* with the value.
*/
export function DetailList({
heading,
items,
}: {
heading: string;
items: readonly DetailItem[];
}) {
const present = items.filter((item) => item.value !== undefined && item.value !== null);
if (present.length === 0) return null;
return (
<section
aria-label={heading}
className="flex flex-col gap-md rounded-card border border-border-subtle bg-surface-raised p-lg"
>
<h2 className="label-md uppercase text-text-tertiary">{heading}</h2>
<dl className="grid gap-md sm:grid-cols-2">
{present.map((item) => (
<div key={item.label} className="flex flex-col gap-2xs">
<dt className="body-sm text-text-tertiary">{item.label}</dt>
<dd className="body-md-bold text-text-primary">{item.value}</dd>
</div>
))}
</dl>
</section>
);
}
/* ---------------------------------------------------------------------------
CONSENT CHECKBOX
----------------------------------------------------------------------------
`event-registration.consentGdpr` is a REQUIRED boolean in the CMS, so the
reader has to be asked - out loud, in a real <label>, with the reason next
to it. ~/components/ui has no Checkbox (this is the only one in the site),
so the control is composed here from the same tier-2 tokens the rest of the
section uses; promote it to ~/components/ui when a second form needs one.
Accessibility: the label wraps nothing - it is associated by `htmlFor`, so
the hint and the error can sit outside it and still be announced, via
`aria-describedby`. `aria-invalid` marks the failure for a screen reader,
and the message is text, never colour alone.
------------------------------------------------------------------------ */
export function ConsentCheckbox({
name,
label,
hint,
error,
defaultChecked = false,
}: {
name: string;
label: string;
hint?: string;
error?: string;
defaultChecked?: boolean;
}) {
const hintId = hint ? `${name}-hint` : undefined;
const errorId = error ? `${name}-error` : undefined;
const describedBy = [hintId, errorId].filter(Boolean).join(" ") || undefined;
return (
<div className="flex flex-col gap-2xs">
<div className="flex items-start gap-sm">
<input
id={name}
name={name}
type="checkbox"
value="true"
defaultChecked={defaultChecked}
required
aria-invalid={error ? true : undefined}
aria-describedby={describedBy}
className="mt-2xs size-md shrink-0 rounded-chip border border-border-strong accent-[var(--interactive-primary-bg)]"
/>
<label htmlFor={name} className="body-sm text-text-primary">
{label}
</label>
</div>
{hint ? (
<p id={hintId} className="body-sm text-text-tertiary ps-lg">
{hint}
</p>
) : null}
{error ? (
<p id={errorId} className="body-sm text-text-danger ps-lg">
{error}
</p>
) : null}
</div>
);
}