feat(signage): gallery widget (pictures and videos one after another, from a list or a media folder); media folders on the Media page
Folders are only a grouping in the database (media_folders, media.folder_id, Alembic 0046): made, renamed, deleted (files stay) on the Media page, a file filed from its details, uploads go into the folder shown, the picker filters by folder. The gallery widget: its own pictures/videos in order or a folder as it is now, seconds each, fade / slide / zoom, cover / contain. Plan 6R.16, F-114. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -175,7 +175,7 @@ const plate = (w, pad) => ({
|
||||
...(w.background_colour ? { background: w.background_colour, borderRadius: cq(1.2), ...(pad ? { padding: `${cq(0.8)} ${cq(1.6)}` } : {}) } : {}),
|
||||
})
|
||||
// a menu, a stack, a shape or a scrolling text in a corner or a bar has no box of its own: it gets one of this size (cqmin)
|
||||
const BOXED = { menu: [48, 56], stack: [60, 36], shape: [18, 18], ticker: [80, 7], reviews: [56, 24] }
|
||||
const BOXED = { menu: [48, 56], stack: [60, 36], shape: [18, 18], ticker: [80, 7], reviews: [56, 24], gallery: [40, 30] }
|
||||
|
||||
/**
|
||||
* The widgets of a slide: in their corners and bars, or (moved and sized by hand: position
|
||||
@@ -336,6 +336,12 @@ function widgetBody(w, ctx, fit, path) {
|
||||
if (w.kind === 'hours') return hoursBody(w, ctx, unit, text)
|
||||
if (w.kind === 'wifi') return wifiBody(w, venue?.identity?.wifi, unit, text)
|
||||
if (w.kind === 'contact') return contactBody(w, venue?.identity?.contact, unit, text)
|
||||
if (w.kind === 'gallery') {
|
||||
const ids = w.gallery_source === 'folder' ? (x.gallery || []) : (w.media_ids || [])
|
||||
const items = ids.map(id => media(id)).filter(Boolean)
|
||||
if (!items.length) return null
|
||||
return boxed(<Gallery w={w} items={items} now={now} />, 'gallery')
|
||||
}
|
||||
if (w.kind === 'reviews') {
|
||||
const list = (venue?.reviews || []).filter(r => r.stars >= (w.reviews_min || 4))
|
||||
if (!list.length) return null
|
||||
@@ -346,6 +352,34 @@ function widgetBody(w, ctx, fit, path) {
|
||||
}
|
||||
|
||||
const STAR = '#fbbf24'
|
||||
const GALLERY_IN = {
|
||||
fade: [{ opacity: 0 }, { opacity: 1 }],
|
||||
slide: [{ transform: 'translateX(100%)' }, { transform: 'translateX(0)' }],
|
||||
zoom: [{ opacity: 0, transform: 'scale(1.12)' }, { opacity: 1, transform: 'scale(1)' }],
|
||||
}
|
||||
|
||||
/** A gallery (6R.16): its pictures and videos one after another, each for its seconds, coming in with its transition. */
|
||||
function Gallery({ w, items, now }) {
|
||||
const i = pageAt(items.length, w.gallery_seconds || 5, now.getTime())
|
||||
const m = items[i]
|
||||
const el = useRef(null)
|
||||
const frames = GALLERY_IN[w.gallery_transition || 'fade']
|
||||
useEffect(() => {
|
||||
if (!frames || !el.current?.animate) return undefined
|
||||
const a = el.current.animate(frames, { duration: 700, easing: 'ease-out' })
|
||||
return () => a.cancel()
|
||||
}, [i, frames])
|
||||
const fit = { width: '100%', height: '100%', objectFit: w.gallery_fit || 'cover', display: 'block' }
|
||||
return (
|
||||
<div style={{ width: '100%', height: '100%', overflow: 'hidden', position: 'relative' }} data-testid="signage-w-gallery" data-index={i} data-count={items.length}>
|
||||
<div key={`${i}-${m.src}`} ref={el} style={{ position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }}>
|
||||
{m.kind === 'video'
|
||||
? <video src={m.src} poster={m.poster} muted autoPlay loop playsInline style={fit} />
|
||||
: <img src={m.src} alt="" style={fit} />}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* One of the venue's reviews (6R.19), the next one every few seconds: its stars, what they wrote,
|
||||
|
||||
Reference in New Issue
Block a user