715 lines
28 KiB
TypeScript
715 lines
28 KiB
TypeScript
import { CaretDown, CaretRight, CaretLeft, Cards, SquaresFour } from '@phosphor-icons/react';
|
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
import { Link } from "react-router-dom";
|
|
import { splitByStatus, typesPresent, useEvents } from "../../lib/eventData.ts";
|
|
import { eventHref } from "../../lib/hrefs.ts";
|
|
import { EVENT_TYPES, eventTypeLabel } from "../../lib/eventTypes.ts";
|
|
import { seriesLabel } from "../../lib/eventSeries.ts";
|
|
import PlatformIcon from "../../components/PlatformIcon.tsx";
|
|
import { mediaUrl } from "../../lib/media.ts";
|
|
import Logo from "../../components/Logo.tsx";
|
|
import { accentText, withAlpha, readableOn, BRAND } from '../../lib/color.ts'
|
|
|
|
/* ═══════════════════════════════════════════════════════════════
|
|
EVENT LIST: CARDS
|
|
|
|
A band of event cards, as a peek carousel or a grid. Self
|
|
contained: give it a filter and it fetches, so the same section
|
|
appears three times on Retreats with a different `scope` each
|
|
time, and could appear on a region's page with `host` instead.
|
|
|
|
<EventListCards scope="national" view="carousel" />
|
|
<EventListCards host="northwest" view="grid" />
|
|
<EventListCards type={["class", "workshop"]} view="grid" />
|
|
|
|
`view` and `accent` come from the page's section manifest.
|
|
|
|
`type` pre-filters the band the way `scope` and `host` do. Left
|
|
off, the band takes every kind it finds and grows a row of chips
|
|
to narrow by, but only once it holds more than one, so a band of
|
|
nothing but retreats shows no control at all.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
|
|
/* Last resort only. The API already falls back to the host
|
|
organization's logo when an event doesn't name its own, so this
|
|
fires only for an event with no host at all. */
|
|
const DEFAULT_ORG_LOGO = null;
|
|
|
|
const INK = "var(--color-ink)"; // button text: the card color is only a border
|
|
const CARD_BG = "var(--color-surface)"; // sits under every card, photo or not
|
|
|
|
/* Laid over a card's background image so black text reads on any
|
|
photo. Heavier at the top, where the title and dates are, and
|
|
lighter lower down so more of the picture shows through. */
|
|
const CARD_IMAGE_VEIL =
|
|
"linear-gradient(to bottom, color-mix(in srgb, var(--color-surface) 90%, transparent), color-mix(in srgb, var(--color-surface) 78%, transparent))";
|
|
|
|
/* The card's background layers, top first: the veil and photo if it
|
|
has one, then the plain surface. */
|
|
function cardBackground(ev) {
|
|
const layers: string[] = [];
|
|
const image = mediaUrl(ev.card_image);
|
|
if (image) {
|
|
layers.push(CARD_IMAGE_VEIL, `url(${JSON.stringify(image)}) center / cover no-repeat`);
|
|
}
|
|
layers.push(CARD_BG);
|
|
return layers.join(", ");
|
|
}
|
|
|
|
/* ── Grid view ────────────────────────────────────────────────
|
|
The grid fits as many columns as the screen allows, with no
|
|
breakpoints: each card is at least CARD_MIN wide, and the
|
|
columns share whatever space is left over.
|
|
CARD_MIN narrowest a card may get before dropping a column
|
|
MAX_COLS ceiling on columns, so cards don't get absurd on
|
|
very wide monitors. GRID_MAX is derived from it.
|
|
───────────────────────────────────────────────────────────── */
|
|
const CARD_MIN = "32rem";
|
|
const MAX_COLS = 4;
|
|
const GRID_MAX = `calc(${MAX_COLS} * 38rem)`;
|
|
const GRID_TEMPLATE = `repeat(auto-fill, minmax(min(${CARD_MIN}, 100%), 1fr))`;
|
|
|
|
/* Collapsed past-events strip: how much shows, and the downward
|
|
fade applied while it's collapsed. */
|
|
const PAST_PEEK = "10rem";
|
|
const PAST_FADE = "linear-gradient(to bottom, black 0%, black 45%, transparent 100%)";
|
|
|
|
/* ── Carousel sizing ──────────────────────────────────────────
|
|
CARD the card itself
|
|
GAP space between cards, raise to push neighbors out
|
|
FADE_DIST how far past the card's edge neighbors fade to nothing
|
|
───────────────────────────────────────────────────────────── */
|
|
const CARD = "min(48rem, 90vw)";
|
|
const GAP = "5rem";
|
|
const SLIDE = `calc(${CARD} + ${GAP})`;
|
|
const HALF_SLIDE = `calc(${CARD} / 2)`;
|
|
const FADE_DIST = "18rem";
|
|
|
|
const EDGE_FADE = `linear-gradient(to right,
|
|
transparent calc(50% - (${HALF_SLIDE} + ${FADE_DIST})),
|
|
black calc(50% - ${HALF_SLIDE}),
|
|
black calc(50% + ${HALF_SLIDE}),
|
|
transparent calc(50% + (${HALF_SLIDE} + ${FADE_DIST})))`;
|
|
|
|
/* Card layout CSS lives in index.css under the .ev- prefix. */
|
|
|
|
/* The title is the way into the event's own page.
|
|
|
|
A link on the title rather than a wrapper around the whole card:
|
|
the footer already holds anchors, and an anchor inside an anchor
|
|
is invalid markup that every browser resolves by guessing. The
|
|
carousel has the same constraint, it needs the card's click to
|
|
mean "bring this one to the front" on anything that isn't the
|
|
active slide. */
|
|
function TitleLink({ ev, linked, children }) {
|
|
if (!linked) return <>{children}</>;
|
|
return (
|
|
<Link to={eventHref(ev.id)} className="hover:underline underline-offset-4">
|
|
{children}
|
|
</Link>
|
|
);
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════════════════════════
|
|
EVENT CARD: one component, two sizes.
|
|
compact=false → the full card used in the carousel
|
|
compact=true → the grid card: details left, text right, and a
|
|
footer pinned to the bottom so every card in a
|
|
row is the same height with aligned buttons.
|
|
|
|
Exported because it takes an event and nothing else: a region's
|
|
page or a home strip can render one without the section around
|
|
it.
|
|
|
|
Fields arrive pre-resolved from the API: `color` is the event's
|
|
own or its host's, `status` is derived from the dates when it
|
|
isn't set, so nothing here reimplements those rules.
|
|
|
|
`linked` is the one thing a caller turns off: a card on the
|
|
event's own page shouldn't link to the page it's already on.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
export function Card({
|
|
ev,
|
|
defaultColor = BRAND,
|
|
accent = BRAND,
|
|
compact = false,
|
|
interactive = true,
|
|
linked = true,
|
|
showType = false,
|
|
}) {
|
|
const past = ev.status === "past";
|
|
const color = ev.color || defaultColor;
|
|
const orgLogo = mediaUrl(ev.org_logo) || DEFAULT_ORG_LOGO;
|
|
const eventLogo = mediaUrl(ev.event_logo);
|
|
const schedule = seriesLabel(ev.series, ev.starts_on);
|
|
const links = ev.links ?? [];
|
|
const igHandle = ev.instagram || null;
|
|
const igUrl = igHandle
|
|
? `https://instagram.com/${igHandle.replace(/^@/, "")}`
|
|
: undefined;
|
|
|
|
/* Off unless the caller says the band is mixed. A "Retreat" badge
|
|
on every card in a row of nothing but retreats is noise, and
|
|
the card can't tell on its own, it only ever sees one event. */
|
|
const typeBadge =
|
|
showType && ev.event_type ? (
|
|
<span
|
|
className="inline-block px-3 py-0.5 mb-2 text-xs font-bold uppercase tracking-wide"
|
|
style={{ border: `1px solid ${color}`, color: INK }}
|
|
>
|
|
{eventTypeLabel(ev.event_type)}
|
|
</span>
|
|
) : null;
|
|
|
|
/* An ordered array, so a card can carry one paragraph or five
|
|
without the component changing. */
|
|
const descriptions = (ev.description ?? []).map((text, i) => (
|
|
<p
|
|
key={i}
|
|
className={`leading-relaxed ${compact ? "text-base" : ""} ${
|
|
i > 0 ? "mt-2" : ""
|
|
}`}
|
|
>
|
|
{text}
|
|
</p>
|
|
));
|
|
|
|
return (
|
|
<div
|
|
className={`text-ink overflow-hidden shadow-2xl h-full flex flex-col ${
|
|
compact ? "ev-card" : ""
|
|
}`}
|
|
style={{
|
|
border: `1px solid ${color}`,
|
|
background: cardBackground(ev),
|
|
filter: past ? "saturate(0.75)" : "none",
|
|
pointerEvents: interactive ? "auto" : "none",
|
|
}}
|
|
// A card shown but not in play (a carousel neighbor, a collapsed
|
|
// past event) keeps its links out of the tab order too.
|
|
inert={!interactive}
|
|
>
|
|
<div className={`flex-1 flex flex-col ${compact ? "p-8" : "p-10"}`}>
|
|
{compact ? (
|
|
/* ── GRID CARD: layout driven by .ev-grid container queries ── */
|
|
<div className="ev-grid mb-2">
|
|
<Logo src={orgLogo} className="ev-org h-11 w-auto mb-4" />
|
|
<div className="ev-info">
|
|
{typeBadge}
|
|
<h3 className="text-3xl font-bold leading-tight">
|
|
<TitleLink ev={ev} linked={linked}>
|
|
{ev.title}
|
|
</TitleLink>
|
|
</h3>
|
|
{ev.theme && (
|
|
<p className="text-xl font-normal font-bold">"{ev.theme}"</p>
|
|
)}
|
|
{ev.date_label && <p className="text-xl">{ev.date_label}</p>}
|
|
{schedule && <p className="text-xl">{schedule}</p>}
|
|
{ev.location_label && (
|
|
<p className="text-xl">{ev.location_label}</p>
|
|
)}
|
|
</div>
|
|
<Logo
|
|
src={eventLogo}
|
|
alt=""
|
|
className="ev-image w-full h-auto object-contain"
|
|
/>
|
|
<div className="ev-desc">{descriptions}</div>
|
|
</div>
|
|
) : (
|
|
/* ── FULL: details left, large event logo right ── */
|
|
<>
|
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-x-8 mb-4">
|
|
<div className="md:col-span-2">
|
|
<Logo src={orgLogo} className="h-15 w-auto mb-6" />
|
|
{typeBadge}
|
|
<h3 className="text-4xl font-bold">
|
|
<TitleLink ev={ev} linked={linked}>
|
|
{ev.title}
|
|
</TitleLink>
|
|
</h3>
|
|
{ev.theme && (
|
|
<p className="text-2xl font-normal font-bold">"{ev.theme}"</p>
|
|
)}
|
|
{ev.date_label && <p className="text-2xl">{ev.date_label}</p>}
|
|
{schedule && <p className="text-2xl">{schedule}</p>}
|
|
{ev.location_label && (
|
|
<p className="text-2xl">{ev.location_label}</p>
|
|
)}
|
|
</div>
|
|
<div className="md:col-span-1 flex items-center justify-end">
|
|
<Logo
|
|
src={eventLogo}
|
|
alt=""
|
|
className="w-full h-auto max-h-72 object-contain"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{descriptions}
|
|
</>
|
|
)}
|
|
|
|
{/* Footer, mt-auto pins the whole block to the bottom so
|
|
buttons line up across every card in a grid row.
|
|
|
|
Three registration states, as before: links to follow, a
|
|
past event, or an announcement still to come. What's new
|
|
is that all three end in the same row, because every
|
|
event now has a page and a past one is often the more
|
|
worth reading, speakers, awards, what actually
|
|
happened. The notice is what changes; the way in
|
|
doesn't. */}
|
|
<div className={`mt-auto ${compact ? "pt-6" : "pt-8"}`}>
|
|
{links.length === 0 && (
|
|
<p className="text-center font-semibold" style={{ color: accentText(accent) }}>
|
|
{past
|
|
? "This event has concluded. Thank you to everyone who joined us!"
|
|
: igHandle
|
|
? "Registration has not opened yet, follow our instagram for more details."
|
|
: "Registration has not opened yet, check back soon for more details."}
|
|
</p>
|
|
)}
|
|
|
|
<div
|
|
className={`flex flex-wrap justify-center items-center ${
|
|
compact ? "gap-2" : "gap-3"
|
|
} ${links.length === 0 ? "mt-4" : ""}`}
|
|
>
|
|
{/* Button text takes the card's color (the event's own,
|
|
or the band's default, teal unless the page sets one),
|
|
the same as the border, rather than the card's black. */}
|
|
{links.map(item => (
|
|
<a
|
|
key={item.label}
|
|
href={item.url}
|
|
className={`inline-flex items-center justify-center gap-2 font-bold transition-all duration-200 hover:scale-105 text-center ${
|
|
compact ? "py-2.5 px-5" : "py-2.5 px-6"
|
|
}`}
|
|
style={{ border: `1px solid ${color}`, color: INK }}
|
|
>
|
|
<PlatformIcon platform={item.platform} />
|
|
{item.label}
|
|
</a>
|
|
))}
|
|
|
|
{/* Only when there's nothing to register for and the
|
|
event hasn't happened, the same condition as before,
|
|
just no longer nested inside that branch. */}
|
|
{igHandle && !past && links.length === 0 && (
|
|
<a
|
|
href={igUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className={`ig-link flex items-center justify-center font-bold transition-all duration-200 hover:scale-[1.02] gap-3 ${
|
|
compact ? "py-2.5 px-5" : "py-3 px-6"
|
|
}`}
|
|
style={{ border: `1px solid ${accent}`, color: accentText(accent) }}
|
|
>
|
|
<PlatformIcon platform="instagram" className="w-6 h-6" />
|
|
{igHandle}
|
|
</a>
|
|
)}
|
|
|
|
{/* Last, so Register reads first when there is one. */}
|
|
{linked && (
|
|
<Link
|
|
to={eventHref(ev.id)}
|
|
className={`font-bold transition-all duration-200 hover:scale-105 text-center ${
|
|
compact ? "py-2.5 px-5" : "py-2.5 px-6"
|
|
}`}
|
|
style={{ border: `1px solid ${color}`, color: INK }}
|
|
>
|
|
Event details
|
|
</Link>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════════════════════════
|
|
TYPE FILTER
|
|
|
|
Drawn only when a band actually holds more than one kind, so it
|
|
costs nothing today, every event is a retreat, and appears on
|
|
its own the first time a class or a workshop lands in that band.
|
|
Nothing on Retreats.tsx has to be reconfigured for it.
|
|
|
|
Chips rather than a select: with four or five options, all of
|
|
them visible is one tap, and the row reads as what the section
|
|
contains rather than as a form control.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
export function TypeFilter({ types, active, setActive, accent }) {
|
|
const chip = on => ({
|
|
border: `1px solid ${accent}`,
|
|
background: on ? accent : "transparent",
|
|
color: on ? readableOn(accent) : accentText(accent),
|
|
});
|
|
|
|
const button = (id, label) => (
|
|
<button
|
|
key={id}
|
|
onClick={() => setActive(id)}
|
|
aria-pressed={active === id}
|
|
className="btn py-1.5 px-4 text-sm transition-colors duration-200"
|
|
style={chip(active === id)}
|
|
>
|
|
{label}
|
|
</button>
|
|
);
|
|
|
|
return (
|
|
<div
|
|
className="mx-auto mb-6 flex flex-wrap gap-2 px-8 md:px-12 lg:px-16"
|
|
style={{ maxWidth: GRID_MAX }}
|
|
role="group"
|
|
aria-label="Filter events by type"
|
|
>
|
|
{button("all", "All")}
|
|
{types.map(entry => button(entry.id, entry.plural))}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════════════════════════
|
|
TOGGLE: the control for the section heading's action bar
|
|
═══════════════════════════════════════════════════════════════ */
|
|
export function EventCardsToggle({ view, setView, accent }) {
|
|
const btn = active => ({
|
|
background: active ? accent : "transparent",
|
|
color: active ? readableOn(accent) : accentText(accent),
|
|
});
|
|
|
|
return (
|
|
<div
|
|
className="inline-flex overflow-hidden shrink-0"
|
|
style={{ border: `1px solid ${accent}` }}
|
|
role="group"
|
|
aria-label="Change how events are displayed"
|
|
>
|
|
<button
|
|
onClick={() => setView("carousel")}
|
|
aria-pressed={view === "carousel"}
|
|
className="flex items-center gap-2 py-2 px-4 font-bold text-sm transition-colors duration-200"
|
|
style={btn(view === "carousel")}
|
|
>
|
|
<Cards className="h-4 w-4" weight="bold" aria-hidden="true" />
|
|
Carousel
|
|
</button>
|
|
<button
|
|
onClick={() => setView("grid")}
|
|
aria-pressed={view === "grid"}
|
|
className="flex items-center gap-2 py-2 px-4 font-bold text-sm transition-colors duration-200"
|
|
style={btn(view === "grid")}
|
|
>
|
|
<SquaresFour className="h-4 w-4" weight="bold" aria-hidden="true" />
|
|
Grid
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════════════════════════
|
|
SECTION
|
|
Fetches its own slice of the events, then draws it as a carousel
|
|
or a grid.
|
|
|
|
An empty list means three different things now, still loading,
|
|
failed, or genuinely nothing scheduled, and they read very
|
|
differently to someone waiting, so they're distinguished rather
|
|
than all falling through to "coming soon".
|
|
═══════════════════════════════════════════════════════════════ */
|
|
export default function EventListCards({
|
|
scope,
|
|
host,
|
|
status,
|
|
type,
|
|
view = "carousel",
|
|
accent = BRAND,
|
|
defaultColor,
|
|
empty = "· Events coming soon, stay connected for announcements ·",
|
|
}: any) {
|
|
const { events: fetched, loading, error } = useEvents({
|
|
scope,
|
|
host,
|
|
status,
|
|
type,
|
|
});
|
|
const cardColor = defaultColor ?? accent;
|
|
|
|
const [index, setIndex] = useState(0);
|
|
const [showPast, setShowPast] = useState(false);
|
|
const [activeType, setActiveType] = useState("all");
|
|
|
|
/* What this band holds, which is what the chips offer, not the
|
|
full list of declared types, three quarters of which would be
|
|
dead buttons. */
|
|
const availableTypes = useMemo(
|
|
() => typesPresent(fetched, EVENT_TYPES),
|
|
[fetched],
|
|
);
|
|
|
|
const mixed = availableTypes.length > 1;
|
|
|
|
const events = useMemo(
|
|
() =>
|
|
activeType === "all"
|
|
? fetched
|
|
: fetched.filter(e => e.event_type === activeType),
|
|
[fetched, activeType],
|
|
);
|
|
|
|
/* Open on the first upcoming event. The list is empty on the
|
|
first render, so this can't be a useState initializer, it has
|
|
to wait for the data and then run once. Clearing the guard when
|
|
the list empties means a refetch re-seeds. */
|
|
const seeded = useRef(false);
|
|
|
|
/* Changing the chip is a different list, so the carousel re-seeds
|
|
on the first upcoming event of that kind rather than holding an
|
|
index that may now be past the end. Declared before the seed
|
|
effect so the guard is already clear when it runs. */
|
|
useEffect(() => {
|
|
seeded.current = false;
|
|
setIndex(0);
|
|
}, [activeType]);
|
|
|
|
useEffect(() => {
|
|
if (events.length === 0) {
|
|
seeded.current = false;
|
|
return;
|
|
}
|
|
if (seeded.current) return;
|
|
seeded.current = true;
|
|
|
|
const first = events.findIndex(e => e.status === "upcoming");
|
|
setIndex(first === -1 ? events.length - 1 : first);
|
|
}, [events]);
|
|
|
|
// Grid view splits the list; the carousel still shows everything.
|
|
const { upcoming, past: pastEvents } = splitByStatus(events);
|
|
|
|
const prev = () => setIndex(i => Math.max(0, i - 1));
|
|
const next = () => setIndex(i => Math.min(events.length - 1, i + 1));
|
|
|
|
// Arrows and dots follow the section accent, not the active card.
|
|
const arrowStyle = enabled => ({
|
|
border: `1px solid ${accent}`,
|
|
background: "color-mix(in srgb, var(--color-surface) 85%, transparent)",
|
|
color: enabled ? accentText(accent) : withAlpha("var(--color-muted)", 50),
|
|
cursor: enabled ? "pointer" : "default",
|
|
opacity: enabled ? 1 : 0.4,
|
|
});
|
|
|
|
const notice = text => (
|
|
<p className="max-w-6xl mx-auto px-6 font-semibold" style={{ color: accentText(accent) }}>
|
|
{text}
|
|
</p>
|
|
);
|
|
|
|
if (loading && events.length === 0) {
|
|
return (
|
|
<div className="overflow-hidden">
|
|
<div
|
|
className="mx-auto px-8 md:px-12 lg:px-16"
|
|
style={{ maxWidth: GRID_MAX }}
|
|
>
|
|
<div className="skeleton" role="status" aria-label="Loading events" />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (error && events.length === 0) {
|
|
return (
|
|
<div className="overflow-hidden">
|
|
{notice("· Events couldn't be loaded just now, please try again shortly ·")}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="overflow-hidden">
|
|
{mixed && (
|
|
<TypeFilter
|
|
types={availableTypes}
|
|
active={activeType}
|
|
setActive={setActiveType}
|
|
accent={accent}
|
|
/>
|
|
)}
|
|
|
|
{events.length === 0 ? (
|
|
/* Two different empties. Nothing scheduled is news; nothing
|
|
of the kind you just picked is a filter you can undo, and
|
|
the chips are still on screen to undo it with. */
|
|
notice(
|
|
activeType === "all"
|
|
? empty
|
|
: `· No ${eventTypeLabel(activeType).toLowerCase()} events in this section yet ·`,
|
|
)
|
|
) : view === "grid" ? (
|
|
/* ── GRID VIEW: upcoming first, past events collapsed below ── */
|
|
<div className="mx-auto px-8 md:px-12 lg:px-16" style={{ maxWidth: GRID_MAX }}>
|
|
{upcoming.length > 0 && (
|
|
<div
|
|
className="grid gap-6 items-stretch"
|
|
style={{ gridTemplateColumns: GRID_TEMPLATE }}
|
|
>
|
|
{upcoming.map(ev => (
|
|
<Card
|
|
key={ev.id}
|
|
ev={ev}
|
|
defaultColor={cardColor}
|
|
accent={accent}
|
|
compact
|
|
showType={mixed}
|
|
/>
|
|
))}
|
|
</div>
|
|
)}
|
|
|
|
{pastEvents.length > 0 && (
|
|
<div className="mt-12">
|
|
<h3
|
|
className="text-2xl font-display font-bold mb-6"
|
|
style={{ color: accentText(accent), opacity: 0.85 }}
|
|
>
|
|
Past Events
|
|
</h3>
|
|
|
|
{/* Collapsed: clipped to PAST_PEEK and faded out at the
|
|
bottom. Expanded: full height, no mask. */}
|
|
<div
|
|
className="relative transition-all duration-500 ease-out"
|
|
style={{
|
|
maxHeight: showPast ? "none" : PAST_PEEK,
|
|
overflow: showPast ? "visible" : "hidden",
|
|
maskImage: showPast ? "none" : PAST_FADE,
|
|
WebkitMaskImage: showPast ? "none" : PAST_FADE,
|
|
}}
|
|
>
|
|
<div
|
|
className="grid gap-6 items-stretch"
|
|
style={{ gridTemplateColumns: GRID_TEMPLATE }}
|
|
aria-hidden={!showPast}
|
|
>
|
|
{pastEvents.map(ev => (
|
|
<Card
|
|
key={ev.id}
|
|
ev={ev}
|
|
defaultColor={cardColor}
|
|
accent={accent}
|
|
compact
|
|
interactive={showPast}
|
|
showType={mixed}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex justify-center mt-6">
|
|
<button
|
|
onClick={() => setShowPast(v => !v)}
|
|
aria-expanded={showPast}
|
|
className="flex items-center gap-2 py-2.5 px-6 font-bold transition-all duration-200 hover:scale-105"
|
|
style={{ border: `1px solid ${accent}`, color: accentText(accent) }}
|
|
>
|
|
{showPast
|
|
? "Hide past events"
|
|
: `See past events (${pastEvents.length})`}
|
|
<CaretDown className="h-4 w-4 transition-transform duration-300" style={{ transform: showPast ? "rotate(180deg)" : "none" }} weight="bold" aria-hidden="true" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
) : (
|
|
/* ── CAROUSEL VIEW ── */
|
|
<>
|
|
<div className="relative mb-6">
|
|
<div
|
|
className="overflow-hidden"
|
|
style={{ maskImage: EDGE_FADE, WebkitMaskImage: EDGE_FADE }}
|
|
>
|
|
<div
|
|
className="flex items-stretch transition-transform duration-500 ease-out"
|
|
style={{ transform: `translateX(calc(50% - ${index + 0.5} * ${SLIDE}))` }}
|
|
>
|
|
{events.map((ev, i) => {
|
|
const active = i === index;
|
|
return (
|
|
<div
|
|
key={ev.id}
|
|
className="shrink-0"
|
|
style={{
|
|
width: SLIDE,
|
|
padding: `0 calc(${GAP} / 2)`,
|
|
cursor: active ? "default" : "pointer",
|
|
}}
|
|
onClick={() => !active && setIndex(i)}
|
|
aria-hidden={!active}
|
|
>
|
|
<Card
|
|
ev={ev}
|
|
defaultColor={cardColor}
|
|
accent={accent}
|
|
interactive={active}
|
|
showType={mixed}
|
|
/>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
|
|
{events.length > 1 && (
|
|
<>
|
|
<button
|
|
onClick={prev}
|
|
disabled={index === 0}
|
|
aria-label="Previous event"
|
|
className="absolute left-2 md:left-6 top-1/2 -translate-y-1/2 z-10 h-12 w-12 btn flex items-center justify-center text-2xl shadow-lg transition-all duration-200 hover:scale-110 disabled:hover:scale-100"
|
|
style={arrowStyle(index > 0)}
|
|
>
|
|
<CaretLeft size={20} weight="bold" aria-hidden="true" />
|
|
</button>
|
|
<button
|
|
onClick={next}
|
|
disabled={index === events.length - 1}
|
|
aria-label="Next event"
|
|
className="absolute right-2 md:right-6 top-1/2 -translate-y-1/2 z-10 h-12 w-12 btn flex items-center justify-center text-2xl shadow-lg transition-all duration-200 hover:scale-110 disabled:hover:scale-100"
|
|
style={arrowStyle(index < events.length - 1)}
|
|
>
|
|
<CaretRight size={20} weight="bold" aria-hidden="true" />
|
|
</button>
|
|
</>
|
|
)}
|
|
</div>
|
|
|
|
{events.length > 1 && (
|
|
<div className="flex justify-center gap-2">
|
|
{events.map((e, i) => (
|
|
<button
|
|
key={e.id}
|
|
onClick={() => setIndex(i)}
|
|
aria-label={`Go to ${e.title}`}
|
|
aria-current={i === index ? "true" : undefined}
|
|
className="h-2.5 rounded-full transition-all duration-200"
|
|
style={{
|
|
width: i === index ? "1.5rem" : "0.625rem",
|
|
background: i === index ? accent : withAlpha("var(--color-muted)", 40),
|
|
}}
|
|
/>
|
|
))}
|
|
</div>
|
|
)}
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|