Blocks

Stories block

The site's stories section: the section head centered over quotes in #262626 cards (the company's mark or name, the quote in Funnel Display 20/24, the person with a ringed 40px avatar and the role in capitals), three columns from 1024 that line up row by row, two cards in the middle, and an optional row of customer marks over a hairline.

Install

React apps get the React files; every other stack gets the web component.

npx spyglass-ds add stories-block
<script type="module" src="/spyglass-ds/elements/stories-block.js"></script>
Six stories with customers

Marketing teams on Spyglass

Marketers, founders and agencies on how they research creative now.

  • Acme

    “Creators, competitor tracking and trend research, all in one place. It changed how our team plans every launch.”

    SamPerformance marketer, Acme
  • Acme Labs

    “The first platform that really cracks creative research. We brief from what is working, not from what we remember.”

    JoHead of growth, Acme Labs
  • Acme Studio

    “Sharp, quick and built by a team that ships fixes the same day. The easiest tool to recommend to any operator.”

    AriFounder, Acme Studio
  • Acme Goods

    “It shows me what our audience actually sees. Finding trends and new audiences has never been easier.”

    KitGeneral manager, Acme Goods
  • Acme Air

    “Agencies cannot afford blind spots. This gives us full competitive visibility across every account we run.”

    RaeOperations lead, Acme Air
  • Acme & Co

    “We built the brand around our customers. This is the one place that shows every creative they engage with.”

    LouCo-founder, Acme & Co
  • Acme
  • Acme Labs
  • Acme Studio
  • Acme Goods
  • Acme Air
  • Acme & Co
Three stories

Creative research, in their words

A head of growth, a founder and a general manager on researching creative.

  • Acme Labs

    “The first platform that really cracks creative research. We brief from what is working, not from what we remember.”

    JoHead of growth, Acme Labs
  • Acme Studio

    “Sharp, quick and built by a team that ships fixes the same day. The easiest tool to recommend to any operator.”

    AriFounder, Acme Studio
  • Acme Goods

    “It shows me what our audience actually sees. Finding trends and new audiences has never been easier.”

    KitGeneral manager, Acme Goods
Two stories

Built by a team that ships

A head of growth and a founder on the team behind the API.

  • Acme Labs

    “The first platform that really cracks creative research. We brief from what is working, not from what we remember.”

    JoHead of growth, Acme Labs
  • Acme Studio

    “Sharp, quick and built by a team that ships fixes the same day. The easiest tool to recommend to any operator.”

    AriFounder, Acme Studio

Usage

Quotes from customers on the home page and on use case pages. stories takes { company, logo?, quote, name, role, photo? }; customers and logos show the row of marks (the use case pages hide it).

Never

  • A real person's quote, name or photo without their consent: Acme placeholders in templates and examples
  • Another company's logo shipped in the library: pass the marks you may show
  • Stars, ratings or a carousel
  • A filter or tint over a photo

Props

The web component takes the same as attributes or properties (<spyglass-stories-block>); title is heading there.

<StoriesBlock>

PropTypeDefault
idstring

The section's id (its heading is `<id>-heading`).

'stories'
headlinestringstoriesContent.headline
leadstringstoriesContent.lead
storiesStory[]

The stories, in order: { company, logo?, quote, name, role, photo? }.

storiesContent.stories
customersboolean

Show the row of customer marks under the stories.

true
logosStoryCustomer[]

The customer marks: { name, src?, ratio?, height? }.

storiesContent.customers
customersLabelstring

The customer row's name for assistive tech.

storiesContent.customersLabel
classNamestring

Examples

The same example in React and as web components; both render identically.

react/examples/stories-block/Home.tsx
import { StoriesBlock } from '@/react/components/blocks/StoriesBlock'
// Six Acme stories in three columns that line up row by row, with the row of customer marks under them.

export default function Home() {
  return <StoriesBlock id="stories-home" />
}
elements/examples/stories-block/Home.html
<!-- Six Acme stories in three columns that line up row by row, with the row of customer marks under them. -->
<spyglass-stories-block section-id="stories-home"></spyglass-stories-block>
react/examples/stories-block/Team.tsx
import { StoriesBlock } from '@/react/components/blocks/StoriesBlock'
import { storiesContent } from '@/lib/stories'
// A use case page's three stories with its own head and no customer row.

