Site
Product compare
The site's product comparison: the section head over a table of what the product does against two other ways of doing it, a check, a cross or a few words in each cell, the last column yours with the logomark and White checks; on phones each row is its label over its cells.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add product-compare<script type="module" src="/spyglass-ds/elements/product-compare.js"></script>See the difference
Ad libraries show what is live. Scrapers hand you raw pages. Spyglass keeps the whole record, ready to ask.
| Ad libraries | Scrapers | Spyglass | |
|---|---|---|---|
| Find creators by niche, place and followers | No | No | Yes |
| One record across Instagram and TikTok | No | You match them | Yes |
| The brands they have worked with | No | No | Yes |
| Ready for your agents over MCP | No | You build it | Yes |
| Ad libraries | Scrapers | Spyglass |
|---|---|---|
| Find creators by niche, place and followers | ||
| No | No | Yes |
| One record across Instagram and TikTok | ||
| No | You match them | Yes |
| The brands they have worked with | ||
| No | No | Yes |
| Ready for your agents over MCP | ||
| No | You build it | Yes |
Usage
A product page's case against the alternatives, three to six rows of things a buyer checks.
Never
- Naming a competitor: the columns are kinds of tools (ad libraries, scrapers)
- More than three columns
- Claims the product does not make good on
rows takes one cell per column: "yes", "no" or a few words. mark (React) or the mark slot (web component) replaces the logomark beside the last column's name.
Adds with it: logo
Props
The web component takes the same as attributes or properties (<spyglass-product-compare>); title is heading there.
<ProductCompare>
| Prop | Type | Default |
|---|---|---|
headline | string | 'See the difference' |
lead | string | 'Ad libraries show what is live. Scrapers hand you raw pages. Spyglass keeps the whole record, ready to ask.' |
columns | string[] The column names; the last is yours and gets the mark. | ['Ad libraries', 'Scrapers', 'Spyglass'] |
rows | CompareRow[] | |
mark | ReactNode The mark beside the last column's name (the logomark by default). | |
yes | string Read for the check and the cross. | 'Yes' |
no | string | 'No' |
id | string Prefix for the heading id. | 'product' |
className | string |
Examples
The same example in React and as web components; both render identically.
import { ProductCompare } from '@/react/components/site/ProductCompare'
// Creator search against ad libraries and scrapers.
export default function Creators() {
return (
<ProductCompare
id="creator-search"
rows={[
{ label: 'Find creators by niche, place and followers', cells: ['no', 'no', 'yes'] },
{ label: 'One record across Instagram and TikTok', cells: ['no', 'You match them', 'yes'] },
{ label: 'The brands they have worked with', cells: ['no', 'no', 'yes'] },
{ label: 'Ready for your agents over MCP', cells: ['no', 'You build it', 'yes'] },
]}
/>
)
}<!-- Creator search against ad libraries and scrapers. -->
<spyglass-product-compare prefix="creator-search" rows='[{"label":"Find creators by niche, place and followers","cells":["no","no","yes"]},{"label":"One record across Instagram and TikTok","cells":["no","You match them","yes"]},{"label":"The brands they have worked with","cells":["no","no","yes"]},{"label":"Ready for your agents over MCP","cells":["no","You build it","yes"]}]'></spyglass-product-compare>Source
import type { ReactNode } from 'react'
import { Logo } from '@/react/components/visuals/Logo'
import { cn } from '@/react/lib/cn'
// The site's product comparison (pages/Products/ProductCompare): the section head (the page head type, a lead 24px
// under it; centered on phones), then a table of what the product does against two other ways of doing it. Rows ruled by
// #363636 hairlines, the label in 16/24 White, three columns of 160px (88 on phones) with a check or a cross in #A3A3A3
// (the last column, ours, in White with the logomark beside its name and its checks White) or a few words in 14/20
// #A3A3A3. On phones each row is the label over its three cells. Nothing moves.
export type CompareCell = 'yes' | 'no' | (string & {})
export interface CompareRow {
label: string
/** One cell per column: "yes", "no" or a few words. */
cells: CompareCell[]
}
export interface ProductCompareProps {
headline?: string
lead?: string
/** The column names; the last is yours and gets the mark. */
columns?: string[]
rows: CompareRow[]
/** The mark beside the last column's name (the logomark by default). */
mark?: ReactNode
/** Read for the check and the cross. */
yes?: string
no?: 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)'
function Mark({ value, ours, yes, no }: { value: string; ours: boolean; yes: string; no: string }) {
if (value === 'yes' || value === 'no') {
const on = value === 'yes'
return (
<span className={cn('inline-grid size-6 place-items-center', on ? (ours ? 'text-fg' : 'text-fg-soft') : 'text-fg-muted')}>
<svg viewBox="0 0 16 16" width="20" height="20" aria-hidden="true" focusable="false">
<path d={on ? 'M3.5 8.5 6.5 11.5 12.5 4.5' : 'M4.5 4.5l7 7M11.5 4.5l-7 7'} fill="none" stroke="currentColor" strokeWidth="1.5" />
</svg>
<span className="sr-only">{on ? yes : no}</span>
</span>
)
}
return <span className="type-caption text-balance text-fg-muted md:type-ui">{value}</span>
}
export function ProductCompare({
headline = 'See the difference',
lead = 'Ad libraries show what is live. Scrapers hand you raw pages. Spyglass keeps the whole record, ready to ask.',
columns = ['Ad libraries', 'Scrapers', 'Spyglass'],
rows,
mark,
yes = 'Yes',
no = 'No',
id = 'product',
className,
}: ProductCompareProps) {
const last = columns.length - 1
const heads = columns.map((c, i) => (
<th key={c} scope="col" className={cn('w-22 pb-4 text-center align-top type-caption md:w-40 md:align-bottom md:type-ui', i === last ? 'font-medium text-fg' : 'font-normal text-fg-muted')}>
{i === last ? <span className="inline-flex items-center gap-2">{mark ?? <Logo variant="mark" height={12} label="" className="flex-none" />}{c}</span> : c}
</th>
))
const cells = (row: CompareRow, phone: boolean) => row.cells.map((cell, i) => (
<td key={columns[i] ?? i} className={cn('text-center', phone ? 'pt-3 pb-4 align-top' : 'py-4 align-middle')}>
<Mark value={cell} ours={i === last} yes={yes} no={no} />
</td>
))
return (
<section data-ds="product-compare" aria-labelledby={`${id}-compare-heading`} className={cn('py-(--ds-layout-section) text-fg', className)}>
<div className={WRAP}>
<header className="mb-12 flex flex-col items-center text-center md:items-start md:text-left lg:mb-16">
<h2 id={`${id}-compare-heading`} className="type-section">{headline}</h2>
{lead && <p className="mt-6 max-w-(--ds-layout-measure) type-body-lg text-fg-soft">{lead}</p>}
</header>
<table className="hidden w-full table-fixed border-collapse md:table">
<thead><tr><td />{heads}</tr></thead>
<tbody>
{rows.map((row) => (
<tr key={row.label} className="border-t border-edge last:border-b">
<th scope="row" className="py-5 pr-4 text-left type-body font-normal text-pretty text-fg">{row.label}</th>
{cells(row, false)}
</tr>
))}
</tbody>
</table>
<table className="w-full table-fixed border-collapse md:hidden">
<thead><tr>{heads}</tr></thead>
{rows.map((row) => (
<tbody key={row.label} className="border-t border-edge last:border-b">
<tr><th scope="rowgroup" colSpan={columns.length} className="pt-4 text-left type-ui font-normal text-pretty text-fg">{row.label}</th></tr>
<tr>{cells(row, true)}</tr>
</tbody>
))}
</table>
</div>
</section>
)
}
export default ProductCompare// 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, svg, nothing } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import '@/elements/components/visuals/logo'
import styles from 'virtual:tw'
// ProductCompare.tsx as <spyglass-product-compare>: the site's product comparison, the head over a table of what the
// product does against two other ways (checks, crosses or a few words), the last column yours with the logomark; on
// phones each row is the label over its cells. `rows` as JSON: [{ label, cells: ["yes" | "no" | words] }].
export type CompareCell = string
export interface CompareRow { label: string; cells: CompareCell[] }
const WRAP = 'mx-auto w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] px-(--ds-layout-gutter)'
/**
* @summary The product comparison table: checks and words against two other ways, the last column yours.
* @slot mark - Replaces the logomark beside the last column's name.
*/
export class ProductCompare extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="product-compare"]'))
static properties = { headline: {}, lead: {}, columns: { type: Array }, rows: { type: Array }, yes: {}, no: {}, prefix: {} }
headline = 'See the difference'
lead = 'Ad libraries show what is live. Scrapers hand you raw pages. Spyglass keeps the whole record, ready to ask.'
/** The column names; the last is yours and gets the mark. */
columns: string[] = ['Ad libraries', 'Scrapers', 'Spyglass']
rows: CompareRow[] = []
yes = 'Yes'
no = 'No'
/** Prefix for the heading id (React's `id`). */
prefix = 'product'
private mark(value: string, ours: boolean) {
if (value === 'yes' || value === 'no') {
const on = value === 'yes'
return html`<span class=${`inline-grid size-6 place-items-center ${on ? (ours ? 'text-fg' : 'text-fg-soft') : 'text-fg-muted'}`}><svg viewBox="0 0 16 16" width="20" height="20" aria-hidden="true" focusable="false">${svg`<path d=${on ? 'M3.5 8.5 6.5 11.5 12.5 4.5' : 'M4.5 4.5l7 7M11.5 4.5l-7 7'} fill="none" stroke="currentColor" stroke-width="1.5"></path>`}</svg><span class="sr-only">${on ? this.yes : this.no}</span></span>`
}
return html`<span class="type-caption text-balance text-fg-muted md:type-ui">${value}</span>`
}
render() {
const columns = this.columns ?? []
const rows = this.rows ?? []
const last = columns.length - 1
const heads = columns.map((c, i) => html`<th scope="col" class=${`w-22 pb-4 text-center align-top type-caption md:w-40 md:align-bottom md:type-ui ${i === last ? 'font-medium text-fg' : 'font-normal text-fg-muted'}`}>${i === last ? html`<span class="inline-flex items-center gap-2"><slot name="mark"><spyglass-logo variant="mark" height="12" aria-label="" class="flex-none"></spyglass-logo></slot>${c}</span>` : c}</th>`)
const cells = (row: CompareRow, phone: boolean) => (row.cells ?? []).map((cell, i) => html`<td class=${`text-center ${phone ? 'pt-3 pb-4 align-top' : 'py-4 align-middle'}`}>${this.mark(cell, i === last)}</td>`)
return html`<section data-ds="product-compare" aria-labelledby=${`${this.prefix}-compare-heading`} class="py-(--ds-layout-section) text-fg"><div class=${WRAP}><header class="mb-12 flex flex-col items-center text-center md:items-start md:text-left lg:mb-16"><h2 id=${`${this.prefix}-compare-heading`} class="type-section">${this.headline}</h2>${this.lead ? html`<p class="mt-6 max-w-(--ds-layout-measure) type-body-lg text-fg-soft">${this.lead}</p>` : nothing}</header><table class="hidden w-full table-fixed border-collapse md:table"><thead><tr><td></td>${heads}</tr></thead><tbody>${rows.map((row) => html`<tr class="border-t border-edge last:border-b"><th scope="row" class="py-5 pr-4 text-left type-body font-normal text-pretty text-fg">${row.label}</th>${cells(row, false)}</tr>`)}</tbody></table><table class="w-full table-fixed border-collapse md:hidden"><thead><tr>${heads}</tr></thead>${rows.map((row) => html`<tbody class="border-t border-edge last:border-b"><tr><th scope="rowgroup" colspan=${columns.length} class="pt-4 text-left type-ui font-normal text-pretty text-fg">${row.label}</th></tr><tr>${cells(row, true)}</tr></tbody>`)}</table></div></section>`
}
}
define('product-compare', ProductCompare)Reference: Site pages/Products/ProductCompare (ProductCompare.module.css): .t-head with a .t-lead 24px under it, 48px (64 at 1024) to the table; rows ruled by --line, labels body 16/24 with 20px above and below, 160px columns (88 on phones) of 20px marks in --text-3 (yes --text-2, ours --text) or words in small 14/20 (caption on phones); the last head Medium White with the logomark; a stacked table under 768.