Site
Product visual
The site's product visuals: the 4:3 stage of a product page's feature row, a #262626 panel with the ASCII field around its clear middle and one small looping scene of the product, picked by kind: records, adding an account, comment themes, filters narrowing a search, timelines, ranked sheets, the links board and the patterns switch.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add product-visual<script type="module" src="/spyglass-ds/elements/product-visual.js"></script>Usage
The visual beside a feature on a product page (the site's ProductFeatures rows alternate the texture's position by row), or any section that shows what the product does in a few seconds.
Never
- Another brand's pictures, logos or people in the data unless you may show them: the defaults are Acme with neutral shapes
- A scene that keeps moving with reduced motion: each rests on its resting step
- Copy that is not the product's: the scenes show real fields and real values
- Two visuals of the same kind side by side
kind is one of brand-record, creative-record, page-record, creator-record, tagged-record, comment-thread, add-account, add-creator, comment-themes, creator-filters, filter-narrow, posts-narrow, collabs-timeline, tagged-timeline, media-mix, campaigns, pages-switch, links-board and patterns-switch. data takes that kind's shape (ProductVisualDataMap[kind] in lib/product-visual-data.ts; its defaults are in productVisualDefaults): pass picture, avatar, logo or src where you may show an image, and leave them out for a neutral shape. texture picks the ASCII field's position (0 to 3; false in React, "none" in web components, for none). The stage measures its own width, so the same visual fits a phone, a half column or a wide row. The loops follow the site's reading pace: a scene starts once it is on screen, holds its first step for 3.8s, then changes and holds 2.8s each time; with reduced motion it stays on its resting step. The ranked sheets and the patterns switch are tabs (arrow keys, Home and End move between them); pressing one stops the loop on that view. The links board holds its composed frame before it starts clearing and building scene after scene. Every picture in data (picture, src, avatar) takes a src or an image slot (src, alt, fit, position); the neutral shapes drawn in their place carry data-ds-placeholder.
Adds with it: ascii-drift, creative-card, pricing-panels-block
Props
The web component takes the same as attributes or properties (<spyglass-product-visual>); title is heading there.
<ProductVisual>
| Prop | Type | Default |
|---|---|---|
kind | K | |
data | ProductVisualDataMap[K] The kind's content; Acme by default. | |
texture | number | false The ASCII field's position, 0 to 3 (a product page alternates by row), or false for none. | 0 |
fill | boolean Fill the box it is in (its height, no 4:3, no panel of its own): the header's live card. | false |
className | string |
Examples
The same example in React and as web components; both render identically.
'use client'
import { ProductVisual } from '@/react/components/site/ProductVisual'
// A brand, a creative and a landing page record, each cycling through its sets beside its picture. Acme's copy; every picture is a neutral shape.
export default function Records() {
return (
<div className="flex w-192 max-w-full flex-col gap-6">
<ProductVisual kind="brand-record" texture={0} />
<ProductVisual kind="creative-record" texture={1} />
<ProductVisual kind="page-record" texture={2} />
</div>
)
}<!-- A brand, a creative and a landing page record, each cycling through its sets beside its picture. Acme's copy; every picture is a neutral shape. -->
<div class="flex w-192 max-w-full flex-col gap-6">
<spyglass-product-visual kind="brand-record" texture="0"></spyglass-product-visual>
<spyglass-product-visual kind="creative-record" texture="1"></spyglass-product-visual>
<spyglass-product-visual kind="page-record" texture="2"></spyglass-product-visual>
</div>'use client'
import { ProductVisual } from '@/react/components/site/ProductVisual'
// A creator record, a tagged post record and a post with its top comments. Acme's copy; every picture is a neutral shape.
export default function People() {
return (
<div className="flex w-192 max-w-full flex-col gap-6">
<ProductVisual kind="creator-record" texture={0} />
<ProductVisual kind="tagged-record" texture={1} />
<ProductVisual kind="comment-thread" texture={2} />
</div>
)
}<!-- A creator record, a tagged post record and a post with its top comments. Acme's copy; every picture is a neutral shape. -->
<div class="flex w-192 max-w-full flex-col gap-6">
<spyglass-product-visual kind="creator-record" texture="0"></spyglass-product-visual>
<spyglass-product-visual kind="tagged-record" texture="1"></spyglass-product-visual>
<spyglass-product-visual kind="comment-thread" texture="2"></spyglass-product-visual>
</div>'use client'
import { ProductVisual } from '@/react/components/site/ProductVisual'
// Adding a brand and a creator by their handles, and comments sorted into themes. Acme's copy; every picture is a neutral shape.
export default function Add() {
return (
<div className="flex w-192 max-w-full flex-col gap-6">
<ProductVisual kind="add-account" texture={0} />
<ProductVisual kind="add-creator" texture={1} />
<ProductVisual kind="comment-themes" texture={2} />
</div>
)
}<!-- Adding a brand and a creator by their handles, and comments sorted into themes. Acme's copy; every picture is a neutral shape. -->
<div class="flex w-192 max-w-full flex-col gap-6">
<spyglass-product-visual kind="add-account" texture="0"></spyglass-product-visual>
<spyglass-product-visual kind="add-creator" texture="1"></spyglass-product-visual>
<spyglass-product-visual kind="comment-themes" texture="2"></spyglass-product-visual>
</div>'use client'
import { ProductVisual } from '@/react/components/site/ProductVisual'
// A creator search narrowing by filters, and two searches narrowing a grid of results. Acme's copy; every picture is a neutral shape.
export default function Filters() {
return (
<div className="flex w-192 max-w-full flex-col gap-6">
<ProductVisual kind="creator-filters" texture={0} />
<ProductVisual kind="filter-narrow" texture={1} />
<ProductVisual kind="posts-narrow" texture={2} />
</div>
)
}<!-- A creator search narrowing by filters, and two searches narrowing a grid of results. Acme's copy; every picture is a neutral shape. -->
<div class="flex w-192 max-w-full flex-col gap-6">
<spyglass-product-visual kind="creator-filters" texture="0"></spyglass-product-visual>
<spyglass-product-visual kind="filter-narrow" texture="1"></spyglass-product-visual>
<spyglass-product-visual kind="posts-narrow" texture="2"></spyglass-product-visual>
</div>'use client'
import { ProductVisual } from '@/react/components/site/ProductVisual'
// Who posts with a brand and who tags it, by window. Acme's copy; every picture is a neutral shape.
export default function Timelines() {
return (
<div className="flex w-192 max-w-full flex-col gap-6">
<ProductVisual kind="collabs-timeline" texture={0} />
<ProductVisual kind="tagged-timeline" texture={1} />
</div>
)
}<!-- Who posts with a brand and who tags it, by window. Acme's copy; every picture is a neutral shape. -->
<div class="flex w-192 max-w-full flex-col gap-6">
<spyglass-product-visual kind="collabs-timeline" texture="0"></spyglass-product-visual>
<spyglass-product-visual kind="tagged-timeline" texture="1"></spyglass-product-visual>
</div>'use client'
import { ProductVisual } from '@/react/components/site/ProductVisual'
// Ranked sheets with a two-way switch: the media mix, campaigns and landing pages. Acme's copy; every picture is a neutral shape.
export default function Sheets() {
return (
<div className="flex w-192 max-w-full flex-col gap-6">
<ProductVisual kind="media-mix" texture={0} />
<ProductVisual kind="campaigns" texture={1} />
<ProductVisual kind="pages-switch" texture={2} />
</div>
)
}<!-- Ranked sheets with a two-way switch: the media mix, campaigns and landing pages. Acme's copy; every picture is a neutral shape. -->
<div class="flex w-192 max-w-full flex-col gap-6">
<spyglass-product-visual kind="media-mix" texture="0"></spyglass-product-visual>
<spyglass-product-visual kind="campaigns" texture="1"></spyglass-product-visual>
<spyglass-product-visual kind="pages-switch" texture="2"></spyglass-product-visual>
</div>'use client'
import { ProductVisual } from '@/react/components/site/ProductVisual'
// The links board and the patterns switch. Acme's copy; every picture is a neutral shape.
export default function Board() {
return (
<div className="flex w-192 max-w-full flex-col gap-6">
<ProductVisual kind="links-board" texture={0} />
<ProductVisual kind="patterns-switch" texture={1} />
</div>
)
}<!-- The links board and the patterns switch. Acme's copy; every picture is a neutral shape. -->
<div class="flex w-192 max-w-full flex-col gap-6">
<spyglass-product-visual kind="links-board" texture="0"></spyglass-product-visual>
<spyglass-product-visual kind="patterns-switch" texture="1"></spyglass-product-visual>
</div>Source
'use client'
import { useEffect, useRef } from 'react'
import { mountProductVisual, productVisualCss, type ProductVisualDataMap, type ProductVisualKind } from '@/lib/product-visual'
import { cn } from '@/react/lib/cn'
// The site's product visuals (pages/Products/visuals, v2/V2Features LinksBoard and PatternsSwitch): the 4:3 stage a
// product page's feature row shows, a #262626 panel with the 8px corner, the ASCII field around its clear middle and one
// small looping scene of the product. `kind` picks the scene: a record cycling through its sets beside a picture
// (brand, creative, page, creator, tagged, a post's comment thread), adding an account (added, indexing, ready),
// comment themes, a creator search narrowing by filters, a search narrowing a grid of results, a timeline of who posts
// with a brand by window, a ranked sheet with a two-way switch (media mix, campaigns, landing pages), the links board
// and the patterns switch. `data` takes the kind's content (Acme by default; every picture is a neutral shape unless
// you pass one). The scenes step at the site's reading pace while on screen and rest with reduced motion; the ranked
// sheet's and the patterns' tabs can be pressed (arrow keys move between them) and stop the loop on that view.
// The stage measures itself (its width picks the site's 440 and 560 layouts), so it fits any column.
export interface ProductVisualProps<K extends ProductVisualKind = ProductVisualKind> {
kind: K
/** The kind's content; Acme by default. */
data?: ProductVisualDataMap[K]
/** The ASCII field's position, 0 to 3 (a product page alternates by row), or false for none. */
texture?: number | false
/** Fill the box it is in (its height, no 4:3, no panel of its own): the header's live card. */
fill?: boolean
className?: string
}
export function ProductVisual<K extends ProductVisualKind>({ kind, data, texture = 0, fill = false, className }: ProductVisualProps<K>) {
const ref = useRef<HTMLDivElement>(null)
const key = JSON.stringify(data ?? null)
useEffect(() => {
const stage = ref.current
if (!stage) return
return mountProductVisual(stage, { kind, data: key === 'null' ? undefined : (JSON.parse(key) as ProductVisualDataMap[K]), texture })
}, [kind, key, texture])
return (
<div ref={ref} data-ds="product-visual" data-kind={kind} data-fill={fill || undefined} className={cn('ds-pv', className)}>
<style href="ds-product-visual" precedence="ds">{productVisualCss}</style>
</div>
)
}
export default ProductVisual// The product visuals, framework-free: both flavors hand this a stage element and a kind, and it builds the visual's
// markup and runs its loop, so React and the web component render the same nodes. Ported from the site's
// pages/Products/visuals (records, add, themes, filters, narrow, timeline, ranked sheet) and v2/V2Features (links
// board, patterns switch); the feature rows on a product page each show one.
//
// Every loop paces like the site's (components/loopPacing): it starts once the stage is on screen and the tab is
// visible, holds its first step for --ds-read-first, then changes and holds for --ds-read-hold each time; with reduced
// motion it stays on its resting step. A switch the visitor can press (the ranked sheet's and the patterns' tabs) stops
// the loop on the view they chose. The records run the shared creative sequence (lib/panels-motion.ts) in its reading
// pace. The links board draws its own timeline (lib/product-visual-board.ts); it holds its composed frame first, so a
// visitor sees the board whole before it clears.
import { startPanelsMotion } from '@/lib/panels-motion'
import { ASCII_TEXTURE } from '@/lib/textures'
import {
BOARD_AVATAR, BOARD_SCENE, BOARD_STEP, BOARD_STILL, BOARD_TILES, BOARD_VIEW,
boardAvatarAt, boardChipAt, boardTileAt, boardZoomAt,
} from '@/lib/product-visual-board'
import {
productVisualDefaults,
type AddData, type BoardData, type FiltersData, type NarrowData, type PatternsData, type ProductVisualDataMap,
type ProductVisualKind, type RecordData, type SheetData, type ThemesData, type ThreadData, type TimelineData,
} from '@/lib/product-visual-data'
import { toSlot, type ImageSlot } from '@/lib/image'
export * from '@/lib/product-visual-data'
export { productVisualCss } from '@/lib/product-visual-css'
/** Where the stage's ASCII field sits, by feature row (the site's ASCII_AT). */
export const productVisualAsciiAt = ['0 0', '40% 24%', '64% 56%', '20% 80%']
type Kid = Node | string | number | null | undefined | false | Kid[]
type Attrs = Record<string, string | number | boolean | null | undefined>
function el(tag: string, attrs: Attrs = {}, ...kids: Kid[]): HTMLElement {
const node = document.createElement(tag)
for (const [k, v] of Object.entries(attrs)) {
if (v === undefined || v === null || v === false) continue
node.setAttribute(k, v === true ? '' : String(v))
}
append(node, kids)
return node
}
function append(node: Node, kids: Kid[]) {
for (const kid of kids) {
if (kid === null || kid === undefined || kid === false) continue
if (Array.isArray(kid)) append(node, kid)
else node.appendChild(typeof kid === 'string' || typeof kid === 'number' ? document.createTextNode(String(kid)) : kid)
}
}
const SVG = 'http://www.w3.org/2000/svg'
function svg(paths: string[], circle = false): SVGElement {
const s = document.createElementNS(SVG, 'svg')
s.setAttribute('class', 'ds-pv-icon')
s.setAttribute('viewBox', '0 0 16 16')
s.setAttribute('aria-hidden', 'true')
if (circle) {
const c = document.createElementNS(SVG, 'circle')
c.setAttribute('cx', '7')
c.setAttribute('cy', '7')
c.setAttribute('r', '4.5')
s.appendChild(c)
}
for (const d of paths) {
const p = document.createElementNS(SVG, 'path')
p.setAttribute('d', d)
s.appendChild(p)
}
return s
}
const searchIcon = () => svg(['m10.5 10.5 3 3'], true)
const filterIcon = () => svg(['M2.5 4.5h11M4.5 8h7M6.5 11.5h3'])
const ANGLES = [160, 200, 135, 225, 180, 150, 210, 120, 170]
/** A picture: the image when there is one (a src or { src, alt, fit, position }), else a neutral shape (its angle
* varies by slot), marked as a placeholder. */
function pic(image: string | ImageSlot | undefined, i: number, attrs: Attrs = {}, at: { x?: number; y?: number; zoom?: number } = {}) {
const style = `--pv-ph-a: ${ANGLES[i % ANGLES.length]}deg`
const slot = toSlot(image)
const x = at.x ?? 50
const y = at.y ?? 50
const where = slot.position ?? `${x}% ${y}%`
const img = slot.src
? el('img', { class: 'ds-pv-img', src: slot.src, alt: slot.alt ?? '', loading: 'lazy', decoding: 'async', style: `object-position: ${where}; transform-origin: ${where}${slot.fit ? `; object-fit: ${slot.fit}` : ''}${at.zoom ? `; scale: ${at.zoom}` : ''}` })
: el('span', { class: 'ds-pv-ph', 'data-ds-placeholder': '' })
return el('span', { class: 'ds-pv-pic', style, ...attrs }, img)
}
/** A round mark: the image, or the initial. */
function mark(src: string | undefined, initial: string | undefined, tone?: 'inset' | 'row', cls = 'ds-pv-mark') {
return el('span', { class: cls, 'data-tone': tone }, src ? el('img', { src, alt: '', loading: 'lazy' }) : el('span', { 'aria-hidden': 'true' }, initial ?? ''))
}
const sr = (text?: string) => (text ? el('p', { class: 'ds-pv-sr' }, text) : null)
// ----- Pacing -----
const REDUCED = '(prefers-reduced-motion: reduce)'
const CHANGE = 700 // the site's --dur-loop-change: a step's change, before its hold starts
const ms = (raw: string, fallback: number) => {
const v = raw.trim()
const n = parseFloat(v)
if (!Number.isFinite(n)) return fallback
return v.endsWith('ms') ? n : v.endsWith('s') ? n * 1000 : n
}
const pacing = (root: Element) => {
const cs = getComputedStyle(root)
return { first: ms(cs.getPropertyValue('--ds-read-first'), 3800), hold: ms(cs.getPropertyValue('--ds-read-hold'), 2800) }
}
interface Cycle {
choose(i: number): void
shown(): number
dispose(): void
}
/** Steps 0..n-1 from `rest` while on screen; `apply` draws a step. With reduced motion it shows `still`. */
function cycle(root: HTMLElement, n: number, rest: number, apply: (i: number) => void, still = rest): Cycle {
const reduce = window.matchMedia(REDUCED)
let step = rest
let inView = false
let chosen = false
let fresh = true
let timer = 0
let key = ''
let drawn = -1
const shown = () => (reduce.matches && !chosen ? still : step)
const sync = () => {
const now = shown()
if (now !== drawn) {
drawn = now
apply(now)
}
const cycling = inView && !document.hidden && !reduce.matches && !chosen && n > 1
const next = `${cycling}:${step}`
if (next === key) return
key = next
window.clearTimeout(timer)
if (!cycling) {
fresh = true
return
}
const p = pacing(root)
timer = window.setTimeout(() => {
fresh = false
step = (step + 1) % n
sync()
}, fresh ? p.first : CHANGE + p.hold)
}
const io = new IntersectionObserver(([e]) => {
inView = e.isIntersecting
sync()
}, { threshold: 0.15 })
io.observe(root)
document.addEventListener('visibilitychange', sync)
reduce.addEventListener('change', sync)
sync()
return {
choose(i) {
if (i === shown()) return
step = i
chosen = true
sync()
},
shown,
dispose() {
window.clearTimeout(timer)
io.disconnect()
document.removeEventListener('visibilitychange', sync)
reduce.removeEventListener('change', sync)
},
}
}
/** The switch's indicator: a pill under the chosen of n equal segments. */
function steps(labels: string[], at: number, attrs: Attrs = {}, tab?: { panel: string; ids: string[] }) {
const items = labels.map((label, i) =>
tab
? el('button', { type: 'button', role: 'tab', id: tab.ids[i], 'aria-controls': tab.panel, class: 'ds-pv-step' }, label)
: el('span', { class: 'ds-pv-step' }, label),
)
const row = el('div', { class: 'ds-pv-steps', style: `--n: ${labels.length}; --i: ${at}`, ...attrs }, el('span', { class: 'ds-pv-indicator', 'aria-hidden': 'true' }), items)
const set = (i: number) => {
row.style.setProperty('--i', String(i))
items.forEach((item, k) => {
if (tab) {
item.setAttribute('aria-selected', String(k === i))
item.tabIndex = k === i ? 0 : -1
} else item.toggleAttribute('data-on', k === i)
})
}
set(at)
return { row, items, set }
}
const on = (nodes: Element[], i: number) => nodes.forEach((n, k) => n.toggleAttribute('data-on', k === i))
let uid = 0
type Built = { node: HTMLElement; start(root: HTMLElement): () => void }
const noop = () => () => () => {}
// ----- Records: brand, creative, page, creator, tagged -----
function record(kind: ProductVisualKind, d: RecordData): Built {
const variant = kind === 'creator-record' || kind === 'tagged-record' ? 'creator' : 'brand'
const clip = kind === 'page-record'
const stack = (rank: number, cls: string, render: (k: number) => Kid) => el('span', { class: 'ds-pv-stack' }, d.sets.map((_, k) => el('span', { class: cls, 'data-set': k, 'data-rank': rank }, render(k))))
const motion = el('div', { class: 'ds-pv-record', 'data-variant': variant, 'aria-hidden': 'true' },
el('span', { class: 'ds-pv-picture' }, d.sets.map((s, k) => pic(s.picture, k, { 'data-set': k, 'data-rank': 0 }))),
el('span', { class: 'ds-pv-panel' },
stack(1, 'ds-pv-who', (k) => {
const s = d.sets[k]
return [s.mark ? mark(s.mark.src, s.mark.initial ?? s.name[0]) : null, el('span', { class: 'ds-pv-names', 'data-clip': clip }, el('span', { class: 'ds-pv-name' }, s.name), el('span', { class: 'ds-pv-handle' }, s.sub))]
}),
d.labels.map((label, i) => el('span', { class: 'ds-pv-row ds-pv-rule' }, el('span', { class: 'ds-pv-label' }, label), stack(i + 2, 'ds-pv-value', (k) => d.sets[k].values[i] ?? ''))),
),
)
const node = el('div', { class: 'ds-pv-root ds-pv-center' }, motion, sr(d.summary))
return { node, start: () => startPanelsMotion(motion, { reading: true }) }
}
function thread(d: ThreadData): Built {
const stack = (rank: number, cls: string, render: (k: number) => Kid) => el('span', { class: 'ds-pv-stack' }, d.sets.map((_, k) => el('span', { class: cls, 'data-set': k, 'data-rank': rank }, render(k))))
const rows = Math.max(...d.sets.map((s) => s.comments.length))
const motion = el('div', { class: 'ds-pv-record', 'data-variant': 'thread', 'aria-hidden': 'true' },
el('span', { class: 'ds-pv-picture' }, d.sets.map((s, k) => pic(s.picture, k, { 'data-set': k, 'data-rank': 0 }))),
el('span', { class: 'ds-pv-panel' },
stack(1, 'ds-pv-who', (k) => [el('span', { class: 'ds-pv-name' }, d.handle), el('span', { class: 'ds-pv-handle' }, d.sets[k].meta)]),
Array.from({ length: rows }, (_, i) => el('span', { class: 'ds-pv-row ds-pv-rule', 'data-thread': true }, stack(i + 2, 'ds-pv-comment', (k) => {
const c = d.sets[k].comments[i]
if (!c) return null
return [mark(c.avatar, c.handle[0]?.toUpperCase(), 'inset'), el('span', { class: 'ds-pv-body' }, el('span', { class: 'ds-pv-by' }, el('span', {}, c.handle), el('span', {}, c.likes)), el('span', { class: 'ds-pv-text ds-pv-ellipsis' }, c.text))]
}))),
),
)
motion.querySelectorAll('.ds-pv-stack > .ds-pv-who').forEach((n) => n.setAttribute('data-column', ''))
const node = el('div', { class: 'ds-pv-root ds-pv-center' }, motion, sr(d.summary))
return { node, start: () => startPanelsMotion(motion, { reading: true }) }
}
// ----- Add an account -----
function add(d: AddData): Built {
const last = d.steps.length - 1
const s = steps(d.steps, last)
const a = d.account
const node = el('div', { class: 'ds-pv-root ds-pv-clip ds-pv-fade ds-pv-add', 'data-step': last },
el('div', { class: 'ds-pv-sheet', 'data-tight': true, 'aria-hidden': 'true', inert: true },
el('div', { class: 'ds-pv-head' }, el('span', { class: 'ds-pv-strong' }, d.title), el('span', { class: 'ds-pv-sub' }, d.free)),
el('div', { class: 'ds-pv-field' }, d.inputs.map((input) => el('span', { class: 'ds-pv-input' }, input))),
el('div', { class: 'ds-pv-control' }, s.row),
el('div', { class: 'ds-pv-account' }, el('div', {}, el('div', { class: 'ds-pv-account-row' },
mark(a.avatar, a.initial),
el('span', { class: 'ds-pv-details' },
el('span', { class: 'ds-pv-bars' }, el('span', { class: 'ds-pv-bar' }), el('span', { class: 'ds-pv-bar' })),
el('span', { class: 'ds-pv-text-block' }, el('span', { class: 'ds-pv-name' }, a.name), el('span', { class: 'ds-pv-sub ds-pv-ellipsis' }, `${a.category}, ${a.followers}`)),
),
))),
),
sr(d.summary),
)
return { node, start: (root) => cycle(root, d.steps.length, last, (i) => { node.dataset.step = String(i); s.set(i) }).dispose }
}
// ----- Comment themes -----
function themes(d: ThemesData): Built {
const s = steps(d.themes.map((t) => t.label), 0)
const shares = d.themes.map((t) => el('span', { class: 'ds-pv-share' }, t.share))
const views = d.themes.map((t) => el('div', { class: 'ds-pv-view' }, t.comments.map((c) => el('div', { class: 'ds-pv-theme-comment' },
mark(c.avatar, c.handle[0]?.toUpperCase(), 'inset'),
el('span', { class: 'ds-pv-body' }, el('span', {}, c.handle), el('span', { class: 'ds-pv-ellipsis' }, c.text)),
))))
const node = el('div', { class: 'ds-pv-root ds-pv-clip ds-pv-fade ds-pv-add ds-pv-themes' },
el('div', { class: 'ds-pv-sheet', 'data-tight': true, 'aria-hidden': 'true' },
el('div', { class: 'ds-pv-head' }, el('span', { class: 'ds-pv-strong' }, d.title), el('span', { class: 'ds-pv-shares' }, shares)),
el('div', { class: 'ds-pv-control' }, s.row),
el('div', { class: 'ds-pv-views' }, views),
),
sr(d.summary),
)
const draw = (i: number) => { s.set(i); on(shares, i); on(views, i) }
draw(0)
return { node, start: (root) => cycle(root, d.themes.length, 0, draw).dispose }
}
// ----- Creator filters -----
function filters(d: FiltersData): Built {
const n = Math.max(...d.filters.map((f) => f.step)) + 1
const chips = d.filters.map((f) => el('span', { class: 'ds-pv-chip' }, el('span', {}, f.label), el('span', {}, f.value)))
const rows = d.rows.map((r) => el('div', { class: 'ds-pv-fold' }, el('div', {}, el('div', { class: 'ds-pv-face ds-pv-rule' },
mark(r.avatar, r.initial, 'row'),
el('span', { class: 'ds-pv-who-col' }, el('span', { class: 'ds-pv-strong ds-pv-ellipsis' }, r.handle), el('span', { class: 'ds-pv-sub ds-pv-ellipsis' }, r.city)),
el('span', { class: 'ds-pv-figure' }, r.followers),
))))
const node = el('div', { class: 'ds-pv-root ds-pv-clip ds-pv-fade ds-pv-filters' },
el('div', { class: 'ds-pv-sheet', 'aria-hidden': 'true' },
el('div', { class: 'ds-pv-query' }, searchIcon(), el('span', {}, d.query)),
el('div', { class: 'ds-pv-chips' }, chips),
el('div', {}, rows),
),
sr(d.summary),
)
const draw = (i: number) => {
d.filters.forEach((f, k) => chips[k].toggleAttribute('data-on', f.step > 0 && i >= f.step))
d.rows.forEach((r, k) => rows[k].toggleAttribute('data-out', r.out !== 0 && i >= r.out))
}
draw(n - 1)
return { node, start: (root) => cycle(root, n, n - 1, draw).dispose }
}
// ----- Narrow -----
function narrow(d: NarrowData): Built {
const n = d.counts.length
const counts = d.counts.map((c) => el('span', {}, c))
const pills = d.filters.map((f) => el('span', { class: 'ds-pv-pill' }, f))
const tiles = d.tiles.map((t, i) => pic(t, i))
const node = el('div', { class: 'ds-pv-root ds-pv-center' },
el('div', { class: 'ds-pv-narrow', 'aria-hidden': 'true' },
el('div', { class: 'ds-pv-search' }, searchIcon(), el('span', { class: 'ds-pv-ellipsis' }, d.query), el('span', { class: 'ds-pv-counts' }, counts)),
el('div', { class: 'ds-pv-narrow-filters' }, filterIcon(), pills),
el('div', { class: 'ds-pv-grid' }, tiles.map((t) => el('span', { class: 'ds-pv-slot' }, t))),
),
sr(d.summary),
)
const draw = (i: number) => {
on(counts, i)
pills.forEach((p, k) => p.toggleAttribute('data-on', i > k))
d.tiles.forEach((t, k) => tiles[k].toggleAttribute('data-out', Boolean(t.out) && i >= t.out))
}
draw(n - 1)
return { node, start: (root) => cycle(root, n, n - 1, draw).dispose }
}
// ----- Timeline -----
const SCALE = '.'.repeat(64)
const RUN = '='.repeat(64)
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']
const day = (iso: string) => Date.parse(`${iso}T00:00:00Z`)
function timeline(d: TimelineData): Built {
const from = day(d.axis.from)
const span = day(d.axis.to) - from
const at = (iso: string) => (day(iso) - from) / span
const year = d.today.slice(0, 4)
const short = (iso: string) => {
const text = `${Number(iso.slice(8, 10))} ${MONTHS[Number(iso.slice(5, 7)) - 1]}`
return iso.startsWith(year) ? text : `${text} ${iso.slice(0, 4)}`
}
const rest = Math.min(1, d.windows.length - 1)
const s = steps(d.windows.map((w) => w.label), rest)
const rows = d.rows.map((r, i) => {
const start = at(r.first)
const length = Math.max(at(r.latest) - start, 0)
return el('div', { class: 'ds-pv-fold' }, el('div', {}, el('div', { class: 'ds-pv-face' },
el('span', { class: 'ds-pv-thumb' }, pic(r.picture, i)),
el('span', { class: 'ds-pv-who-col' }, el('span', { class: 'ds-pv-strong ds-pv-ellipsis' }, r.name), el('span', { class: 'ds-pv-sub ds-pv-ellipsis' }, `${short(r.first)} to ${short(r.latest)}`)),
el('span', { class: 'ds-pv-glyphs ds-pv-track' }, SCALE, el('span', { class: 'ds-pv-window' }, SCALE), el('span', { class: 'ds-pv-run', style: `--start: ${start}; --span: ${length}` }, RUN)),
el('span', { class: 'ds-pv-count' }, r.posts),
)))
})
const node = el('div', { class: 'ds-pv-root ds-pv-clip ds-pv-fade ds-pv-timeline' },
el('div', { class: 'ds-pv-sheet', 'aria-hidden': 'true' },
el('div', { class: 'ds-pv-head' }, el('span', { class: 'ds-pv-brand' }, mark(d.brand.mark, d.brand.name[0], undefined, 'ds-pv-logo'), el('span', { class: 'ds-pv-strong' }, d.brand.name)), el('span', { class: 'ds-pv-sub' }, d.title)),
el('div', { class: 'ds-pv-control' }, s.row),
el('div', {}, rows),
el('div', { class: 'ds-pv-axis' }, d.axis.labels.map((l) => el('span', {}, l))),
),
sr(d.summary),
)
const draw = (i: number) => {
const w = d.windows[i]?.from ?? null
node.style.setProperty('--shade', String(w ? 1 - at(w) : 1))
s.set(i)
d.rows.forEach((r, k) => rows[k].toggleAttribute('data-out', Boolean(w) && r.first < (w as string)))
}
draw(rest)
return { node, start: (root) => cycle(root, d.windows.length, rest, draw).dispose }
}
// ----- Ranked sheet -----
const SHARE = '='.repeat(64)
function sheet(d: SheetData): Built {
const id = `ds-pv-${++uid}`
const n = d.views.length
const tabs = d.views.map((label, i) => el('button', { type: 'button', role: 'tab', id: `${id}-tab-${i}`, 'aria-controls': `${id}-panel`, class: 'ds-pv-tab' }, label))
const pill = el('span', { class: 'ds-pv-tray-pill', 'aria-hidden': 'true' })
const tray = el('div', { role: 'tablist', 'aria-label': `${d.brand.name}: ${d.switchLabel}`, class: 'ds-pv-tray' }, pill, tabs)
const slots = Math.max(...d.views.map((_, v) => d.rows.filter((r) => r.at[v] !== null).length))
const rows = d.rows.map((r, k) => {
const values = r.values.map((v) => el('span', {}, v))
const fill = r.fill ? el('span', { class: 'ds-pv-fill' }, SHARE) : null
const li = el('li', { class: 'ds-pv-rank', 'data-muted': r.muted },
el('span', { class: 'ds-pv-rank-thumb' }, pic(r.picture, k)),
el('span', { class: 'ds-pv-rank-main' },
el('span', { class: 'ds-pv-rank-line' }, el('span', { class: 'ds-pv-name-cell ds-pv-ellipsis' }, r.name), r.tag ? el('span', { class: 'ds-pv-sub' }, r.tag) : null),
fill ? el('span', { class: 'ds-pv-glyphs ds-pv-fill-track' }, SCALE, fill) : null,
),
el('span', { class: 'ds-pv-values' }, values),
)
return { li, values, fill }
})
const summary = el('p', { class: 'ds-pv-sr' })
const panel = el('div', { role: 'tabpanel', id: `${id}-panel` }, el('ol', { class: 'ds-pv-ranked', style: `--slots: ${slots}`, 'aria-hidden': 'true' }, rows.map((r) => r.li)), summary)
const node = el('div', { class: 'ds-pv-root ds-pv-clip ds-pv-fade ds-pv-sheetlist' },
el('div', { class: 'ds-pv-sheet' },
el('div', { class: 'ds-pv-sheet-head' }, mark(d.brand.logo, d.brand.name[0], undefined, 'ds-pv-logo'), el('span', { class: 'ds-pv-strong' }, d.brand.name), el('span', { class: 'ds-pv-sub ds-pv-ellipsis ds-pv-note' }, d.brand.note), tray),
panel,
),
)
const measure = () => {
const tab = tabs.find((t) => t.getAttribute('aria-selected') === 'true')
if (!tab) return
pill.style.setProperty('--x', `${tab.offsetLeft}px`)
pill.style.setProperty('--w', `${tab.offsetWidth}px`)
}
const draw = (i: number) => {
tabs.forEach((t, k) => {
t.setAttribute('aria-selected', String(k === i))
t.tabIndex = k === i ? 0 : -1
})
panel.setAttribute('aria-labelledby', tabs[i].id)
measure()
d.rows.forEach((r, k) => {
const place = r.at[i]
rows[k].li.toggleAttribute('data-out', place === null)
rows[k].li.style.setProperty('--at', String(place ?? r.at.find((a) => a !== null) ?? 0))
on(rows[k].values, i)
rows[k].fill?.style.setProperty('--share', String(r.fill?.[i] ?? 0))
})
summary.textContent = d.summary?.[i] ?? ''
}
draw(0)
return {
node,
start(root) {
const c = cycle(root, n, 0, draw, 0)
const choose = (i: number) => c.choose(i)
tabs.forEach((t, i) => t.addEventListener('click', () => choose(i)))
tray.addEventListener('keydown', (e) => keys(e, c.shown(), n, (to) => { choose(to); tabs[to].focus() }))
const ro = new ResizeObserver(measure)
ro.observe(tray)
return () => { c.dispose(); ro.disconnect() }
},
}
}
function keys(e: KeyboardEvent, at: number, n: number, go: (to: number) => void) {
const to = e.key === 'ArrowRight' ? (at + 1) % n : e.key === 'ArrowLeft' ? (at + n - 1) % n : e.key === 'Home' ? 0 : e.key === 'End' ? n - 1 : null
if (to === null) return
e.preventDefault()
go(to)
}
// ----- Patterns switch -----
const SHARE_MAX = 40
function patterns(d: PatternsData): Built {
const id = `ds-pv-${++uid}`
const n = d.views.length
const ids = d.views.map((_, i) => `${id}-tab-${i}`)
const s = steps(d.views.map((v) => v.label), 0, { role: 'tablist', 'aria-label': `${d.brand} patterns` }, { panel: `${id}-panel`, ids })
const slots = Math.max(...d.views.map((v) => v.rows.length))
const names: HTMLElement[][] = []
const values: HTMLElement[][] = []
const fills: HTMLElement[] = []
const set = el('ol', { class: 'ds-pv-set' }, Array.from({ length: slots }, (_, slot) => {
names[slot] = d.views.map((v) => el('span', {}, v.rows[slot]?.name ?? ''))
values[slot] = d.views.map((v) => el('span', {}, v.rows[slot] ? `${v.rows[slot].share}%` : ''))
fills[slot] = el('span', { class: 'ds-pv-bar-fill' })
return el('li', { class: 'ds-pv-share-row' }, el('span', { class: 'ds-pv-swap' }, names[slot]), el('span', { class: 'ds-pv-swap' }, values[slot]), el('span', { class: 'ds-pv-bar-track' }, fills[slot]))
}))
const summary = el('p', { class: 'ds-pv-sr' })
const panel = el('div', { role: 'tabpanel', id: `${id}-panel` }, set, summary)
const ads = d.ads.map((a, i) => el('div', { class: 'ds-pv-ad' }, pic(a, i + 3, {}, { x: a.x }), el('span', { class: 'ds-pv-badge' }, '1')))
const node = el('div', { class: 'ds-pv-root ds-pv-clip ds-pv-fade ds-pv-patterns' },
el('div', { class: 'ds-pv-sheet' },
el('div', { class: 'ds-pv-head' }, mark(d.logo, d.brand[0], undefined, 'ds-pv-logo'), el('span', { class: 'ds-pv-strong' }, d.brand), el('span', { class: 'ds-pv-sub' }, d.window)),
el('div', { class: 'ds-pv-control' }, s.row),
panel,
el('div', { class: 'ds-pv-ads', 'aria-hidden': 'true' }, ads),
),
)
const draw = (i: number) => {
const view = d.views[i]
s.set(i)
panel.setAttribute('aria-labelledby', ids[i])
set.setAttribute('aria-label', `Top ${view.label.toLowerCase()}, share of ${d.brand}'s ads`)
for (let slot = 0; slot < slots; slot++) {
names[slot].forEach((x, k) => { x.toggleAttribute('data-on', k === i); x.setAttribute('aria-hidden', String(k !== i)) })
values[slot].forEach((x, k) => { x.toggleAttribute('data-on', k === i); x.setAttribute('aria-hidden', String(k !== i)) })
fills[slot].style.transform = `scaleX(${Math.min((view.rows[slot]?.share ?? 0) / SHARE_MAX, 1)})`
}
ads.forEach((a, k) => a.toggleAttribute('data-top', view.top.includes(k)))
summary.textContent = `${d.brand}, ${d.window.toLowerCase()}. Top ${view.label.toLowerCase().replace(/s$/, '')}: ${view.rows[0]?.name ?? ''}, ${view.rows[0]?.share ?? 0}% of ads.`
}
draw(0)
return {
node,
start(root) {
const c = cycle(root, n, 0, draw, 0)
s.items.forEach((t, i) => t.addEventListener('click', () => c.choose(i)))
s.row.addEventListener('keydown', (e) => keys(e, c.shown(), n, (to) => { c.choose(to); s.items[to].focus() }))
return c.dispose
},
}
}
// ----- Links board -----
function board(d: BoardData): Built {
const scenes = d.scenes.map((s, n) => {
const t0 = BOARD_TILES[0]
const tileStyle = (t: { x: number; y: number; w: number; h: number }) => `--x: ${t.x}; --y: ${t.y}; --w: ${t.w}; --h: ${t.h}`
const page = el('div', { class: 'ds-pv-tile', style: tileStyle(t0) },
pic(s.page, n, {}, { y: s.page.y }),
el('div', { class: 'ds-pv-page-ui' },
el('span', { class: 'ds-pv-ads-count' }, s.page.ads),
el('span', { class: 'ds-pv-url-bar' }, mark(s.logo, s.brand[0], undefined, 'ds-pv-logo'), el('span', { class: 'ds-pv-ellipsis' }, el('span', { class: 'ds-pv-sub' }, s.page.domain), s.page.path)),
),
)
const tiles = BOARD_TILES.slice(1).map((t, i) => el('div', { class: 'ds-pv-tile', style: tileStyle(t) }, pic(s.tiles[i], n + i + 1, {}, s.tiles[i] ?? {})))
const avatars = [0, 1].map((i) => el('div', { class: 'ds-pv-avatar', style: `--cx: ${BOARD_AVATAR.x[i]}; --cy: ${BOARD_AVATAR.y}; --d: ${BOARD_AVATAR.d}` }, pic(s.creators[i]?.avatar, n + i + 4)))
const chips = [0, 1].map((i) => el('span', { class: 'ds-pv-handle-chip', style: `--cx: ${BOARD_AVATAR.x[i]}; --edge: ${BOARD_AVATAR.y + BOARD_AVATAR.d / 2}` }, s.creators[i]?.handle ?? ''))
const scene = el('div', { class: 'ds-pv-scene', style: `visibility: ${n === 0 ? 'visible' : 'hidden'}` }, page, tiles, avatars.map((a, i) => [a, chips[i]]))
return { scene, tiles: [page, ...tiles], avatars, chips }
})
const view = el('div', { class: 'ds-pv-boardview' }, scenes.map((s) => s.scene))
const canvas = el('div', { class: 'ds-pv-canvas', 'aria-hidden': 'true' }, view)
const node = el('div', { class: 'ds-pv-board' }, canvas,
el('div', { class: 'ds-pv-sr' }, d.scenes.map((s) => el('p', {}, `${s.brand}: ${s.page.ads.replace('point here', 'point to')} ${s.page.domain}${s.page.path}. Creators it works with: ${s.creators.map((c) => c.handle).join(' and ')}.`))),
)
const loop = BOARD_SCENE * scenes.length
return {
node,
start(root) {
let u = 1
const measure = () => (u = Math.max(node.clientWidth, node.clientHeight) / BOARD_VIEW)
let shown = 0
let drawn = -1
const draw = (f: number) => {
if (f === drawn) return
drawn = f
const n = Math.floor(f / BOARD_SCENE) % scenes.length
const k = f - Math.floor(f / BOARD_SCENE) * BOARD_SCENE
if (n !== shown) {
scenes[shown].scene.style.visibility = 'hidden'
scenes[n].scene.style.visibility = 'visible'
shown = n
}
view.style.transform = `scale(${boardZoomAt(k)})`
const p = scenes[n]
p.tiles.forEach((t, i) => {
const v = boardTileAt(i, k)
t.style.opacity = String(v.opacity)
t.style.transform = v.scale < 1 ? `scale(${v.scale})` : ''
})
for (let i = 0; i < 2; i++) {
const a = boardAvatarAt(i, k)
p.avatars[i].style.opacity = String(a.opacity)
p.avatars[i].style.transform = `scale(${a.scale})`
const c = boardChipAt(i, k)
p.chips[i].style.opacity = String(c.opacity)
p.chips[i].style.transform = `translate(-50%, ${(c.dy * u).toFixed(2)}px)`
}
}
const reduce = window.matchMedia(REDUCED)
let raf = 0
let onScreen = false
let last = 0
let clock = BOARD_STILL * BOARD_STEP
let owed = pacing(root).first
const frame = () => (clock / BOARD_STEP) % loop
const tick = (now: number) => {
const dt = last ? Math.min(now - last, 100) : 0
last = now
if (owed > 0) owed -= dt
else clock += dt
draw(frame())
raf = requestAnimationFrame(tick)
}
const update = () => {
cancelAnimationFrame(raf)
raf = 0
last = 0
if (reduce.matches) return draw(BOARD_STILL)
draw(frame())
if (onScreen && document.visibilityState === 'visible') raf = requestAnimationFrame(tick)
}
const io = new IntersectionObserver((entries) => {
onScreen = entries[entries.length - 1].isIntersecting
update()
}, { threshold: 0.25 })
const ro = new ResizeObserver(() => {
measure()
const f = drawn
drawn = -1
if (f >= 0) draw(f)
})
measure()
io.observe(root)
ro.observe(node)
document.addEventListener('visibilitychange', update)
reduce.addEventListener('change', update)
update()
return () => {
cancelAnimationFrame(raf)
io.disconnect()
ro.disconnect()
document.removeEventListener('visibilitychange', update)
reduce.removeEventListener('change', update)
}
},
}
}
function build(kind: ProductVisualKind, data: unknown): Built {
switch (kind) {
case 'brand-record':
case 'creative-record':
case 'page-record':
case 'creator-record':
case 'tagged-record':
return record(kind, data as RecordData)
case 'comment-thread':
return thread(data as ThreadData)
case 'add-account':
case 'add-creator':
return add(data as AddData)
case 'comment-themes':
return themes(data as ThemesData)
case 'creator-filters':
return filters(data as FiltersData)
case 'filter-narrow':
case 'posts-narrow':
return narrow(data as NarrowData)
case 'collabs-timeline':
case 'tagged-timeline':
return timeline(data as TimelineData)
case 'media-mix':
case 'campaigns':
case 'pages-switch':
return sheet(data as SheetData)
case 'links-board':
return board(data as BoardData)
case 'patterns-switch':
return patterns(data as PatternsData)
default:
return { node: el('div', { class: 'ds-pv-root' }), start: noop() }
}
}
export interface MountProductVisualOptions<K extends ProductVisualKind = ProductVisualKind> {
kind: K
/** The kind's data; its Acme default when left out. */
data?: ProductVisualDataMap[K]
/** Which of the four ASCII field positions the stage takes (a product page alternates them by row), or false for none. */
texture?: number | false
}
/** Builds the visual inside `stage` (the element carrying the `ds-pv` stage class) and starts its loop. Returns the
* function that stops the loop and removes what it built. */
export function mountProductVisual<K extends ProductVisualKind>(stage: HTMLElement, { kind, data, texture = 0 }: MountProductVisualOptions<K>): () => void {
const built = build(kind, data ?? productVisualDefaults[kind] ?? productVisualDefaults['brand-record'])
const added: Node[] = []
if (texture !== false) {
const ascii = el('span', { class: 'ds-pv-ascii', 'aria-hidden': 'true', style: `--pv-ascii-at: ${productVisualAsciiAt[Math.abs(Math.trunc(texture)) % productVisualAsciiAt.length]}` })
ascii.style.setProperty('--pv-ascii', `url("${ASCII_TEXTURE}")`)
added.push(ascii)
}
added.push(built.node)
added.forEach((n) => stage.appendChild(n))
const stop = built.start(stage)
return () => {
stop()
added.forEach((n) => n.parentNode?.removeChild(n))
}
}// The product visuals' data: one shape per family of visual and the defaults (Acme), shared by both flavors. The site's
// own visuals (pages/Products/visuals and v2/V2Features LinksBoard and PatternsSwitch) show real brands, creators and
// their pictures; these defaults keep the copy's shape with Acme and invented people, and leave every picture out, so
// each slot draws a neutral shape. Pass your own pictures (`picture`, `avatar`, `logo`, `src`) where you may show them.
import type { ImageSlot } from '@/lib/image'
export type ProductVisualKind =
| 'brand-record'
| 'creative-record'
| 'page-record'
| 'creator-record'
| 'tagged-record'
| 'comment-thread'
| 'add-account'
| 'add-creator'
| 'comment-themes'
| 'creator-filters'
| 'filter-narrow'
| 'posts-narrow'
| 'collabs-timeline'
| 'tagged-timeline'
| 'media-mix'
| 'campaigns'
| 'pages-switch'
| 'links-board'
| 'patterns-switch'
export const productVisualKinds: ProductVisualKind[] = ['brand-record', 'creative-record', 'page-record', 'creator-record', 'tagged-record', 'comment-thread', 'add-account', 'add-creator', 'comment-themes', 'creator-filters', 'filter-narrow', 'posts-narrow', 'collabs-timeline', 'tagged-timeline', 'media-mix', 'campaigns', 'pages-switch', 'links-board', 'patterns-switch']
/** A record panel beside a picture, cycling through its sets (brand, creative, page, creator and tagged records). */
export interface RecordSet {
/** The picture beside the panel (4:5): a src or { src, alt, fit, position }. A neutral shape when left out. */
picture?: string | ImageSlot
/** The panel's first line: a brand, a page or a person. */
name: string
/** The line under it: a handle, a domain or what the picture is. */
sub: string
/** The round mark before the name: an image, or the initial on White when there is none. */
mark?: { src?: string; initial?: string }
/** One value per label, in order. */
values: string[]
}
export interface RecordData {
labels: string[]
sets: RecordSet[]
/** Read by screen readers in place of the panel. */
summary?: string
}
/** A post with three of its comments (comment-thread). */
export interface ThreadComment {
handle: string
likes: string
text: string
avatar?: string
}
export interface ThreadData {
/** The account the posts are from. */
handle: string
sets: { picture?: string | ImageSlot; meta: string; comments: ThreadComment[] }[]
summary?: string
}
/** Adding an account by its handles: added, indexing, ready (add-account, add-creator). */
export interface AddData {
title: string
/** The note opposite the title ("Free"). */
free: string
/** What was typed: a website, a handle. */
inputs: string[]
/** The status steps; the last is where the loop rests. */
steps: string[]
account: { name: string; initial: string; avatar?: string; category: string; followers: string }
summary?: string
}
/** Comments sorted into themes, one theme at a time (comment-themes). */
export interface ThemesData {
title: string
themes: { label: string; share: string; comments: { handle: string; text: string; avatar?: string }[] }[]
summary?: string
}
/** A creator search narrowed by filters (creator-filters). `step` is when a filter turns on (0: never), `out` when a
* row leaves (0: never). */
export interface FiltersData {
query: string
filters: { label: string; value: string; step: number }[]
rows: { handle: string; initial: string; avatar?: string; city: string; followers: string; out: number }[]
summary?: string
}
/** A search narrowed by three filters over a grid of eight results (filter-narrow, posts-narrow). A tile dims at
* step `out` (0: it stays). */
export interface NarrowData {
query: string
filters: string[]
/** The result count at each step: before any filter, then after each. */
counts: string[]
tiles: (ImageSlot & { out: number })[]
summary?: string
}
/** People ranked by posts with a brand, each with their run of posts on a time axis, filtered by window
* (collabs-timeline, tagged-timeline). Dates are ISO days. */
export interface TimelineData {
brand: { name: string; mark?: string }
title: string
/** Today, so dates in this year drop their year. */
today: string
axis: { from: string; to: string; labels: string[] }
/** The windows; `from` null for all time. The loop rests on the second. */
windows: { label: string; from: string | null }[]
rows: { name: string; picture?: string | ImageSlot; first: string; latest: string; posts: string }[]
summary?: string
}
/** A ranked sheet with a two-way switch: rows move, leave or change values with the view (media-mix, campaigns,
* pages-switch). `at` is each row's place per view (null: not in that view); `fill` its share bar per view (0 to 1). */
export interface SheetData {
brand: { name: string; logo?: string; note: string }
views: string[]
/** The switch's accessible name. */
switchLabel: string
rows: { key: string; picture?: string | ImageSlot; name: string; tag?: string; values: string[]; fill?: number[]; at: (number | null)[]; muted?: boolean }[]
/** One per view, read by screen readers. */
summary?: string[]
}
/** A board of a brand's landing page, its ads and two creators, building and clearing scene after scene
* (links-board). Each scene takes eight tiles after the page. */
export interface BoardScene {
brand: string
logo?: string
page: ImageSlot & { y?: number; domain: string; path: string; ads: string }
tiles: (ImageSlot & { x?: number; y?: number; zoom?: number })[]
creators: { handle: string; avatar?: string | ImageSlot }[]
}
export interface BoardData {
scenes: BoardScene[]
}
/** A brand's top hooks, angles and personas as share bars over three ads, the top ad in focus (patterns-switch).
* `top` lists the ads (by index) in focus for a view. */
export interface PatternsData {
brand: string
logo?: string
window: string
ads: (ImageSlot & { x?: number })[]
views: { label: string; rows: { name: string; share: number }[]; top: number[] }[]
}
export interface ProductVisualDataMap {
'brand-record': RecordData
'creative-record': RecordData
'page-record': RecordData
'creator-record': RecordData
'tagged-record': RecordData
'comment-thread': ThreadData
'add-account': AddData
'add-creator': AddData
'comment-themes': ThemesData
'creator-filters': FiltersData
'filter-narrow': NarrowData
'posts-narrow': NarrowData
'collabs-timeline': TimelineData
'tagged-timeline': TimelineData
'media-mix': SheetData
campaigns: SheetData
'pages-switch': SheetData
'links-board': BoardData
'patterns-switch': PatternsData
}
const brandRecord: RecordData = {
labels: ['Category', 'Instagram', 'TikTok'],
sets: [
{ name: 'Acme', sub: '@acme', mark: { initial: 'A' }, values: ['Beauty and personal care', '3.1M followers', '1.1M followers'] },
{ name: 'Acme Studio', sub: '@acmestudio', mark: { initial: 'A' }, values: ['Health and beauty', '1.5M followers', '816K followers'] },
{ name: 'Acme Goods', sub: '@acmegoods', mark: { initial: 'A' }, values: ['Health and beauty', '1.3M followers', '220K followers'] },
],
summary: "Acme (@acme): beauty and personal care, 3.1M followers on Instagram, 1.1M on TikTok. Acme Studio (@acmestudio): health and beauty, 1.5M followers on Instagram, 816K on TikTok. Acme Goods (@acmegoods): health and beauty, 1.3M followers on Instagram, 220K on TikTok.",
}
const creativeRecord: RecordData = {
labels: ['Hook', 'Angle', 'For'],
sets: [
{ name: 'Acme', sub: 'Meta ad, ran 74 days', values: ['Support for the long run', 'Supportive cushioning', 'Daily road runners'] },
{ name: 'Acme Run', sub: 'Meta ad, ran 72 days', values: ['Introducing the Veil', 'A new shoe, shown whole', 'Style-led runners'] },
{ name: 'Acme Trail', sub: 'Meta ad, running 63 days', values: ['One shoe, road to trail', 'Made for travel', 'Light packers'] },
],
summary: 'Acme, Meta ad, ran 74 days: hook "Support for the long run", angle supportive cushioning, for daily road runners. Acme Run, Meta ad, ran 72 days: hook "Introducing the Veil", angle a new shoe, shown whole, for style-led runners. Acme Trail, Meta ad, running 63 days: hook "One shoe, road to trail", angle made for travel, for light packers.',
}
const pageRecord: RecordData = {
labels: ['Path', 'Ads pointing here', 'Rank'],
sets: [
{ name: 'Daily shake', sub: 'acme.com', mark: { initial: 'A' }, values: ['/products/daily-shake', '519', '1 of 6'] },
{ name: 'Daily shake for runners', sub: 'try.acme.com', mark: { initial: 'A' }, values: ['/us/daily-shake-run', '35', '2 of 6'] },
{ name: 'Ready-to-drink', sub: 'acme.com', mark: { initial: 'A' }, values: ['/products/daily-shake-ready-to-drink', '25', '3 of 6'] },
],
summary: "Acme's landing pages, most ads first: acme.com/products/daily-shake, 519 ads; try.acme.com/us/daily-shake-run, 35 ads; acme.com/products/daily-shake-ready-to-drink, 25 ads. The count is ads that point to the page.",
}
const creatorRecord: RecordData = {
labels: ['Instagram', 'Location', 'Focus', 'Age'],
sets: [
{ name: 'Avery Cole', sub: '@averycole', mark: { initial: 'A' }, values: ['367K followers', 'Austin, Texas', 'Functional training', '25 to 34'] },
{ name: 'Nora Bell', sub: '@norabell', mark: { initial: 'N' }, values: ['457K followers', 'Austin, Texas', 'Beginner strength', '25 to 34'] },
{ name: 'Jun Park', sub: '@junpark.lifts', mark: { initial: 'J' }, values: ['194K followers', 'Amarillo, Texas', 'Home-gym workouts', '25 to 34'] },
],
summary: 'Avery Cole (@averycole): 367K followers on Instagram, based in Austin, Texas, posting about functional training, aged 25 to 34. Nora Bell (@norabell): 457K followers, Austin, Texas, beginner strength, 25 to 34. Jun Park (@junpark.lifts): 194K followers, Amarillo, Texas, home-gym workouts, 25 to 34.',
}
const taggedRecord: RecordData = {
labels: ['Tagged', 'Posted', 'Likes', 'Followers'],
sets: [
{ name: 'Mia Torres', sub: '@miacooks', mark: { initial: 'M' }, values: ['@acme', '12 Nov', '4,812', '86K'] },
{ name: 'Leo Grant', sub: '@leogrant', mark: { initial: 'L' }, values: ['@acme', '8 Nov', '967', '12K'] },
{ name: 'Ines Moreau', sub: '@inesbakes', mark: { initial: 'I' }, values: ['@acme', '4 Nov', '2,140', '31K'] },
],
summary: 'Mia Torres (@miacooks) tagged @acme in an Instagram post on 12 Nov: 4,812 likes, 86K followers. Leo Grant (@leogrant) on 8 Nov: 967 likes, 12K followers. Ines Moreau (@inesbakes) on 4 Nov: 2,140 likes, 31K followers.',
}
const commentThread: ThreadData = {
handle: '@acme',
sets: [
{ meta: 'Instagram post, 1,204 comments', comments: [
{ handle: 'maya.bakes', likes: '312 likes', text: 'Restock the white set please' },
{ handle: 'jordan_eats', likes: '148 likes', text: 'Need this for the club' },
{ handle: 'sipsbysam', likes: '96 likes', text: 'Is it the same fleece as the sweats?' },
] },
{ meta: 'Instagram post, 2,860 comments', comments: [
{ handle: 'lena.k', likes: '540 likes', text: 'The colors, the fit, all of it' },
{ handle: 'drinkswithdev', likes: '221 likes', text: 'Restock the ringer tee' },
{ handle: 'tom.runs', likes: '87 likes', text: 'What size is the tee?' },
] },
{ meta: 'Instagram post, 936 comments', comments: [
{ handle: 'ari.snacks', likes: '264 likes', text: 'Does this ship to Canada?' },
{ handle: 'kchen', likes: '119 likes', text: 'Need it in green' },
{ handle: 'noor.m', likes: '72 likes', text: 'Is the vest wool?' },
] },
],
summary: '@acme, Instagram post, 1,204 comments: maya.bakes, "Restock the white set please" (312 likes); jordan_eats, "Need this for the club" (148 likes); sipsbysam, "Is it the same fleece as the sweats?" (96 likes). Two more posts follow, with their top comments.',
}
const addAccount: AddData = {
title: 'Add an account',
free: 'Free',
inputs: ['acme.com', '@acme'],
steps: ['Added', 'Indexing', 'Ready'],
account: { name: 'Acme', initial: 'A', category: 'Skincare', followers: '48K on Instagram' },
summary: 'A brand missing from the index is added by its website and Instagram handle. Its status goes from added to indexing to ready, and then it can be searched like any other brand.',
}
const addCreator: AddData = {
...addAccount,
inputs: ['@rosa.runs'],
account: { name: 'Rosa Vidal', initial: 'R', category: 'Running', followers: '41K on Instagram' },
summary: 'A creator missing from the index is added by their Instagram handle. Their status goes from added to indexing to ready, and then they can be searched like any other creator.',
}
const commentThemes: ThemesData = {
title: '@acme, last 20 posts',
themes: [
{ label: 'Questions', share: '66% of comments', comments: [
{ handle: 'maya.bakes', text: 'Recipe please!' },
{ handle: 'ari.snacks', text: 'Where do I find these?' },
{ handle: 'jules.p', text: 'Does it work without the syrup?' },
] },
{ label: 'Tags', share: '24% of comments', comments: [
{ handle: 'lena.k', text: 'You in for Friday?' },
{ handle: 'max.w', text: 'Making this for us this weekend' },
{ handle: 'rio.d', text: 'This is so you' },
] },
{ label: 'Praise', share: '10% of comments', comments: [
{ handle: 'priya.eats', text: 'Pomegranate is the best one' },
{ handle: 'kchen', text: 'Ginger forever' },
{ handle: 'drinkswithdev', text: 'Best soda in the fridge' },
] },
],
summary: "The comments under Acme's last 20 posts, sorted into questions, 66 percent, such as asking for the recipe or where to buy; tags of friends, 24 percent; and praise for the flavors, 10 percent.",
}
const creatorFilters: FiltersData = {
query: 'Fitness creators',
filters: [
{ label: 'Location', value: 'Texas', step: 1 },
{ label: 'Followers', value: '50K to 500K', step: 1 },
{ label: 'Language', value: 'English', step: 2 },
{ label: 'Age', value: '25 to 34', step: 2 },
{ label: 'Gender', value: 'Any', step: 0 },
],
rows: [
{ handle: '@averycole', initial: 'A', city: 'Austin, Texas', followers: '367K', out: 0 },
{ handle: '@camilleross', initial: 'C', city: 'Denver, Colorado', followers: '507K', out: 1 },
{ handle: '@norabell', initial: 'N', city: 'Austin, Texas', followers: '457K', out: 0 },
{ handle: '@hollisfit', initial: 'H', city: 'Houston, Texas', followers: '62.1K', out: 2 },
{ handle: '@junpark.lifts', initial: 'J', city: 'Amarillo, Texas', followers: '194K', out: 0 },
],
summary: 'A search for fitness creators, narrowed by location, follower range, language and age range, goes from five creators to the three in Texas with 50K to 500K followers.',
}
const filterNarrow: NarrowData = {
query: 'Product shots on a pale ground',
filters: ['Meta ads', 'Product aware', 'Ran 30+ days'],
counts: ['2,418 results', '1,306 results', '412 results', '88 results'],
tiles: [{ out: 0 }, { out: 1 }, { out: 3 }, { out: 2 }, { out: 1 }, { out: 0 }, { out: 2 }, { out: 0 }],
summary: 'A search for product shots on a pale ground returns ads and posts. Three filters, Meta ads, product aware and ran 30 days or more, narrow eight of them to three Acme ads.',
}
const postsNarrow: NarrowData = {
query: 'Fall drinks',
filters: ['Soft drinks', 'Last 30 days', 'Top outliers'],
counts: ['3,912 posts', '860 posts', '214 posts', '12 posts'],
tiles: [{ out: 0 }, { out: 1 }, { out: 2 }, { out: 0 }, { out: 1 }, { out: 3 }, { out: 1 }, { out: 0 }],
summary: 'A search for fall drinks on Instagram and TikTok, narrowed to soft drinks, the last 30 days and the top outliers, leaves three Acme posts worth reading the comments under.',
}
const collabsTimeline: TimelineData = {
brand: { name: 'Acme' },
title: 'Creators',
today: '2026-11-19',
axis: { from: '2025-06-01', to: '2026-11-30', labels: ['Jun 2025', 'Nov 2026'] },
windows: [{ label: 'All time', from: null }, { label: 'This year', from: '2026-01-01' }, { label: 'Last 90 days', from: '2026-08-21' }],
rows: [
{ name: 'Lena Ortega', first: '2026-01-14', latest: '2026-11-09', posts: '12 posts' },
{ name: 'Rosa Lindgren', first: '2025-06-14', latest: '2026-02-20', posts: '9 posts' },
{ name: 'Marcus Hale', first: '2026-02-02', latest: '2026-11-01', posts: '7 posts' },
{ name: 'June Abara', first: '2026-03-21', latest: '2026-10-28', posts: '5 posts' },
{ name: 'Ade Morgan', first: '2026-09-12', latest: '2026-10-17', posts: '3 posts' },
],
summary: "Acme's creators, most posts together first, each with their first and latest post. Over all time there are five; this year four, led by Lena Ortega with 12 posts since 14 January; in the last 90 days one, Ade Morgan.",
}
const taggedTimeline: TimelineData = {
...collabsTimeline,
title: 'Tagged by',
today: '2026-11-20',
rows: [
{ name: 'Northside Run Club', first: '2026-01-08', latest: '2026-11-14', posts: '16 posts' },
{ name: 'Ava Lind', first: '2025-07-02', latest: '2026-11-02', posts: '10 posts' },
{ name: 'Mila Hartley', first: '2026-04-11', latest: '2026-11-11', posts: '6 posts' },
{ name: 'Cold Miles Club', first: '2026-02-19', latest: '2026-10-29', posts: '4 posts' },
{ name: 'Jonas Kerr', first: '2026-09-30', latest: '2026-11-06', posts: '2 posts' },
],
summary: 'The people who tag Acme on Instagram, most posts first, each with their first and latest tagged post. Over all time there are five; this year four, led by Northside Run Club with 16 posts since 8 January; in the last 90 days one, Jonas Kerr.',
}
const pct = (n: number) => `${n}%`
const mediaMix: SheetData = {
brand: { name: 'Acme', note: 'Ads by format' },
views: ['30 days', '90 days'],
switchLabel: 'How far back to look',
rows: [
{ key: 'video', name: 'Video', values: [pct(51), pct(43)], fill: [0.51, 0.43], at: [0, 0] },
{ key: 'image', name: 'Image', values: [pct(29), pct(35)], fill: [0.29, 0.35], at: [1, 1] },
{ key: 'carousel', name: 'Carousel', values: [pct(13), pct(14)], fill: [0.13, 0.14], at: [2, 2] },
{ key: 'catalog', name: 'Catalog', values: [pct(7), pct(8)], fill: [0.07, 0.08], at: [3, 3] },
],
summary: ["Acme's ads by format over the last 30 days: video 51%, image 29%, carousel 13%, catalog 7%.", "Acme's ads by format over the last 90 days: video 43%, image 35%, carousel 14%, catalog 8%."],
}
const campaigns: SheetData = {
brand: { name: 'Acme', note: 'Campaigns and offers' },
views: ['Newest', 'Fastest'],
switchLabel: 'Sort by',
rows: [
{ key: 'flavors', name: 'Every flavor in one box', tag: 'Offer', values: ['Started 14 Nov', '6 new ads'], at: [0, 3] },
{ key: 'value', name: 'Under $4 a meal', tag: 'Offer', values: ['Started 10 Nov', '9 new ads'], at: [1, 2] },
{ key: 'runners', name: 'The daily shake for runners', tag: 'Campaign', values: ['Started 3 Nov', '24 new ads'], at: [2, 0] },
{ key: 'parents', name: 'Protein for busy parents', tag: 'Campaign', values: ['Started 28 Oct', '15 new ads'], at: [3, 1] },
],
summary: ["Acme's campaigns and offers, newest first: Every flavor in one box, started 14 Nov; Under $4 a meal, 10 Nov; The daily shake for runners, 3 Nov; Protein for busy parents, 28 Oct.", "Acme's campaigns and offers, fastest first, by new ads in the last 7 days: The daily shake for runners, 24; Protein for busy parents, 15; Under $4 a meal, 9; Every flavor in one box, 6."],
}
const TOP = 519
const pagesSwitch: SheetData = {
brand: { name: 'Acme', note: 'Most ads first' },
views: ['Active', 'All'],
switchLabel: 'Which pages',
rows: [
{ key: 'daily', name: '/products/daily-shake', values: ['519 ads', '519 ads'], fill: [1, 1], at: [0, 0] },
{ key: 'bars', name: '/products/protein-bars', tag: 'Stopped', values: ['48 ads', '48 ads'], fill: [48 / TOP, 48 / TOP], at: [null, 1], muted: true },
{ key: 'run', name: '/us/daily-shake-run', values: ['35 ads', '35 ads'], fill: [35 / TOP, 35 / TOP], at: [1, 2] },
{ key: 'rtd', name: '/products/daily-shake-ready-to-drink', values: ['25 ads', '25 ads'], fill: [25 / TOP, 25 / TOP], at: [2, 3] },
],
summary: ["Acme's active landing pages, most ads first: daily-shake, 519 ads; daily-shake-run, 35; daily-shake-ready-to-drink, 25.", "All of Acme's landing pages, including those whose ads have stopped: daily-shake, 519 ads; protein-bars, stopped, 48; daily-shake-run, 35; daily-shake-ready-to-drink, 25."],
}
const blank = (n: number) => Array.from({ length: n }, () => ({}))
const linksBoard: BoardData = {
scenes: [
{ brand: 'Acme', page: { domain: 'acme.com', path: '/products/daily-shake', ads: '14 ads point here' }, tiles: blank(8), creators: [{ handle: '@mattmeals' }, { handle: '@dan.fuels' }] },
{ brand: 'Acme Studio', page: { domain: 'acmestudio.com', path: '/products/pocket-blush', ads: '9 ads point here' }, tiles: blank(8), creators: [{ handle: '@nina.glow' }, { handle: '@beautybyjo' }] },
{ brand: 'Acme Soda', page: { domain: 'acmesoda.com', path: '/pages/fall-collab', ads: '22 ads point here' }, tiles: blank(8), creators: [{ handle: '@leogrant' }, { handle: '@miacooks' }] },
],
}
const patternsSwitch: PatternsData = {
brand: 'Acme',
window: 'Last 90 days',
ads: [{ x: 0 }, { x: 50 }, { x: 50 }],
views: [
{ label: 'Hooks', rows: [{ name: 'Does it actually work?', share: 29 }, { name: 'One scoop, not a shelf of pills', share: 24 }, { name: 'Built for training days', share: 21 }], top: [0] },
{ label: 'Angles', rows: [{ name: 'Simplify your daily routine', share: 34 }, { name: 'Fuel for training', share: 27 }, { name: 'Tested to a higher standard', share: 22 }], top: [1] },
{ label: 'Personas', rows: [{ name: 'Gym-goers', share: 33 }, { name: 'Busy professionals', share: 26 }, { name: 'Wellness skeptics', share: 23 }], top: [2] },
],
}
/** Each kind's default data (Acme). */
export const productVisualDefaults: ProductVisualDataMap = {
'brand-record': brandRecord,
'creative-record': creativeRecord,
'page-record': pageRecord,
'creator-record': creatorRecord,
'tagged-record': taggedRecord,
'comment-thread': commentThread,
'add-account': addAccount,
'add-creator': addCreator,
'comment-themes': commentThemes,
'creator-filters': creatorFilters,
'filter-narrow': filterNarrow,
'posts-narrow': postsNarrow,
'collabs-timeline': collabsTimeline,
'tagged-timeline': taggedTimeline,
'media-mix': mediaMix,
campaigns,
'pages-switch': pagesSwitch,
'links-board': linksBoard,
'patterns-switch': patternsSwitch,
}// The product visuals' stylesheet, shared by both flavors: React renders it in a hoisted <style>, the web component
// adopts it in its shadow root. Ported from the site's CSS modules (pages/Products/visuals/*.module.css,
// ProductFeatures.module.css .stage and .ascii, v2/V2Features LinksBoard and PatternsSwitch), sizes kept, values
// through the brand tokens. The site's inset hairline rings are drawn as inset outlines, and its row rules as a 1px
// gradient line, so nothing shifts. The stage is a container ("ds-pv"): the site's 440 and 560 steps read its width.
export const productVisualCss = `
.ds-pv {
position: relative; isolation: isolate; display: block; min-width: 0; aspect-ratio: 4 / 3; overflow: clip;
container: ds-pv / inline-size; border-radius: var(--ds-radius-panel); background: var(--ds-color-surface-raised);
color: var(--ds-color-fg); font-family: var(--ds-font-text); font-size: var(--ds-text-caption);
line-height: var(--ds-text-caption-leading); font-weight: var(--ds-font-weight-regular); text-align: left;
}
.ds-pv[data-fill] { aspect-ratio: auto; height: 100%; border-radius: var(--ds-radius-sm); background: transparent; }
.ds-pv *, .ds-pv *::before, .ds-pv *::after { box-sizing: border-box; }
.ds-pv-ascii {
position: absolute; inset: 0; z-index: -1; pointer-events: none; background-image: var(--pv-ascii);
background-size: var(--ds-ascii-tile) var(--ds-ascii-tile); background-position: var(--pv-ascii-at, 0 0);
opacity: var(--ds-ascii-quiet); mix-blend-mode: screen;
mask-image: radial-gradient(ellipse var(--ds-pv-ascii-clear-w) var(--ds-pv-ascii-clear-h) at 50% 50%, transparent 40%, var(--ds-color-black) 100%);
}
.ds-pv-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.ds-pv-root { position: absolute; inset: 0; }
.ds-pv-center { display: grid; place-items: center; }
.ds-pv-clip { overflow: clip; }
.ds-pv-fade::after {
content: ""; position: absolute; right: 0; bottom: 0; left: 0; z-index: 10; height: 96px; pointer-events: none;
background: linear-gradient(to bottom, transparent, var(--ds-color-surface-raised));
}
.ds-pv-strong { font-weight: var(--ds-font-weight-medium); }
.ds-pv-sub { color: var(--ds-color-fg-muted); }
.ds-pv-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A picture: an image, or a neutral shape when there is none. */
.ds-pv-pic { position: absolute; inset: 0; overflow: hidden; border-radius: var(--ds-radius-sm); background: var(--ds-color-surface); }
.ds-pv-img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.ds-pv-ph { position: absolute; inset: 0; background: linear-gradient(var(--pv-ph-a, 160deg), var(--ds-color-neutral-6), var(--ds-color-neutral-3) 70%); }
/* A round mark: an image, or the initial (on White, or on the inset fill for commenters). */
.ds-pv-mark {
position: relative; display: grid; flex: none; place-items: center; overflow: hidden; width: 24px; height: 24px;
border-radius: 50%; background: var(--ds-color-white); color: var(--ds-color-black); font-weight: var(--ds-font-weight-medium);
}
.ds-pv-mark[data-tone="inset"] { background: var(--ds-color-surface-inset); color: var(--ds-color-fg-soft); }
.ds-pv-mark[data-tone="row"] { background: var(--ds-color-surface-inset); color: var(--ds-color-fg); }
.ds-pv-mark > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* The sheet: a Black panel rising from the stage's floor, the floor fading it out. */
.ds-pv-sheet {
position: absolute; top: 12.5%; left: 50%; display: flex; flex-direction: column; width: 70%;
min-height: calc(87.5% + 16px); translate: -50%; padding: 16px 12px 0; border: var(--ds-border-hairline) solid var(--ds-color-edge-surface);
border-radius: var(--ds-radius-panel) var(--ds-radius-panel) 0 0; background: var(--ds-color-black); color: var(--ds-color-fg);
}
.ds-pv-sheet[data-wide] { top: 16px; width: calc(100% - 32px); min-height: 100%; }
.ds-pv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 20px; margin-bottom: 16px; }
.ds-pv-control { margin-bottom: 16px; padding: 4px; border-radius: var(--ds-radius-panel); outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface); outline-offset: calc(-1 * var(--ds-border-hairline)); }
.ds-pv-steps { position: relative; display: flex; isolation: isolate; }
.ds-pv-step {
display: grid; flex: 1 1 0; place-items: center; min-width: 0; height: 32px; padding: 0 4px; border: 0; border-radius: var(--ds-radius-panel);
background: none; color: var(--ds-color-fg-muted); font: inherit; font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading);
font-weight: var(--ds-font-weight-medium); white-space: nowrap; transition: color var(--ds-duration-micro) var(--ds-easing-loop);
}
.ds-pv-step[data-on], .ds-pv-step[aria-selected="true"] { color: var(--ds-color-black); }
button.ds-pv-step { cursor: pointer; }
button.ds-pv-step:focus-visible { outline: var(--ds-border-focus) solid var(--ds-color-edge-focus); outline-offset: calc(-1 * var(--ds-border-focus)); }
.ds-pv-indicator {
position: absolute; top: 0; left: 0; z-index: -1; width: calc(100% / var(--n)); height: 100%; border-radius: var(--ds-radius-panel);
background: var(--ds-color-white); translate: calc(var(--i) * 100%); transition: translate var(--ds-duration-micro) var(--ds-easing-loop);
}
@media (hover: hover) and (pointer: fine) { button.ds-pv-step[aria-selected="false"]:hover { color: var(--ds-color-fg-soft); } }
@media (pointer: coarse) { button.ds-pv-step { position: relative; } button.ds-pv-step::after { content: ""; position: absolute; inset: -8px 0; } }
.ds-pv-swap { display: grid; }
.ds-pv-swap > * { grid-area: 1 / 1; opacity: 0; transition: opacity var(--ds-duration-micro) var(--ds-easing-loop); }
.ds-pv-swap > [data-on] { opacity: 1; }
/* Records: a picture beside a panel, the sets crossing in turn (brand, creative, page, creator, tagged, thread). */
.ds-pv-record { --pic-w: 128px; --panel-w: 224px; --head-h: 48px; --row-h: 36px; --avatar: 24px; display: flex; align-items: center; gap: 16px; }
.ds-pv-record[data-variant="creator"] { --row-h: 32px; }
.ds-pv-record[data-variant="thread"] { --row-h: 48px; }
.ds-pv-record [data-set]:not([data-set="0"]) { opacity: 0; }
.ds-pv-picture { position: relative; flex: none; width: var(--pic-w); aspect-ratio: 4 / 5; }
.ds-pv-panel {
display: flex; flex-direction: column; width: var(--panel-w); padding: 4px 12px; border-radius: var(--ds-radius-panel);
outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface); outline-offset: calc(-1 * var(--ds-border-hairline));
background: var(--ds-color-black); color: var(--ds-color-fg);
}
.ds-pv-stack { display: grid; min-width: 0; }
.ds-pv-stack > * { grid-area: 1 / 1; }
.ds-pv-who { display: flex; align-items: center; gap: 8px; height: var(--head-h); min-width: 0; transform-origin: left center; }
.ds-pv-who[data-column] { flex-direction: column; align-items: stretch; justify-content: center; gap: 0; }
.ds-pv-names { display: flex; flex-direction: column; min-width: 0; }
.ds-pv-names[data-clip] { overflow: hidden; }
.ds-pv-names[data-clip] > * { overflow: hidden; text-overflow: ellipsis; }
.ds-pv-name { font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); font-weight: var(--ds-font-weight-medium); white-space: nowrap; }
.ds-pv-handle { color: var(--ds-color-fg-muted); white-space: nowrap; }
.ds-pv-rule { background: linear-gradient(var(--ds-color-edge-surface), var(--ds-color-edge-surface)) top / 100% var(--ds-border-hairline) no-repeat; }
.ds-pv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--row-h); }
.ds-pv-label { flex: none; color: var(--ds-color-fg-muted); }
.ds-pv-row > .ds-pv-stack { justify-items: end; }
.ds-pv-row[data-thread] > .ds-pv-stack { flex: 1; justify-items: stretch; }
.ds-pv-value { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; transform-origin: right center; }
.ds-pv-comment { display: flex; align-items: center; gap: 8px; min-width: 0; transform-origin: left center; }
.ds-pv-comment > .ds-pv-mark { width: var(--avatar); height: var(--avatar); }
.ds-pv-body { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.ds-pv-by { display: flex; justify-content: space-between; gap: 8px; color: var(--ds-color-fg-muted); white-space: nowrap; }
.ds-pv-by > :first-child { overflow: hidden; text-overflow: ellipsis; }
.ds-pv-by > :last-child { flex: none; font-variant-numeric: tabular-nums; }
@container ds-pv (width < 440px) {
.ds-pv-record { --pic-w: 96px; --panel-w: 216px; --head-h: 40px; --row-h: 32px; gap: 12px; }
.ds-pv-record[data-variant="creator"] { --row-h: 28px; }
.ds-pv-record[data-variant="thread"] { --row-h: 44px; }
}
@container ds-pv (width >= 560px) {
.ds-pv-record { --pic-w: 176px; --panel-w: 296px; --head-h: 64px; --row-h: 48px; gap: 24px; font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); }
.ds-pv-record[data-variant="creator"] { --row-h: 44px; }
.ds-pv-record[data-variant="thread"] { --head-h: 56px; --row-h: 56px; --avatar: 32px; font-size: var(--ds-text-caption); line-height: var(--ds-text-caption-leading); }
.ds-pv-record[data-variant="thread"] .ds-pv-comment { gap: 12px; }
.ds-pv-record[data-variant="thread"] .ds-pv-text { font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); }
.ds-pv-record .ds-pv-panel { padding-inline: 16px; }
.ds-pv-record .ds-pv-who > .ds-pv-mark { width: 32px; height: 32px; }
.ds-pv-record .ds-pv-name { font-size: var(--ds-text-body); line-height: var(--ds-text-body-leading); }
}
/* Add an account: the typed handles, the status switch, then the account's row filling in. */
.ds-pv-field {
display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 40px; margin-bottom: 16px; padding: 8px;
border-radius: var(--ds-radius-panel); outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface); outline-offset: calc(-1 * var(--ds-border-hairline));
}
.ds-pv-input { height: 24px; padding-inline: 8px; border-radius: var(--ds-radius-sm); background: var(--ds-color-surface-inset); line-height: 24px; white-space: nowrap; }
.ds-pv-account { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows var(--ds-duration-slow) var(--ds-easing-loop), opacity var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-add:not([data-step="0"]) .ds-pv-account { grid-template-rows: 1fr; opacity: 1; }
.ds-pv-account > div { min-height: 0; overflow: hidden; }
.ds-pv-account-row { display: flex; align-items: center; gap: 12px; height: 48px; padding-inline: 8px; border-radius: var(--ds-radius-panel); background: var(--ds-color-surface-raised); }
.ds-pv-account-row > .ds-pv-mark { width: 32px; height: 32px; font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); }
.ds-pv-details { display: grid; flex: 1; min-width: 0; }
.ds-pv-bars, .ds-pv-text-block { grid-area: 1 / 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; transition: opacity var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-bars { gap: 8px; opacity: 0; }
.ds-pv-bar { width: 60%; height: 8px; border-radius: var(--ds-radius-sm); background: var(--ds-color-surface-inset); }
.ds-pv-bar + .ds-pv-bar { width: 40%; }
.ds-pv-add[data-step="1"] .ds-pv-bars { opacity: 1; }
.ds-pv-add[data-step="1"] .ds-pv-text-block { opacity: 0; }
.ds-pv-text-block > .ds-pv-name { white-space: normal; }
@container ds-pv (width < 440px) {
.ds-pv-sheet[data-tight] { top: 16px; width: calc(100% - 32px); min-height: 100%; }
.ds-pv-add .ds-pv-head, .ds-pv-add .ds-pv-field, .ds-pv-add .ds-pv-control { margin-bottom: 12px; }
.ds-pv-add .ds-pv-step { font-size: var(--ds-text-caption); line-height: var(--ds-text-caption-leading); }
}
@container ds-pv (width >= 560px) {
.ds-pv-add, .ds-pv-themes { font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); }
.ds-pv-add .ds-pv-sheet, .ds-pv-themes .ds-pv-sheet { top: 20%; min-height: calc(80% + 16px); padding: 24px 16px 0; }
.ds-pv-add .ds-pv-head, .ds-pv-themes .ds-pv-head { margin-bottom: 20px; }
.ds-pv-add .ds-pv-field, .ds-pv-add .ds-pv-control, .ds-pv-themes .ds-pv-control { margin-bottom: 20px; }
.ds-pv-add .ds-pv-step, .ds-pv-themes .ds-pv-step { height: 40px; }
.ds-pv-account-row { height: 56px; }
.ds-pv-add .ds-pv-name { font-size: var(--ds-text-body); line-height: var(--ds-text-body-leading); }
}
/* Comment themes: one theme's comments at a time under the add sheet's switch. */
.ds-pv-shares { display: grid; justify-items: end; }
.ds-pv-share { grid-area: 1 / 1; color: var(--ds-color-fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; opacity: 0; transition: opacity var(--ds-duration-micro) var(--ds-easing-loop); }
.ds-pv-share[data-on] { opacity: 1; }
.ds-pv-views { display: grid; }
.ds-pv-view { grid-area: 1 / 1; display: flex; flex-direction: column; min-width: 0; opacity: 0; transition: opacity var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-view[data-on] { opacity: 1; }
.ds-pv-theme-comment { display: flex; align-items: center; gap: 8px; height: 48px; padding-inline: 8px; background: linear-gradient(var(--ds-color-edge-surface), var(--ds-color-edge-surface)) bottom / 100% var(--ds-border-hairline) no-repeat; }
.ds-pv-theme-comment .ds-pv-body > :first-child { color: var(--ds-color-fg-muted); white-space: nowrap; }
@container ds-pv (width < 440px) { .ds-pv-theme-comment { height: 40px; padding-inline: 4px; } }
@container ds-pv (width >= 560px) {
.ds-pv-theme-comment { gap: 12px; height: 56px; padding-inline: 12px; font-size: var(--ds-text-caption); line-height: var(--ds-text-caption-leading); }
.ds-pv-theme-comment > .ds-pv-mark { width: 32px; height: 32px; }
}
/* Creator filters: the query, chips turning on, rows folding away. */
.ds-pv-query {
display: flex; align-items: center; gap: 8px; height: 32px; margin-bottom: 12px; padding-inline: 8px; border-radius: var(--ds-radius-panel);
outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface); outline-offset: calc(-1 * var(--ds-border-hairline)); font-weight: var(--ds-font-weight-medium);
}
.ds-pv-icon { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--ds-color-fg-muted); stroke-width: 1.5; stroke-linecap: round; }
.ds-pv-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.ds-pv-chip {
display: grid; height: 24px; padding-inline: 8px; border-radius: var(--ds-radius-sm); outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface);
outline-offset: calc(-1 * var(--ds-border-hairline)); color: var(--ds-color-fg-muted); white-space: nowrap;
transition: background-color var(--ds-duration-micro) var(--ds-easing-loop), color var(--ds-duration-micro) var(--ds-easing-loop);
}
.ds-pv-chip[data-on] { background-color: var(--ds-color-white); color: var(--ds-color-black); }
.ds-pv-chip > span { grid-area: 1 / 1; justify-self: center; line-height: 24px; transition: opacity var(--ds-duration-micro) var(--ds-easing-loop); }
.ds-pv-chip > span + span { opacity: 0; font-weight: var(--ds-font-weight-medium); }
.ds-pv-chip[data-on] > span:first-child { opacity: 0; }
.ds-pv-chip[data-on] > span + span { opacity: 1; }
.ds-pv-fold { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows var(--ds-duration-slow) var(--ds-easing-loop), opacity var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-fold[data-out] { grid-template-rows: 0fr; opacity: 0; }
.ds-pv-fold > div { min-height: 0; overflow: hidden; }
.ds-pv-face { display: flex; align-items: center; gap: 8px; height: 40px; }
.ds-pv-who-col { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.ds-pv-figure { flex: none; font-variant-numeric: tabular-nums; font-weight: var(--ds-font-weight-medium); }
.ds-pv-filters .ds-pv-sheet { top: 16px; width: calc(100% - 32px); min-height: 100%; }
@container ds-pv (width >= 560px) {
.ds-pv-filters { font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); }
.ds-pv-filters .ds-pv-sheet { top: 12.5%; width: calc(100% - 96px); min-height: calc(87.5% + 16px); padding: 20px 16px 0; }
.ds-pv-filters .ds-pv-query { height: 40px; margin-bottom: 16px; padding-inline: 12px; }
.ds-pv-filters .ds-pv-chips { gap: 8px; margin-bottom: 16px; }
.ds-pv-filters .ds-pv-chip { height: 32px; padding-inline: 12px; }
.ds-pv-filters .ds-pv-chip > span { line-height: 32px; }
.ds-pv-filters .ds-pv-face { gap: 12px; height: 48px; }
.ds-pv-filters .ds-pv-face > .ds-pv-mark { width: 32px; height: 32px; }
.ds-pv-filters .ds-pv-who-col > .ds-pv-sub { font-size: var(--ds-text-caption); line-height: var(--ds-text-caption-leading); }
}
/* Narrow: a search, three filters arriving, eight results dimming. */
.ds-pv-narrow { --w: 400px; --field-h: 40px; --chip-h: 24px; --gap: 12px; --tile-gap: 8px; --tile-ratio: 4 / 5; display: flex; flex-direction: column; gap: var(--gap); width: var(--w); color: var(--ds-color-fg); }
.ds-pv-search {
display: flex; align-items: center; gap: 8px; height: var(--field-h); padding-inline: 12px; border-radius: var(--ds-radius-panel);
outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface); outline-offset: calc(-1 * var(--ds-border-hairline)); background: var(--ds-color-black);
}
.ds-pv-search > .ds-pv-ellipsis { flex: 1; }
.ds-pv-counts { display: grid; flex: none; justify-items: end; }
.ds-pv-counts > span { grid-area: 1 / 1; color: var(--ds-color-fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; opacity: 0; transition: opacity var(--ds-duration-micro) var(--ds-easing-loop); }
.ds-pv-counts > [data-on] { opacity: 1; }
.ds-pv-narrow-filters { display: flex; align-items: center; gap: 8px; height: var(--chip-h); }
.ds-pv-pill {
display: grid; place-items: center; height: var(--chip-h); padding-inline: 8px; border-radius: var(--ds-radius-panel); background: var(--ds-color-surface-inset);
white-space: nowrap; opacity: 0; scale: 0.9; transition: opacity var(--ds-duration-micro) var(--ds-easing-loop), scale var(--ds-duration-micro) var(--ds-easing-loop);
}
.ds-pv-pill[data-on] { opacity: 1; scale: 1; }
.ds-pv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--tile-gap); }
.ds-pv-slot { position: relative; aspect-ratio: var(--tile-ratio); border-radius: var(--ds-radius-sm); outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface); outline-offset: calc(-1 * var(--ds-border-hairline)); background: var(--ds-color-surface-raised); }
.ds-pv-slot > .ds-pv-pic { transition: opacity var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-slot > .ds-pv-pic[data-out] { opacity: 0.32; }
.ds-pv-slot > .ds-pv-pic > * { transition: filter var(--ds-duration-slow) var(--ds-easing-loop), scale var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-slot > .ds-pv-pic[data-out] > * { filter: blur(8px); scale: 1.12; }
@container ds-pv (width < 440px) {
.ds-pv-narrow { --w: calc(100% - 32px); --field-h: 32px; --gap: 8px; --tile-ratio: 1; }
.ds-pv-search { padding-inline: 8px; }
}
@container ds-pv (width >= 560px) {
.ds-pv-narrow { --w: 512px; --field-h: 48px; --chip-h: 32px; --gap: 16px; --tile-gap: 12px; font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); }
.ds-pv-search { gap: 12px; padding-inline: 16px; }
.ds-pv-pill { padding-inline: 12px; }
}
/* Timeline: rows by posts, each run on a time axis drawn in glyphs, the window shading what falls outside. */
.ds-pv-timeline { --pic: 32px; --who-w: 136px; --count-w: 48px; --gap: 8px; }
.ds-pv-timeline .ds-pv-sheet { top: 16px; width: calc(100% - 32px); min-height: 100%; }
.ds-pv-timeline .ds-pv-head { height: 24px; margin-bottom: 12px; }
.ds-pv-timeline .ds-pv-control { margin-bottom: 8px; }
.ds-pv-timeline .ds-pv-step { font-size: inherit; line-height: inherit; }
.ds-pv-brand { display: flex; align-items: center; gap: 8px; }
.ds-pv-brand > .ds-pv-logo { width: 24px; height: 24px; }
.ds-pv-timeline .ds-pv-face { gap: var(--gap); height: 48px; }
.ds-pv-timeline .ds-pv-fold + .ds-pv-fold .ds-pv-face { background: linear-gradient(var(--ds-color-edge-surface), var(--ds-color-edge-surface)) top / 100% var(--ds-border-hairline) no-repeat; }
.ds-pv-thumb { position: relative; flex: none; width: var(--pic); height: var(--pic); }
.ds-pv-glyphs { font-family: var(--ds-font-ascii); font-size: calc(40px / 3); font-variant-ligatures: none; line-height: 16px; letter-spacing: 0; white-space: pre; }
.ds-pv-track { position: relative; display: none; flex: 1; min-width: 0; height: 8px; overflow: visible; clip-path: inset(-4px 0); color: var(--ds-color-edge-strong); line-height: 8px; }
.ds-pv-window {
position: absolute; inset: 0; color: var(--ds-color-fg-muted);
clip-path: inset(-4px 0 -4px round(down, calc((1 - var(--shade)) * 100%), 8px)); transition: clip-path var(--ds-duration-slow) var(--ds-easing-loop);
}
.ds-pv-run { position: absolute; top: 0; bottom: 0; left: round(down, calc(var(--start) * 100%), 8px); width: max(round(nearest, calc(var(--span) * 100%), 8px), 16px); overflow: hidden; color: var(--ds-color-fg); }
.ds-pv-count { flex: none; width: var(--count-w); text-align: right; font-variant-numeric: tabular-nums; font-weight: var(--ds-font-weight-medium); }
.ds-pv-axis {
display: none; justify-content: space-between; margin-left: calc(var(--pic) + var(--who-w) + 2 * var(--gap)); margin-right: calc(var(--count-w) + var(--gap));
padding-block: 8px; color: var(--ds-color-fg-muted); background: linear-gradient(var(--ds-color-edge-surface), var(--ds-color-edge-surface)) top / 100% var(--ds-border-hairline) no-repeat;
}
@container ds-pv (width >= 560px) {
.ds-pv-timeline { --who-w: 152px; --count-w: 64px; --gap: 12px; font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); }
.ds-pv-timeline .ds-pv-sheet { top: 12.5%; width: calc(100% - 96px); min-height: calc(87.5% + 16px); padding: 20px 16px 0; }
.ds-pv-timeline .ds-pv-head { margin-bottom: 16px; }
.ds-pv-timeline .ds-pv-control { margin-bottom: 12px; }
.ds-pv-timeline .ds-pv-step { height: 40px; }
.ds-pv-timeline .ds-pv-face { height: 48px; }
.ds-pv-timeline .ds-pv-who-col { flex: none; width: var(--who-w); }
.ds-pv-timeline .ds-pv-who-col > .ds-pv-sub { font-size: var(--ds-text-caption); line-height: var(--ds-text-caption-leading); }
.ds-pv-track { display: block; }
.ds-pv-axis { display: flex; font-size: var(--ds-text-caption); line-height: var(--ds-text-caption-leading); }
}
/* Ranked sheet: rows that move, leave and change value with a two-way switch. */
.ds-pv-sheetlist { --row-h: 52px; --thumb-w: 32px; --thumb-h: 40px; }
.ds-pv-sheet-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ds-pv-logo { position: relative; display: grid; flex: none; place-items: center; overflow: hidden; width: 20px; height: 20px; border-radius: 50%; background: var(--ds-color-white); color: var(--ds-color-black); font-size: var(--ds-text-caption); line-height: 1; font-weight: var(--ds-font-weight-medium); }
.ds-pv-logo > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ds-pv-tray { position: relative; isolation: isolate; display: flex; flex: none; margin-left: auto; padding: 4px; border-radius: var(--ds-radius-panel); outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface); outline-offset: calc(-1 * var(--ds-border-hairline)); }
.ds-pv-tray-pill { position: absolute; top: 4px; left: 0; z-index: -1; width: var(--w); height: calc(100% - 8px); border-radius: var(--ds-radius-sm); background: var(--ds-color-white); translate: var(--x); transition: translate var(--ds-duration-micro) var(--ds-easing-loop), width var(--ds-duration-micro) var(--ds-easing-loop); }
.ds-pv-tab {
height: 32px; padding: 0 12px; border: 0; border-radius: var(--ds-radius-sm); background: none; color: var(--ds-color-fg-muted); font: inherit;
font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); font-weight: var(--ds-font-weight-medium); white-space: nowrap; cursor: pointer;
transition: color var(--ds-duration-micro) var(--ds-easing-loop);
}
.ds-pv-tab[aria-selected="true"] { color: var(--ds-color-black); }
.ds-pv-tab:focus-visible { outline: var(--ds-border-focus) solid var(--ds-color-edge-focus); outline-offset: calc(-1 * var(--ds-border-focus)); }
@media (hover: hover) and (pointer: fine) { .ds-pv-tab[aria-selected="false"]:hover { color: var(--ds-color-fg); } }
@media (pointer: coarse) { .ds-pv-tab { position: relative; } .ds-pv-tab::after { content: ""; position: absolute; inset: -8px 0; } }
.ds-pv-ranked { position: relative; height: calc(var(--slots) * var(--row-h)); margin: 16px 0 0; padding: 0; list-style: none; }
.ds-pv-rank {
position: absolute; top: 0; right: 0; left: 0; z-index: 1; display: flex; align-items: center; gap: 12px; height: var(--row-h);
background: linear-gradient(var(--ds-color-edge-surface), var(--ds-color-edge-surface)) top / 100% var(--ds-border-hairline) no-repeat, var(--ds-color-black);
transform: translateY(calc(var(--at) * var(--row-h)));
transition: transform var(--ds-duration-slow) var(--ds-easing-loop), opacity var(--ds-duration-slow) var(--ds-easing-loop) var(--ds-duration-slow);
}
.ds-pv-rank[data-out] { z-index: 0; opacity: 0; transition: transform var(--ds-duration-slow) var(--ds-easing-loop), opacity var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-rank-thumb { position: relative; flex: none; width: var(--thumb-w); height: var(--thumb-h); }
.ds-pv-rank-main { display: flex; flex: 1; flex-direction: column; gap: 8px; min-width: 0; }
.ds-pv-rank-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ds-pv-rank-line > .ds-pv-sub { flex: none; }
.ds-pv-fill-track { position: relative; display: block; min-width: 0; height: 4px; overflow: visible; clip-path: inset(-8px 0); color: var(--ds-color-edge-strong); line-height: 4px; }
.ds-pv-fill { position: absolute; inset: 0; color: var(--ds-color-fg); clip-path: inset(-8px calc(100% - round(down, calc(var(--share) * 100%), 8px)) -8px 0); transition: clip-path var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-values { display: grid; flex: none; justify-items: end; min-width: 48px; }
.ds-pv-values > span { grid-area: 1 / 1; color: var(--ds-color-fg-soft); font-variant-numeric: tabular-nums; white-space: nowrap; opacity: 0; transition: opacity var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-values > [data-on] { opacity: 1; }
.ds-pv-rank[data-muted] .ds-pv-name-cell, .ds-pv-rank[data-muted] .ds-pv-values > span, .ds-pv-rank[data-muted] .ds-pv-fill { color: var(--ds-color-fg-faint); }
.ds-pv-rank[data-muted] .ds-pv-pic > * { filter: grayscale(1); }
@container ds-pv (width < 440px) {
.ds-pv-sheetlist { --row-h: 44px; --thumb-w: 28px; --thumb-h: 36px; }
.ds-pv-sheetlist .ds-pv-sheet { top: 12px; width: calc(100% - 32px); min-height: 100%; padding-top: 12px; }
.ds-pv-sheetlist .ds-pv-note, .ds-pv-rank:not([data-muted]) .ds-pv-rank-line > .ds-pv-sub { display: none; }
.ds-pv-tab { padding-inline: 8px; font-size: var(--ds-text-caption); line-height: var(--ds-text-caption-leading); }
.ds-pv-ranked { margin-top: 8px; }
}
@container ds-pv (width >= 560px) {
.ds-pv-sheetlist { --row-h: 64px; --thumb-w: 40px; --thumb-h: 48px; font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading); }
.ds-pv-sheetlist .ds-pv-sheet { top: 16%; min-height: calc(84% + 16px); padding: 24px 16px 0; }
.ds-pv-sheet-head { gap: 12px; }
.ds-pv-sheetlist .ds-pv-logo { width: 24px; height: 24px; }
.ds-pv-sheet-head > .ds-pv-strong { font-size: var(--ds-text-body); line-height: var(--ds-text-body-leading); }
.ds-pv-tab { height: 40px; padding-inline: 16px; }
.ds-pv-rank-main { gap: 12px; }
.ds-pv-name-cell { font-size: var(--ds-text-body); line-height: var(--ds-text-body-leading); }
}
/* Patterns: share bars by hook, angle or persona over three ads, the top ad in focus. */
.ds-pv-patterns .ds-pv-head { justify-content: flex-start; }
.ds-pv-patterns .ds-pv-head > .ds-pv-sub { margin-left: auto; }
.ds-pv-set { display: grid; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.ds-pv-share-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; row-gap: 4px; }
.ds-pv-share-row > .ds-pv-swap { min-width: 0; }
.ds-pv-share-row > .ds-pv-swap > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-pv-share-row > .ds-pv-swap > [data-on] { transition-delay: var(--ds-duration-micro); }
.ds-pv-share-row > .ds-pv-swap + .ds-pv-swap { justify-items: end; color: var(--ds-color-fg-soft); }
.ds-pv-bar-track { grid-column: 1 / -1; height: 4px; overflow: hidden; border-radius: var(--ds-radius-panel); background: var(--ds-color-surface-inset); }
.ds-pv-bar-fill { display: block; height: 100%; background: var(--ds-color-white); transform-origin: left center; transition: transform var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-ads { flex: 1 1 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ds-pv-ad { position: relative; overflow: hidden; container-type: inline-size; border-radius: var(--ds-radius-sm); background: var(--ds-color-surface-raised); }
.ds-pv-ad > .ds-pv-pic > * { filter: blur(calc(100cqw * 24 / 117.4)); scale: 1.1; transition: filter var(--ds-duration-slow) var(--ds-easing-loop), scale var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-ad[data-top] > .ds-pv-pic > * { filter: blur(0); scale: 1; }
.ds-pv-badge { position: absolute; top: 8px; left: 8px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--ds-radius-panel); background: var(--ds-color-white); color: var(--ds-color-black); font-weight: var(--ds-font-weight-medium); opacity: 0; transition: opacity var(--ds-duration-slow) var(--ds-easing-loop); }
.ds-pv-ad[data-top] > .ds-pv-badge { opacity: 1; }
@container ds-pv (width < 440px) {
.ds-pv-patterns .ds-pv-sheet { top: 16px; width: calc(100% - 32px); min-height: 100%; padding-top: 12px; }
.ds-pv-patterns .ds-pv-head, .ds-pv-patterns .ds-pv-control { margin-bottom: 8px; }
.ds-pv-set { gap: 4px; margin-bottom: 8px; }
}
/* Links board: a 1080 board scaled to the stage, building and clearing scene by scene. */
.ds-pv-board { position: absolute; inset: 0; container: ds-pv-board / size; }
.ds-pv-canvas { --u: calc(max(100cqw, 100cqh) / 1080); --cut-x: max(0px, (100cqh - 100cqw) / 2); position: absolute; inset: 0; overflow: clip; }
.ds-pv-boardview { position: absolute; left: calc(50% - var(--u) * 540); top: calc(50% - var(--u) * 540); width: calc(var(--u) * 1080); height: calc(var(--u) * 1080); will-change: transform; }
.ds-pv-scene { position: absolute; inset: 0; }
.ds-pv-tile { position: absolute; left: calc(var(--u) * var(--x)); top: calc(var(--u) * var(--y)); width: calc(var(--u) * var(--w)); height: calc(var(--u) * var(--h)); overflow: hidden; border-radius: var(--ds-radius-sm); }
.ds-pv-tile > .ds-pv-pic { border-radius: 0; }
.ds-pv-page-ui { position: absolute; left: var(--cut-x); right: 0; bottom: 0; display: grid; justify-items: start; gap: 8px; }
.ds-pv-ads-count {
height: 24px; margin-left: 8px; padding-inline: 8px; border-radius: var(--ds-radius-panel); outline: var(--ds-border-hairline) solid var(--ds-color-edge-surface);
outline-offset: calc(-1 * var(--ds-border-hairline)); background: var(--ds-color-black); color: var(--ds-color-fg); line-height: 24px; white-space: nowrap;
}
.ds-pv-url-bar {
display: flex; align-items: center; gap: 8px; justify-self: stretch; min-width: 0; height: 32px; padding-inline: 8px;
border-top: var(--ds-border-hairline) solid var(--ds-color-edge-surface); background: var(--ds-color-black); color: var(--ds-color-fg);
font-size: var(--ds-text-ui); line-height: var(--ds-text-ui-leading);
}
.ds-pv-url-bar > .ds-pv-logo { width: 16px; height: 16px; font-size: var(--ds-text-caption); }
.ds-pv-url-bar .ds-pv-sub { color: var(--ds-color-fg-muted); }
.ds-pv-avatar { position: absolute; left: calc(var(--u) * (var(--cx) - var(--d) / 2)); top: calc(var(--u) * (var(--cy) - var(--d) / 2)); width: calc(var(--u) * var(--d)); height: calc(var(--u) * var(--d)); overflow: hidden; border-radius: var(--ds-radius-sm); background: var(--ds-color-surface-inset); }
.ds-pv-handle-chip {
--chip-h: 24px; position: absolute; left: calc(var(--u) * var(--cx)); top: calc(var(--u) * var(--edge) - var(--chip-h) - 8px); height: var(--chip-h); padding-inline: 8px;
border: var(--ds-border-hairline) solid var(--ds-color-edge-surface); border-radius: var(--ds-radius-panel); background: var(--ds-color-black); color: var(--ds-color-fg);
font-size: var(--ds-text-ui); line-height: calc(var(--chip-h) - 2 * var(--ds-border-hairline)); font-weight: var(--ds-font-weight-medium); white-space: nowrap; transform: translateX(-50%);
}
@container ds-pv (width < 440px) {
.ds-pv-handle-chip { --chip-h: 20px; font-size: var(--ds-text-caption); }
.ds-pv-url-bar { height: 24px; font-size: var(--ds-text-caption); line-height: var(--ds-text-caption-leading); }
.ds-pv-url-bar > .ds-pv-logo, .ds-pv-url-bar .ds-pv-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
.ds-pv-step, .ds-pv-indicator, .ds-pv-swap > *, .ds-pv-account, .ds-pv-bars, .ds-pv-text-block, .ds-pv-share, .ds-pv-view, .ds-pv-chip,
.ds-pv-chip > span, .ds-pv-fold, .ds-pv-counts > span, .ds-pv-pill, .ds-pv-slot > .ds-pv-pic, .ds-pv-slot > .ds-pv-pic > *, .ds-pv-window,
.ds-pv-tray-pill, .ds-pv-tab, .ds-pv-rank, .ds-pv-rank[data-out], .ds-pv-fill, .ds-pv-values > span, .ds-pv-bar-fill, .ds-pv-ad > .ds-pv-pic > *,
.ds-pv-badge { transition: none; }
}
`// The links board's timeline (site v2/motion/collaborate.ts), framework-free: a 1080 board of nine tiles and two
// creators, drawn frame by frame at 60fps. Each scene is 158 frames: the view zooms in from 1.2564, the tiles fade in
// one after another, the creators' pictures grow in with their handles sliding up, and near the end everything clears
// for the next scene. The curves are the site's, sampled per frame.
export const BOARD_STEP = 1000 / 60
export const BOARD_SCENE = 158
export const BOARD_VIEW = 1080
/** The composed frame, shown with reduced motion and held before the loop starts. */
export const BOARD_STILL = 110
type Bezier = [number, number, number, number]
type Ease = { frames: number; curve: Bezier }
const ZOOM = { from: 1.2564, start: -4.174, frames: 97.585, curve: [0.184, -0.154, 0.187, 0.913] as Bezier }
export const BOARD_TILES = [
{ x: 0, y: 0, w: 522, h: 355, in: 24.79, out: 144 },
{ x: 550, y: 0, w: 272, h: 356, in: 20.4, out: 142 },
{ x: 849, y: 0, w: 231, h: 520, in: 27.97, out: 146 },
{ x: 0, y: 384, w: 223, h: 312, in: 23.84, out: 144 },
{ x: 849, y: 548, w: 231, h: 532, in: 27.97, out: 146 },
{ x: 0, y: 724, w: 223, h: 356, in: 27.97, out: 146 },
{ x: 250, y: 724, w: 273, h: 174, in: 16.45, out: 140 },
{ x: 552, y: 724, w: 270, h: 356, in: 20.37, out: 142 },
{ x: 251, y: 927, w: 272, h: 153, in: 25.27, out: 144 },
]
const TILE_IN: Ease = { frames: 21.78, curve: [0.417, 0.889, 0.791, 0.925] }
const TILE_OUT: Ease = { frames: 10.02, curve: [0.34, 0.82, 0.621, 0.953] }
const TILE_OUT_SHRINK: Ease = { frames: 10.44, curve: [0.333, 0.735, 0.486, 0.676] }
const TILE_OUT_SCALE = 0.955
export const BOARD_AVATAR = { d: 255, y: 509.3, x: [385.6, 685.6] }
const AVATAR_IN = { opacityFrames: 8, scaleFrom: 0.7, scale: { frames: 12.51, curve: [0.1, 0.165, 0.279, 1] as Bezier } }
const AVATAR_OUT = { at: [132, 137], scaleTo: 0.7, scale: { frames: 8, curve: [0.479, 1.17, 1, 0.919] as Bezier }, opacity: { frames: 9.01, curve: [0.387, 1.057, 0.799, 0.971] as Bezier } }
const CHIP_IN = { at: [4, 8], from: 18, slide: { frames: 14.03, curve: [0.06, 0.097, 0.27, 0.982] as Bezier }, opacityFrames: 8 }
const CHIP_OUT = { at: [132, 137], to: 12, slide: { frames: 8.02, curve: [0.45, 1.394, 1, 0.837] as Bezier }, opacityFrames: 8 }
function bezier([x1, y1, x2, y2]: Bezier, t: number) {
if (t <= 0) return 0
if (t >= 1) return 1
const bx = (u: number) => 3 * (1 - u) ** 2 * u * x1 + 3 * (1 - u) * u ** 2 * x2 + u ** 3
const by = (u: number) => 3 * (1 - u) ** 2 * u * y1 + 3 * (1 - u) * u ** 2 * y2 + u ** 3
let lo = 0
let hi = 1
let u = t
for (let i = 0; i < 24; i++) {
const x = bx(u) - t
if (Math.abs(x) < 1e-6) break
if (x > 0) hi = u
else lo = u
u = (lo + hi) / 2
}
return by(u)
}
const ease = (e: Ease, from: number, k: number) => bezier(e.curve, (k - from) / e.frames)
const linear = (from: number, frames: number, k: number) => Math.min(Math.max((k - from) / frames, 0), 1)
export const boardZoomAt = (k: number) => 1 + (ZOOM.from - 1) * (1 - bezier(ZOOM.curve, (k - ZOOM.start) / ZOOM.frames))
export function boardTileAt(i: number, k: number) {
const t = BOARD_TILES[i]
return { opacity: ease(TILE_IN, t.in, k) * (1 - ease(TILE_OUT, t.out, k)), scale: 1 - (1 - TILE_OUT_SCALE) * ease(TILE_OUT_SHRINK, t.out, k) }
}
export function boardAvatarAt(i: number, k: number) {
const leave = AVATAR_OUT.at[i]
const scaleIn = AVATAR_IN.scaleFrom + (1 - AVATAR_IN.scaleFrom) * ease(AVATAR_IN.scale, 0, k)
const scaleOut = 1 - (1 - AVATAR_OUT.scaleTo) * ease(AVATAR_OUT.scale, leave, k)
return { opacity: linear(0, AVATAR_IN.opacityFrames, k) * (1 - ease(AVATAR_OUT.opacity, leave, k)), scale: scaleIn * scaleOut }
}
export function boardChipAt(i: number, k: number) {
const arrive = CHIP_IN.at[i]
const go = CHIP_OUT.at[i]
return {
opacity: linear(arrive, CHIP_IN.opacityFrames, k) * (1 - linear(go, CHIP_OUT.opacityFrames, k)),
dy: CHIP_IN.from * (1 - ease(CHIP_IN.slide, arrive, k)) + CHIP_OUT.to * ease(CHIP_OUT.slide, go, k),
}
}// Joins class names, skipping falsy ones: cn('a', on && 'b', ['c', undefined]). It does not merge conflicting
// utilities (no tailwind-merge), as Vue's class binding does not: the library's classes are written not to compete,
// and a className from the caller is appended after them, as Vue appends a fallthrough class.
export type ClassValue = string | false | null | undefined | 0 | ClassValue[]
export function cn(...values: ClassValue[]): string {
const out: string[] = []
for (const v of values) {
if (!v) continue
if (Array.isArray(v)) {
const s = cn(...v)
if (s) out.push(s)
}
else out.push(v)
}
return out.join(' ')
}import { html, unsafeCSS, type PropertyValues } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { mountProductVisual, productVisualCss, type ProductVisualKind } from '@/lib/product-visual'
import styles from 'virtual:tw'
// ProductVisual.tsx as <spyglass-product-visual>: the 4:3 stage of a product page's feature row with one looping scene
// of the product, built by the same engine (lib/product-visual.ts) so both flavors draw the same nodes. `kind` picks
// the scene, `data` (JSON) its content (Acme by default), `texture` the ASCII field's position (0 to 3, or "none").
/**
* @summary A product page's feature visual: a small looping scene of the product on the 4:3 stage.
*/
export class ProductVisual extends DsElement {
static styles = [DsElement.styles, styles, unsafeCSS(productVisualCss)]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="product-visual"]'))
static properties = { kind: { reflect: true }, data: { type: Object }, texture: {}, fill: { type: Boolean } }
/** Which scene. */
kind: ProductVisualKind = 'brand-record'
/** The kind's content; Acme by default. */
data?: unknown
/** The ASCII field's position, 0 to 3, or "none". */
texture?: number | string
/** Fill the box it is in (its height, no 4:3, no panel of its own): the header's live card. */
fill = false
private stop?: () => void
render() {
return html`<div data-ds="product-visual" data-kind=${this.kind} ?data-fill=${this.fill} class="ds-pv"></div>`
}
protected updated(changed: PropertyValues) {
super.updated(changed)
if (!changed.has('kind') && !changed.has('data') && !changed.has('texture')) return
this.stop?.()
const stage = this.renderRoot.querySelector<HTMLElement>('[data-ds="product-visual"]')
if (!stage) return
const t = this.texture
const texture = t === 'none' ? false : Number(t ?? 0) || 0
this.stop = mountProductVisual(stage, { kind: this.kind, data: (this.data ?? undefined) as never, texture })
}
connectedCallback() {
super.connectedCallback()
if (this.hasUpdated && !this.stop) this.requestUpdate('kind')
}
disconnectedCallback() {
super.disconnectedCallback()
this.stop?.()
this.stop = undefined
}
}
define('product-visual', ProductVisual)Reference: Site pages/Products/visuals (AddAccount, AddCreator, BrandRecord, CollabsTimeline, CommentThemes, CommentThread, CreativeRecord, CreatorFilters, CreatorRecord, FilterNarrow, PageRecord, RankedSheet, TaggedRecord, TaggedTimeline, useLoopCycle), v2/V2Features (LinksBoard, PatternsSwitch, v2/motion/collaborate.ts), ProductFeatures.module.css .stage and .ascii, components/loopPacing.ts; the records use v2/V2Pricing PanelsMotion (lib/panels-motion.ts) in its reading pace.