export default function Team() {
  return <StoriesBlock id="stories-team" headline="Creative research, in their words" lead="A head of growth, a founder and a general manager on researching creative." stories={storiesContent.stories.slice(1, 4)} customers={false} />
}
elements/examples/stories-block/Team.html
<!-- A use case page's three stories with its own head and no customer row. -->
<spyglass-stories-block section-id="stories-team" headline="Creative research, in their words" lead="A head of growth, a founder and a general manager on researching creative." customers="false" stories='[{"company":"Acme Labs","quote":"The first platform that really cracks creative research. We brief from what is working, not from what we remember.","name":"Jo","role":"Head of growth"},{"company":"Acme Studio","quote":"Sharp, quick and built by a team that ships fixes the same day. The easiest tool to recommend to any operator.","name":"Ari","role":"Founder"},{"company":"Acme Goods","quote":"It shows me what our audience actually sees. Finding trends and new audiences has never been easier.","name":"Kit","role":"General manager"}]'></spyglass-stories-block>
react/examples/stories-block/Pair.tsx
import { StoriesBlock } from '@/react/components/blocks/StoriesBlock'
import { storiesContent } from '@/lib/stories'
// Two stories sit in the middle of the row.

export default function Pair() {
  return <StoriesBlock id="stories-pair" headline="Built by a team that ships" lead="A head of growth and a founder on the team behind the API." stories={storiesContent.stories.slice(1, 3)} customers={false} />
}
elements/examples/stories-block/Pair.html
<!-- Two stories sit in the middle of the row. -->
<spyglass-stories-block section-id="stories-pair" headline="Built by a team that ships" lead="A head of growth and a founder on the team behind the API." customers="false" stories='[{"company":"Acme Labs","quote":"The first platform that really cracks creative research. We brief from what is working, not from what we remember.","name":"Jo","role":"Head of growth"},{"company":"Acme Studio","quote":"Sharp, quick and built by a team that ships fixes the same day. The easiest tool to recommend to any operator.","name":"Ari","role":"Founder"}]'></spyglass-stories-block>

Source

react/components/blocks/StoriesBlock.tsx
import type { CSSProperties } from 'react'
import { storiesContent, storiesCss, storyInitials, type Story, type StoryCustomer, type StoryMark } from '@/lib/stories'
import { cn } from '@/react/lib/cn'

// The site's stories section (v3/V3Stories): the section head centered over cards of quotes, #262626 with 8px corners.
// Each card has the company (its mark in the soft gray, or its name), the quote in Funnel Display 20/24 and the person
// at the foot (a 40px avatar ringed by the strong hairline, the name, the role in capitals). One column up to 640px wide
// on phones; from 1024 three columns whose cards line up row by row; two cards sit in the middle. Under them, with
// `customers`, a row of customer marks over a hairline. Quotes come through `stories`: Acme placeholders by default,
// never a real person or customer without their consent.
export interface StoriesBlockProps {
  /** The section's id (its heading is `<id>-heading`). */
  id?: string
  headline?: string
  lead?: string
  /** The stories, in order: { company, logo?, quote, name, role, photo? }. */
  stories?: Story[]
  /** Show the row of customer marks under the stories. */
  customers?: boolean
  /** The customer marks: { name, src?, ratio?, height? }. */
  logos?: StoryCustomer[]
  /** The customer row's name for assistive tech. */
  customersLabel?: string
  className?: string
}

function Mark({ logo, label, className, at = 'left center' }: { logo: StoryMark; label: string; className: string; at?: string }) {
  return <span role="img" aria-label={label} className={className} style={{ height: logo.height, aspectRatio: String(logo.ratio), mask: `url("${logo.src}") ${at} / contain no-repeat` } as CSSProperties} />
}

