Events block: featured events open in full above the cards, under a heading
Migration 090 adds heading and subheading to content_block_items. An events block's item ticked Featured shows in full above the cards, under its heading and subheading when set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a7495f09e5
commit
8a79206998
6 changed files with 88 additions and 28 deletions
|
|
@ -266,8 +266,9 @@ function EventInFull({ item, accent, level }: { item: ContentBlockItem; accent:
|
|||
}
|
||||
|
||||
/* An events block (088): its events as cards; one opened shows in
|
||||
full under them, scrolled into view. Reading mode has them all in
|
||||
full. */
|
||||
full under them, scrolled into view. A featured one (090) is
|
||||
already open, above the cards, under its own heading and
|
||||
subheading. Reading mode has them all in full. */
|
||||
function EventsBlock({ items, accent, level }: { items: ContentBlockItem[]; accent: string; level: 3 | 4 | 5 }) {
|
||||
const [open, setOpen] = useState<number | null>(null)
|
||||
const panelId = useId()
|
||||
|
|
@ -277,33 +278,55 @@ function EventsBlock({ items, accent, level }: { items: ContentBlockItem[]; acce
|
|||
if (open != null) panel.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
||||
}, [open])
|
||||
|
||||
if (reading) {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{items.map((item, i) => (
|
||||
<EventInFull key={i} item={item} accent={accent} level={level} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const featured = reading ? items : items.filter((item) => item.featured)
|
||||
const cards = reading ? [] : items.filter((item) => !item.featured)
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{items.map((item, i) => (
|
||||
<li key={i}>
|
||||
<EventCard
|
||||
item={item}
|
||||
accent={accent}
|
||||
open={open === i}
|
||||
panelId={panelId}
|
||||
onToggle={() => setOpen(open === i ? null : i)}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div ref={panel} id={panelId}>
|
||||
{open != null && items[open] && <EventInFull item={items[open]} accent={accent} level={level} />}
|
||||
{featured.map((item, i) => (
|
||||
<FeaturedEvent key={i} item={item} accent={accent} level={level} />
|
||||
))}
|
||||
{cards.length > 0 && (
|
||||
<>
|
||||
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{cards.map((item, i) => (
|
||||
<li key={i}>
|
||||
<EventCard
|
||||
item={item}
|
||||
accent={accent}
|
||||
open={open === i}
|
||||
panelId={panelId}
|
||||
onToggle={() => setOpen(open === i ? null : i)}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div ref={panel} id={panelId}>
|
||||
{open != null && cards[open] && <EventInFull item={cards[open]} accent={accent} level={level} />}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/* A featured event: its heading and subheading, if set, then the
|
||||
event in full, its title a level under the heading. */
|
||||
function FeaturedEvent({ item, accent, level }: { item: ContentBlockItem; accent: string; level: 3 | 4 | 5 }) {
|
||||
if (!item.heading && !item.subheading) return <EventInFull item={item} accent={accent} level={level} />
|
||||
const Heading = `h${level}` as 'h3'
|
||||
const color = item.event?.color || accent
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
{item.heading && (
|
||||
<Heading className="text-2xl font-bold" style={{ color: accentText(color) }}>
|
||||
{item.heading}
|
||||
</Heading>
|
||||
)}
|
||||
{item.subheading && <p className="mt-1 text-lg text-body">{item.subheading}</p>}
|
||||
</div>
|
||||
<EventInFull item={item} accent={accent} level={item.heading ? (Math.min(level + 1, 5) as 3 | 4 | 5) : level} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue