Site
Resource cards
The site's resource hub: linked cards on the #262626 surface with a Black cover (a row of creatives or a few lines of code), the title, the line and a meta line, in two columns (or three for the use-cases hub), and hairline rows under them for what is not ready yet.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add resource-cards<script type="module" src="/spyglass-ds/elements/resource-cards.js"></script>Templates
Ready-made playbooks that run inside Claude or ChatGPT on Acme data.4 templates, coming soonDocs
Set up the MCP server, call the REST API and use the SDKs.docs.acme.comCase studies
How agencies and marketing teams put Acme to work.2 case studies
Blog
What the Acme team shipped, and what is next.Coming soonArticles
Guides to creative research with agents.Coming soonDemos
Acme at work in Claude, ChatGPT and Cursor.Coming soon
Usage
An index of resources, use cases, templates or guides: each card links to its page. rows lists what is coming with a badge; columns={3} sets the use-cases hub.
Never
- Another brand's creative in a cover: pass the user's images as
srcor keep the Acme placeholders - Cards that lift, scale or move on hover: only the surface changes color
- More than three columns, or a card without a link
Cards are links; a card whose href starts with http opens in a new tab. A row without href is plain text (a resource that is not live). The use-cases hub passes each use case as a card: its creatives as the cover, the name as the title, the line and who it is for as the meta. Each picture is an image slot (src, alt, fit, position); without src it keeps its placeholder, which carries data-ds-placeholder.
Adds with it: badge, code-block, creative-card
Props
The web component takes the same as attributes or properties (<spyglass-resource-cards>); title is heading there.
<ResourceCards>
| Prop | Type | Default |
|---|---|---|
cards | ResourceCard[] | |
rows | ResourceRow[] Rows under the cards (resources that are not ready). | [] |
rowsLabel | string The rows' list name. | 'More resources' |
columns | 2 | 3 2 (resources) or 3 (use cases, from 1024). | 2 |
className | string |
Examples
The same example in React and as web components; both render identically.
import { ResourceCards, type ResourceCard, type ResourceRow } from '@/react/components/site/ResourceCards'
// The resources hub with Acme's copy: templates and case studies with placeholder creatives, the docs with code, and
// three resources that are coming soon.
const cards: ResourceCard[] = [
{ title: 'Templates', line: 'Ready-made playbooks that run inside Claude or ChatGPT on Acme data.', href: '/templates', meta: '4 templates, coming soon', cover: { kind: 'creatives', items: [{ brand: 'Acme Skin', tone: 2 }, { brand: 'Acme Drinks', tone: 3 }, { brand: 'Acme Studio', tone: 1 }, { brand: 'Acme Fit', tone: 4 }] } },
{ title: 'Docs', line: 'Set up the MCP server, call the REST API and use the SDKs.', href: 'https://docs.acme.com', meta: 'docs.acme.com', cover: { kind: 'code', source: '# The CLI\nnpm install -g @acme/cli\n# The MCP server\nhttps://mcp.acme.com/mcp\n# The REST API\nhttps://api.acme.com/v2' } },
{ title: 'Case studies', line: 'How agencies and marketing teams put Acme to work.', href: '/resources/case-studies', meta: '2 case studies', cover: { kind: 'creatives', items: [{ brand: 'Acme Skin', tone: 3 }, { brand: 'Acme Beauty', tone: 2 }, { brand: 'Acme Skin', tone: 4 }] } },
]
const rows: ResourceRow[] = [
{ title: 'Blog', line: 'What the Acme team shipped, and what is next.', badge: 'Coming soon' },
{ title: 'Articles', line: 'Guides to creative research with agents.', badge: 'Coming soon' },
{ title: 'Demos', line: 'Acme at work in Claude, ChatGPT and Cursor.', badge: 'Coming soon' },
]
export default function Hub() {
return (
<div className="mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter) py-12">
<ResourceCards cards={cards} rows={rows} rowsLabel="More resources" />
</div>
)
}<!-- The resources hub with Acme's copy: templates and case studies with placeholder creatives, the docs with code, and three resources that are coming soon. -->
<div class="mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter) py-12">
<spyglass-resource-cards rows-label="More resources" cards='[{"title":"Templates","line":"Ready-made playbooks that run inside Claude or ChatGPT on Acme data.","href":"/templates","meta":"4 templates, coming soon","cover":{"kind":"creatives","items":[{"brand":"Acme Skin","tone":2},{"brand":"Acme Drinks","tone":3},{"brand":"Acme Studio","tone":1},{"brand":"Acme Fit","tone":4}]}},{"title":"Docs","line":"Set up the MCP server, call the REST API and use the SDKs.","href":"https://docs.acme.com","meta":"docs.acme.com","cover":{"kind":"code","source":"# The CLI\nnpm install -g @acme/cli\n# The MCP server\nhttps://mcp.acme.com/mcp\n# The REST API\nhttps://api.acme.com/v2"}},{"title":"Case studies","line":"How agencies and marketing teams put Acme to work.","href":"/resources/case-studies","meta":"2 case studies","cover":{"kind":"creatives","items":[{"brand":"Acme Skin","tone":3},{"brand":"Acme Beauty","tone":2},{"brand":"Acme Skin","tone":4}]}}]' rows='[{"title":"Blog","line":"What the Acme team shipped, and what is next.","badge":"Coming soon"},{"title":"Articles","line":"Guides to creative research with agents.","badge":"Coming soon"},{"title":"Demos","line":"Acme at work in Claude, ChatGPT and Cursor.","badge":"Coming soon"}]'></spyglass-resource-cards>
</div>import { ResourceCards, type ResourceCard } from '@/react/components/site/ResourceCards'
// The use-cases hub: three columns from 1024, each use case with its creatives, its line and who it is for.
const tiles = (tone: 1 | 2 | 3 | 4) => ({ kind: 'creatives' as const, items: [{ brand: 'Acme Skin', tone }, { brand: 'Acme Drinks', tone: (tone % 4) + 1 as 1 | 2 | 3 | 4 }, { brand: 'Acme Fit', tone }] })
const cards: ResourceCard[] = [
{ title: 'Creative research', line: 'The hooks, angles and formats that win for any brand.', meta: 'For creative strategists.', href: '/use-cases/creative-research', cover: tiles(2) },
{ title: 'Paid ads', line: 'What competitors run, how long it runs and where it leads.', meta: 'For performance teams.', href: '/use-cases/paid-ads', cover: tiles(3) },
{ title: 'Creator sourcing', line: 'The creators behind a category’s best ads.', meta: 'For partnership teams.', href: '/use-cases/creator-sourcing', cover: tiles(1) },
]
export default function UseCases() {
return (
<div className="mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter) py-12">
<ResourceCards cards={cards} columns={3} />
</div>
)
}<!-- The use-cases hub: three columns from 1024, each use case with its creatives, its line and who it is for. -->
<div class="mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter) py-12">
<spyglass-resource-cards columns="3" cards='[{"title":"Creative research","line":"The hooks, angles and formats that win for any brand.","meta":"For creative strategists.","href":"/use-cases/creative-research","cover":{"kind":"creatives","items":[{"brand":"Acme Skin","tone":2},{"brand":"Acme Drinks","tone":3},{"brand":"Acme Fit","tone":2}]}},{"title":"Paid ads","line":"What competitors run, how long it runs and where it leads.","meta":"For performance teams.","href":"/use-cases/paid-ads","cover":{"kind":"creatives","items":[{"brand":"Acme Skin","tone":3},{"brand":"Acme Drinks","tone":4},{"brand":"Acme Fit","tone":3}]}},{"title":"Creator sourcing","line":"The creators behind a category’s best ads.","meta":"For partnership teams.","href":"/use-cases/creator-sourcing","cover":{"kind":"creatives","items":[{"brand":"Acme Skin","tone":1},{"brand":"Acme Drinks","tone":2},{"brand":"Acme Fit","tone":1}]}}]'></spyglass-resource-cards>
</div>Source
import { Badge } from '@/react/components/ui/Badge'
import { Code } from '@/react/components/site/Code'
import { CreativeCard } from '@/react/components/site/CreativeCard'
import { isExternal, type ResourceCard, type ResourceCover, type ResourceRow } from '@/lib/resource-cards'
import { cn } from '@/react/lib/cn'
export type { ResourceCard, ResourceCover, ResourceCreative, ResourceRow } from '@/lib/resource-cards'
// The site's resource hub (pages/Resources/ResourceHub, Resources.module.css; UseCaseHub reuses it): cards on the
// #262626 surface, 8px in with the 8px corner, each a link with a Black cover (240px tall, 320 from 1024 with two
// columns; 24px in, the 4px corner) holding a row of creatives (4:5, 12px apart, up to 120px wide) or a few lines of
// code, then the title (Funnel Display 24/28), the line in the soft gray and the meta at the foot in the muted gray.
// One column on phones, two from 768; `columns={3}` sets the use-cases hub: three from 1024, the cover 240px at every
// width and its creatives 80px (64 at 1024, 80 at 1280, 96 at 1440). Under the cards, `rows` lists what is not ready:
// hairline rows with the name, the line in the faint gray and a badge, the line in its own column from 1024. A card's
// surface turns #363636 under a mouse and a row's name turns White (160ms, ease-out); nothing moves.
export interface ResourceCardsProps {
cards: ResourceCard[]
/** Rows under the cards (resources that are not ready). */
rows?: ResourceRow[]
/** The rows' list name. */
rowsLabel?: string
/** 2 (resources) or 3 (use cases, from 1024). */
columns?: 2 | 3
className?: string
}
function Cover({ cover, columns }: { cover: ResourceCover; columns: 2 | 3 }) {
if (cover.kind === 'code') {
return (
<span className="max-w-full overflow-hidden">
<Code source={cover.source} language={cover.language} />
</span>
)
}
return (
<span className="flex w-full justify-center gap-3">
{cover.items.map((c, i) => (
<span key={i} className={cn('block aspect-4/5 min-w-0', columns === 3 ? 'shrink-0 basis-20 lg:basis-16 xl:basis-20 min-[1440px]:basis-24' : 'shrink grow-0 basis-30')}>
<CreativeCard ratio="fill" src={c.src} alt={c.alt} fit={c.fit} position={c.position} brand={c.brand} caption={c.caption} tone={c.tone} />
</span>
))}
</span>
)
}
export function ResourceCards({ cards, rows = [], rowsLabel = 'More resources', columns = 2, className }: ResourceCardsProps) {
return (
<div data-ds="resource-cards" className={cn('flex flex-col gap-12 text-fg', className)}>
<ul role="list" className={cn('m-0 grid list-none grid-cols-[minmax(0,1fr)] gap-4 p-0 md:grid-cols-2', columns === 3 && 'lg:grid-cols-3')}>
{cards.map((card) => (
<li key={card.href}>
<a href={card.href} target={isExternal(card.href) ? '_blank' : undefined} rel={isExternal(card.href) ? 'noreferrer' : undefined} className="flex h-full flex-col rounded-panel bg-surface-raised p-2 transition-[background-color] duration-160 ease-out hover:bg-surface-hover focus-visible:-outline-offset-2">
<span aria-hidden="true" className={cn('grid h-60 place-items-center overflow-hidden rounded-container bg-surface p-6', columns === 2 && 'lg:h-80')}>
{card.cover ? <Cover cover={card.cover} columns={columns} /> : null}
</span>
<span className="flex flex-1 flex-col gap-2 p-4 md:pt-6">
<h2 className="type-heading-3">{card.title}</h2>
<span className="type-body text-pretty text-fg-soft">{card.line}</span>
{card.meta ? <span className="mt-auto pt-2 type-ui text-fg-muted">{card.meta}</span> : null}
</span>
</a>
</li>
))}
</ul>
{rows.length > 0 ? (
<ul role="list" aria-label={rowsLabel} className="m-0 list-none border-t border-edge p-0">
{rows.map((row) => {
const body = (
<>
<h2 className="col-start-1 row-start-1 type-body font-medium text-fg-soft transition-[color] duration-160 ease-out group-hover:text-fg">{row.title}</h2>
<span className="col-span-full row-start-2 type-body text-pretty text-fg-faint lg:col-span-1 lg:col-start-2 lg:row-start-1">{row.line}</span>
{row.badge ? <span className="col-start-2 row-start-1 flex justify-self-end lg:col-start-3"><Badge variant="secondary">{row.badge}</Badge></span> : null}
</>
)
const classes = 'grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-4 gap-y-1 border-b border-edge py-5 lg:grid-cols-[240px_minmax(0,1fr)_auto] lg:py-6'
return (
<li key={row.title}>
{row.href ? <a href={row.href} target={isExternal(row.href) ? '_blank' : undefined} rel={isExternal(row.href) ? 'noreferrer' : undefined} className={cn('group focus-visible:-outline-offset-2', classes)}>{body}</a> : <div className={classes}>{body}</div>}
</li>
)
})}
</ul>
) : null}
</div>
)
}
export default ResourceCards// The resource cards' data, shared by both flavors (the site's ResourceHub; the code cover is the code-block item's
// Code).
import type { ImageSlot } from '@/lib/image'
/** A creative in a card's cover: the user's image as `src`, or an Acme placeholder (advertiser and tone). */
export interface ResourceCreative extends ImageSlot {
brand?: string
caption?: string
tone?: 1 | 2 | 3 | 4
}
/** A card's cover: a row of creatives, or a few lines of code. */
export type ResourceCover = { kind: 'creatives'; items: ResourceCreative[] } | { kind: 'code'; source: string; language?: string }
export interface ResourceCard {
title: string
line: string
href: string
/** The small gray line at the foot ("4 templates", "docs.acme.com"). */
meta?: string
cover?: ResourceCover
}
/** A row under the cards: a resource that is not ready, or a plain link. */
export interface ResourceRow {
title: string
line: string
/** Leave it out for a row that is not live (it is not a link). */
href?: string
/** The badge on the right ("Coming soon"). */
badge?: string
}
/** A link to another site opens in a new tab. */
export const isExternal = (href: string) => /^https?:\/\//.test(href)// 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, nothing } from 'lit'
import { ifDefined } from 'lit/directives/if-defined.js'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { isExternal, type ResourceCard, type ResourceCover, type ResourceRow } from '@/lib/resource-cards'
import '@/elements/components/site/code'
import '@/elements/components/site/creative-card'
import '@/elements/components/ui/badge'
import styles from 'virtual:tw'
export type { ResourceCard, ResourceCover, ResourceCreative, ResourceRow } from '@/lib/resource-cards'
// ResourceCards.tsx as <spyglass-resource-cards>: the site's resource hub cards (a cover of creatives or code, the
// title, the line and the meta) on the #262626 surface, two columns from 768 or `columns="3"` for the use-cases hub
// (three from 1024), and the hairline rows of what is not ready under them. `cards` and `rows` are lists (JSON
// attributes or properties). A card's surface and a row's name change color under a mouse; nothing moves.
const ROW = 'grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-4 gap-y-1 border-b border-edge py-5 lg:grid-cols-[240px_minmax(0,1fr)_auto] lg:py-6'
/**
* @summary The resource hub's cards and rows.
*/
export class ResourceCards extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="resource-cards"]'))
static properties = { cards: { type: Array }, rows: { type: Array }, rowsLabel: { attribute: 'rows-label' }, columns: { type: Number } }
/** The cards: { title, line, href, meta?, cover? }. */
cards: ResourceCard[] = []
/** Rows under the cards: { title, line, href?, badge? }. */
rows: ResourceRow[] = []
/** The rows' list name. */
rowsLabel = 'More resources'
/** 2 (resources) or 3 (use cases, from 1024). */
columns: 2 | 3 = 2
#cover(cover: ResourceCover, columns: 2 | 3) {
if (cover.kind === 'code') return html`<span class="max-w-full overflow-hidden"><spyglass-code source=${cover.source} language=${cover.language ?? 'shell'}></spyglass-code></span>`
const size = columns === 3 ? 'shrink-0 basis-20 lg:basis-16 xl:basis-20 min-[1440px]:basis-24' : 'shrink grow-0 basis-30'
return html`<span class="flex w-full justify-center gap-3">${cover.items.map((c) => html`<span class=${['block aspect-4/5 min-w-0', size].join(' ')}><spyglass-creative-card ratio="fill" src=${ifDefined(c.src)} fit=${ifDefined(c.fit)} position=${ifDefined(c.position)} alt=${ifDefined(c.alt)} brand=${ifDefined(c.brand)} caption=${ifDefined(c.caption)} tone=${ifDefined(c.tone)}></spyglass-creative-card></span>`)}</span>`
}
render() {
const columns = Number(this.columns) === 3 ? 3 : 2
const cards = this.cards ?? []
const rows = this.rows ?? []
const out = (href: string) => (isExternal(href) ? { target: '_blank', rel: 'noreferrer' } : { target: undefined, rel: undefined })
return html`<div data-ds="resource-cards" class="flex flex-col gap-12 text-fg"><ul role="list" class=${['m-0 grid list-none grid-cols-[minmax(0,1fr)] gap-4 p-0 md:grid-cols-2', columns === 3 ? 'lg:grid-cols-3' : ''].join(' ')}>${cards.map((card) => html`<li><a href=${card.href} target=${ifDefined(out(card.href).target)} rel=${ifDefined(out(card.href).rel)} class="flex h-full flex-col rounded-panel bg-surface-raised p-2 transition-[background-color] duration-160 ease-out hover:bg-surface-hover focus-visible:-outline-offset-2"><span aria-hidden="true" class=${['grid h-60 place-items-center overflow-hidden rounded-container bg-surface p-6', columns === 2 ? 'lg:h-80' : ''].join(' ')}>${card.cover ? this.#cover(card.cover, columns) : nothing}</span><span class="flex flex-1 flex-col gap-2 p-4 md:pt-6"><h2 class="type-heading-3">${card.title}</h2><span class="type-body text-pretty text-fg-soft">${card.line}</span>${card.meta ? html`<span class="mt-auto pt-2 type-ui text-fg-muted">${card.meta}</span>` : nothing}</span></a></li>`)}</ul>${rows.length ? html`<ul role="list" aria-label=${this.rowsLabel} class="m-0 list-none border-t border-edge p-0">${rows.map((row) => {
const body = html`<h2 class="col-start-1 row-start-1 type-body font-medium text-fg-soft transition-[color] duration-160 ease-out group-hover:text-fg">${row.title}</h2><span class="col-span-full row-start-2 type-body text-pretty text-fg-faint lg:col-span-1 lg:col-start-2 lg:row-start-1">${row.line}</span>${row.badge ? html`<span class="col-start-2 row-start-1 flex justify-self-end lg:col-start-3"><spyglass-badge variant="secondary">${row.badge}</spyglass-badge></span>` : nothing}`
return html`<li>${row.href ? html`<a href=${row.href} target=${ifDefined(out(row.href).target)} rel=${ifDefined(out(row.href).rel)} class=${['group focus-visible:-outline-offset-2', ROW].join(' ')}>${body}</a>` : html`<div class=${ROW}>${body}</div>`}</li>`
})}</ul>` : nothing}</div>`
}
}
define('resource-cards', ResourceCards)Reference: Site pages/Resources (ResourceHub.tsx, Resources.module.css) and pages/UseCasesPage (UseCaseHub.tsx, UseCaseHub.module.css): cards 8px in on --surface with --radius-m, turning --surface-hover (160ms, ease-out); the cover 240px (320 from 1024; the use-cases hub keeps 240) 24px in on --bg with --radius-s; tiles 4:5, 12px apart, flex 0 1 --resources-tile-w 120px (use cases 80, 64 at 1024, 80 at 1280, 96 at 1440); the code in mono 14/20 with comments and marks in --text-3; text 16px in (24 on top from 768), h5 title, body line in --text-2, meta 14/20 in --text-3; 16px between cards, 48 before the rows; rows 20px tall padding (24 from 1024) with a 240px name column from 1024, the line in --text-off and the .t-badge.