export function StoriesBlock({ id = 'stories', headline = storiesContent.headline, lead = storiesContent.lead, stories = storiesContent.stories, customers = true, logos = storiesContent.customers, customersLabel = storiesContent.customersLabel, className }: StoriesBlockProps) {
  return (
    <section data-ds="stories-block" id={id} aria-labelledby={`${id}-heading`} className={cn('py-(--ds-layout-section) text-fg', className)}>
      <style href="ds-stories-block" precedence="ds">{storiesCss}</style>
      <div className="mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)">
        <header className="mb-16 flex flex-col items-center text-center lg:mb-20">
          <h2 id={`${id}-heading`} className="type-section [text-box:trim-start_cap_alphabetic]">{headline}</h2>
          <p className="mt-6 max-w-measure type-body-lg text-pretty text-fg-soft">{lead}</p>
        </header>
        <ul role="list" className="ds-stories mx-auto grid max-w-measure grid-cols-1 gap-4 lg:max-w-none lg:grid-cols-3 lg:gap-6">
          {stories.map((story) => (
            <li key={`${story.company}-${story.name}`} className="min-w-0 rounded-panel bg-surface-raised p-6 lg:row-span-3 lg:grid lg:grid-rows-subgrid lg:gap-y-0 lg:p-8">
              <figure className="flex h-full flex-col lg:row-span-3 lg:grid lg:grid-rows-subgrid lg:gap-y-0">
                <p className="flex min-h-8 items-center">
                  {story.logo
                    ? <Mark logo={story.logo} label={story.company} className="block bg-fg-soft" />
                    : <span className="type-body font-medium text-fg-soft">{story.company}</span>}
                </p>
                <blockquote className="mt-8 type-heading-4 text-pretty text-fg lg:self-start">
                  <p>&ldquo;{story.quote}&rdquo;</p>
                </blockquote>
                <figcaption className="mt-auto flex items-center gap-3 pt-8">
                  <span className={cn('relative grid size-10 flex-none place-items-center overflow-hidden rounded-full border border-edge-strong type-ui font-medium text-fg-soft', story.photo ? 'bg-edge-strong' : 'bg-surface-inset')}>
                    <span aria-hidden="true">{storyInitials(story.name)}</span>
                    {story.photo ? <img src={story.photo} alt="" loading="lazy" decoding="async" className="absolute inset-0 size-full rounded-full object-cover" /> : null}
                  </span>
                  <span className="flex min-w-0 flex-col">
                    <span className="type-ui font-medium text-fg">{story.name}</span>
                    <span className="mt-1 type-label text-fg-muted">{story.role}, {story.company}</span>
                  </span>
                </figcaption>
              </figure>
            </li>
          ))}
        </ul>
        {customers && logos.length ? (
          <ul role="list" aria-label={customersLabel} className="mx-auto mt-16 grid max-w-measure grid-cols-2 items-center justify-items-center gap-x-4 gap-y-8 border-t border-edge pt-12 md:grid-cols-3 lg:mt-20 lg:flex lg:max-w-none lg:flex-wrap lg:justify-between lg:px-12">
            {logos.map((logo) => (
              <li key={logo.name}>
                {logo.src
                  ? <Mark logo={{ src: logo.src, ratio: logo.ratio ?? 4, height: logo.height ?? 24 }} label={logo.name} className="block bg-fg-muted" at="center" />
                  : <span className="type-heading-4 whitespace-nowrap text-fg-muted">{logo.name}</span>}
              </li>
            ))}
          </ul>
        ) : null}
      </div>
    </section>
  )
}

export default StoriesBlock
lib/stories.ts
// The stories block's data and Acme placeholders (site v3/V3Stories, content/v3/stories.ts), read by both flavors.
// A story is a quote with the person under it; a company's mark is drawn in the soft gray through a mask, so any
// single-color file works. The placeholders are Acme's, with no photo: the avatar shows the initials.

/** A company's mark: a single-color file drawn through a mask. */
export interface StoryMark {
  src: string
  /** Width over height. */
  ratio: number
  /** Height in px: 16, 20, 24 or 32. */
  height: number
}

export interface Story {
  company: string
  /** The company's mark; without one the company is set as text. */
  logo?: StoryMark
  quote: string
  name: string
  role: string
  /** The person's photo, cropped round; without one, their initials. */
  photo?: string
}

