The site's case study: a centered head (breadcrumb, headline, kind and read time), the facts with the products it uses, the lead picture, the opening line over three figures, a pull quote, the sections with a second quote, and the pager to the other studies, with ASCII crops in the margins from 1024.
Install
React apps get the React files; every other stack gets the web component.
Competitor ads, hooks and landing pages for every client, pulled before the Monday stand-up.
12 hourssaved per strategist every week
9client brands briefed from one agent
3xmore hooks tested a month, in one quarter
“Most of our client report is written before anyone opens a deck.”
The challenge
Every Monday, each strategist spent half a day in ad libraries: screenshotting competitors' new ads, guessing how long they had run and pasting them into a deck for the client.
With nine brands in three categories, the research was always a week old by the time it reached a brief.
What they built
Acme Social connected Acme to Claude over MCP and wrote one prompt per client: the competitors to watch, the hooks to track and the formats that matter.
Each Monday the agent pulls every new ad, the hooks behind them and where each one leads, and drafts the client's competitor page in the agency's own template.
“We stopped arguing about what competitors were running. We just ask.”
The result
Strategists start the week reading a brief instead of building one. The time went back into testing: three times as many hooks a month, picked from what is already working in the category.
A customer story or case study page; study takes the story (lib/pages/case-studies.ts shows the fields), content.studies the list the pager walks.
Never
Real customers, people, quotes or logos unless you may show them: the examples are Acme
Another brand's photo as the lead picture without permission: the placeholder stands in
Figures that are not true for the story: they read as facts
sections lists the sections to show, in order (head, facts, cover, lead, body, more, close); a key left out is not shown. All but the close stay inside the article, where the first of them falls. The study's cover is an image slot; without src the placeholder carries data-ds-placeholder. menus passes the header menus (the live card's picture, the use cases' shots).
The web component takes the same as attributes or properties (<spyglass-case-study-page>); title is heading there.
<CaseStudyPage>
Prop
Type
Default
study
CaseStudy
content
CaseStudyContent
menus
HeaderMenus
The header menus' content, pictures included (the live card's `picture`, the use cases' `shots`); Acme by default.
sections
readonly CaseStudyPageSection[]
The sections to show, in order; all of them in the page order by default (leave one out to omit it).
className
string
Examples
The same example in React and as web components; both render identically.
react/examples/case-study-page/Page.tsx
import { CaseStudyPage } from '@/react/components/pages/CaseStudyPage'
// A case study as the site sets it, for Acme Social: a placeholder lead picture and the pager to the other study.
export default function Page() {
return <CaseStudyPage />
}
elements/examples/case-study-page/Page.html
<!-- A case study as the site sets it, for Acme Social: a placeholder lead picture and the pager to the other study. -->
<spyglass-case-study-page></spyglass-case-study-page>
Source
react/components/pages/CaseStudyPage.tsx
import { type CSSProperties, Fragment, type ReactNode } from 'react'
import { AsciiTrail } from '@/react/components/visuals/AsciiTrail'
import { Badge } from '@/react/components/ui/Badge'
import { CreativeCard } from '@/react/components/site/CreativeCard'
import { PageClose } from '@/react/components/site/PageClose'
import { SiteHeader } from '@/react/components/site/SiteHeader'
import { SiteFooter } from '@/react/components/blocks/SiteFooter'
import { asciiDriftStyleObject, type AsciiDriftCrop, type AsciiDriftFrom } from '@/lib/ascii-drift'
import { caseStudies, caseStudyContent, caseStudyMinutes, caseStudyNeighbors, type CaseStudy, type CaseStudyContent, caseStudyPageSections, type CaseStudyPageSection } from '@/lib/pages/case-studies'
import { cn } from '@/react/lib/cn'
import { pageSections, groupSections, imageFit } from '@/lib/image'
import type { HeaderMenus } from '@/lib/site-header'
// The site's case study (app/resources/case-studies/[slug], pages/CaseStudies/CaseStudyArticle): the header, then a
// centered head (the breadcrumb, the headline at the section head's size, the kind and the read time as badges), the
// facts in four columns (two on phones) with the products it uses linked, the lead picture (16:9, 4:5 on phones), the
// opening line over three figures, the pull quote on the #262626 surface, the sections with a second quote after the
// second, and the pager to the other studies between hairlines; the closing section and the footer follow. From 1024
// crops of the ASCII texture sit in the margins beside each band. Links change color under a mouse; nothing moves.
// `study` picks the study (lib/pages/case-studies.ts); `content.studies` sets the pager's neighbors.
export interface CaseStudyPageProps {
study?: CaseStudy
content?: CaseStudyContent
/** The header menus' content, pictures included (the live card's `picture`, the use cases' `shots`); Acme by default. */
menus?: HeaderMenus
/** The sections to show, in order; all of them in the page order by default (leave one out to omit it). */
sections?: readonly CaseStudyPageSection[]
className?: string
}
const CONTAINER = 'mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)'
const MEASURE = 'mx-auto w-full max-w-[calc(var(--ds-layout-measure)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)'
// The margins beside the head (its 880px title) and beside the 640px measure, less 64px.
const HEAD_SIDE = 'w-[calc((100%-880px)/2-64px)]'
const BODY_SIDE = 'w-[calc((100%-var(--ds-layout-measure))/2-64px)]'
function Drift({ crop, from, hero, className }: { crop: AsciiDriftCrop; from: AsciiDriftFrom; hero?: boolean; className: string }) {
return <span aria-hidden="true" className={cn('pointer-events-none absolute -z-1 hidden select-none lg:block', className)} style={asciiDriftStyleObject(crop, from, hero ? 'hero' : 'quiet') as CSSProperties} />
}
function Arrow({ back }: { back?: boolean }) {
return (
<svg viewBox="0 0 16 16" width={16} height={16} aria-hidden="true" focusable="false" className="size-4 transition-[color] duration-160 ease-out group-hover:text-fg group-focus-visible:text-fg">
<path d={back ? 'M13 8H4M7.5 4.5 4 8l3.5 3.5' : 'M3 8h9M8.5 4.5 12 8l-3.5 3.5'} fill="none" stroke="currentColor" strokeWidth="1.5" />
</svg>
)
}
const ARTICLE: readonly CaseStudyPageSection[] = ['head', 'facts', 'cover', 'lead', 'body', 'more']
const LABEL = 'type-ui text-fg-muted transition-[color] duration-160 ease-out group-hover:text-fg group-focus-visible:text-fg'
export function CaseStudyPage({ study: s = caseStudies[0], content: c = caseStudyContent, menus, sections, className }: CaseStudyPageProps) {
const { previous, next } = caseStudyNeighbors(c.studies, s.slug)
const id = `${s.slug}-heading`
const parts: Record<CaseStudyPageSection, ReactNode> = {
head: (
<div className="relative">
<Drift crop="column" from="left" hero className={cn(HEAD_SIDE, 'top-[8%] left-0 h-[84%]')} />
<Drift crop="scatter" from="right" hero className={cn(HEAD_SIDE, 'top-0 right-0 h-[72%]')} />
<header className={cn(CONTAINER, 'flex flex-col items-center gap-6 pt-20 pb-12 text-center lg:gap-8 lg:pt-40 lg:pb-16')}>
<nav aria-label="Breadcrumb" className="flex items-center gap-2 type-ui text-fg-muted">
<a href={c.labels.all.href} className="transition-[color] duration-160 ease-out hover:text-fg">{c.labels.all.label}</a>
<span aria-hidden="true">/</span>
<span aria-current="page" className="text-fg">{s.company}</span>
</nav>
<h1 id={id} className="max-w-[880px] type-section text-balance">{s.headline}</h1>
<p className="flex items-center gap-1">
<Badge variant="secondary">{s.kind}</Badge>
<Badge variant="secondary">{c.labels.read(caseStudyMinutes(s))}</Badge>
</p>
</header>
</div>
),
facts: (
<div className="relative">
<Drift crop="mass" from="right" className={cn(BODY_SIDE, '-top-8 right-0 h-40')} />
<div className={MEASURE}>
<dl className="m-0 mb-12 grid grid-cols-2 gap-x-5 gap-y-6 md:mb-16 md:grid-cols-4">
{s.facts.map((f) => (
<div key={f.label} className="flex min-w-0 flex-col gap-1">
<dt className="type-ui-strong text-fg">{f.label}</dt>
<dd className="m-0 type-ui text-fg-soft">{f.value}</dd>
</div>
))}
<div className="flex min-w-0 flex-col gap-1">
<dt className="type-ui-strong text-fg">{c.labels.uses}</dt>
<dd className="m-0 type-ui text-fg-soft">
{s.uses.map((u, i) => (
<span key={u.href}>
<a href={u.href} className="text-fg-soft underline decoration-edge-strong underline-offset-4 transition-[color,text-decoration-color] duration-160 ease-out hover:text-fg hover:decoration-fg">{u.label}</a>
{i < s.uses.length - 1 ? ', ' : null}
</span>
))}
</dd>
</div>
</dl>
</div>
</div>
),
cover: (
<div className={CONTAINER}>
<div className="relative aspect-4/5 overflow-hidden rounded-panel bg-surface-raised md:aspect-video">
{s.cover?.src ? <img src={s.cover.src} alt={s.cover.alt ?? ''} className="absolute inset-0 block size-full object-cover" style={imageFit(s.cover)} /> : <div className="absolute inset-0"><CreativeCard ratio="fill" brand={s.cover?.brand} tone={2} /></div>}
</div>
</div>
),
lead: (
<div className="relative">
<Drift crop="cluster" from="left" className={cn(BODY_SIDE, 'top-0 left-0 h-full')} />
<div className={MEASURE}>
<p className="m-0 mt-16 type-body-lg text-pretty text-fg">{s.lead}</p>
<ul role="list" className="m-0 mt-12 grid list-none grid-cols-[minmax(0,1fr)] gap-6 border-t border-edge p-0 pt-8 md:grid-cols-3 md:gap-5">
{s.figures.map((f) => (
<li key={f.label} className="flex flex-col gap-2">
<span className="type-heading-2 text-fg tabular-nums">{f.value}</span>
<span className="type-ui text-balance text-fg-muted">{f.label}</span>
</li>
))}
</ul>
</div>
</div>
),
body: (
<div className="relative">
<Drift crop="scatter" from="right" className={cn(BODY_SIDE, 'top-[8%] right-0 h-[28%]')} />
<Drift crop="column" from="left" className={cn(BODY_SIDE, 'top-[52%] left-0 h-[30%]')} />
<div className={cn(MEASURE, 'pt-16 pb-24')}>
<blockquote className="m-0 flex flex-col gap-4 rounded-panel bg-surface-raised p-8">
<p className="m-0 type-heading-4 text-pretty md:type-heading-3 md:text-pretty">“{s.quote.text}”</p>
<footer className="type-ui text-fg-muted">{s.quote.role ? `${s.quote.name}, ${s.quote.role}` : s.quote.name}</footer>
</blockquote>
{s.sections.map((section, i) => (
<section key={section.title} aria-labelledby={`${s.slug}-s${i}`} className="mt-24">
<h2 id={`${s.slug}-s${i}`} className="m-0 type-heading-2 text-balance lg:type-heading-1">{section.title}</h2>
{section.paragraphs.map((p) => <p key={p} className="m-0 mt-6 type-body text-pretty text-fg-soft">{p}</p>)}
{i === 1 && s.aside ? (
<blockquote className="m-0 mt-10 flex flex-col gap-4 border-l border-edge-strong pl-6">
<p className="m-0 type-heading-4 text-pretty md:type-heading-3 md:text-pretty">“{s.aside.text}”</p>
<footer className="type-ui text-fg-muted">{s.aside.name}</footer>
</blockquote>
) : null}
</section>
))}
</div>
</div>
),
more: (
next ? (
<nav aria-label={c.labels.more} className={MEASURE}>
<div className="flex justify-between gap-6 border-y border-edge py-10">
{previous ? (
<a href={c.href(previous.slug)} className="group grid min-w-0 grid-cols-[16px_auto] items-center gap-x-3 gap-y-2 text-fg-muted">
<Arrow back />
<span className={LABEL}>{c.labels.previous}</span>
<span className="col-start-2 justify-self-end type-body font-medium text-fg">{previous.company}</span>
</a>
) : <span />}
<a href={c.href(next.slug)} className="group grid min-w-0 grid-cols-[auto_16px] items-center gap-x-3 gap-y-2 text-left text-fg-muted">
<span className={LABEL}>{c.labels.next}</span>
<Arrow />
<span className="col-start-1 justify-self-start type-body font-medium text-fg">{next.company}</span>
</a>
</div>
</nav>
) : null
),
close: <PageClose lines={c.close.lines} note={c.close.note} primary={c.close.primary} />,
}
return (
<div data-ds="case-study-page" className={cn('isolate overflow-x-clip bg-surface text-fg', className)}>
<AsciiTrail mode="page" />
<SiteHeader menus={menus} links={c.header.nav} secondary={c.header.secondary} cta={c.header.cta} />
<main>
{groupSections(pageSections(caseStudyPageSections, sections), ARTICLE).map((k) => (Array.isArray(k) ? <article key="article" aria-labelledby={id} className="relative isolate overflow-x-clip">{k.map((a) => <Fragment key={a}>{parts[a]}</Fragment>)}</article> : <Fragment key={k}>{parts[k]}</Fragment>))}
</main>
<SiteFooter columns={c.footer.columns} legal={c.footer.legal} />
</div>
)
}
export default CaseStudyPage
lib/pages/case-studies.ts
// The case study pages' copy (the site's content/pages/caseStudies.ts), retold for the two Acme agencies the home's
// case stories show (lib/home/stories.ts): no real customers, people, quotes or pictures. The lead picture comes through `cover` (an image you may show); without it the
// page draws a neutral placeholder. Both flavors read this file.
import { siteChrome } from '@/lib/pages/site-chrome'
import { storyCases, storyQuotes, type StoryCase, type StoryQuote } from '@/lib/home/stories'
import type { ImageSlot } from '@/lib/image'
export interface CaseStudyFigure {
value: string
label: string
}
export interface CaseStudySection {
title: string
paragraphs: string[]
}
export interface CaseStudy {
slug: string
company: string
/** The kind of company, as a badge under the title. */
kind: string
headline: string
lead: string
figures: CaseStudyFigure[]
facts: { label: string; value: string }[]
/** The products it uses, linked in the facts. */
uses: { label: string; href: string }[]
/** The pull quote and who said it (a role, or a name you may print). */
quote: { text: string; name: string; role?: string }
/** A second, shorter quote after the second section. */
aside?: { text: string; name: string }
sections: CaseStudySection[]
/** The lead picture (16:9, 4:5 on phones); a neutral placeholder without it. */
cover?: ImageSlot & { brand?: string }
}
export const caseStudies: CaseStudy[] = [
{
slug: 'acme-social',
company: 'Acme Social',
kind: 'Paid social agency',
headline: 'How Acme Social briefs nine client brands from one agent',
lead: 'Competitor ads, hooks and landing pages for every client, pulled before the Monday stand-up.',
figures: [
{ value: '12 hours', label: 'saved per strategist every week' },
{ value: '9', label: 'client brands briefed from one agent' },
{ value: '3x', label: 'more hooks tested a month, in one quarter' },
],
facts: [
{ label: 'Agency', value: 'Acme Social' },
{ label: 'Team', value: 'Paid social, 24 people' },
{ label: 'Clients', value: '9 beauty and wellness brands' },
],
uses: [
{ label: 'Media API', href: '/products/media-search' },
{ label: 'Creative insights', href: '/products/creative-insights' },
{ label: 'Landing Pages API', href: '/products/landing-pages' },
],
quote: { text: 'Most of our client report is written before anyone opens a deck.', name: 'Alex Rivera', role: 'Creative strategy lead, Acme Social' },
aside: { text: 'We stopped arguing about what competitors were running. We just ask.', name: 'Alex Rivera' },
sections: [
{
title: 'The challenge',
paragraphs: [
"Every Monday, each strategist spent half a day in ad libraries: screenshotting competitors' new ads, guessing how long they had run and pasting them into a deck for the client.",
'With nine brands in three categories, the research was always a week old by the time it reached a brief.',
],
},
{
title: 'What they built',
paragraphs: [
'Acme Social connected Acme to Claude over MCP and wrote one prompt per client: the competitors to watch, the hooks to track and the formats that matter.',
"Each Monday the agent pulls every new ad, the hooks behind them and where each one leads, and drafts the client's competitor page in the agency's own template.",
],
},
{
title: 'The result',
paragraphs: ['Strategists start the week reading a brief instead of building one. The time went back into testing: three times as many hooks a month, picked from what is already working in the category.'],
},
],
cover: { brand: 'Acme Skin' },
},
{
slug: 'acme-studio',
company: 'Acme Studio',
kind: 'Creator and performance agency',
headline: "How Acme Studio finds the creators behind a category's best ads",
lead: 'A shortlist of proven creators in an afternoon, from the ads and posts that are already working.',
figures: [
{ value: '140', label: 'creators shortlisted in one afternoon' },
{ value: '2 weeks', label: 'of manual sourcing cut to a day' },
{ value: '31%', label: 'lower cost per acquisition on creator ads' },
],
facts: [
{ label: 'Agency', value: 'Acme Studio' },
{ label: 'Team', value: 'Creator partnerships, 11 people' },
{ label: 'Clients', value: 'Running, outdoor and apparel brands' },
],
uses: [
{ label: 'Creator search', href: '/products/creator-search' },
{ label: 'Collaborations', href: '/products/creator-collabs' },
{ label: 'Media API', href: '/products/media-search' },
],
quote: { text: 'The shortlist came back as a table we sent straight to outreach.', name: 'Jordan Lee', role: 'Head of creator partnerships, Acme Studio' },
aside: { text: 'We only reach out to creators whose ads already ran for a brand like ours.', name: 'Jordan Lee' },
sections: [
{
title: 'The challenge',
paragraphs: [
'Sourcing meant scrolling: hashtags, follower counts and gut feel, then weeks of outreach to creators who had never made an ad that worked.',
'Clients wanted creators with a record, and the agency had no way to see who already had one.',
],
},
{
title: 'What they built',
paragraphs: [
"Acme Studio asks for the longest-running creator ads in a client's category, then for every creator those brands have worked with, their reach and where they post.",
"The answer lands as one table, ranked by how long each creator's ads kept running, and goes straight into the outreach sheet.",
],
},
{
title: 'The result',
paragraphs: ['A shortlist that took two weeks now takes an afternoon, and every creator on it has already made an ad a brand kept paying for.'],
},
],
cover: { brand: 'Acme Fit' },
},
]
export const caseStudyContent = {
...siteChrome,
labels: {
/** The breadcrumb's first step and where it links. */
all: { label: 'Case studies', href: '/resources/case-studies' },
more: 'More case studies',
uses: 'Uses',
previous: 'Previous case study',
next: 'Next case study',
/** How a read time reads, from minutes. */
read: (minutes: number) => `${minutes} min read`,
},
/** Where a study's page lives, from its slug. */
href: (slug: string) => `/resources/case-studies/${slug}`,
studies: caseStudies,
}
export type CaseStudyContent = typeof caseStudyContent
/** Minutes to read a study at 220 words a minute, at least 1. */
export function caseStudyMinutes(study: CaseStudy): number {
const words = [study.lead, ...study.sections.flatMap((s) => [s.title, ...s.paragraphs]), study.quote.text].join(' ').split(/\s+/).length
return Math.max(1, Math.round(words / 220))
}
/** The studies before and after this one, wrapping; `previous` is left out when it is the same as `next`. */
export function caseStudyNeighbors(studies: CaseStudy[], slug: string): { previous?: CaseStudy; next?: CaseStudy } {
if (studies.length < 2) return {}
const at = Math.max(0, studies.findIndex((s) => s.slug === slug))
const previous = studies[(at - 1 + studies.length) % studies.length]
const next = studies[(at + 1) % studies.length]
return { previous: previous.slug === next.slug ? undefined : previous, next }
}
/** The case studies index (the site's CaseStudyIndex): the page head over the home's case stories, every quote shown. */
export const caseStudiesIndexContent = {
...siteChrome,
head: { id: 'case-studies', lines: ['Case studies'], lead: 'How agencies and marketing teams put Acme to work, in their own words.' },
cases: storyCases as StoryCase[],
quotes: [
...storyQuotes,
{ company: 'Acme Signals', quote: 'Sharp, intuitive, and built by a team that ships fixes the same day. The easiest pick for anyone serious about creative research.', name: 'Casey Brooks', role: 'Founder, Acme Signals' },
{ company: 'Acme Energy', quote: 'The only creative tool that shows me what my audience actually sees. Finding new audiences has never been easier.', name: 'Taylor Quinn', role: 'GM, Acme Energy' },
{ company: 'Acme Bottle', quote: 'We built the brand by obsessing over our customers. This shows us the creative they engage with, from brands to creators.', name: 'Jamie Ellis', role: 'Co-founder, Acme Bottle' },
] as StoryQuote[],
}
export type CaseStudiesIndexContent = typeof caseStudiesIndexContent
/** The case studies index's sections in order; pass `sections` to reorder them or leave some out. */
export const caseStudiesSections = ['head', 'stories', 'close'] as const
export type CaseStudiesSection = (typeof caseStudiesSections)[number]
/** A case study's sections in order (all but the close stay inside the article, where the first of them falls); pass `sections` to reorder them or leave some out. */
export const caseStudyPageSections = ['head', 'facts', 'cover', 'lead', 'body', 'more', 'close'] as const
export type CaseStudyPageSection = (typeof caseStudyPageSections)[number]
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/pages/case-study-page.ts
import { html, nothing, svg } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { asciiDriftStyle, type AsciiDriftCrop, type AsciiDriftFrom } from '@/lib/ascii-drift'
import { caseStudies, caseStudyContent, caseStudyMinutes, caseStudyNeighbors, type CaseStudy, type CaseStudyContent, caseStudyPageSections, type CaseStudyPageSection } from '@/lib/pages/case-studies'
import '@/elements/components/ui/badge'
import '@/elements/components/site/creative-card'
import '@/elements/components/site/site-header'
import '@/elements/components/site/page-close'
import '@/elements/components/blocks/site-footer'
import '@/elements/components/visuals/ascii-trail'
import styles from 'virtual:tw'
import { pageSections, groupSections, imageFit } from '@/lib/image'
import { styleMap } from 'lit/directives/style-map.js'
import { headerMenus, type HeaderMenus } from '@/lib/site-header'
// CaseStudyPage.tsx as <spyglass-case-study-page>: the header, the centered head (breadcrumb, headline, kind and read
// time), the facts, the lead picture, the opening line and figures, the pull quote, the sections and the pager, the
// closing section and the footer; ASCII crops in the margins from 1024. `study` (JSON) picks the study, `content`
// (JSON) the rest (lib/pages/case-studies.ts; its studies set the pager). Links change color; nothing moves.
const ARTICLE: readonly CaseStudyPageSection[] = ['head', 'facts', 'cover', 'lead', 'body', 'more']
const CONTAINER = 'mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)'
const MEASURE = 'mx-auto w-full max-w-[calc(var(--ds-layout-measure)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)'
const HEAD_SIDE = 'w-[calc((100%-880px)/2-64px)]'
const BODY_SIDE = 'w-[calc((100%-var(--ds-layout-measure))/2-64px)]'
const LABEL = 'type-ui text-fg-muted transition-[color] duration-160 ease-out group-hover:text-fg group-focus-visible:text-fg'
const drift = (crop: AsciiDriftCrop, from: AsciiDriftFrom, place: string, hero = false) => html`<span aria-hidden="true" class=${['pointer-events-none absolute -z-1 hidden select-none lg:block', place].join(' ')} style=${asciiDriftStyle(crop, from, hero ? 'hero' : 'quiet')}></span>`
const arrow = (back = false) => html`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false" class="size-4 transition-[color] duration-160 ease-out group-hover:text-fg group-focus-visible:text-fg">${svg`<path d=${back ? 'M13 8H4M7.5 4.5 4 8l3.5 3.5' : 'M3 8h9M8.5 4.5 12 8l-3.5 3.5'} fill="none" stroke="currentColor" stroke-width="1.5"></path>`}</svg>`
/**
* @summary A case study article.
*/
export class CaseStudyPage extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="case-study-page"]'))
static properties = { study: { type: Object }, content: { type: Object }, menus: { type: Object }, sections: { type: Array } }
/** The study (the first of lib/pages/case-studies.ts by default). */
study: CaseStudy = caseStudies[0]
/** The copy and the studies for the pager. */
content: CaseStudyContent = caseStudyContent
/** The header menus' content, pictures included (the live card's `picture`, the use cases' `shots`); Acme by default. */
menus?: HeaderMenus
/** The sections to show, in order (a list of names); all of them in the page order by default. */
sections?: CaseStudyPageSection[]
render() {
const c = this.content ?? caseStudyContent
const s = this.study ?? caseStudies[0]
const { previous, next } = caseStudyNeighbors(c.studies, s.slug)
const id = `${s.slug}-heading`
const cover = s.cover?.src
? html`<img src=${s.cover.src} alt=${s.cover.alt ?? ''} class="absolute inset-0 block size-full object-cover" style=${styleMap(imageFit(s.cover) ?? {})}>`
: html`<div class="absolute inset-0"><spyglass-creative-card ratio="fill" brand=${s.cover?.brand ?? nothing} tone="2"></spyglass-creative-card></div>`
const pager = next
? html`<nav aria-label=${c.labels.more} class=${MEASURE}><div class="flex justify-between gap-6 border-y border-edge py-10">${previous ? html`<a href=${c.href(previous.slug)} class="group grid min-w-0 grid-cols-[16px_auto] items-center gap-x-3 gap-y-2 text-fg-muted">${arrow(true)}<span class=${LABEL}>${c.labels.previous}</span><span class="col-start-2 justify-self-end type-body font-medium text-fg">${previous.company}</span></a>` : html`<span></span>`}<a href=${c.href(next.slug)} class="group grid min-w-0 grid-cols-[auto_16px] items-center gap-x-3 gap-y-2 text-left text-fg-muted"><span class=${LABEL}>${c.labels.next}</span>${arrow()}<span class="col-start-1 justify-self-start type-body font-medium text-fg">${next.company}</span></a></div></nav>`
: nothing
const parts: Record<CaseStudyPageSection, unknown> = {
head: html`<div class="relative">${drift('column', 'left', `${HEAD_SIDE} top-[8%] left-0 h-[84%]`, true)}${drift('scatter', 'right', `${HEAD_SIDE} top-0 right-0 h-[72%]`, true)}<header class=${[CONTAINER, 'flex flex-col items-center gap-6 pt-20 pb-12 text-center lg:gap-8 lg:pt-40 lg:pb-16'].join(' ')}><nav aria-label="Breadcrumb" class="flex items-center gap-2 type-ui text-fg-muted"><a href=${c.labels.all.href} class="transition-[color] duration-160 ease-out hover:text-fg">${c.labels.all.label}</a><span aria-hidden="true">/</span><span aria-current="page" class="text-fg">${s.company}</span></nav><h1 id=${id} class="max-w-[880px] type-section text-balance">${s.headline}</h1><p class="flex items-center gap-1"><spyglass-badge variant="secondary">${s.kind}</spyglass-badge><spyglass-badge variant="secondary">${c.labels.read(caseStudyMinutes(s))}</spyglass-badge></p></header></div>`,
facts: html`<div class="relative">${drift('mass', 'right', `${BODY_SIDE} -top-8 right-0 h-40`)}<div class=${MEASURE}><dl class="m-0 mb-12 grid grid-cols-2 gap-x-5 gap-y-6 md:mb-16 md:grid-cols-4">${s.facts.map((f) => html`<div class="flex min-w-0 flex-col gap-1"><dt class="type-ui-strong text-fg">${f.label}</dt><dd class="m-0 type-ui text-fg-soft">${f.value}</dd></div>`)}<div class="flex min-w-0 flex-col gap-1"><dt class="type-ui-strong text-fg">${c.labels.uses}</dt><dd class="m-0 type-ui text-fg-soft">${s.uses.map((u, i) => html`<span><a href=${u.href} class="text-fg-soft underline decoration-edge-strong underline-offset-4 transition-[color,text-decoration-color] duration-160 ease-out hover:text-fg hover:decoration-fg">${u.label}</a>${i < s.uses.length - 1 ? ', ' : nothing}</span>`)}</dd></div></dl></div></div>`,
cover: html`<div class=${CONTAINER}><div class="relative aspect-4/5 overflow-hidden rounded-panel bg-surface-raised md:aspect-video">${cover}</div></div>`,
lead: html`<div class="relative">${drift('cluster', 'left', `${BODY_SIDE} top-0 left-0 h-full`)}<div class=${MEASURE}><p class="m-0 mt-16 type-body-lg text-pretty text-fg">${s.lead}</p><ul role="list" class="m-0 mt-12 grid list-none grid-cols-[minmax(0,1fr)] gap-6 border-t border-edge p-0 pt-8 md:grid-cols-3 md:gap-5">${s.figures.map((f) => html`<li class="flex flex-col gap-2"><span class="type-heading-2 text-fg tabular-nums">${f.value}</span><span class="type-ui text-balance text-fg-muted">${f.label}</span></li>`)}</ul></div></div>`,
body: html`<div class="relative">${drift('scatter', 'right', `${BODY_SIDE} top-[8%] right-0 h-[28%]`)}${drift('column', 'left', `${BODY_SIDE} top-[52%] left-0 h-[30%]`)}<div class=${[MEASURE, 'pt-16 pb-24'].join(' ')}><blockquote class="m-0 flex flex-col gap-4 rounded-panel bg-surface-raised p-8"><p class="m-0 type-heading-4 text-pretty md:type-heading-3 md:text-pretty">“${s.quote.text}”</p><footer class="type-ui text-fg-muted">${s.quote.role ? `${s.quote.name}, ${s.quote.role}` : s.quote.name}</footer></blockquote>${s.sections.map((section, i) => html`<section aria-labelledby=${`${s.slug}-s${i}`} class="mt-24"><h2 id=${`${s.slug}-s${i}`} class="m-0 type-heading-2 text-balance lg:type-heading-1">${section.title}</h2>${section.paragraphs.map((p) => html`<p class="m-0 mt-6 type-body text-pretty text-fg-soft">${p}</p>`)}${i === 1 && s.aside ? html`<blockquote class="m-0 mt-10 flex flex-col gap-4 border-l border-edge-strong pl-6"><p class="m-0 type-heading-4 text-pretty md:type-heading-3 md:text-pretty">“${s.aside.text}”</p><footer class="type-ui text-fg-muted">${s.aside.name}</footer></blockquote>` : nothing}</section>`)}</div></div>`,
more: html`${pager}`,
close: html`<spyglass-page-close .lines=${c.close.lines} note=${c.close.note} .primary=${c.close.primary}></spyglass-page-close>`,
}
return html`<div data-ds="case-study-page" class="isolate overflow-x-clip bg-surface text-fg"><spyglass-ascii-trail mode="page"></spyglass-ascii-trail><spyglass-site-header .menus=${this.menus ?? headerMenus} .links=${c.header.nav} .secondary=${c.header.secondary} .cta=${c.header.cta}></spyglass-site-header><main>${groupSections(pageSections(caseStudyPageSections, this.sections), ARTICLE).map((k) => (Array.isArray(k) ? html`<article aria-labelledby=${id} class="relative isolate overflow-x-clip">${k.map((a) => parts[a])}</article>` : parts[k]))}</main><spyglass-site-footer .columns=${c.footer.columns} legal=${c.footer.legal}></spyglass-site-footer></div>`
}
}
define('case-study-page', CaseStudyPage)
Reference: Site app/resources/case-studies/[slug]/page.tsx and pages/CaseStudies (CaseStudyArticle.tsx, CaseStudyPage.module.css): head 80/48px (160/64 from 1024), 24px gaps (32 from 1024), the title at most 880px; the 640px measure; facts 2 then 4 columns, 24/20 gaps, 48px under (64 from 768), underlined links in --line-strong; the cover 16:9 (4:5 under 768) with --radius-m; the lead .t-lead 64px down, figures 48px further over a hairline, h4 values; body 64/96px, the pull quote 32px in on --surface, sections 96px apart with h4 titles (h2 from 1024), paragraphs 24px apart in --text-2, the aside 40px down with a --line-strong rule; the pager 40px tall padding between hairlines; drifts from 1024 beside each band.