v1.14.2-present: event schedules, venues and map blocks, Present mode and its phone remote #33
6 changed files with 88 additions and 28 deletions
|
|
@ -207,6 +207,9 @@ export const blocksChild = (ownerKind) => ({
|
|||
// block's venue map (088).
|
||||
text("event_id"),
|
||||
text("location_key"),
|
||||
// A featured event's heading and subheading (090).
|
||||
text("heading"),
|
||||
text("subheading"),
|
||||
],
|
||||
children: [
|
||||
{
|
||||
|
|
|
|||
15
server/src/migrations/090_featured_event_items.sql
Normal file
15
server/src/migrations/090_featured_event_items.sql
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 090 FEATURED EVENTS IN AN EVENTS BLOCK
|
||||
--
|
||||
-- An events block's item ticked Featured (086's `featured`) shows
|
||||
-- opened in full above the cards, under its own heading and
|
||||
-- subheading, both optional:
|
||||
--
|
||||
-- heading eg. This year's keynote
|
||||
-- subheading a line under it
|
||||
--
|
||||
-- Other item kinds ignore both.
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
ALTER TABLE content_block_items ADD COLUMN heading TEXT;
|
||||
ALTER TABLE content_block_items ADD COLUMN subheading TEXT;
|
||||
|
|
@ -116,7 +116,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
|
|||
|
||||
const itemRows = db
|
||||
.prepare(
|
||||
`SELECT i.id, i.block_id, i.day, i.kind, ${ENTRY_FIELDS}
|
||||
`SELECT i.id, i.block_id, i.day, i.kind, i.heading, i.subheading, ${ENTRY_FIELDS}
|
||||
FROM content_block_items i
|
||||
LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1
|
||||
WHERE i.block_id IN (${placeholders(blockIds.length)})
|
||||
|
|
@ -128,7 +128,14 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
|
|||
// ride along anyway rather than branching on the block's type.
|
||||
const itemsById = new Map();
|
||||
for (const row of itemRows) {
|
||||
const item = { ...scheduleEntry(row), day: row.day, kind: row.kind ?? "entry", items: [] };
|
||||
const item = {
|
||||
...scheduleEntry(row),
|
||||
day: row.day,
|
||||
kind: row.kind ?? "entry",
|
||||
heading: row.heading,
|
||||
subheading: row.subheading,
|
||||
items: [],
|
||||
};
|
||||
itemsById.set(row.id, item);
|
||||
byId.get(row.block_id)?.items.push(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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