/** A customer's mark in the row under the stories; without `src` the name is set as a wordmark. */
export interface StoryCustomer {
  name: string
  src?: string
  ratio?: number
  height?: number
}

export const storiesContent = {
  headline: 'Marketing teams on Spyglass',
  lead: 'Marketers, founders and agencies on how they research creative now.',
  customersLabel: 'Spyglass customers',
  stories: [
    { company: 'Acme', quote: 'Creators, competitor tracking and trend research, all in one place. It changed how our team plans every launch.', name: 'Sam', role: 'Performance marketer' },
    { company: 'Acme Labs', quote: 'The first platform that really cracks creative research. We brief from what is working, not from what we remember.', name: 'Jo', role: 'Head of growth' },
    { company: 'Acme Studio', quote: 'Sharp, quick and built by a team that ships fixes the same day. The easiest tool to recommend to any operator.', name: 'Ari', role: 'Founder' },
    { company: 'Acme Goods', quote: 'It shows me what our audience actually sees. Finding trends and new audiences has never been easier.', name: 'Kit', role: 'General manager' },
    { company: 'Acme Air', quote: 'Agencies cannot afford blind spots. This gives us full competitive visibility across every account we run.', name: 'Rae', role: 'Operations lead' },
    { company: 'Acme & Co', quote: 'We built the brand around our customers. This is the one place that shows every creative they engage with.', name: 'Lou', role: 'Co-founder' },
  ] as Story[],
  customers: [{ name: 'Acme' }, { name: 'Acme Labs' }, { name: 'Acme Studio' }, { name: 'Acme Goods' }, { name: 'Acme Air' }, { name: 'Acme & Co' }] as StoryCustomer[],
}

/** The first letters of the first two words (the avatar without a photo). */
export const storyInitials = (name: string) => name.split(' ').map((part) => part[0] ?? '').join('').slice(0, 2)

// The grid's rules a class cannot say: from 1024 the cards share rows through a subgrid (company, quote, person line
// up across a row); three cards or fewer take one row; two cards sit in the middle eight of twelve columns.
export const storiesCss = `
@media (min-width: 1024px) {
  .ds-stories { grid-template-rows: repeat(2, auto 1fr auto); }
  .ds-stories:not(:has(> :nth-child(4))) { grid-template-rows: auto 1fr auto; }
  .ds-stories:has(> :nth-child(2):last-child) { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .ds-stories:has(> :nth-child(2):last-child) > :first-child { grid-column: 3 / span 4; }
  .ds-stories:has(> :nth-child(2):last-child) > :last-child { grid-column: 7 / span 4; }
}
`
react/lib/cn.ts
// 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(' ')
}
elements/components/blocks/stories-block.ts
import { html, unsafeCSS } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { storiesContent, storiesCss, storyInitials, type Story, type StoryCustomer, type StoryMark } from '@/lib/stories'
import styles from 'virtual:tw'

// StoriesBlock.tsx as <spyglass-stories-block>: the section head centered over cards of quotes (company, quote, person),
// three columns from 1024 that line up row by row, two cards in the middle, and with `customers` a row of marks over a
// hairline. `stories` and `logos` as JSON; `section-id` names the section (React's `id`); `customers="false"` hides the row.

const mark = (logo: StoryMark, label: string, className: string, at = 'left center') => html`<span role="img" aria-label=${label} class=${className} style=${`height: ${logo.height}px; aspect-ratio: ${logo.ratio}; mask: url("${logo.src}") ${at} / contain no-repeat`}></span>`

