Site
Product pricing
The site's product pricing section. receipt (the site's): the head, the free note and two buttons beside a receipt of three records at the rate, the free row and the total in credits with what is left of the free month; open: the rate set large beside what is free; plans: what each plan buys at the rate; rate: the rate alone in a ruled card.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add product-pricing<script type="module" src="/spyglass-ds/elements/product-pricing.js"></script>You pay for what comes back
No per-call fee. You pay per record returned, and the API and the MCP server share one pool.
500 free credits every month. No card required.
- Acme Fit@acmefit1 credit
- Acme Run@acmerun1 credit
- Acme Yoga@acmeyoga1 credit
- Add a missing creatorIndexed automaticallyFree
3 creators found3 credits
Free credits left this month497 of 500
Pay for what you get back.
No per-call fee. You are charged for the records a search returns, nothing else.
1 creditper creator foundFind 20 creators, use 20 credits.
- 500 credits a month, no card
- Free
- Adding a missing brand or creator
- Free
- Looking up product categories
- Free
- The API and the MCP server
- One pool
Start free.Pay for what you use
1 credit per creator found
Here is what each plan buys. The API and the MCP server share one pool of credits.
Free
$0 a month
500 creators a month
Creator
$10 a month
5,000 creators a month
Pro
$20 minimum a month
Pay as you go
Enterprise
Custom
Volume pricing
1 credit per creator found
500 free credits every month. No card required.
Missing a brand or creator? Add it for free. Spyglass indexes it automatically.
Usage
The pricing section of a product page, with the product's own rate and records.
Never
- A total that does not add up: the item counts it from the rate and the rows
- Prices other than the plans you sell
- Two White buttons
The receipt counts its total from value (the leading number, one credit by default) times the rows, and what is left from freeMonthly. A row without picture shows a neutral block; the free row without one shows the empty frame with a plus. plans reads the leading number of each plan's credits to say how many records it buys, and shows after when there is none. Each row's picture takes a src or an image slot; the neutral block and the free row's empty frame carry data-ds-placeholder.
Adds with it: button, creative-card
Props
The web component takes the same as attributes or properties (<spyglass-product-pricing>); title is heading there.
<ProductPricing>
| Prop | Type | Default |
|---|---|---|
variant | ProductPricingVariant | 'receipt' |
value | string The rate: "1 credit". | |
unit | string "per creator found". | |
headline | string | |
lead | string | |
note | string The free line under the lead. | '500 free credits every month. No card required.' |
primary | ProductPricingAction | { label: 'Get a free API key', href: '#' } |
secondary | ProductPricingAction | { label: 'See pricing', href: '/pricing' } |
product | string receipt: the product's name at the top. | '' |
rows | ReceiptRow[] receipt: three records. | [] |
free | ReceiptRow receipt: the free row. | { name: 'Add a missing brand', meta: 'Indexed automatically' } |
tally | string receipt: "3 creators found". | '' |
freeMonthly | number Free credits a month. | 500 |
freeRows | { label: string; value: string }[] open: what is free, label and value. | [] |
example | string open: "Find 20 creators, use 20 credits." | |
plans | PricingPlanLine[] plans: the plans. | [] |
noun | string plans: what the records are called: "creators". | 'records' |
missing | string rate: the second line beside the rate. | 'Missing a brand or creator? Add it for free. Spyglass indexes it automatically.' |
id | string Prefix for the heading id. | 'product' |
className | string |
Examples
The same example in React and as web components; both render identically.
import { ProductPricing } from '@/react/components/site/ProductPricing'
// The site's receipt for Creator search: three Acme creators at one credit each and the free row.
export default function Receipt() {
return (
<ProductPricing
id="creator-search"
value="1 credit"
unit="per creator found"
product="Creator search"
rows={[
{ name: 'Acme Fit', meta: '@acmefit' },
{ name: 'Acme Run', meta: '@acmerun' },
{ name: 'Acme Yoga', meta: '@acmeyoga' },
]}
free={{ name: 'Add a missing creator', meta: 'Indexed automatically' }}
tally="3 creators found"
/>
)
}<!-- The site's receipt for Creator search: three Acme creators at one credit each and the free row. -->
<spyglass-product-pricing prefix="creator-search" value="1 credit" unit="per creator found" product="Creator search" rows='[{"name":"Acme Fit","meta":"@acmefit"},{"name":"Acme Run","meta":"@acmerun"},{"name":"Acme Yoga","meta":"@acmeyoga"}]' free='{"name":"Add a missing creator","meta":"Indexed automatically"}' tally="3 creators found"></spyglass-product-pricing>import { ProductPricing } from '@/react/components/site/ProductPricing'
// The rate set large beside what is free.
export default function Open() {
return (
<ProductPricing
variant="open"
id="creator-search"
value="1 credit"
unit="per creator found"
example="Find 20 creators, use 20 credits."
freeRows={[
{ label: '500 credits a month, no card', value: 'Free' },
{ label: 'Adding a missing brand or creator', value: 'Free' },
{ label: 'Looking up product categories', value: 'Free' },
{ label: 'The API and the MCP server', value: 'One pool' },
]}
/>
)
}<!-- The rate set large beside what is free. -->
<spyglass-product-pricing variant="open" prefix="creator-search" value="1 credit" unit="per creator found" example="Find 20 creators, use 20 credits." free-rows='[{"label":"500 credits a month, no card","value":"Free"},{"label":"Adding a missing brand or creator","value":"Free"},{"label":"Looking up product categories","value":"Free"},{"label":"The API and the MCP server","value":"One pool"}]'></spyglass-product-pricing>import { ProductPricing } from '@/react/components/site/ProductPricing'
// What each plan buys at one credit per creator.
export default function Plans() {
return (
<ProductPricing
variant="plans"
id="creator-search"
value="1 credit"
unit="per creator found"
noun="creators"
plans={[
{ name: 'Free', price: '$0', unit: 'a month', credits: '500 credits a month' },
{ name: 'Creator', price: '$10', unit: 'a month', credits: '5,000 credits a month' },
{ name: 'Pro', price: '$20', unit: 'minimum a month', credits: '$1.50 per 1K credits', after: 'Pay as you go' },
{ name: 'Enterprise', price: 'Custom', credits: 'Volume pricing', after: 'Volume pricing' },
]}
/>
)
}<!-- What each plan buys at one credit per creator. -->
<spyglass-product-pricing variant="plans" prefix="creator-search" value="1 credit" unit="per creator found" noun="creators" plans='[{"name":"Free","price":"$0","unit":"a month","credits":"500 credits a month"},{"name":"Creator","price":"$10","unit":"a month","credits":"5,000 credits a month"},{"name":"Pro","price":"$20","unit":"minimum a month","credits":"$1.50 per 1K credits","after":"Pay as you go"},{"name":"Enterprise","price":"Custom","credits":"Volume pricing","after":"Volume pricing"}]'></spyglass-product-pricing>import { ProductPricing } from '@/react/components/site/ProductPricing'
// The rate alone in a ruled card beside the free note.
export default function Rate() {
return <ProductPricing variant="rate" id="creator-search" value="1 credit" unit="per creator found" />
}<!-- The rate alone in a ruled card beside the free note. -->
<spyglass-product-pricing variant="rate" prefix="creator-search" value="1 credit" unit="per creator found"></spyglass-product-pricing>Source
import { Button } from '@/react/components/ui/Button'
import { cn } from '@/react/lib/cn'
import { imageFit, toSlot, type ImageSlot } from '@/lib/image'
// The site's product pricing section (pages/Products/ProductPricing and its variants). The site shows `receipt`: the
// section head, a lead, the free note in 14/20 #A3A3A3 and two buttons beside a receipt on #1A1A1A with the 8px corner
// (16px in, 32 from 768): the product and its rate over a "Credits" column, three records (a 4:5 picture, 48px, 64 from
// 768; the name and a muted line; what each costs), the free row (an empty frame with a plus, or a picture) costing
// "Free", then under a #666666 rule the tally and the total in Funnel Display (24/28, 32/36 from 768) and the free
// credits left. `open` sets the rate large beside what is free; `plans` sets what each plan buys at the rate; `rate`
// is the rate alone in a ruled card beside the free note. Copy 5 parts to 7 from 1024; centered on phones. Nothing moves.
export type ProductPricingVariant = 'receipt' | 'open' | 'plans' | 'rate'
export interface ReceiptRow {
name: string
meta: string
/** A 4:5 picture (a src or { src, alt, fit, position }); a neutral block when left out. */
picture?: string | ImageSlot
}
export interface PricingPlanLine {
name: string
/** "$10", "Custom" or "From $20". */
price: string
unit?: string
/** "5,000 credits a month": the leading number sets how many records it buys. */
credits?: string
/** Shown when `credits` has no number. */
after?: string
}
export interface ProductPricingAction { label: string; href: string }
export interface ProductPricingProps {
variant?: ProductPricingVariant
/** The rate: "1 credit". */
value: string
/** "per creator found". */
unit: string
headline?: string
lead?: string
/** The free line under the lead. */
note?: string
primary?: ProductPricingAction
secondary?: ProductPricingAction
/** receipt: the product's name at the top. */
product?: string
/** receipt: three records. */
rows?: ReceiptRow[]
/** receipt: the free row. */
free?: ReceiptRow
/** receipt: "3 creators found". */
tally?: string
/** Free credits a month. */
freeMonthly?: number
/** open: what is free, label and value. */
freeRows?: { label: string; value: string }[]
/** open: "Find 20 creators, use 20 credits." */
example?: string
/** plans: the plans. */
plans?: PricingPlanLine[]
/** plans: what the records are called: "creators". */
noun?: string
/** rate: the second line beside the rate. */
missing?: string
/** Prefix for the heading id. */
id?: string
className?: string
}
const WRAP = 'mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)'
const fmt = (n: number) => n.toLocaleString('en-US')
const credits = (n: number) => `${fmt(n)} ${n === 1 ? 'credit' : 'credits'}`
const each = (value: string) => { const n = Number.parseInt(value, 10); return Number.isFinite(n) && n > 0 ? n : 1 }
const leading = (line?: string) => { const m = line?.match(/^[\d,]+/); return m ? Number(m[0].replace(/,/g, '')) : null }
function Actions({ primary, secondary, className }: { primary?: ProductPricingAction; secondary?: ProductPricingAction; className?: string }) {
if (!primary && !secondary) return null
return (
<div className={cn('flex flex-wrap gap-3', className)}>
{primary && <Button href={primary.href}>{primary.label}</Button>}
{secondary && <Button href={secondary.href} variant="secondary">{secondary.label}</Button>}
</div>
)
}
function Picture({ image }: { image?: string | ImageSlot }) {
const p = toSlot(image)
return p.src
? <img src={p.src} alt={p.alt ?? ''} width={64} height={80} className="block aspect-4/5 h-auto w-12 rounded-ds-sm object-cover md:w-16" style={imageFit(p)} />
: <span aria-hidden="true" data-ds-placeholder="" className="block aspect-4/5 w-12 rounded-ds-sm bg-surface-inset md:w-16" />
}
export function ProductPricing({
variant = 'receipt',
value,
unit,
headline,
lead,
note = '500 free credits every month. No card required.',
primary = { label: 'Get a free API key', href: '#' },
secondary = { label: 'See pricing', href: '/pricing' },
product = '',
rows = [],
free = { name: 'Add a missing brand', meta: 'Indexed automatically' },
tally = '',
freeMonthly = 500,
freeRows = [],
example,
plans = [],
noun = 'records',
missing = 'Missing a brand or creator? Add it for free. Spyglass indexes it automatically.',
id = 'product',
className,
}: ProductPricingProps) {
const headingId = `${id}-pricing-heading`
const per = each(value)
if (variant === 'open') {
return (
<section data-ds="product-pricing" aria-labelledby={headingId} className={cn('border-t border-edge py-(--ds-layout-section) text-fg', className)}>
<style href="ds-product-pricing" precedence="ds">{css}</style>
<div className={cn(WRAP, 'ds-pp-open grid grid-cols-[minmax(0,1fr)] gap-y-12 lg:gap-x-16 xl:gap-x-24')}>
<div className="[grid-area:head]">
<h2 id={headingId} className="type-section">{headline ?? 'Pay for what you get back.'}</h2>
<p className="mt-4 max-w-(--ds-layout-measure) type-body-lg text-pretty text-fg-soft">{lead ?? 'No per-call fee. You are charged for the records a search returns, nothing else.'}</p>
</div>
<p className="flex flex-col items-start [grid-area:rate]">
<span className="ds-pp-value whitespace-nowrap tabular-nums">{value}</span>
<span className="mt-1 whitespace-nowrap type-body-lg md:type-body-xl">{unit}</span>
{example && <span className="mt-4 whitespace-nowrap type-body text-fg-soft tabular-nums md:type-body-lg">{example}</span>}
</p>
<dl className="border-b border-edge [grid-area:free]">
{freeRows.map((r) => (
<div key={r.label} className="flex items-baseline justify-between gap-4 border-t border-edge py-4">
<dt className="min-w-0 truncate type-body md:type-body-lg">{r.label}</dt>
<dd className="flex-none type-body text-fg-soft md:type-body-lg">{r.value}</dd>
</div>
))}
</dl>
<Actions primary={primary} secondary={secondary} className="self-start [grid-area:actions]" />
</div>
</section>
)
}
if (variant === 'plans') {
const lines = (headline ?? 'Start free. Pay for what you use').split(/(?<=\.)\s+/)
return (
<section data-ds="product-pricing" aria-labelledby={headingId} className={cn('border-t border-edge py-(--ds-layout-section) text-fg', className)}>
<style href="ds-product-pricing" precedence="ds">{css}</style>
<div className={cn(WRAP, 'ds-pp-plans grid grid-cols-[minmax(0,1fr)] gap-y-8 lg:items-end lg:gap-x-16 lg:gap-y-16 xl:gap-x-24')}>
<h2 id={headingId} className="type-section [grid-area:headline]">{lines.map((l) => <span key={l} className="block">{l}</span>)}</h2>
<div className="[grid-area:rate]">
<p className="whitespace-nowrap type-body-lg tabular-nums md:type-body-xl">{value} {unit}</p>
<p className="mt-1 max-w-(--ds-layout-measure) type-body text-fg-soft md:type-body-lg">{lead ?? 'Here is what each plan buys. The API and the MCP server share one pool of credits.'}</p>
</div>
<ul role="list" className="grid grid-cols-[minmax(0,1fr)] border-b border-edge [grid-area:plans] lg:grid-cols-4 lg:border-t lg:border-b-0">
{plans.map((p) => {
const at = p.price.search(/[$\d]/)
const prefix = at > 0 ? p.price.slice(0, at).trim() : ''
const amount = at > 0 ? p.price.slice(at) : p.price
const n = leading(p.credits)
return (
<li key={p.name} className="ds-pp-plan grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-4 gap-y-1 border-t border-edge py-4 lg:grid-cols-[minmax(0,1fr)] lg:gap-y-2 lg:border-t-0 lg:border-l lg:px-6 lg:pt-6 lg:pb-0 lg:first:border-l-0 lg:first:pl-0">
<h3 className="type-heading-4 [grid-area:name]">{p.name}</h3>
<p className="whitespace-nowrap [grid-area:price] lg:mt-4">
{prefix && <span className="type-ui text-fg-muted">{prefix} </span>}
<span className="ds-pp-amount tabular-nums">{amount}</span>{' '}
{p.unit && <span className="type-ui text-fg-muted">{p.unit}</span>}
</p>
<p className="min-w-0 truncate type-body tabular-nums [grid-area:gets] lg:type-body-lg">{n === null ? p.after : `${fmt(Math.floor(n / per))} ${noun} a month`}</p>
</li>
)
})}
</ul>
<Actions primary={primary} secondary={secondary} className="mt-4 [grid-area:actions] lg:mt-0" />
</div>
</section>
)
}
if (variant === 'rate') {
return (
<section data-ds="product-pricing" aria-labelledby={headingId} className={cn('border-t border-edge py-(--ds-layout-section) text-fg', className)}>
<style href="ds-product-pricing" precedence="ds">{css}</style>
<div className={WRAP}>
<div className="grid grid-cols-[minmax(0,1fr)] gap-y-8 rounded-panel border border-edge bg-surface p-6 md:grid-cols-[minmax(0,5fr)_minmax(0,7fr)] md:items-center md:gap-x-12 md:p-12 lg:p-16">
<h2 id={headingId} className="flex flex-col gap-2">
<span className="ds-pp-value tabular-nums">{value}</span>{' '}
<span className="max-w-(--ds-layout-measure) type-body-lg text-pretty text-fg-soft">{unit}</span>
</h2>
<div className="flex flex-col items-start">
<p className="max-w-(--ds-layout-measure) type-body-lg">{note}</p>
{missing && <p className="mt-2 max-w-(--ds-layout-measure) type-body text-pretty text-fg-soft">{missing}</p>}
<Actions primary={primary} secondary={secondary} className="mt-8" />
</div>
</div>
</div>
</section>
)
}
const total = per * rows.length
return (
<section data-ds="product-pricing" aria-labelledby={headingId} className={cn('py-(--ds-layout-section) text-fg', className)}>
<div className={cn(WRAP, 'grid grid-cols-[minmax(0,1fr)] items-center gap-y-12 lg:grid-cols-[minmax(0,5fr)_minmax(0,7fr)] lg:gap-x-16 xl:gap-x-24')}>
<div className="flex flex-col items-center text-center md:items-start md:text-left">
<h2 id={headingId} className="type-section">{headline ?? 'You pay for what comes back'}</h2>
<p className="mt-4 max-w-(--ds-layout-measure) type-body-lg text-pretty text-fg-soft">{lead ?? 'No per-call fee. You pay per record returned, and the API and the MCP server share one pool.'}</p>
{note && <p className="mt-4 type-ui text-fg-muted">{note}</p>}
<Actions primary={primary} secondary={secondary} className="mt-8 flex-col justify-center self-stretch md:flex-row md:self-auto" />
</div>
<figure className="min-w-0 rounded-panel bg-surface-subtle p-4 md:p-8">
<figcaption className="flex justify-between gap-4 type-ui text-fg-muted">
<span className="min-w-0 truncate">{product}<span className="hidden md:inline">, {value} {unit}</span></span>
<span aria-hidden="true" className="flex-none">Credits</span>
</figcaption>
<ul role="list" className="mt-3">
{[...rows.map((r) => ({ ...r, cost: credits(per), zero: false })), { ...free, cost: 'Free', zero: true }].map((r) => (
<li key={`${r.name}, ${r.meta}`} className="grid grid-cols-[48px_minmax(0,1fr)_auto] items-center gap-x-4 border-t border-edge py-3 md:grid-cols-[64px_minmax(0,1fr)_auto] md:py-4">
{r.zero && !toSlot(r.picture).src
? <span aria-hidden="true" data-ds-placeholder="" className="relative grid aspect-4/5 w-12 place-items-center border border-edge-strong text-fg-soft md:w-16"><svg viewBox="0 0 16 16" width="16" height="16" fill="none"><path d="M8 0v16M0 8h16" stroke="currentColor" strokeWidth="2" /></svg></span>
: <Picture image={r.picture} />}
<span className="flex min-w-0 flex-col">
<span className="truncate type-body">{r.name}</span>
<span className="truncate type-ui text-fg-muted">{r.meta}</span>
</span>
<span className={cn('whitespace-nowrap type-ui md:type-body', r.zero ? 'text-fg' : 'text-fg-soft tabular-nums')}>{r.cost}</span>
</li>
))}
</ul>
<p className="flex items-baseline justify-between gap-4 border-t border-edge-strong pt-4">
<span className="min-w-0 truncate type-body md:type-body-lg">{tally}</span>
<span className="flex-none type-heading-3 tabular-nums md:type-heading-2">{credits(total)}</span>
</p>
<p className="mt-2 flex justify-between gap-4 type-ui text-fg-muted">
<span>Free credits left this month</span>
<span className="tabular-nums">{fmt(freeMonthly - total)} of {fmt(freeMonthly)}</span>
</p>
</figure>
</div>
</section>
)
}
export default ProductPricing
const css = `
.ds-pp-value { font-family: var(--ds-font-heading); font-weight: var(--ds-font-weight-regular); font-size: var(--ds-text-display-phone); line-height: var(--ds-text-display-phone-leading); }
.ds-pp-amount { font-family: var(--ds-font-heading); font-weight: var(--ds-font-weight-regular); font-size: var(--ds-text-heading-4); line-height: var(--ds-text-heading-4-leading); }
.ds-pp-open { grid-template-areas: "head" "rate" "free" "actions"; }
.ds-pp-plans { grid-template-areas: "headline" "rate" "plans" "actions"; }
.ds-pp-plan { grid-template-areas: "name price" "gets gets"; }
@media (min-width: 768px) { .ds-pp-value { font-size: var(--ds-text-display-s); line-height: var(--ds-text-display-s-leading); } }
@media (min-width: 1024px) {
.ds-pp-value { font-size: var(--ds-text-display); line-height: var(--ds-text-display-leading); }
.ds-pp-amount { font-size: var(--ds-text-display-phone); line-height: var(--ds-text-display-phone-leading); }
.ds-pp-open { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-rows: auto 1fr; grid-template-areas: "head rate" "actions free"; }
.ds-pp-plans { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); grid-template-areas: "headline rate" "plans plans" "actions actions"; }
.ds-pp-plan { grid-template-areas: "name" "price" "gets"; }
}
`// 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 { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import '@/elements/components/ui/button'
import styles from 'virtual:tw'
import { imageFit, toSlot, type ImageSlot } from '@/lib/image'
import { styleMap } from 'lit/directives/style-map.js'
// ProductPricing.tsx as <spyglass-product-pricing>: the product pricing section. `receipt` (the site's): the head and
// two buttons beside a receipt of three records, the free row and the total; `open`: the rate large beside what is
// free; `plans`: what each plan buys at the rate; `rate`: the rate alone in a ruled card. Lists as JSON.
export type ProductPricingVariant = 'receipt' | 'open' | 'plans' | 'rate'
export interface ReceiptRow { name: string; meta: string; picture?: string | ImageSlot }
export interface PricingPlanLine { name: string; price: string; unit?: string; credits?: string; after?: string }
export interface ProductPricingAction { label: string; href: string }
const WRAP = 'mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)'
const fmt = (n: number) => n.toLocaleString('en-US')
const credits = (n: number) => `${fmt(n)} ${n === 1 ? 'credit' : 'credits'}`
const each = (value: string) => { const n = Number.parseInt(value, 10); return Number.isFinite(n) && n > 0 ? n : 1 }
const leading = (line?: string) => { const m = line?.match(/^[\d,]+/); return m ? Number(m[0].replace(/,/g, '')) : null }
/**
* @summary The product pricing section: a receipt of what a search costs, or the rate, what is free or what each plan buys.
*/
export class ProductPricing extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="product-pricing"]'))
static properties = {
variant: {}, value: {}, unit: {}, headline: {}, lead: {}, note: {}, primary: { type: Object }, secondary: { type: Object }, product: {}, rows: { type: Array }, free: { type: Object }, tally: {},
freeMonthly: { type: Number, attribute: 'free-monthly' }, freeRows: { type: Array, attribute: 'free-rows' }, example: {}, plans: { type: Array }, noun: {}, missing: {}, prefix: {},
}
variant: ProductPricingVariant = 'receipt'
/** The rate: "1 credit". */
value = ''
/** "per creator found". */
unit = ''
headline?: string
lead?: string
note = '500 free credits every month. No card required.'
primary?: ProductPricingAction = { label: 'Get a free API key', href: '#' }
secondary?: ProductPricingAction = { label: 'See pricing', href: '/pricing' }
/** receipt: the product's name at the top. */
product = ''
rows: ReceiptRow[] = []
free: ReceiptRow = { name: 'Add a missing brand', meta: 'Indexed automatically' }
tally = ''
freeMonthly = 500
freeRows: { label: string; value: string }[] = []
example?: string
plans: PricingPlanLine[] = []
noun = 'records'
missing = 'Missing a brand or creator? Add it for free. Spyglass indexes it automatically.'
/** Prefix for the heading id (React's `id`). */
prefix = 'product'
private actions(cls: string) {
const { primary, secondary } = this
if (!primary && !secondary) return nothing
return html`<div class=${`flex flex-wrap gap-3 ${cls}`}>${primary ? html`<spyglass-button href=${primary.href}>${primary.label}</spyglass-button>` : nothing}${secondary ? html`<spyglass-button href=${secondary.href} variant="secondary">${secondary.label}</spyglass-button>` : nothing}</div>`
}
private picture(image?: string | ImageSlot) {
const p = toSlot(image)
return p.src ? html`<img src=${p.src} alt=${p.alt ?? ''} width="64" height="80" class="block aspect-4/5 h-auto w-12 rounded-ds-sm object-cover md:w-16" style=${styleMap(imageFit(p) ?? {})}>` : html`<span aria-hidden="true" data-ds-placeholder="" class="block aspect-4/5 w-12 rounded-ds-sm bg-surface-inset md:w-16"></span>`
}
render() {
const headingId = `${this.prefix}-pricing-heading`
const per = each(this.value)
const { value, unit } = this
if (this.variant === 'open') {
return html`<section data-ds="product-pricing" aria-labelledby=${headingId} class="border-t border-edge py-(--ds-layout-section) text-fg"><div class=${`${WRAP} ds-pp-open grid grid-cols-[minmax(0,1fr)] gap-y-12 lg:gap-x-16 xl:gap-x-24`}><div class="[grid-area:head]"><h2 id=${headingId} class="type-section">${this.headline ?? 'Pay for what you get back.'}</h2><p class="mt-4 max-w-(--ds-layout-measure) type-body-lg text-pretty text-fg-soft">${this.lead ?? 'No per-call fee. You are charged for the records a search returns, nothing else.'}</p></div><p class="flex flex-col items-start [grid-area:rate]"><span class="ds-pp-value whitespace-nowrap tabular-nums">${value}</span><span class="mt-1 whitespace-nowrap type-body-lg md:type-body-xl">${unit}</span>${this.example ? html`<span class="mt-4 whitespace-nowrap type-body text-fg-soft tabular-nums md:type-body-lg">${this.example}</span>` : nothing}</p><dl class="border-b border-edge [grid-area:free]">${(this.freeRows ?? []).map((r) => html`<div class="flex items-baseline justify-between gap-4 border-t border-edge py-4"><dt class="min-w-0 truncate type-body md:type-body-lg">${r.label}</dt><dd class="flex-none type-body text-fg-soft md:type-body-lg">${r.value}</dd></div>`)}</dl>${this.actions('self-start [grid-area:actions]')}</div></section>`
}
if (this.variant === 'plans') {
const lines = (this.headline ?? 'Start free. Pay for what you use').split(/(?<=\.)\s+/)
return html`<section data-ds="product-pricing" aria-labelledby=${headingId} class="border-t border-edge py-(--ds-layout-section) text-fg"><div class=${`${WRAP} ds-pp-plans grid grid-cols-[minmax(0,1fr)] gap-y-8 lg:items-end lg:gap-x-16 lg:gap-y-16 xl:gap-x-24`}><h2 id=${headingId} class="type-section [grid-area:headline]">${lines.map((l) => html`<span class="block">${l}</span>`)}</h2><div class="[grid-area:rate]"><p class="whitespace-nowrap type-body-lg tabular-nums md:type-body-xl">${value} ${unit}</p><p class="mt-1 max-w-(--ds-layout-measure) type-body text-fg-soft md:type-body-lg">${this.lead ?? 'Here is what each plan buys. The API and the MCP server share one pool of credits.'}</p></div><ul role="list" class="grid grid-cols-[minmax(0,1fr)] border-b border-edge [grid-area:plans] lg:grid-cols-4 lg:border-t lg:border-b-0">${(this.plans ?? []).map((p) => {
const at = p.price.search(/[$\d]/)
const prefix = at > 0 ? p.price.slice(0, at).trim() : ''
const amount = at > 0 ? p.price.slice(at) : p.price
const n = leading(p.credits)
return html`<li class="ds-pp-plan grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-4 gap-y-1 border-t border-edge py-4 lg:grid-cols-[minmax(0,1fr)] lg:gap-y-2 lg:border-t-0 lg:border-l lg:px-6 lg:pt-6 lg:pb-0 lg:first:border-l-0 lg:first:pl-0"><h3 class="type-heading-4 [grid-area:name]">${p.name}</h3><p class="whitespace-nowrap [grid-area:price] lg:mt-4">${prefix ? html`<span class="type-ui text-fg-muted">${prefix} </span>` : nothing}<span class="ds-pp-amount tabular-nums">${amount}</span> ${p.unit ? html`<span class="type-ui text-fg-muted">${p.unit}</span>` : nothing}</p><p class="min-w-0 truncate type-body tabular-nums [grid-area:gets] lg:type-body-lg">${n === null ? p.after : `${fmt(Math.floor(n / per))} ${this.noun} a month`}</p></li>`
})}</ul>${this.actions('mt-4 [grid-area:actions] lg:mt-0')}</div></section>`
}
if (this.variant === 'rate') {
return html`<section data-ds="product-pricing" aria-labelledby=${headingId} class="border-t border-edge py-(--ds-layout-section) text-fg"><div class=${WRAP}><div class="grid grid-cols-[minmax(0,1fr)] gap-y-8 rounded-panel border border-edge bg-surface p-6 md:grid-cols-[minmax(0,5fr)_minmax(0,7fr)] md:items-center md:gap-x-12 md:p-12 lg:p-16"><h2 id=${headingId} class="flex flex-col gap-2"><span class="ds-pp-value tabular-nums">${value}</span> <span class="max-w-(--ds-layout-measure) type-body-lg text-pretty text-fg-soft">${unit}</span></h2><div class="flex flex-col items-start"><p class="max-w-(--ds-layout-measure) type-body-lg">${this.note}</p>${this.missing ? html`<p class="mt-2 max-w-(--ds-layout-measure) type-body text-pretty text-fg-soft">${this.missing}</p>` : nothing}${this.actions('mt-8')}</div></div></div></section>`
}
const rows = this.rows ?? []
const total = per * rows.length
const lines = [...rows.map((r) => ({ ...r, cost: credits(per), zero: false })), { ...this.free, cost: 'Free', zero: true }]
return html`<section data-ds="product-pricing" aria-labelledby=${headingId} class="py-(--ds-layout-section) text-fg"><div class=${`${WRAP} grid grid-cols-[minmax(0,1fr)] items-center gap-y-12 lg:grid-cols-[minmax(0,5fr)_minmax(0,7fr)] lg:gap-x-16 xl:gap-x-24`}><div class="flex flex-col items-center text-center md:items-start md:text-left"><h2 id=${headingId} class="type-section">${this.headline ?? 'You pay for what comes back'}</h2><p class="mt-4 max-w-(--ds-layout-measure) type-body-lg text-pretty text-fg-soft">${this.lead ?? 'No per-call fee. You pay per record returned, and the API and the MCP server share one pool.'}</p>${this.note ? html`<p class="mt-4 type-ui text-fg-muted">${this.note}</p>` : nothing}${this.actions('mt-8 flex-col justify-center self-stretch md:flex-row md:self-auto')}</div><figure class="min-w-0 rounded-panel bg-surface-subtle p-4 md:p-8"><figcaption class="flex justify-between gap-4 type-ui text-fg-muted"><span class="min-w-0 truncate">${this.product}<span class="hidden md:inline">, ${value} ${unit}</span></span><span aria-hidden="true" class="flex-none">Credits</span></figcaption><ul role="list" class="mt-3">${lines.map((r) => html`<li class="grid grid-cols-[48px_minmax(0,1fr)_auto] items-center gap-x-4 border-t border-edge py-3 md:grid-cols-[64px_minmax(0,1fr)_auto] md:py-4">${r.zero && !toSlot(r.picture).src ? html`<span aria-hidden="true" data-ds-placeholder="" class="relative grid aspect-4/5 w-12 place-items-center border border-edge-strong text-fg-soft md:w-16"><svg viewBox="0 0 16 16" width="16" height="16" fill="none"><path d="M8 0v16M0 8h16" stroke="currentColor" stroke-width="2"></path></svg></span>` : this.picture(r.picture)}<span class="flex min-w-0 flex-col"><span class="truncate type-body">${r.name}</span><span class="truncate type-ui text-fg-muted">${r.meta}</span></span><span class=${`whitespace-nowrap type-ui md:type-body ${r.zero ? 'text-fg' : 'text-fg-soft tabular-nums'}`}>${r.cost}</span></li>`)}</ul><p class="flex items-baseline justify-between gap-4 border-t border-edge-strong pt-4"><span class="min-w-0 truncate type-body md:type-body-lg">${this.tally}</span><span class="flex-none type-heading-3 tabular-nums md:type-heading-2">${credits(total)}</span></p><p class="mt-2 flex justify-between gap-4 type-ui text-fg-muted"><span>Free credits left this month</span><span class="tabular-nums">${fmt(this.freeMonthly - total)} of ${fmt(this.freeMonthly)}</span></p></figure></div></section>`
}
}
define('product-pricing', ProductPricing).ds-pp-value { font-family: var(--ds-font-heading); font-weight: var(--ds-font-weight-regular); font-size: var(--ds-text-display-phone); line-height: var(--ds-text-display-phone-leading); }
.ds-pp-amount { font-family: var(--ds-font-heading); font-weight: var(--ds-font-weight-regular); font-size: var(--ds-text-heading-4); line-height: var(--ds-text-heading-4-leading); }
.ds-pp-open { grid-template-areas: "head" "rate" "free" "actions"; }
.ds-pp-plans { grid-template-areas: "headline" "rate" "plans" "actions"; }
.ds-pp-plan { grid-template-areas: "name price" "gets gets"; }
@media (min-width: 768px) { .ds-pp-value { font-size: var(--ds-text-display-s); line-height: var(--ds-text-display-s-leading); } }
@media (min-width: 1024px) {
.ds-pp-value { font-size: var(--ds-text-display); line-height: var(--ds-text-display-leading); }
.ds-pp-amount { font-size: var(--ds-text-display-phone); line-height: var(--ds-text-display-phone-leading); }
.ds-pp-open { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-rows: auto 1fr; grid-template-areas: "head rate" "actions free"; }
.ds-pp-plans { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); grid-template-areas: "headline rate" "plans plans" "actions actions"; }
.ds-pp-plan { grid-template-areas: "name" "price" "gets"; }
}Reference: Site pages/Products/ProductPricing, ProductPricingReceipt, ProductPricingOpen, ProductPricingPlans (and their CSS modules, ProductPricing.content.ts): the receipt on --raised with --radius-m, 16px in (32 from 768), rows ruled by --line with 48px pictures (64 from 768) 4:5, the total under --line-strong in h5 (h4 from 768); copy 5fr to 7fr from 1024 with 64px between (96 at 1280); the rate in h1-alt, display-s at 768 and display-l at 1024.