v1.14.2-present: event schedules, venues and map blocks, Present mode and its phone remote #33
4 changed files with 79 additions and 22 deletions
|
|
@ -642,8 +642,8 @@ function Block({
|
|||
if (!block.team_id && picked.length === 0) return null
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} headingLevel={level} row={presenting} />}
|
||||
{picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} headingLevel={level} row={presenting} />}
|
||||
{block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} headingLevel={level} row={presenting} titles={block.present?.titles} />}
|
||||
{picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} headingLevel={level} row={presenting} titles={block.present?.titles} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,6 +167,8 @@ export interface PeopleTilesProps
|
|||
headingLevel?: 3 | 4 | 5;
|
||||
/** Just round photos and names in a row, as presented (095). */
|
||||
row?: boolean;
|
||||
/** In the row, each one's role or title under their name. */
|
||||
titles?: boolean;
|
||||
/** How long a fetched team or person is reused, in ms. */
|
||||
ttl?: number;
|
||||
emptyMessage?: string;
|
||||
|
|
@ -198,9 +200,13 @@ export default function PeopleTiles({
|
|||
loadingMessage = "Loading…",
|
||||
errorMessage = "Couldn't load this list right now.",
|
||||
row = false,
|
||||
titles = false,
|
||||
...view
|
||||
}: PeopleTilesProps) {
|
||||
const View = row ? PeopleRow : PeopleTilesView;
|
||||
const View = useMemo(
|
||||
() => (row ? (props) => <PeopleRow {...props} titles={titles} /> : PeopleTilesView),
|
||||
[row, titles],
|
||||
);
|
||||
const specs = useMemo(() => normalizeTeams(teams), [teams]);
|
||||
const teamKey = specs.map((spec) => spec.id).join(",");
|
||||
|
||||
|
|
@ -774,7 +780,7 @@ function Tile({
|
|||
|
||||
/* Everyone in the groups, then the people, as round photos over
|
||||
their names, left to right: a people block presented (095). */
|
||||
function PeopleRow({ groups, people }: { groups?: PeopleGroup[]; people?: Person[] }) {
|
||||
function PeopleRow({ groups, people, titles = false }: { groups?: PeopleGroup[]; people?: Person[]; titles?: boolean }) {
|
||||
const everyone = [...(groups ?? []).flatMap((group) => group.people), ...(people ?? [])];
|
||||
return (
|
||||
<ul className="flex flex-wrap justify-center gap-6">
|
||||
|
|
@ -784,6 +790,7 @@ function PeopleRow({ groups, people }: { groups?: PeopleGroup[]; people?: Person
|
|||
<Photo src={mediaUrl(person.photo)} name={person.name} />
|
||||
</span>
|
||||
<span className="mt-2 text-sm font-semibold leading-tight text-ink">{person.name}</span>
|
||||
{titles && person.title && <span className="mt-0.5 text-xs leading-tight text-muted">{person.title}</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ export type ContentBlock = {
|
|||
|
||||
/** A block's presentation settings (095), EventPresent.tsx. */
|
||||
export type BlockPresent = {
|
||||
/** A people block: each one's role or title under their name, as
|
||||
* the Present setup picks (not stored). */
|
||||
titles?: boolean
|
||||
/** Only on the page: left out of the presentation (099). */
|
||||
hide: boolean
|
||||
/** Only in the presentation: left off the page (099). */
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@
|
|||
A list picked for neither is part of its section's text. The
|
||||
setup picks them per list (`lists`, o<section>.<block> and
|
||||
i<section>.<block>) and ticks its items on and off (`hide`,
|
||||
l<section>.<block>.<item>).
|
||||
l<section>.<block>.<item>). A people block shows each one's role
|
||||
or title when the setup ticks it (`titles`, <section>.<block>).
|
||||
|
||||
A schedule's slides, for each day picked, in order:
|
||||
overview the day's picked entries on one slide
|
||||
|
|
@ -99,6 +100,7 @@ import { Presenting } from '../lib/presenting.ts'
|
|||
import {
|
||||
useEvent,
|
||||
type ContentBlock,
|
||||
type BlockPresent,
|
||||
type ContentBlockItem,
|
||||
type EventPresentLook,
|
||||
type ScheduleTag,
|
||||
|
|
@ -262,11 +264,12 @@ function readSettings(params: URLSearchParams) {
|
|||
only: params.get('only') || null,
|
||||
order: list(params.get('order')),
|
||||
lists: new Set(list(params.get('lists')) ?? []),
|
||||
titles: new Set(list(params.get('titles')) ?? []),
|
||||
theme: THEMES.find((theme) => theme === params.get('theme')) ?? null,
|
||||
}
|
||||
}
|
||||
type Settings = ReturnType<typeof readSettings>
|
||||
type Picks = Pick<Settings, 'skipped' | 'hidden' | 'seconds' | 'only' | 'lists'>
|
||||
type Picks = Pick<Settings, 'skipped' | 'hidden' | 'seconds' | 'only' | 'lists' | 'titles'>
|
||||
|
||||
/* An entry or sub-item with its key (key()), carried through the
|
||||
picks and the tag filter, which copy blocks. */
|
||||
|
|
@ -359,12 +362,17 @@ function mapSlides(slides: Slide[], block: ContentBlock, at: string, label: stri
|
|||
o, k, s, g and m a schedule's overview, block, spotlight, graphic
|
||||
and map image, and x its tag slides, by key(). */
|
||||
function buildSlides(sections: Section[], schedules: Map<ContentBlock, Schedule>, picks: Picks): Slide[] {
|
||||
const { skipped, seconds, hidden, lists } = picks
|
||||
const { skipped, seconds, hidden, lists, titles } = picks
|
||||
const slides: Slide[] = []
|
||||
sections.forEach((section, s) => {
|
||||
if (skipped.has(s)) return
|
||||
const label = section.title
|
||||
const text = section.blocks.filter((block, b) => !ownSlides(block, lists, s, b))
|
||||
const text = section.blocks.flatMap((block, b) => {
|
||||
if (ownSlides(block, lists, s, b)) return []
|
||||
// A people block picked to show roles and titles.
|
||||
if (block.type === 'people' && titles.has(`${s}.${b}`)) return [{ ...block, present: { ...block.present, titles: true } as BlockPresent }]
|
||||
return [block]
|
||||
})
|
||||
// Nothing but a heading: it titles the slides that follow.
|
||||
const own = text.some((block) => !FILLER.has(block.type))
|
||||
if (seconds.section && own) slides.push({ id: `t${s}`, kind: 'section', seconds: seconds.section, label, blocks: text })
|
||||
|
|
@ -541,6 +549,7 @@ export default function EventPresent() {
|
|||
if (next.order?.length) out.set('order', next.order.join(','))
|
||||
if (next.theme) out.set('theme', next.theme)
|
||||
if (next.lists.size) out.set('lists', [...next.lists].join(','))
|
||||
if (next.titles.size) out.set('titles', [...next.titles].join(','))
|
||||
out.set('play', '1')
|
||||
setParams(out)
|
||||
}}
|
||||
|
|
@ -575,8 +584,9 @@ function Setup({
|
|||
const [order, setOrder] = useState(settings.order)
|
||||
const [theme, setTheme] = useState(settings.theme)
|
||||
const [lists, setLists] = useState(settings.lists)
|
||||
const [titles, setTitles] = useState(settings.titles)
|
||||
const [dragging, setDragging] = useState<number | null>(null)
|
||||
const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only, lists }), order)
|
||||
const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only, lists, titles }), order)
|
||||
const count = slides.length
|
||||
// Moves a slide in the list, which then names every slide shown.
|
||||
const move = (from: number, to: number) => {
|
||||
|
|
@ -758,6 +768,19 @@ function Setup({
|
|||
</div>
|
||||
)
|
||||
}
|
||||
// A people block: their roles and titles, or not.
|
||||
if (block.type === 'people') {
|
||||
return (
|
||||
<div key={b} className="mt-3 pl-7">
|
||||
<PickEntry
|
||||
label="People: each one's role or title under their name"
|
||||
enabled={on}
|
||||
checked={titles.has(`${s}.${b}`)}
|
||||
onToggle={() => setTitles(toggle(titles, `${s}.${b}`))}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
// An events block: what's shown, then which events.
|
||||
if (block.type === 'events') {
|
||||
const events = (block.items ?? []).flatMap((item, i) => (item.event ? [{ item, i }] : []))
|
||||
|
|
@ -905,7 +928,7 @@ function Setup({
|
|||
<button
|
||||
type="button"
|
||||
disabled={count === 0}
|
||||
onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order, theme, lists })}
|
||||
onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order, theme, lists, titles })}
|
||||
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
|
||||
style={{ background: accent, color: readableOn(accent) }}
|
||||
>
|
||||
|
|
@ -1253,6 +1276,32 @@ function Scroll({ center = false, className = '', children }: {
|
|||
)
|
||||
}
|
||||
|
||||
/* A slide's part shrunk to fit the room it has, never scrolled:
|
||||
zoomed down until its content is no taller than its box (a few
|
||||
passes, since text narrower in zoom wraps less). */
|
||||
function Fit({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
const box = useRef<HTMLDivElement>(null)
|
||||
const inner = useRef<HTMLDivElement>(null)
|
||||
useLayoutEffect(() => {
|
||||
const outer = box.current
|
||||
const content = inner.current
|
||||
if (!outer || !content) return
|
||||
let zoom = 1
|
||||
content.style.zoom = '1'
|
||||
for (let pass = 0; pass < 4; pass++) {
|
||||
const tall = content.getBoundingClientRect().height
|
||||
if (tall <= outer.clientHeight + 1) break
|
||||
zoom *= outer.clientHeight / tall
|
||||
content.style.zoom = String(zoom)
|
||||
}
|
||||
}, [])
|
||||
return (
|
||||
<div ref={box} className={`min-h-0 flex-1 overflow-hidden ${className}`}>
|
||||
<div ref={inner}>{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/* A slide's big title. */
|
||||
function SlideTitle({ children, color }: { children: ReactNode; color: string }) {
|
||||
return (
|
||||
|
|
@ -1485,32 +1534,30 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
|
|||
}
|
||||
|
||||
if (slide.kind === 'cards') {
|
||||
// The events' titles, each with its presenter, as rows.
|
||||
// The events' titles, each with its presenter under it, in
|
||||
// columns that flow (no row lined up with its neighbor's), shrunk
|
||||
// to fit rather than scrolled.
|
||||
const items = slide.items ?? []
|
||||
const off = slide.off ?? new Set()
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
<SlideTitle color={color}>{slide.title ?? slide.label}</SlideTitle>
|
||||
<Scroll>
|
||||
<ul className={`grid content-start gap-x-[4vw] ${items.length > ONE_COLUMN ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
<Fit>
|
||||
<ul className={`gap-x-[4vw] ${items.length > ONE_COLUMN ? 'columns-2' : ''}`}>
|
||||
{items.map((item, i) => (
|
||||
<li key={i} className="even:bg-tint-soft/60">
|
||||
<Rise
|
||||
order={i + 1}
|
||||
from="left"
|
||||
className="flex items-baseline justify-between gap-[2vw] border-b border-brand/15 px-[1vw] py-[1.4vh]"
|
||||
>
|
||||
<span className="min-w-0 text-[clamp(1.2rem,2.4vw,3rem)] font-bold leading-tight text-ink">
|
||||
<li key={i} className="break-inside-avoid border-b border-brand/15 even:bg-tint-soft/60">
|
||||
<Rise order={i + 1} from="left" className="px-[1vw] py-[1.2vh]">
|
||||
<span className="block text-[clamp(1.2rem,2.2vw,2.8rem)] font-bold leading-tight text-ink">
|
||||
{item.text || item.event!.title}
|
||||
</span>
|
||||
{item.person && !off.has('person') && (
|
||||
<span className="shrink-0 text-[clamp(1rem,1.8vw,2.4rem)] text-muted">{item.person.name}</span>
|
||||
<span className="mt-[0.4vh] block text-[clamp(0.9rem,1.5vw,2rem)] text-muted">{item.person.name}</span>
|
||||
)}
|
||||
</Rise>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Scroll>
|
||||
</Fit>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue