Pages
Case studies page
The site's case studies index: the header, the page head, the home's case stories without their head (each case as a wide picture with its panel, then every quote in cards three across), the closing section and the footer.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add case-studies-page<script type="module" src="/spyglass-ds/elements/case-studies-page.js"></script>Case studies
How agencies and marketing teams put Acme to work, in their own words.
Give your agents the social internet
500 free credits every month. No card required.
Usage
An index of customer stories; content takes the cases (each linking to its case study page) and the quotes.
Never
- Customers' names, marks, photos or quotes you may not show: the defaults are Acme placeholders
- A case without a concrete figure
- A second head over the stories: the page head names the page
sections lists the sections to show, in order (head, stories, close); a key left out is not shown. Each case's picture is an image slot (src, alt, fit, position) or a placeholder tone. menus passes the header menus (the live card's picture, the use cases' shots).
Adds with it: ascii-trail, case-stories-block, case-study-page, creative-card, page-close, page-head, site-footer, site-header
Props
The web component takes the same as attributes or properties (<spyglass-case-studies-page>); title is heading there.
<CaseStudiesPage>
| Prop | Type | Default |
|---|---|---|
content | CaseStudiesIndexContent | |
menus | HeaderMenus The header menus' content, pictures included (the live card's `picture`, the use cases' `shots`); Acme by default. | |
sections | readonly CaseStudiesSection[] 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.
import { CaseStudiesPage } from '@/react/components/pages/CaseStudiesPage'
// The case studies index as the site sets it, with Acme's cases and quotes.
export default function Page() {
return <CaseStudiesPage />
}<!-- The case studies index as the site sets it, with Acme's cases and quotes. -->
<spyglass-case-studies-page></spyglass-case-studies-page>Source
import { CaseStoriesBlock } from '@/react/components/blocks/CaseStoriesBlock'
import { AsciiTrail } from '@/react/components/visuals/AsciiTrail'
import { PageClose } from '@/react/components/site/PageClose'
import { PageHead } from '@/react/components/site/PageHead'
import { SiteHeader } from '@/react/components/site/SiteHeader'
import { SiteFooter } from '@/react/components/blocks/SiteFooter'
import { caseStudiesIndexContent, type CaseStudiesIndexContent, caseStudiesSections, type CaseStudiesSection } from '@/lib/pages/case-studies'
import { cn } from '@/react/lib/cn'
import { pageSections } from '@/lib/image'
import { Fragment, type ReactNode } from 'react'
import type { HeaderMenus } from '@/lib/site-header'
// The site's case studies index (app/resources/case-studies, pages/CaseStudies/CaseStudyIndex): the header, the page
// head, the home's case stories without their head (each case's picture and panel, then every quote in cards three
// across) right under it with 96px below, the closing section and the footer. `content` replaces the copy, the cases
// and the quotes (lib/pages/case-studies.ts; Acme placeholders).
export interface CaseStudiesPageProps {
content?: CaseStudiesIndexContent
/** 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 CaseStudiesSection[]
className?: string
}
export function CaseStudiesPage({ content: c = caseStudiesIndexContent, menus, sections, className }: CaseStudiesPageProps) {
const parts: Record<CaseStudiesSection, ReactNode> = {
head: <PageHead id={c.head.id} lines={c.head.lines} lead={c.head.lead} />,
stories: (
<div aria-label={c.head.lines.join(' ')} role="region" className="-mt-(--ds-layout-section) pb-[calc(96px-var(--ds-layout-section))]">
<CaseStoriesBlock cases={c.cases} quotes={c.quotes} quoteCount={c.quotes.length} head={false} />
</div>
),
close: <PageClose lines={c.close.lines} note={c.close.note} primary={c.close.primary} />,
}
return (
<div data-ds="case-studies-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>
{pageSections(caseStudiesSections, sections).map((k) => <Fragment key={k}>{parts[k]}</Fragment>)}
</main>
<SiteFooter columns={c.footer.columns} legal={c.footer.legal} />
</div>
)
}
export default CaseStudiesPage// 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 } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { caseStudiesIndexContent, type CaseStudiesIndexContent, caseStudiesSections, type CaseStudiesSection } from '@/lib/pages/case-studies'
import '@/elements/components/site/site-header'
import '@/elements/components/site/page-head'
import '@/elements/components/blocks/case-stories-block'
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 } from '@/lib/image'
import { headerMenus, type HeaderMenus } from '@/lib/site-header'
// CaseStudiesPage.tsx as <spyglass-case-studies-page>: the header, the page head, the home's case stories without
// their head (every quote shown), the closing section and the footer. `content` (JSON) replaces the copy, the cases
// and the quotes (lib/pages/case-studies.ts).
/**
* @summary The case studies index.
*/
export class CaseStudiesPage extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="case-studies-page"]'))
static properties = { content: { type: Object }, menus: { type: Object }, sections: { type: Array } }
/** The copy, cases and quotes (lib/pages/case-studies.ts by default). */
content: CaseStudiesIndexContent = caseStudiesIndexContent
/** 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?: CaseStudiesSection[]
render() {
const c = this.content ?? caseStudiesIndexContent
const parts: Record<CaseStudiesSection, unknown> = {
head: html`<spyglass-page-head head-id=${c.head.id} .lines=${c.head.lines} lead=${c.head.lead}></spyglass-page-head>`,
stories: html`<div aria-label=${c.head.lines.join(' ')} role="region" class="-mt-(--ds-layout-section) pb-[calc(96px-var(--ds-layout-section))]"><spyglass-case-stories-block .cases=${c.cases} .quotes=${c.quotes} .quoteCount=${c.quotes.length} head="false"></spyglass-case-stories-block></div>`,
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-studies-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>${pageSections(caseStudiesSections, this.sections).map((k) => parts[k])}</main><spyglass-site-footer .columns=${c.footer.columns} legal=${c.footer.legal}></spyglass-site-footer></div>`
}
}
define('case-studies-page', CaseStudiesPage)Reference: Site app/resources/case-studies/page.tsx and pages/CaseStudies (CaseStudyIndex.tsx, .module.css): PageHead, then CaseStoriesGrid with every quote in the container with 96px under it, PageClose and the footer.