Site
Footer row
The row every post, ad and deck ends on: the lockup on the left, the domain on the right. Links between them make it a website footer.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add footer-row<script type="module" src="/spyglass-ds/elements/footer-row.js"></script>Usage
The foot of a page, a post, an ad or a slide. The domain in DM Sans, or in capitals as the posts set it.
Never
- The lockup on the right or centered with the domain
- A colored or redrawn lockup
- Social icons in place of the domain
Adds with it: logo
Props
The web component takes the same as attributes or properties (<spyglass-footer-row>); title is heading there.
<FooterRow>
| Prop | Type | Default |
|---|---|---|
domain | string The domain on the right. | |
domainHref | string Where the domain links (https://<domain> by default). | |
homeHref | string Where the lockup links; without it the lockup is not a link. | |
caps | boolean The domain in capitals with 6% tracking, as the posts set it. | false |
links | FooterLink[] Links between the lockup and the domain. | [] |
label | string The lockup's accessible name. | 'Spyglass' |
className | string |
Examples
The same example in React and as web components; both render identically.
import { FooterRow } from '@/react/components/site/FooterRow'
// As the ads end: the lockup and the domain, and the posts' capitals.
export default function Asset() {
return (
<div className="grid gap-10">
<FooterRow domain="spyglass.so" />
<FooterRow domain="spyglass.so" caps />
</div>
)
}<!-- As the ads end: the lockup and the domain, and the posts' capitals. -->
<div class="grid gap-10">
<spyglass-footer-row domain="spyglass.so"></spyglass-footer-row>
<spyglass-footer-row domain="spyglass.so" caps></spyglass-footer-row>
</div>import { FooterRow } from '@/react/components/site/FooterRow'
// A website footer: the pages between the lockup and the domain.
const links = [
{ label: 'Product', href: '#product' },
{ label: 'Pricing', href: '#pricing' },
{ label: 'Changelog', href: '#changelog' },
{ label: 'Blog', href: '#blog' },
{ label: 'Terms', href: '#terms' },
]
export default function Site() {
return <FooterRow domain="spyglass.so" homeHref="#home" links={links} />
}<!-- A website footer: the pages between the lockup and the domain. -->
<spyglass-footer-row domain="spyglass.so" home-href="#home" links='[{"label":"Product","href":"#product"},{"label":"Pricing","href":"#pricing"},{"label":"Changelog","href":"#changelog"},{"label":"Blog","href":"#blog"},{"label":"Terms","href":"#terms"}]'></spyglass-footer-row>Source
import { Logo } from '@/react/components/visuals/Logo'
import { cn } from '@/react/lib/cn'
// The row every post, ad and deck ends on: the lockup on the left and the domain on the right (the lockup 183x28 on
// the canvas, 20px tall here; the domain in DM Sans, or in capitals with `caps` as the posts set it). `links` puts a
// row of DM Sans links between them for a website footer; on phones they wrap onto their own line. Links change color
// on hover, nothing moves.
export interface FooterLink {
label: string
href: string
}
export interface FooterRowProps {
/** The domain on the right. */
domain: string
/** Where the domain links (https://<domain> by default). */
domainHref?: string
/** Where the lockup links; without it the lockup is not a link. */
homeHref?: string
/** The domain in capitals with 6% tracking, as the posts set it. */
caps?: boolean
/** Links between the lockup and the domain. */
links?: FooterLink[]
/** The lockup's accessible name. */
label?: string
className?: string
}
const LINK = 'rounded-control text-fg-muted transition-[color] duration-160 ease-standard hover:text-fg'
export function FooterRow({ domain, domainHref, homeHref, caps = false, links = [], label = 'Spyglass', className }: FooterRowProps) {
return (
<div data-ds="footer-row" className={cn('flex flex-wrap items-center justify-between gap-x-8 gap-y-6 text-fg', className)}>
{homeHref ? (
<a href={homeHref} aria-label={label} className="rounded-control"><Logo height={20} label={label} /></a>
) : (
<Logo height={20} label={label} />
)}
{links.length > 0 && (
<nav aria-label="Footer" className="max-sm:order-last max-sm:w-full">
<ul className="flex flex-wrap gap-x-6 gap-y-2 type-ui">
{links.map((l) => <li key={l.href}><a href={l.href} className={LINK}>{l.label}</a></li>)}
</ul>
</nav>
)}
<a href={domainHref ?? `https://${domain}`} className={cn('rounded-control text-fg', caps ? 'type-label' : 'type-ui')}>{domain}</a>
</div>
)
}
export default FooterRow// 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/visuals/logo'
import styles from 'virtual:tw'
// FooterRow.tsx as <spyglass-footer-row>: the lockup on the left, the domain on the right (`caps` for capitals), and
// `links` (a list of { label, href }) between them for a website footer.
export interface FooterLink { label: string; href: string }
const LINK = 'rounded-control text-fg-muted transition-[color] duration-160 ease-standard hover:text-fg'
/**
* @summary The footer row: lockup left, domain right, links between.
*/
export class FooterRow extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="footer-row"]'))
static properties = { domain: {}, domainHref: { attribute: 'domain-href' }, homeHref: { attribute: 'home-href' }, caps: { type: Boolean }, links: { type: Array }, label: { attribute: 'logo-label' } }
/** The domain on the right. */
domain = ''
/** Where the domain links (https://<domain> by default). */
domainHref?: string
/** Where the lockup links. */
homeHref?: string
/** The domain in capitals. */
caps = false
/** Links between the lockup and the domain. */
links: FooterLink[] = []
/** The lockup's accessible name. */
label = 'Spyglass'
render() {
const links = this.links ?? []
const logo = html`<spyglass-logo height="20" aria-label=${this.label}></spyglass-logo>`
return html`<div data-ds="footer-row" class="flex flex-wrap items-center justify-between gap-x-8 gap-y-6 text-fg">${this.homeHref ? html`<a href=${this.homeHref} aria-label=${this.label} class="rounded-control">${logo}</a>` : logo}${links.length ? html`<nav aria-label="Footer" class="max-sm:order-last max-sm:w-full"><ul class="flex flex-wrap gap-x-6 gap-y-2 type-ui">${links.map((l) => html`<li><a href=${l.href} class=${LINK}>${l.label}</a></li>`)}</ul></nav>` : nothing}<a href=${this.domainHref ?? `https://${this.domain}`} class=${['rounded-control text-fg', this.caps ? 'type-label' : 'type-ui'].join(' ')}>${this.domain}</a></div>`
}
}
define('footer-row', FooterRow)Reference: Figma page 8: every post and ad's Spyglass lockup (183x28 at 64 or 72 from the edge) and spyglass.so text on one line; posts set the domain in capitals.