/** @summary The stories section: quotes in cards, with an optional row of customer marks. */
export class StoriesBlock extends DsElement {
	static styles = [DsElement.styles, styles, unsafeCSS(storiesCss)]
	protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="stories-block"]'))
	static properties = { sectionId: { attribute: 'section-id' }, headline: {}, lead: {}, stories: { type: Array }, customers: { type: Boolean, converter: { fromAttribute: (v: string | null) => v !== 'false' } }, logos: { type: Array }, customersLabel: { attribute: 'customers-label' } }
	/** The section's id (React's `id`); its heading is `<id>-heading`. */
	sectionId = 'stories'
	headline = storiesContent.headline
	lead = storiesContent.lead
	/** The stories: { company, logo?, quote, name, role, photo? }. */
	stories: Story[] = storiesContent.stories
	/** Show the row of customer marks ("false" hides it). */
	customers = true
	/** The customer marks: { name, src?, ratio?, height? }. */
	logos: StoryCustomer[] = storiesContent.customers
	/** The customer row's name for assistive tech. */
	customersLabel = storiesContent.customersLabel

	render() {
		const id = this.sectionId
		const stories = this.stories ?? storiesContent.stories
		const logos = this.logos ?? storiesContent.customers
		return html`<section data-ds="stories-block" id=${id} aria-labelledby=${`${id}-heading`} class="py-(--ds-layout-section) text-fg"><div class="mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)"><header class="mb-16 flex flex-col items-center text-center lg:mb-20"><h2 id=${`${id}-heading`} class="type-section [text-box:trim-start_cap_alphabetic]">${this.headline}</h2><p class="mt-6 max-w-measure type-body-lg text-pretty text-fg-soft">${this.lead}</p></header><ul role="list" class="ds-stories mx-auto grid max-w-measure grid-cols-1 gap-4 lg:max-w-none lg:grid-cols-3 lg:gap-6">${stories.map((story) => html`<li class="min-w-0 rounded-panel bg-surface-raised p-6 lg:row-span-3 lg:grid lg:grid-rows-subgrid lg:gap-y-0 lg:p-8"><figure class="flex h-full flex-col lg:row-span-3 lg:grid lg:grid-rows-subgrid lg:gap-y-0"><p class="flex min-h-8 items-center">${story.logo ? mark(story.logo, story.company, 'block bg-fg-soft') : html`<span class="type-body font-medium text-fg-soft">${story.company}</span>`}</p><blockquote class="mt-8 type-heading-4 text-pretty text-fg lg:self-start"><p>&ldquo;${story.quote}&rdquo;</p></blockquote><figcaption class="mt-auto flex items-center gap-3 pt-8"><span class=${`relative grid size-10 flex-none place-items-center overflow-hidden rounded-full border border-edge-strong type-ui font-medium text-fg-soft ${story.photo ? 'bg-edge-strong' : 'bg-surface-inset'}`}><span aria-hidden="true">${storyInitials(story.name)}</span>${story.photo ? html`<img src=${story.photo} alt="" loading="lazy" decoding="async" class="absolute inset-0 size-full rounded-full object-cover">` : ''}</span><span class="flex min-w-0 flex-col"><span class="type-ui font-medium text-fg">${story.name}</span><span class="mt-1 type-label text-fg-muted">${story.role}, ${story.company}</span></span></figcaption></figure></li>`)}</ul>${this.customers && logos.length ? html`<ul role="list" aria-label=${this.customersLabel} class="mx-auto mt-16 grid max-w-measure grid-cols-2 items-center justify-items-center gap-x-4 gap-y-8 border-t border-edge pt-12 md:grid-cols-3 lg:mt-20 lg:flex lg:max-w-none lg:flex-wrap lg:justify-between lg:px-12">${logos.map((logo) => html`<li>${logo.src ? mark({ src: logo.src, ratio: logo.ratio ?? 4, height: logo.height ?? 24 }, logo.name, 'block bg-fg-muted', 'center') : html`<span class="type-heading-4 whitespace-nowrap text-fg-muted">${logo.name}</span>`}</li>`)}</ul>` : ''}</div></section>`
	}
}

define('stories-block', StoriesBlock)

Reference: Site v3/V3Stories (V3Stories.tsx and .module.css, ui/Avatar): head 64px over the cards (80 from 1024), lead 24px under the head; cards 24px padding (32 from 1024), 8px corners, --surface, gaps 16 (24 from 1024), 640px wide on phones; quote 32px under the company, person 32px over the foot; customers 64px under (80), 48px over a hairline, two columns, three from 768, a spread row from 1024.