Product Gallery 7
Lets buyers inspect each product photo up close with a magnifier and zoom, each photo captioned below.
Use it in a prompt
Use offer/product-gallery-7 from the FunnelDNA library. Follow the skill and theme contract. Ask me for the copy, images, and brand details you need; do not invent proof.
Paste into Claude or ChatGPT with FunnelDNA connected (MCP setup), or alongside the skill.
Use it in code
- Save
component.tsx(Code tab) ascomponents/funneldna/offer/product-gallery-7.tsx. - Import it and pass your copy and images (Props tab):
import { ProductGalleryStage } from "@/components/funneldna/offer/product-gallery-7"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/product-gallery-7/component.tsx 686 lines
// Lets buyers inspect each product photo up close with a magnifier and zoom, each photo captioned below.
'use client'
import * as React from 'react'
import { ChevronLeft, ChevronRight, Hand, ImageOff, MousePointer2, RotateCw, ZoomIn, ZoomOut } from 'lucide-react'
export type StageShot = {
/** Real product photograph: hero angle, detail or in use. */
src: string
alt: string
/** Short name on the panel and thumbnail, e.g. 'In use'. */
label: string
/** One line under the photo. */
caption?: string
}
export type ProductGalleryStageState = 'default' | 'hover' | 'active' | 'disabled' | 'error'
export type ProductGalleryStageCopy = {
zoom: string
exitZoom: string
previous: string
next: string
railLabel: string
hintPointer: string
hintTouch: string
keyboardHelp: string
failed: string
retry: string
/** {zoom} is replaced with the magnification. */
magnified: string
/** {alt} is replaced. */
frameLabel: string
/** {index}, {count} and {label} are replaced. */
thumbLabel: string
announce: string
}
const DEFAULT_COPY: ProductGalleryStageCopy = {
zoom: 'Zoom',
exitZoom: 'Exit zoom',
previous: 'Previous photo',
next: 'Next photo',
railLabel: 'Choose a photo',
hintPointer: 'Hover to magnify. Click to inspect up close.',
hintTouch: 'Swipe to browse. Tap a photo to zoom in.',
keyboardHelp: 'Press Enter to zoom. Left and right arrows change the photo. While zoomed, the arrows pan and Escape exits.',
failed: 'This photo didn’t load.',
retry: 'Try again',
magnified: '{zoom}× zoom',
frameLabel: 'Zoom photo: {alt}',
thumbLabel: 'Show photo {index} of {count}: {label}',
announce: 'Photo {index} of {count}: {label}',
}
export type ProductGalleryStageProps = {
/** Up to 3 real product photos (hero angle, detail, in use). */
images?: StageShot[]
productName?: string
/** One short line under the name, e.g. what is in the kit. */
subtitle?: string
copy?: Partial<ProductGalleryStageCopy>
/** Magnification for the loupe and the inspect zoom (1.5 to 4). */
zoom?: number
initialIndex?: number
disabled?: boolean
/** Studio preview state. */
state?: ProductGalleryStageState
onChange?: (index: number) => void
className?: string
style?: React.CSSProperties
}
type Point = { x: number; y: number }
type Size = { w: number; h: number }
type Inspect = { on: boolean; x: number; y: number }
type Gesture = { id: number; x: number; y: number; ox: number; oy: number; moved: boolean; type: string }
const HOVER_PREVIEW: Point = { x: 62, y: 46 }
const PAN: Record<string, [number, number]> = { ArrowLeft: [-10, 0], ArrowRight: [10, 0], ArrowUp: [0, -10], ArrowDown: [0, 10] }
const useIso = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect
const pct = (n: number) => Math.min(100, Math.max(0, n))
const clampIndex = (i: number, count: number) => (count ? Math.min(count - 1, Math.max(0, i)) : 0)
const pad = (n: number) => String(n).padStart(2, '0')
const fill = (t: string, vars: Record<string, string | number>) =>
Object.entries(vars).reduce((s, [k, v]) => s.split('{' + k + '}').join(String(v)), t)
function pointIn(el: HTMLElement, cx: number, cy: number): Point {
const r = el.getBoundingClientRect()
if (!r.width || !r.height) return { x: 50, y: 50 }
return { x: pct(((cx - r.left) / r.width) * 100), y: pct(((cy - r.top) / r.height) * 100) }
}
function useReducedMotion() {
const [reduced, setReduced] = React.useState(false)
React.useEffect(() => {
if (typeof window === 'undefined' || !window.matchMedia) return
const m = window.matchMedia('(prefers-reduced-motion: reduce)')
const update = () => setReduced(m.matches)
update()
m.addEventListener?.('change', update)
return () => m.removeEventListener?.('change', update)
}, [])
return reduced
}
export function ProductGalleryStage({
images = [],
productName = 'Product',
subtitle,
copy: copyIn,
zoom = 2.4,
initialIndex = 0,
disabled = false,
state = 'default',
onChange,
className = '',
style,
}: ProductGalleryStageProps) {
const copy: ProductGalleryStageCopy = { ...DEFAULT_COPY }
if (copyIn) for (const [k, v] of Object.entries(copyIn)) if (typeof v === 'string') (copy as Record<string, string>)[k] = v
const shots = images.slice(0, 3)
const count = shots.length
const uid = 'pgs' + React.useId().replace(/[^a-zA-Z0-9]/g, '')
const locked = disabled || state === 'disabled'
const z = Math.min(4, Math.max(1.5, zoom))
const reduced = useReducedMotion()
const startFor = (s: ProductGalleryStageState) => clampIndex(s === 'active' ? 1 : s === 'error' ? 0 : initialIndex, count)
const [index, setIndex] = React.useState(() => startFor(state))
const [inspect, setInspect] = React.useState<Inspect>(() => ({ on: state === 'active', x: 50, y: 50 }))
const [lens, setLens] = React.useState<Point | null>(() => (state === 'hover' ? HOVER_PREVIEW : null))
const [ready, setReady] = React.useState<Record<number, boolean>>({})
const [failed, setFailed] = React.useState<Record<number, boolean>>((): Record<number, boolean> => (state === 'error' ? { 0: true } : {}))
const [thumbFailed, setThumbFailed] = React.useState<Record<number, boolean>>({})
const [attempt, setAttempt] = React.useState<Record<number, number>>({})
const [natural, setNatural] = React.useState<Record<number, Size>>({})
const [frame, setFrame] = React.useState<Size>({ w: 0, h: 0 })
const indexRef = React.useRef(index)
const reducedRef = React.useRef(reduced)
reducedRef.current = reduced
const onChangeRef = React.useRef(onChange)
onChangeRef.current = onChange
const trackRef = React.useRef<HTMLDivElement>(null)
const panelRefs = React.useRef<Array<HTMLElement | null>>([])
const frameRefs = React.useRef<Array<HTMLDivElement | null>>([])
const thumbRefs = React.useRef<Array<HTMLButtonElement | null>>([])
const imgRefs = React.useRef<Array<HTMLImageElement | null>>([])
const gesture = React.useRef<Gesture | null>(null)
const target = React.useRef<number | null>(null)
const targetTimer = React.useRef(0)
const raf = React.useRef(0)
const scrollToIndex = React.useCallback((i: number, smooth: boolean) => {
const t = trackRef.current
const p = panelRefs.current[i]
if (!t || !p) return
if (typeof t.scrollTo === 'function') t.scrollTo({ left: p.offsetLeft, behavior: smooth && !reducedRef.current ? 'smooth' : 'auto' })
else t.scrollLeft = p.offsetLeft
}, [])
const commit = React.useCallback((next: number) => {
indexRef.current = next
setIndex(next)
setInspect((s) => (s.on ? { on: false, x: 50, y: 50 } : s))
setLens(null)
onChangeRef.current?.(next)
}, [])
useIso(() => {
const s = startFor(state)
indexRef.current = s
setIndex(s)
setInspect({ on: state === 'active', x: 50, y: 50 })
setLens(state === 'hover' ? HOVER_PREVIEW : null)
setFailed(state === 'error' ? { 0: true } : {})
scrollToIndex(s, false)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state, count])
React.useEffect(() => {
const t = trackRef.current
if (!t) return
const measure = () => {
const f = frameRefs.current[indexRef.current] ?? frameRefs.current[0]
if (f) setFrame((prev) => (prev.w === f.clientWidth && prev.h === f.clientHeight ? prev : { w: f.clientWidth, h: f.clientHeight }))
const p = panelRefs.current[indexRef.current]
if (p && target.current === null) t.scrollLeft = p.offsetLeft
}
measure()
if (typeof ResizeObserver === 'undefined') return
const ro = new ResizeObserver(measure)
ro.observe(t)
return () => ro.disconnect()
}, [count])
React.useEffect(() => () => {
cancelAnimationFrame(raf.current)
window.clearTimeout(targetTimer.current)
}, [])
const markReady = (i: number, img: HTMLImageElement) => {
setReady((r) => (r[i] ? r : { ...r, [i]: true }))
if (img.naturalWidth) setNatural((n) => (n[i] ? n : { ...n, [i]: { w: img.naturalWidth, h: img.naturalHeight } }))
}
React.useEffect(() => {
imgRefs.current.forEach((img, i) => {
if (img && img.complete && img.naturalWidth) markReady(i, img)
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [count, attempt, failed])
const isFailed = (i: number) => !!failed[i]
const canZoom = (i: number) => !locked && !isFailed(i)
const select = (next: number, focus?: 'thumb' | 'frame') => {
if (locked || !count) return
const n = clampIndex(next, count)
target.current = n
window.clearTimeout(targetTimer.current)
targetTimer.current = window.setTimeout(() => { target.current = null }, 900)
if (n !== indexRef.current) commit(n)
scrollToIndex(n, true)
if (focus === 'thumb') thumbRefs.current[n]?.focus()
if (focus === 'frame') {
const f = frameRefs.current[n]
if (f && !isFailed(n)) f.focus({ preventScroll: true })
else thumbRefs.current[n]?.focus()
}
}
const onScroll = () => {
cancelAnimationFrame(raf.current)
raf.current = requestAnimationFrame(() => {
const t = trackRef.current
if (!t) return
let best = indexRef.current
let dist = Infinity
for (let i = 0; i < count; i++) {
const p = panelRefs.current[i]
if (!p) continue
const d = Math.abs(p.offsetLeft - t.scrollLeft)
if (d < dist) { dist = d; best = i }
}
if (dist > 6) return
if (target.current !== null) {
if (best === target.current) target.current = null
return
}
if (best !== indexRef.current) commit(best)
})
}
const onFrameDown = (e: React.PointerEvent<HTMLDivElement>, i: number) => {
if (i !== index || !canZoom(i)) return
gesture.current = { id: e.pointerId, x: e.clientX, y: e.clientY, ox: inspect.x, oy: inspect.y, moved: false, type: e.pointerType }
if (inspect.on && e.pointerType !== 'mouse') e.currentTarget.setPointerCapture?.(e.pointerId)
}
const onFrameMove = (e: React.PointerEvent<HTMLDivElement>, i: number) => {
if (i !== index || !canZoom(i)) return
const el = e.currentTarget
const g = gesture.current
if (g && g.id === e.pointerId) {
const dx = e.clientX - g.x
const dy = e.clientY - g.y
if (!g.moved && Math.hypot(dx, dy) > 8) g.moved = true
if (g.type !== 'mouse' && inspect.on && g.moved) {
const w = el.clientWidth || 1
const h = el.clientHeight || 1
setInspect({ on: true, x: pct(g.ox - (dx / w) * 115), y: pct(g.oy - (dy / h) * 115) })
return
}
}
if (e.pointerType === 'mouse') {
const p = pointIn(el, e.clientX, e.clientY)
if (inspect.on) setInspect({ on: true, ...p })
else setLens(p)
}
}
const onFrameUp = (e: React.PointerEvent<HTMLDivElement>, i: number) => {
const g = gesture.current
gesture.current = null
if (!g || g.id !== e.pointerId || g.moved || i !== index || !canZoom(i)) return
const p = pointIn(e.currentTarget, e.clientX, e.clientY)
if (inspect.on) {
setInspect((s) => ({ ...s, on: false }))
if (e.pointerType === 'mouse') setLens(p)
} else {
setLens(null)
setInspect({ on: true, ...p })
}
}
const onFrameCancel = () => { gesture.current = null }
const onFrameLeave = (e: React.PointerEvent<HTMLDivElement>) => {
if (e.pointerType === 'mouse') setLens(null)
}
const onFrameKey = (e: React.KeyboardEvent<HTMLDivElement>, i: number) => {
if (locked || i !== index) return
const k = e.key
if (inspect.on) {
const step = PAN[k]
if (step) {
e.preventDefault()
setInspect((s) => ({ on: true, x: pct(s.x + step[0]), y: pct(s.y + step[1]) }))
return
}
if (k === 'Escape' || k === 'Enter' || k === ' ') {
e.preventDefault()
setInspect((s) => ({ ...s, on: false }))
}
return
}
if (k === 'Enter' || k === ' ') {
e.preventDefault()
setLens(null)
setInspect({ on: true, x: 50, y: 50 })
} else if (k === 'ArrowRight' && index < count - 1) {
e.preventDefault()
select(index + 1, 'frame')
} else if (k === 'ArrowLeft' && index > 0) {
e.preventDefault()
select(index - 1, 'frame')
} else if (k === 'Home') {
e.preventDefault()
select(0, 'frame')
} else if (k === 'End') {
e.preventDefault()
select(count - 1, 'frame')
} else if (k === 'ArrowRight' || k === 'ArrowLeft') {
e.preventDefault()
}
}
const onThumbKey = (e: React.KeyboardEvent<HTMLButtonElement>, i: number) => {
const map: Record<string, number> = { ArrowRight: i + 1, ArrowLeft: i - 1, Home: 0, End: count - 1 }
if (e.key in map) {
e.preventDefault()
select(map[e.key], 'thumb')
}
}
const toggleZoom = () => {
if (!canZoom(index)) return
setLens(null)
setInspect((s) => (s.on ? { ...s, on: false } : { on: true, x: 50, y: 50 }))
}
const retry = (i: number) => {
setFailed((f) => ({ ...f, [i]: false }))
setThumbFailed((f) => ({ ...f, [i]: false }))
setReady((r) => ({ ...r, [i]: false }))
setAttempt((a) => ({ ...a, [i]: (a[i] ?? 0) + 1 }))
requestAnimationFrame(() => frameRefs.current[i]?.focus({ preventScroll: true }))
}
const onRootKey = (e: React.KeyboardEvent<HTMLElement>) => {
if (e.key === 'Escape' && inspect.on) setInspect((s) => ({ ...s, on: false }))
}
if (!count) return null
const loupe = (() => {
if (!lens || inspect.on || locked || isFailed(index) || !frame.w || !frame.h) return null
const nat = natural[index] ?? { w: frame.w, h: frame.h }
const s = Math.max(frame.w / nat.w, frame.h / nat.h)
const rw = nat.w * s
const rh = nat.h * s
const ox = (frame.w - rw) / 2
const oy = (frame.h - rh) / 2
const size = Math.round(Math.min(220, Math.max(124, frame.w * 0.3)))
const inner = size - 8
const px = (lens.x / 100) * frame.w
const py = (lens.y / 100) * frame.h
return {
size,
left: px - size / 2,
top: py - size / 2,
w: rw * z,
h: rh * z,
x: inner / 2 - (px - ox) * z,
y: inner / 2 - (py - oy) * z,
}
})()
const current = shots[index] ?? shots[0]
const trackId = uid + '-track'
const helpId = uid + '-help'
const magText = fill(copy.magnified, { zoom: Math.round(z * 10) / 10 })
return (
<section
className={('pgs ' + className).trim()}
style={style}
aria-roledescription='carousel'
aria-label={productName + ' photos'}
data-state={state}
data-locked={locked ? '' : undefined}
onKeyDown={onRootKey}
>
<style>{CSS}</style>
<div className='pgs-stage'>
<div className='pgs-top'>
<div className='pgs-head'>
<p className='pgs-title'>{productName}</p>
{subtitle ? <p className='pgs-sub'>{subtitle}</p> : null}
</div>
<button
type='button'
className='pgs-btn pgs-zoom'
aria-pressed={inspect.on}
aria-controls={trackId}
disabled={!canZoom(index)}
onClick={toggleZoom}
>
{inspect.on ? <ZoomOut size={18} aria-hidden /> : <ZoomIn size={18} aria-hidden />}
<span>{inspect.on ? copy.exitZoom : copy.zoom}</span>
</button>
</div>
<div className='pgs-view'>
<div
id={trackId}
ref={trackRef}
className='pgs-track'
data-locked={locked || inspect.on ? '' : undefined}
onScroll={onScroll}
onPointerDown={(e) => { if (e.pointerType !== 'mouse') target.current = null }}
>
{shots.map((shot, i) => {
const active = i === index
const fail = isFailed(i)
const isReady = !!ready[i]
const zoomed = active && inspect.on
return (
<figure
key={i}
ref={(el) => { panelRefs.current[i] = el }}
className='pgs-panel'
role='group'
aria-roledescription='slide'
aria-label={i + 1 + ' of ' + count}
aria-hidden={active ? undefined : true}
>
{fail ? (
<div ref={(el) => { frameRefs.current[i] = el }} className='pgs-frame' data-failed=''>
<div className='pgs-fail' role='alert'>
<span className='pgs-fail-ic'><ImageOff size={24} aria-hidden /></span>
<p className='pgs-fail-msg'>{copy.failed}</p>
<button type='button' className='pgs-btn' onClick={() => retry(i)} disabled={locked} tabIndex={active ? 0 : -1}>
<RotateCw size={18} aria-hidden />
<span>{copy.retry}</span>
</button>
</div>
</div>
) : (
<div
ref={(el) => { frameRefs.current[i] = el }}
className='pgs-frame'
role='button'
tabIndex={active && !locked ? 0 : -1}
aria-label={fill(copy.frameLabel, { alt: shot.alt })}
aria-pressed={zoomed}
aria-disabled={locked || undefined}
aria-describedby={helpId}
aria-busy={isReady ? undefined : true}
data-inspect={zoomed ? '' : undefined}
data-loading={isReady ? undefined : ''}
style={{ '--z': z, '--ox': (zoomed ? inspect.x : 50) + '%', '--oy': (zoomed ? inspect.y : 50) + '%' } as React.CSSProperties}
onPointerDown={(e) => onFrameDown(e, i)}
onPointerMove={(e) => onFrameMove(e, i)}
onPointerUp={(e) => onFrameUp(e, i)}
onPointerCancel={onFrameCancel}
onPointerLeave={onFrameLeave}
onKeyDown={(e) => onFrameKey(e, i)}
>
<img
key={attempt[i] ?? 0}
ref={(el) => { imgRefs.current[i] = el }}
className='pgs-img'
src={shot.src}
alt={shot.alt}
loading='eager'
decoding='async'
draggable={false}
data-ready={isReady ? '' : undefined}
onLoad={(e) => markReady(i, e.currentTarget)}
onError={() => setFailed((f) => ({ ...f, [i]: true }))}
/>
{zoomed ? (
<span className='pgs-mag' aria-hidden>
<ZoomIn size={15} aria-hidden />
<span>{magText}</span>
</span>
) : null}
{active && loupe ? (
<span className='pgs-loupe' aria-hidden style={{ width: loupe.size, height: loupe.size, left: loupe.left, top: loupe.top }}>
<span className='pgs-loupe-in'>
<img src={shot.src} alt='' draggable={false} style={{ width: loupe.w, height: loupe.h, left: loupe.x, top: loupe.y }} />
</span>
</span>
) : null}
</div>
)}
<figcaption className='pgs-cap'>
{count > 1 ? (
<span className='pgs-num' aria-hidden>
<span>{pad(i + 1)}</span>
<small>/{pad(count)}</small>
</span>
) : null}
<span className='pgs-cap-text'>
<span className='pgs-label'>{shot.label}</span>
{shot.caption ? <span className='pgs-line'>{shot.caption}</span> : null}
</span>
</figcaption>
</figure>
)
})}
</div>
{count > 1 ? (
<>
<button
type='button'
className='pgs-btn pgs-arrow'
data-dir='prev'
data-end={!locked && index === 0 ? '' : undefined}
aria-label={copy.previous}
aria-controls={trackId}
disabled={locked || index === 0}
onClick={() => select(index - 1)}
>
<ChevronLeft size={22} aria-hidden />
</button>
<button
type='button'
className='pgs-btn pgs-arrow'
data-dir='next'
data-end={!locked && index === count - 1 ? '' : undefined}
aria-label={copy.next}
aria-controls={trackId}
disabled={locked || index === count - 1}
onClick={() => select(index + 1)}
>
<ChevronRight size={22} aria-hidden />
</button>
</>
) : null}
</div>
{count > 1 ? (
<div className='pgs-rail' role='group' aria-label={copy.railLabel} style={{ '--n': count } as React.CSSProperties}>
{shots.map((shot, i) => {
const on = i === index
return (
<button
key={i}
ref={(el) => { thumbRefs.current[i] = el }}
type='button'
className='pgs-thumb'
aria-current={on ? 'true' : undefined}
aria-label={fill(copy.thumbLabel, { index: i + 1, count, label: shot.label })}
aria-controls={trackId}
tabIndex={on ? 0 : -1}
disabled={locked}
onClick={() => select(i)}
onKeyDown={(e) => onThumbKey(e, i)}
>
<span className='pgs-thumb-img'>
{thumbFailed[i] ? (
<ImageOff size={22} aria-hidden />
) : (
<img src={shot.src} alt='' loading='eager' decoding='async' draggable={false} onError={() => setThumbFailed((f) => ({ ...f, [i]: true }))} />
)}
</span>
<span className='pgs-bar' aria-hidden><i /></span>
<span className='pgs-thumb-label'>{shot.label}</span>
</button>
)
})}
</div>
) : null}
<p className='pgs-hint' aria-hidden>
<span className='pgs-hint-pointer'><MousePointer2 size={16} aria-hidden />{copy.hintPointer}</span>
<span className='pgs-hint-touch'><Hand size={16} aria-hidden />{copy.hintTouch}</span>
</p>
<p className='pgs-sr' id={helpId}>{copy.keyboardHelp}</p>
<p className='pgs-sr' aria-live='polite'>{fill(copy.announce, { index: index + 1, count, label: current.label })}</p>
</div>
</section>
)
}
export default ProductGalleryStage
/* Photographs retain their designed colours and arrive through specimen image slots.
All UI colours, including lens glass, derive from theme tokens. Zero-blur rings
are borders/focus indicators; outer shadows use the dark shadow token.
Chevron buttons are gallery navigation controls. */
const CSS = `
.pgs{--pgs-card:var(--card);--pgs-ink:var(--ink);--pgs-muted:var(--muted);--pgs-accent:var(--accent);--pgs-raise:color-mix(in oklch,var(--pgs-ink) 5%,var(--pgs-card));--pgs-rim:var(--card-border,color-mix(in oklch,var(--pgs-ink) 12%,transparent));--pgs-line:oklch(from var(--pgs-ink) l c h / 0.14);--pgs-shade:oklch(from var(--shadow) l c h / 0.28);--pgs-r:var(--card-radius,var(--radius));--pgs-btn-bg:var(--button-2-bg,var(--secondary));--pgs-btn-ink:var(--button-2-ink,var(--secondary-ink));--pgs-btn-line:var(--button-2-border,transparent);--pgs-btn-shadow:var(--button-2-shadow,inset 0 -2px 0 oklch(from var(--secondary) calc(l - 0.1) c h),var(--shadow-sm));container:pgs / inline-size;display:block;width:100%;min-width:0;color:var(--pgs-ink);font-family:var(--font-body);font-size:1rem;line-height:1.5}
.pgs *,.pgs *::before,.pgs *::after{box-sizing:border-box}
.pgs :where(p,figure){margin:0}
.pgs-stage{position:relative;isolation:isolate;overflow:hidden;padding:clamp(1.125rem,2.8vw,2rem);border:1px solid var(--pgs-rim);border-radius:calc(var(--pgs-r) + 6px);background:var(--pgs-card);box-shadow:var(--card-shadow,var(--shadow-md)),inset 0 1px 0 oklch(from var(--pgs-card) calc(l + 0.04) c h / 0.6)}
.pgs-top{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:clamp(1.125rem,2.4vw,1.5rem)}
.pgs-head{min-width:0}
.pgs-title{font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.625rem,3.2vw,2.5rem);line-height:1.04;letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);text-wrap:balance;color:var(--pgs-ink)}
.pgs-sub{margin-top:0.75rem;font-size:clamp(1rem,1.5vw,1.0625rem);font-weight:500;line-height:1.4;color:var(--pgs-muted);text-wrap:pretty}
.pgs-btn{appearance:none;-webkit-appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:0.5rem;flex:none;min-height:44px;margin:0;padding:0 1.125rem;border:1px solid var(--pgs-btn-line);border-radius:var(--button-radius,var(--radius));background:var(--pgs-btn-bg);color:var(--pgs-btn-ink);font-family:var(--button-font,var(--font-display));font-size:1rem;font-weight:var(--button-weight,800);text-transform:var(--button-case,none);line-height:1;white-space:nowrap;cursor:pointer;box-shadow:var(--pgs-btn-shadow);transition:background-color .2s ease,transform .12s ease,box-shadow .2s ease;-webkit-tap-highlight-color:transparent}
.pgs-btn svg{flex:none}
.pgs-btn:hover:not(:disabled){background:var(--pgs-btn-bg);box-shadow:var(--pgs-btn-shadow),inset 0 0 0 1px var(--pgs-btn-ink)}
.pgs-btn:active:not(:disabled){transform:translateY(1px);box-shadow:var(--pgs-btn-shadow)}
.pgs-btn:focus-visible{outline:2px solid var(--pgs-accent);outline-offset:3px}
.pgs-btn:disabled{cursor:not-allowed;box-shadow:none}
.pgs-zoom[aria-pressed='true']{box-shadow:inset 0 0 0 2px var(--pgs-accent),var(--pgs-btn-shadow)}
.pgs-view{position:relative;container:pgsview / inline-size}
.pgs-track{position:relative;display:flex;gap:1rem;overflow-x:auto;overflow-y:hidden;padding-bottom:2px;scroll-snap-type:x mandatory;overscroll-behavior-x:contain;scrollbar-width:none;-webkit-overflow-scrolling:touch}
.pgs-track::-webkit-scrollbar{display:none}
.pgs-track[data-locked]{overflow-x:hidden}
.pgs-panel{flex:0 0 100%;min-width:0;scroll-snap-align:start;scroll-snap-stop:always}
.pgs-frame{position:relative;overflow:hidden;aspect-ratio:3 / 2;border-radius:var(--pgs-r);background:var(--pgs-raise);cursor:zoom-in;touch-action:pan-x pan-y;outline:none;box-shadow:0 0 0 1px var(--pgs-line);-webkit-tap-highlight-color:transparent}
.pgs-frame::after{content:'';position:absolute;inset:0;z-index:5;border-radius:inherit;pointer-events:none;box-shadow:inset 0 0 0 1px var(--pgs-line);transition:box-shadow .2s ease}
.pgs-frame:focus-visible::after{box-shadow:inset 0 0 0 3px var(--pgs-accent),inset 0 0 0 5px var(--pgs-card)}
.pgs-frame[data-inspect]{cursor:zoom-out;touch-action:none}
.pgs-frame[aria-disabled='true'],.pgs-frame[data-failed]{cursor:default}
.pgs-frame[data-loading]::before{content:'';position:absolute;inset:0;z-index:1;background:linear-gradient(100deg,transparent 30%,oklch(from var(--pgs-ink) l c h / 0.07) 50%,transparent 70%) 0 0 / 240% 100%;animation:pgs-shimmer 1.4s linear infinite}
@keyframes pgs-shimmer{from{background-position:120% 0}to{background-position:-120% 0}}
.pgs-img{position:absolute;inset:0;z-index:2;display:block;width:100%;height:100%;max-width:none;object-fit:cover;object-position:center;opacity:0;transform:scale(1);transform-origin:var(--ox,50%) var(--oy,50%);transition:opacity .45s ease,transform .38s cubic-bezier(.2,.8,.2,1),transform-origin .14s linear;user-select:none;-webkit-user-drag:none;pointer-events:none}
.pgs-img[data-ready]{opacity:1}
.pgs-frame[data-inspect] .pgs-img{transform:scale(var(--z,2.4))}
.pgs-mag{position:absolute;z-index:6;top:0.875rem;left:0.875rem;display:inline-flex;align-items:center;gap:0.4375rem;min-height:34px;padding:0 0.875rem;border-radius:999px;background:var(--band);color:var(--band-ink);font-size:0.875rem;font-weight:700;line-height:1;white-space:nowrap;pointer-events:none;box-shadow:0 1px 2px var(--pgs-shade),0 4px 10px -4px var(--pgs-shade);animation:pgs-pop .18s ease-out both}
.pgs-mag svg{flex:none}
.pgs-loupe{position:absolute;z-index:4;display:block;padding:4px;border-radius:50%;pointer-events:none;background:conic-gradient(from 210deg,var(--pgs-card),color-mix(in oklch,var(--pgs-ink) 38%,var(--pgs-card)),color-mix(in oklch,var(--pgs-ink) 12%,var(--pgs-card)),var(--pgs-card),color-mix(in oklch,var(--pgs-ink) 30%,var(--pgs-card)),var(--pgs-card));box-shadow:0 0 0 1px var(--pgs-line),0 2px 3px var(--pgs-shade),0 4px 10px -2px var(--pgs-shade);animation:pgs-pop .18s ease-out both}
@keyframes pgs-pop{from{opacity:0;transform:scale(.88)}to{opacity:1;transform:scale(1)}}
.pgs-loupe-in{position:relative;display:block;width:100%;height:100%;overflow:hidden;border-radius:50%;background:var(--pgs-raise)}
.pgs-loupe-in img{position:absolute;display:block;max-width:none;user-select:none}
.pgs-loupe-in::after{content:'';position:absolute;inset:0;border-radius:50%;background:radial-gradient(90% 60% at 30% 12%,oklch(from var(--pgs-card) calc(l + 0.04) c h / 0.22),oklch(from var(--pgs-card) calc(l + 0.04) c h / 0) 55%);box-shadow:inset 0 0 0 1px oklch(from var(--shadow) l c h / 0.2),inset 0 -8px 16px -10px oklch(from var(--shadow) l c h / 0.3)}
.pgs-fail{position:absolute;inset:0;z-index:3;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.875rem;padding:1.25rem;text-align:center;background:var(--pgs-card)}
.pgs-fail-ic{display:grid;place-items:center;width:56px;height:56px;border-radius:50%;background:var(--danger-soft);color:var(--danger)}
.pgs-fail-msg{font-family:var(--font-display);font-weight:var(--display-weight,700);font-size:1.125rem;line-height:1.25;letter-spacing:var(--display-tracking,normal);text-transform:var(--display-case,none);color:var(--pgs-ink);text-wrap:balance}
.pgs-arrow{position:absolute;z-index:6;top:36%;top:calc(100cqw / 3);width:48px;height:48px;min-height:48px;padding:0;transform:translateY(-50%)}
.pgs-arrow[data-dir='prev']{left:0.875rem}
.pgs-arrow[data-dir='next']{right:0.875rem}
.pgs-arrow:active:not(:disabled){transform:translateY(calc(-50% + 1px))}
.pgs-arrow[data-end]{visibility:hidden}
.pgs-cap{display:flex;align-items:flex-start;gap:clamp(0.875rem,2.2vw,1.5rem);padding-top:clamp(1rem,2.2vw,1.375rem)}
.pgs-num{display:flex;align-items:flex-start;flex:none;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(2.75rem,5.6vw,4.25rem);line-height:0.84;letter-spacing:var(--display-tracking,-0.045em);text-transform:var(--display-case,none);font-variant-numeric:tabular-nums;color:var(--pgs-ink)}
.pgs-num small{padding-top:0.18em;margin-left:0.16em;font-size:0.3em;font-weight:var(--display-weight,700);letter-spacing:var(--display-tracking,0.02em);line-height:1;color:var(--pgs-muted)}
.pgs-cap-text{display:grid;gap:0.4375rem;min-width:0;padding-top:0.125rem}
.pgs-label{font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.25rem,2.1vw,1.5rem);line-height:1.12;letter-spacing:var(--display-tracking,-0.015em);text-transform:var(--display-case,none);color:var(--pgs-ink);text-wrap:balance}
.pgs-line{max-width:52ch;font-size:clamp(1rem,1.5vw,1.0625rem);font-weight:500;line-height:1.45;color:var(--pgs-muted);text-wrap:pretty}
.pgs-rail{display:grid;grid-template-columns:repeat(var(--n,3),minmax(0,1fr));gap:clamp(0.625rem,1.8vw,1.125rem);margin-top:clamp(1.25rem,2.8vw,1.75rem)}
.pgs-thumb{appearance:none;-webkit-appearance:none;display:grid;align-content:start;gap:0.625rem;width:100%;min-width:0;margin:0;padding:0;border:0;border-radius:max(0px,calc(var(--pgs-r) - 2px));background:none;color:var(--pgs-muted);font-family:var(--button-font,var(--font-display));font-size:1rem;text-align:left;cursor:pointer;-webkit-tap-highlight-color:transparent}
.pgs-thumb:focus-visible{outline:2px solid var(--pgs-accent);outline-offset:6px}
.pgs-thumb-img{position:relative;display:grid;place-items:center;aspect-ratio:16 / 10;overflow:hidden;border-radius:max(0px,calc(var(--pgs-r) - 4px));background:var(--pgs-raise);color:var(--pgs-ink);box-shadow:0 0 0 1px var(--pgs-line);transition:transform .25s cubic-bezier(.2,.8,.2,1),box-shadow .25s ease}
.pgs-thumb-img img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:0.72;filter:saturate(0.6);transition:opacity .3s ease,filter .3s ease}
.pgs-thumb:hover:not(:disabled) .pgs-thumb-img{transform:translateY(-3px);box-shadow:0 0 0 1px var(--pgs-line)}
.pgs-thumb:hover:not(:disabled) .pgs-thumb-img img,.pgs-thumb[aria-current='true'] .pgs-thumb-img img{opacity:1;filter:none}
.pgs-thumb:active:not(:disabled) .pgs-thumb-img{transform:translateY(0) scale(0.97)}
.pgs-thumb[aria-current='true'] .pgs-thumb-img{box-shadow:0 0 0 2px var(--pgs-card),0 0 0 4px var(--pgs-accent)}
.pgs-bar{display:block;height:3px;border-radius:3px;overflow:hidden;background:oklch(from var(--pgs-ink) l c h / 0.12)}
.pgs-bar i{display:block;height:100%;border-radius:inherit;background:var(--accent-fill,var(--pgs-accent));transform:scaleX(0);transform-origin:left center;transition:transform .5s cubic-bezier(.2,.8,.2,1)}
.pgs-thumb[aria-current='true'] .pgs-bar i{transform:scaleX(1)}
.pgs-thumb-label{min-width:0;font-size:0.9375rem;font-weight:600;line-height:1.3;color:var(--pgs-muted);text-wrap:pretty}
.pgs-thumb[aria-current='true'] .pgs-thumb-label{color:var(--pgs-ink);font-weight:800}
.pgs-thumb:disabled{cursor:not-allowed}
.pgs-thumb:disabled .pgs-thumb-img img{opacity:0.5}
.pgs-hint{display:flex;margin-top:clamp(1rem,2.2vw,1.25rem);font-size:0.875rem;font-weight:500;line-height:1.4;color:var(--pgs-muted);text-wrap:pretty}
.pgs-hint-pointer,.pgs-hint-touch{display:inline-flex;align-items:center;gap:0.5rem}
.pgs-hint svg{flex:none;color:var(--pgs-accent)}
.pgs-hint-pointer{display:none}
@media (hover:hover) and (pointer:fine){.pgs-hint-pointer{display:inline-flex}.pgs-hint-touch{display:none}}
.pgs-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
@container pgsview (max-width: 600px){.pgs-frame{aspect-ratio:4 / 3}.pgs-arrow{display:none}}
@container pgs (max-width: 560px){.pgs-stage{padding:1rem}.pgs-top{flex-direction:column;align-items:stretch;gap:1rem}.pgs-zoom{width:100%}.pgs-mag{top:0.625rem;left:0.625rem}}
@media (prefers-reduced-motion: reduce){.pgs *,.pgs *::before,.pgs *::after{animation:none!important;transition:none!important}}
`
pieces/offer/product-gallery-7/specimen.tsx 44 lines
import __studioImage75a2ccd1 from "../assets/8e82c8d0b9257593.webp";
import __studioImagead1f99d6 from "../assets/1efb6988156c6fbf.webp";
import __studioImagec827084b from "../assets/419d016e0ee1ef7d.webp";
import * as React from 'react'
import { ProductGalleryStage, type ProductGalleryStageState } from '../product-gallery-7'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
export default function ProductGalleryStageSpecimen({ state = 'default' }: { state?: string }) {
const sample = defaults.sample
const [guide, workbook, checklist] = sample.items
const images = [
{
src: slot('product', __studioImage75a2ccd1),
alt: `${sample.name}: the ${guide.name}, ${workbook.name} and ${checklist.name} together on a studio set`,
label: 'Full kit',
caption: 'The guide, workbook and checklist, together in one kit.',
},
{
src: slot('item-2', __studioImagead1f99d6),
alt: `The ${workbook.name} open to its fill-in pages, with a pen across the spread`,
label: 'Workbook',
caption: workbook.detail,
},
{
src: slot('scene', __studioImagec827084b),
alt: `The ${workbook.name} in use at a desk, with the guide and checklist beside it`,
label: 'In use',
caption: 'Plan, write and check every step before you launch.',
},
]
return (
<ProductGalleryStage
productName={sample.name}
subtitle='Guide · Workbook · Checklist'
images={images}
state={state as ProductGalleryStageState}
style={{ maxWidth: 860, marginInline: 'auto' }}
/>
)
}
| Name | Type | Details |
|---|---|---|
images OptionalProductGalleryStage |
StageShot[] |
Default []
|
productName OptionalProductGalleryStage |
string |
Default 'Product'
|
subtitle OptionalProductGalleryStage |
string |
|
copy OptionalProductGalleryStage |
Partial<ProductGalleryStageCopy> |
|
zoom OptionalProductGalleryStage |
number |
Default 2.4
|
initialIndex OptionalProductGalleryStage |
number |
Default 0
|
disabled OptionalProductGalleryStage |
boolean |
Default false
|
state OptionalProductGalleryStage |
ProductGalleryStageState |
Default 'default'
|
onChange OptionalProductGalleryStage |
(index: number) => void |
|
className OptionalProductGalleryStage |
string |
Default ''
|
style OptionalProductGalleryStage |
React.CSSProperties |
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
--button-case--button-font--button-radius--button-weight- Main CTA button: background, ink, font, weight, case, radius and shadow.
--button-2-bg--button-2-border--button-2-ink--button-2-shadow- Secondary button.
--card-border--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
item-2- One image per offer item (item-1, item-2…), shown in stacks and lists.
product- The main product shot or cover (ebook, kit, bottle).
scene- A wide atmosphere photo behind or beside the copy.
-
1efb6988156c6fbf.webp
image/webp · 132 KB
-
419d016e0ee1ef7d.webp
image/webp · 87.6 KB
-
8e82c8d0b9257593.webp
image/webp · 72.6 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB