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>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -760,6 +760,15 @@ export const blocksChild = {
|
|||
},
|
||||
{ path: "featured", label: "Featured", widget: "checkbox", help: "Makes the row stand out", when: SCHEDULE_ENTRY },
|
||||
{ ...TAGS_FIELD, when: SCHEDULE_ENTRY },
|
||||
{
|
||||
path: "featured",
|
||||
label: "Featured",
|
||||
widget: "checkbox",
|
||||
help: "Shows it opened in full above the cards, under the heading and subheading below",
|
||||
when: EVENT_ITEM,
|
||||
},
|
||||
{ path: "heading", label: "Heading", help: "Featured only, eg. This year's keynote. Default: none", when: EVENT_ITEM },
|
||||
{ path: "subheading", label: "Subheading", help: "Featured only: a line under the heading. Default: none", full: true, when: EVENT_ITEM },
|
||||
],
|
||||
children: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -130,6 +130,9 @@ export type ContentBlockItem = {
|
|||
start_time?: string | null
|
||||
end_time?: string | null
|
||||
featured?: boolean
|
||||
/** A featured event's heading and subheading (090). */
|
||||
heading?: string | null
|
||||
subheading?: string | null
|
||||
/** A block entry's sub-items. */
|
||||
items?: ContentBlockItem[]
|
||||
/** Its block's tags it has, by key (087). */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue