Site
Creative corridor
Creatives as walls on both sides, receding in perspective to a small light at the vanishing point, in the ad's exact places.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add creative-corridor<script type="module" src="/spyglass-ds/elements/creative-corridor.js"></script>Usage
The one picture of scale on a page: an index of every network, the depth of the archive. Headline above, a line of copy below.
Never
- Text over the corridor
- A corridor that moves or scrolls
- Two corridors on one page
Each picture is an image slot (src, alt, fit, position); without src it keeps its placeholder, which carries data-ds-placeholder.
Adds with it: brand-light, creative-card
Props
The web component takes the same as attributes or properties (<spyglass-creative-corridor>); title is heading there.
<CreativeCorridor>
| Prop | Type | Default |
|---|---|---|
items | CreativeItem[] Up to twelve creatives, nearest first, alternating left and right (fewer repeat). | |
seed | number The light's seed. | 0 |
className | string |
Examples
The same example in React and as web components; both render identically.
import { CreativeCorridor } from '@/react/components/site/CreativeCorridor'
// The ad's corridor: twelve walls receding to the light.
const items = [
{ brand: 'Acme Studio', tone: 3 as const },
{ brand: 'Acme Studio', tone: 2 as const },
{ brand: 'Acme Fit', tone: 4 as const },
{ brand: 'Acme Drinks', tone: 3 as const },
{ brand: 'Acme Skin', tone: 2 as const },
{ brand: 'Acme Fit', tone: 1 as const },
]
export default function Corridor() {
return <CreativeCorridor items={items} />
}<!-- The ad's corridor: twelve walls receding to the light. -->
<spyglass-creative-corridor items='[{"brand":"Acme Studio","tone":3},{"brand":"Acme Studio","tone":2},{"brand":"Acme Fit","tone":4},{"brand":"Acme Drinks","tone":3},{"brand":"Acme Skin","tone":2},{"brand":"Acme Fit","tone":1}]'></spyglass-creative-corridor>Source
import { BrandLight } from '@/react/components/visuals/BrandLight'
import { CreativeCard, type CreativeItem } from '@/react/components/site/CreativeCard'
import { CORRIDOR_FRAME, CORRIDOR_LIGHT, corridorWalls, placeAt } from '@/lib/creative-layouts'
import { cn } from '@/react/lib/cn'
// The corridor (Ad, The world's largest creative search engine): creatives as walls on both sides, receding in
// perspective to a small light at the vanishing point. Twelve walls, nearest first and left then right, in the ad's
// exact places; each is clipped so its far edge is shorter. The corridor scales with its width (1080 by 744).
export interface CreativeCorridorProps {
/** Up to twelve creatives, nearest first, alternating left and right (fewer repeat). */
items: CreativeItem[]
/** The light's seed. */
seed?: number
className?: string
}
export function CreativeCorridor({ items, seed = 0, className }: CreativeCorridorProps) {
const { width, height } = CORRIDOR_FRAME
return (
<div data-ds="creative-corridor" className={cn('relative w-full overflow-hidden', className)} style={{ aspectRatio: `${width} / ${height}` }}>
<div className="absolute" style={placeAt(CORRIDOR_LIGHT, width, height)}>
<BrandLight variant="close-up" seed={seed} cover className="size-full" />
</div>
{corridorWalls().map((wall, i) => {
const { light: _light, seed: _seed, ...item } = items.length ? items[i % items.length] : ({} as CreativeItem)
return (
<div key={i} className="absolute" style={{ ...placeAt(wall, width, height), clipPath: wall.clip }}>
<CreativeCard {...item} ratio="fill" />
</div>
)
})}
</div>
)
}
export default CreativeCorridor// 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 type { ImageFit } from '@/lib/image'
import { html } from 'lit'
import { ifDefined } from 'lit/directives/if-defined.js'
import { styleMap } from 'lit/directives/style-map.js'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { CORRIDOR_FRAME, CORRIDOR_LIGHT, corridorWalls, placeAt } from '@/lib/creative-layouts'
import '@/elements/components/site/creative-card'
import '@/elements/components/visuals/brand-light'
import styles from 'virtual:tw'
// CreativeCorridor.tsx as <spyglass-creative-corridor>: twelve creatives as walls receding to a small light, in the
// ad's places, nearest first and alternating left and right (`items`); `seed` draws the light.
export interface CreativeItem { src?: string; alt?: string; fit?: ImageFit; position?: string; brand?: string; caption?: string; tone?: 1 | 2 | 3 | 4; href?: string; light?: boolean; seed?: number }
/**
* @summary The corridor: creatives as walls receding to the light.
*/
export class CreativeCorridor extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="creative-corridor"]'))
static properties = { items: { type: Array }, seed: { type: Number } }
/** Up to twelve creatives, nearest first, left then right. */
items: CreativeItem[] = []
/** The light's seed. */
seed = 0
render() {
const { width, height } = CORRIDOR_FRAME
const items = this.items ?? []
return html`<div data-ds="creative-corridor" class="relative w-full overflow-hidden" style="aspect-ratio: ${width} / ${height};"><div class="absolute" style=${styleMap(placeAt(CORRIDOR_LIGHT, width, height))}><spyglass-brand-light variant="close-up" seed=${this.seed} cover class="size-full"></spyglass-brand-light></div>${corridorWalls().map((wall, i) => {
const it: CreativeItem = items.length ? items[i % items.length] : {}
return html`<div class="absolute" style=${styleMap({ ...placeAt(wall, width, height), clipPath: wall.clip })}><spyglass-creative-card ratio="fill" src=${ifDefined(it.src)} fit=${ifDefined(it.fit)} position=${ifDefined(it.position)} alt=${ifDefined(it.alt)} brand=${ifDefined(it.brand)} caption=${ifDefined(it.caption)} tone=${ifDefined(it.tone)} href=${ifDefined(it.href)}></spyglass-creative-card></div>`
})}</div>`
}
}
define('creative-corridor', CreativeCorridor)Reference: Figma page 8: Ad, The world's largest creative search engine (Corridor L0 to L5 and R0 to R5, Light, end of corridor 140x104 at the vanishing point).