v1.14.2-present: event schedules, venues and map blocks, Present mode and its phone remote #33
1 changed files with 51 additions and 18 deletions
|
|
@ -84,7 +84,7 @@
|
|||
screen (the browser's), S goes back to the setup.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { ArrowDown, ArrowUp, ArrowsOut, CaretLeft, CaretRight, DotsSixVertical, Gear, Pause, Play } from '@phosphor-icons/react'
|
||||
import { ArrowDown, ArrowUp, ArrowsOut, CaretLeft, CaretRight, Check, DotsSixVertical, Gear, LinkSimple, Pause, Play } from '@phosphor-icons/react'
|
||||
import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
|
||||
import { useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
|
|
@ -577,25 +577,31 @@ export default function EventPresent() {
|
|||
onPlay={(next) => {
|
||||
// Full screen needs the click itself, so it's asked for here.
|
||||
document.documentElement.requestFullscreen?.().catch(() => {})
|
||||
const out = new URLSearchParams()
|
||||
if (next.skipped.size) out.set('skip', [...next.skipped].sort((a, b) => a - b).join(','))
|
||||
if (next.hidden.size) out.set('hide', [...next.hidden].join(','))
|
||||
for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key]))
|
||||
out.set('screen', String(next.screen))
|
||||
// Not 'tag': that's the tag slides' seconds.
|
||||
if (next.only) out.set('only', next.only)
|
||||
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(','))
|
||||
if (next.pictures.size) out.set('pictures', [...next.pictures].map(([at, side]) => `${at}:${side}`).join(','))
|
||||
out.set('play', '1')
|
||||
setParams(out)
|
||||
setParams(addressFor(next))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
/* The setup's choices as the address's query, playing (`play=1`):
|
||||
what Play goes to and Copy link copies. readSettings reads it. */
|
||||
function addressFor(next: Settings): URLSearchParams {
|
||||
const out = new URLSearchParams()
|
||||
if (next.skipped.size) out.set('skip', [...next.skipped].sort((a, b) => a - b).join(','))
|
||||
if (next.hidden.size) out.set('hide', [...next.hidden].join(','))
|
||||
for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key]))
|
||||
out.set('screen', String(next.screen))
|
||||
// Not 'tag': that's the tag slides' seconds.
|
||||
if (next.only) out.set('only', next.only)
|
||||
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(','))
|
||||
if (next.pictures.size) out.set('pictures', [...next.pictures].map(([at, side]) => `${at}:${side}`).join(','))
|
||||
out.set('play', '1')
|
||||
return out
|
||||
}
|
||||
|
||||
/* ── Setup ──────────────────────────────────────────────────── */
|
||||
|
||||
function Setup({
|
||||
|
|
@ -626,6 +632,17 @@ function Setup({
|
|||
const [titles, setTitles] = useState(settings.titles)
|
||||
const [pictures, setPictures] = useState(settings.pictures)
|
||||
const [dragging, setDragging] = useState<number | null>(null)
|
||||
const [copied, setCopied] = useState<'yes' | 'failed' | null>(null)
|
||||
const picked: Settings = { skipped, hidden, seconds, screen, only, order, theme, lists, titles, pictures }
|
||||
// The address that starts a screen with these choices, playing.
|
||||
const copyLink = () => {
|
||||
const link = `${window.location.origin}${window.location.pathname}?${addressFor(picked)}`
|
||||
navigator.clipboard
|
||||
.writeText(link)
|
||||
.then(() => setCopied('yes'))
|
||||
.catch(() => setCopied('failed'))
|
||||
window.setTimeout(() => setCopied(null), 2500)
|
||||
}
|
||||
const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only, lists, titles, pictures }), order)
|
||||
const count = slides.length
|
||||
// Moves a slide in the list, which then names every slide shown.
|
||||
|
|
@ -655,8 +672,8 @@ function Setup({
|
|||
{title}
|
||||
</h1>
|
||||
<p className="mt-2 text-muted">
|
||||
Pick what to show and for how long, then Play. It loops until you stop it. Bookmark the address after
|
||||
pressing Play to start a screen the same way next time.
|
||||
Pick what to show and for how long, then Play. It loops until you stop it. Copy link (at the bottom) gives
|
||||
an address that starts a screen with these choices, playing, eg. to bookmark on a signage device.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
|
|
@ -1046,7 +1063,7 @@ function Setup({
|
|||
<button
|
||||
type="button"
|
||||
disabled={count === 0}
|
||||
onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order, theme, lists, titles, pictures })}
|
||||
onClick={() => onPlay(picked)}
|
||||
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
|
||||
style={{ background: accent, color: readableOn(accent) }}
|
||||
>
|
||||
|
|
@ -1056,6 +1073,22 @@ function Setup({
|
|||
<span className="text-sm text-muted">
|
||||
{count === 0 ? 'Nothing picked to show.' : `${count} slide${count === 1 ? '' : 's'} in the loop`}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
disabled={count === 0}
|
||||
onClick={copyLink}
|
||||
className="btn inline-flex items-center gap-2 border border-muted/25 px-4 py-2 text-sm text-ink transition-colors hover:bg-tint disabled:opacity-50"
|
||||
>
|
||||
{copied === 'yes' ? (
|
||||
<Check aria-hidden="true" weight="bold" className="h-4 w-4" />
|
||||
) : (
|
||||
<LinkSimple aria-hidden="true" weight="bold" className="h-4 w-4" />
|
||||
)}
|
||||
{copied === 'yes' ? 'Copied' : 'Copy link'}
|
||||
</button>
|
||||
<span role="status" className="text-sm text-muted">
|
||||
{copied === 'failed' ? "Couldn't copy: press Play, then copy the address bar." : ''}
|
||||
</span>
|
||||
<a href={back} className="ml-auto text-sm text-link underline">
|
||||
Back to the event
|
||||
</a>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue