Site
Product features
The site's product feature rows: one row per thing the product does, the title, lead and an optional quiet button beside a 4:3 stage on the #262626 fill where the ASCII texture shows around a clear middle and the feature's picture sits; copy 5 parts to the stage's 7 from 1024, every other row flipped, stacked below.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add product-features<script type="module" src="/spyglass-ds/elements/product-features.js"></script>Search creators by name or by description
Use a name, a handle or a plain brief, like fitness creators in Texas. Filter by location, language, gender, age range and followers.
Acme Fit, Austin
Acme Run, Dallas
Acme Yoga, Houston
See who already works with your competitors
Look up a brand to see the creators it has posted with, how often and since when. Start your shortlist there.
See Creator collabsAcme Studio, 12 posts
Acme Goods, 7 posts
Acme Air, 5 posts
Usage
The body of a product page: three or four features, each with a product visual on its stage.
Never
- A stage without a picture
- More than one button in a row
- Rows that do not alternate
Each feature's visual (React) or the slot visual-1, visual-2... (web component) fills its stage; the stage is a size container named stage, so a picture can size itself with cqi. On a product page the visuals are the product visual item's kinds.
Adds with it: ascii-drift, button
Props
The web component takes the same as attributes or properties (<spyglass-product-features>); title is heading there.
<ProductFeatures>
| Prop | Type | Default |
|---|---|---|
features | ProductFeature[] | |
id | string Prefix for the heading ids. | 'product' |
className | string |
Examples
The same example in React and as web components; both render identically.
import { ProductFeatures } from '@/react/components/site/ProductFeatures'
// Two feature rows with a plain Acme list on each stage, the second row flipped.
function Panel({ rows }: { rows: string[] }) {
return (
<div className="absolute inset-x-[14%] top-[18%] bottom-0 flex flex-col rounded-t-panel border border-b-0 border-edge-strong bg-surface p-4">
{rows.map((r) => <p key={r} className="border-b border-edge py-3 type-ui text-fg">{r}</p>)}
</div>
)
}
export default function Rows() {
return (
<ProductFeatures
id="creator-search"
features={[
{ headline: 'Search creators by name or by description', text: 'Use a name, a handle or a plain brief, like fitness creators in Texas. Filter by location, language, gender, age range and followers.', visual: <Panel rows={['Acme Fit, Austin', 'Acme Run, Dallas', 'Acme Yoga, Houston']} /> },
{ headline: 'See who already works with your competitors', text: 'Look up a brand to see the creators it has posted with, how often and since when. Start your shortlist there.', link: { label: 'See Creator collabs', href: '#' }, visual: <Panel rows={['Acme Studio, 12 posts', 'Acme Goods, 7 posts', 'Acme Air, 5 posts']} /> },
]}
/>
)
}<!-- Two feature rows with a plain Acme list on each stage, the second row flipped. -->
<spyglass-product-features prefix="creator-search" features='[{"headline":"Search creators by name or by description","text":"Use a name, a handle or a plain brief, like fitness creators in Texas. Filter by location, language, gender, age range and followers."},{"headline":"See who already works with your competitors","text":"Look up a brand to see the creators it has posted with, how often and since when. Start your shortlist there.","link":{"label":"See Creator collabs","href":"#"}}]'>
<div slot="visual-1" class="absolute inset-x-[14%] top-[18%] bottom-0 flex flex-col rounded-t-panel border border-b-0 border-edge-strong bg-surface p-4"><p class="border-b border-edge py-3 type-ui text-fg">Acme Fit, Austin</p><p class="border-b border-edge py-3 type-ui text-fg">Acme Run, Dallas</p><p class="border-b border-edge py-3 type-ui text-fg">Acme Yoga, Houston</p></div>
<div slot="visual-2" class="absolute inset-x-[14%] top-[18%] bottom-0 flex flex-col rounded-t-panel border border-b-0 border-edge-strong bg-surface p-4"><p class="border-b border-edge py-3 type-ui text-fg">Acme Studio, 12 posts</p><p class="border-b border-edge py-3 type-ui text-fg">Acme Goods, 7 posts</p><p class="border-b border-edge py-3 type-ui text-fg">Acme Air, 5 posts</p></div>
</spyglass-product-features>Source
import type { ReactNode } from 'react'
import { Button } from '@/react/components/ui/Button'
import { ASCII_TEXTURE } from '@/lib/textures'
import { cn } from '@/react/lib/cn'
// The site's product feature rows (pages/Products/ProductFeatures): one row per thing the product does, the copy (a
// Funnel Display 450 title, 24/28 on phones, 32/36 at 768 and 40/44 at 1280, a 20/28 lead 16px under it and a quiet
// button 32px under that) beside a 4:3 stage on the #262626 fill with the 8px corner, where the ASCII texture shows at
// half strength around a clear middle (screen blended, its tile placed differently in each row) and the feature's
// picture sits on top. From 1024 the copy takes 5 parts and the stage 7, 64px apart (96 at 1280), every other row
// flipped; below, the copy sits over the stage. Rows 80px apart (120 from 768). Nothing moves here; the pictures bring
// their own motion.
export interface ProductFeature {
headline: string
text: string
/** A quiet button under the text. */
link?: { label: string; href: string }
/** What sits on the stage (a product visual). */
visual?: ReactNode
}
export interface ProductFeaturesProps {
features: ProductFeature[]
/** Prefix for the heading ids. */
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)'
export const FEATURE_ASCII_AT = ['0 0', '40% 24%', '64% 56%', '20% 80%']
export function ProductFeatures({ features, id = 'product', className }: ProductFeaturesProps) {
return (
<div data-ds="product-features" className={cn('py-(--ds-layout-section) text-fg', className)}>
<style href="ds-product-features" precedence="ds">{css}</style>
<div className={cn(WRAP, 'grid gap-y-20 md:gap-y-30')}>
{features.map((f, i) => (
<section key={f.headline} aria-labelledby={`${id}-feature-${i + 1}`} className={cn('grid grid-cols-[minmax(0,1fr)] items-center gap-y-8 lg:gap-x-16 xl:gap-x-24', i % 2 ? 'lg:grid-cols-[minmax(0,7fr)_minmax(0,5fr)]' : 'lg:grid-cols-[minmax(0,5fr)_minmax(0,7fr)]')}>
<div className={cn('flex flex-col items-start', i % 2 ? 'lg:order-2' : '')}>
<h2 id={`${id}-feature-${i + 1}`} className="ds-pf-title">{f.headline}</h2>
<p className="mt-4 max-w-(--ds-layout-measure) type-body-lg text-pretty text-fg-soft">{f.text}</p>
{f.link && <Button href={f.link.href} variant="secondary" className="mt-8 max-md:w-full">{f.link.label}</Button>}
</div>
<div className="ds-pf-stage relative isolate aspect-4/3 min-w-0 overflow-clip rounded-panel bg-surface-raised">
<span aria-hidden="true" className="ds-pf-ascii" style={{ backgroundImage: `url("${ASCII_TEXTURE}")`, backgroundPosition: FEATURE_ASCII_AT[i % FEATURE_ASCII_AT.length] }} />
{f.visual}
</div>
</section>
))}
</div>
</div>
)
}
export default ProductFeatures
const css = `
.ds-pf-title { font-family: var(--ds-font-heading); font-weight: var(--ds-font-weight-heading); font-size: var(--ds-text-heading-3); line-height: var(--ds-text-heading-3-leading); letter-spacing: 0; text-wrap: balance; }
@media (min-width: 768px) { .ds-pf-title { font-size: var(--ds-text-heading-2); line-height: var(--ds-text-heading-2-leading); } }
@media (min-width: 1280px) { .ds-pf-title { font-size: var(--ds-text-figure); line-height: var(--ds-text-figure-leading); } }
.ds-pf-stage { container: stage / inline-size; }
.ds-pf-ascii { position: absolute; inset: 0; z-index: -1; pointer-events: none; background-size: var(--ds-feature-ascii-tile) var(--ds-feature-ascii-tile); opacity: var(--ds-feature-ascii-opacity); mix-blend-mode: screen; mask-image: radial-gradient(ellipse var(--ds-feature-ascii-clear-w) var(--ds-feature-ascii-clear-h) at 50% 50%, transparent 40%, var(--ds-color-black) 100%); }
`// 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 { ASCII_TEXTURE } from '@/lib/textures'
import styles from 'virtual:tw'
// ProductFeatures.tsx as <spyglass-product-features>: one row per thing the product does, the copy beside a 4:3 stage
// with the ASCII texture around a clear middle, every other row flipped from 1024. `features` as JSON: [{ headline,
// text, link?: { label, href } }]; each row's picture goes in the slot `visual-1`, `visual-2`...
export interface ProductFeature { headline: string; text: string; link?: { 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 ASCII_AT = ['0 0', '40% 24%', '64% 56%', '20% 80%']
/**
* @summary The product feature rows: copy beside a stage for each feature's picture, alternating.
* @slot visual-1 - The first row's picture (visual-2, visual-3... for the next rows).
*/
export class ProductFeatures extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="product-features"]'))
static properties = { features: { type: Array }, prefix: {} }
features: ProductFeature[] = []
/** Prefix for the heading ids (React's `id`). */
prefix = 'product'
render() {
return html`<div data-ds="product-features" class="py-(--ds-layout-section) text-fg"><div class=${`${WRAP} grid gap-y-20 md:gap-y-30`}>${(this.features ?? []).map((f, i) => html`<section aria-labelledby=${`${this.prefix}-feature-${i + 1}`} class=${`grid grid-cols-[minmax(0,1fr)] items-center gap-y-8 lg:gap-x-16 xl:gap-x-24 ${i % 2 ? 'lg:grid-cols-[minmax(0,7fr)_minmax(0,5fr)]' : 'lg:grid-cols-[minmax(0,5fr)_minmax(0,7fr)]'}`}><div class=${`flex flex-col items-start ${i % 2 ? 'lg:order-2' : ''}`}><h2 id=${`${this.prefix}-feature-${i + 1}`} class="ds-pf-title">${f.headline}</h2><p class="mt-4 max-w-(--ds-layout-measure) type-body-lg text-pretty text-fg-soft">${f.text}</p>${f.link ? html`<spyglass-button href=${f.link.href} variant="secondary" class="mt-8 max-md:w-full">${f.link.label}</spyglass-button>` : nothing}</div><div class="ds-pf-stage relative isolate aspect-4/3 min-w-0 overflow-clip rounded-panel bg-surface-raised"><span aria-hidden="true" class="ds-pf-ascii" style=${`background-image: url("${ASCII_TEXTURE}"); background-position: ${ASCII_AT[i % ASCII_AT.length]}`}></span><slot name=${`visual-${i + 1}`}></slot></div></section>`)}</div></div>`
}
}
define('product-features', ProductFeatures).ds-pf-title { font-family: var(--ds-font-heading); font-weight: var(--ds-font-weight-heading); font-size: var(--ds-text-heading-3); line-height: var(--ds-text-heading-3-leading); letter-spacing: 0; text-wrap: balance; }
@media (min-width: 768px) { .ds-pf-title { font-size: var(--ds-text-heading-2); line-height: var(--ds-text-heading-2-leading); } }
@media (min-width: 1280px) { .ds-pf-title { font-size: var(--ds-text-figure); line-height: var(--ds-text-figure-leading); } }
.ds-pf-stage { container: stage / inline-size; }
.ds-pf-ascii { position: absolute; inset: 0; z-index: -1; pointer-events: none; background-size: var(--ds-feature-ascii-tile) var(--ds-feature-ascii-tile); opacity: var(--ds-feature-ascii-opacity); mix-blend-mode: screen; mask-image: radial-gradient(ellipse var(--ds-feature-ascii-clear-w) var(--ds-feature-ascii-clear-h) at 50% 50%, transparent 40%, var(--ds-color-black) 100%); }Reference: Site pages/Products/ProductFeatures (ProductFeatures.module.css): rows 80px apart (120 from 768), .t-h2 titles (24/28, 32/36 at 768, 40/44 at 1280, weight 450), .t-lead 16px under, a quiet button 32px under; the stage 4:3, --radius-m, --surface, the ASCII texture at --features-ascii-tile and --features-ascii-opacity (screen) masked clear in a 46% by 50% ellipse; 5fr/7fr from 1024 with a 64px gap (96 at 1280), flipped rows 7fr/5fr.