Blocks
Steps block
How it works in numbered steps under hairlines: the number as a label, a title and a line, side by side from 768.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add steps-block<script type="module" src="/spyglass-ds/elements/steps-block.js"></script>Set up in under a minute
- 01
Connect
Add the brands and creators you track.
- 02
Ask
Search in words, the way you would ask a teammate.
- 03
Share
Save what you find to a board and send the link.
Usage
A setup or how-it-works section of two to four steps.
Never
- More than four steps in a row
- Icons that move
Props
The web component takes the same as attributes or properties (<spyglass-steps-block>); title is heading there.
<StepsBlock>
| Prop | Type | Default |
|---|---|---|
steps | Step[] | |
title | ReactNode | |
body | ReactNode | |
className | string |
Examples
The same example in React and as web components; both render identically.
import { StepsBlock } from '@/react/components/blocks/StepsBlock'
// Acme's setup in three steps.
const steps = [
{
"title": "Connect",
"body": "Add the brands and creators you track."
},
{
"title": "Ask",
"body": "Search in words, the way you would ask a teammate."
},
{
"title": "Share",
"body": "Save what you find to a board and send the link."
}
]
export default function Setup() {
return <StepsBlock title="Set up in under a minute" steps={steps} />
}<!-- Acme's setup in three steps. -->
<spyglass-steps-block heading="Set up in under a minute" steps='[{"title":"Connect","body":"Add the brands and creators you track."},{"title":"Ask","body":"Search in words, the way you would ask a teammate."},{"title":"Share","body":"Save what you find to a board and send the link."}]'></spyglass-steps-block>Source
import type { ReactNode } from 'react'
import { cn } from '@/react/lib/cn'
// How it works in steps, as the site's "Set up in under a minute": each step under a #363636 hairline, its number as
// a label in capitals, a Funnel Display 24/28 title and a #D4D4D4 line; side by side from 768 (up to four), stacked on
// phones. Nothing moves.
export interface Step {
title: string
body?: string
}
export interface StepsBlockProps {
steps: Step[]
title?: ReactNode
body?: ReactNode
className?: string
}
export function StepsBlock({ steps, title, body, className }: StepsBlockProps) {
return (
<section data-ds="steps-block" className={cn('grid gap-10 text-fg', className)}>
{(title || body) && (
<div className="grid max-w-3xl gap-6">
{title && <h2 className="type-section">{title}</h2>}
{body && <p className="max-w-measure type-body-lg text-fg-soft">{body}</p>}
</div>
)}
<ol className="m-0 grid list-none grid-cols-1 gap-8 p-0 md:auto-cols-fr md:grid-flow-col md:gap-6">
{steps.map((s, n) => (
<li key={s.title} className="grid content-start gap-3 border-t border-edge pt-6">
<span className="type-label text-fg-muted">{String(n + 1).padStart(2, '0')}</span>
<h3 className="type-heading-3">{s.title}</h3>
{s.body && <p className="type-body text-fg-soft">{s.body}</p>}
</li>
))}
</ol>
</section>
)
}
export default StepsBlock// 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 styles from 'virtual:tw'
// StepsBlock.tsx as <spyglass-steps-block>: numbered `steps` ({ title, body }) under hairlines, with an optional
// `heading` (React's `title`) and `body`.
export interface Step { title: string; body?: string }
/**
* @summary How it works, in numbered steps.
*/
export class StepsBlock extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="steps-block"]'))
static properties = { steps: { type: Array }, heading: {}, body: {} }
steps: Step[] = []
/** The heading (React's `title`). */
heading?: string
body?: string
render() {
return html`<section data-ds="steps-block" class="grid gap-10 text-fg">${this.heading || this.body ? html`<div class="grid max-w-3xl gap-6">${this.heading ? html`<h2 class="type-section">${this.heading}</h2>` : nothing}${this.body ? html`<p class="max-w-measure type-body-lg text-fg-soft">${this.body}</p>` : nothing}</div>` : nothing}<ol class="m-0 grid list-none grid-cols-1 gap-8 p-0 md:auto-cols-fr md:grid-flow-col md:gap-6">${(this.steps ?? []).map((s, n) => html`<li class="grid content-start gap-3 border-t border-edge pt-6"><span class="type-label text-fg-muted">${String(n + 1).padStart(2, '0')}</span><h3 class="type-heading-3">${s.title}</h3>${s.body ? html`<p class="type-body text-fg-soft">${s.body}</p>` : nothing}</li>`)}</ol></section>`
}
}
define('steps-block', StepsBlock)Reference: Built from the site's How it works (HowItWorks: hairline rows, labels in capitals, h5 titles).