Site

Page close

The site's closing section: a centered last head over its lines, a note in the soft gray, the connect menu with a quiet button (or a White and a quiet button), and from 1024 two ASCII drifts fading in at the corners.

Install

React apps get the React files; every other stack gets the web component.

npx spyglass-ds add page-close
<script type="module" src="/spyglass-ds/elements/page-close.js"></script>
With the connect menu

Give your agents the social internet

500 free credits every month. No card required.

Two buttons

Start building with Acme today

Free to try. No card required.

Usage

The last section before the footer on any site page; control={null} (connect="false" in web components) for two plain buttons; texture={false} on a page that already has drifts nearby.

Never

  • Two White buttons: beside the connect menu the button is quiet
  • A display-size head: it is the section head
  • Moving drifts

Adds with it: ascii-drift, button, connect-menu, page-head

Props

The web component takes the same as attributes or properties (<spyglass-page-close>); title is heading there.

<PageClose>

PropTypeDefault
idstring

The section's id; names its heading (`<id>-heading`).

'close'
linesstring[]['Give your agents', 'the social internet']
notestring'500 free credits every month. No card required.'
primaryPageAction

The White button (quiet beside a control).

{ label: 'Get a free API key', href: '#' }
secondaryPageAction

The quiet button when there is no control.

{ label: 'Talk to us', href: '#' }
controlReactNode

The main control (the connect menu by default); null for two buttons.

<ConnectMenu />
textureboolean

The two ASCII drifts from 1024.

true
classNamestring

Examples

The same example in React and as web components; both render identically.

react/examples/page-close/Default.tsx
import { PageClose } from '@/react/components/site/PageClose'
// The closing section as the site sets it: the connect menu beside a quiet button, the drifts at the corners.

export default function Default() {
  return <PageClose />
}
elements/examples/page-close/Default.html
<!-- The closing section as the site sets it: the connect menu beside a quiet button, the drifts at the corners. -->
<spyglass-page-close></spyglass-page-close>
react/examples/page-close/Buttons.tsx
import { PageClose } from '@/react/components/site/PageClose'
// A White and a quiet button, without the texture.

export default function Buttons() {
  return <PageClose id="start" lines={['Start building', 'with Acme today']} note="Free to try. No card required." control={null} texture={false} />
}
elements/examples/page-close/Buttons.html
<!-- A White and a quiet button, without the texture. -->
<spyglass-page-close close-id="start" lines='["Start building","with Acme today"]' note="Free to try. No card required." connect="false" texture="false"></spyglass-page-close>

Source

react/components/site/PageClose.tsx
import type { ReactNode } from 'react'
import { ConnectMenu } from '@/react/components/site/ConnectMenu'
import type { PageAction } from '@/react/components/site/PageHead'
import { Button } from '@/react/components/ui/Button'
import { asciiDriftStyleObject } from '@/lib/ascii-drift'
import { cn } from '@/react/lib/cn'

// The site's closing section (pages/PageClose): a centered section head (each of `lines` on its own line), a note in
// the soft gray and the actions 16px under it: the connect menu with a quiet button by default, or, with `control`
// set to null, a White and a quiet button. On phones the actions stack at full width, and beside a control the control
// steps aside and the quiet button turns White (the site's MCP pair). From 1024 two crops of the
// ASCII texture fade in, the mass from the lower left and the scatter from the upper right. Nothing moves.
export interface PageCloseProps {
  /** The section's id; names its heading (`<id>-heading`). */
  id?: string
  lines?: string[]
  note?: string
  /** The White button (quiet beside a control). */
  primary?: PageAction
  /** The quiet button when there is no control. */
  secondary?: PageAction
  /** The main control (the connect menu by default); null for two buttons. */
  control?: ReactNode
  /** The two ASCII drifts from 1024. */
  texture?: boolean
  className?: string
}

export function PageClose({
  id = 'close',
  lines = ['Give your agents', 'the social internet'],
  note = '500 free credits every month. No card required.',
  primary = { label: 'Get a free API key', href: '#' },
  secondary = { label: 'Talk to us', href: '#' },
  control = <ConnectMenu />,
  texture = true,
  className,
}: PageCloseProps) {
  return (
    <section data-ds="page-close" id={id} aria-labelledby={`${id}-heading`} className={cn('relative isolate overflow-x-clip py-(--ds-layout-section) text-fg', className)}>
      {texture ? (
        <>
          <span aria-hidden="true" className="pointer-events-none absolute bottom-(--ds-layout-section) left-0 -z-1 hidden h-[64%] w-[min(calc(50%-var(--ds-page-head-drift-clear)),var(--ds-page-close-drift-w))] select-none lg:block" style={asciiDriftStyleObject('mass', 'left')} />
          <span aria-hidden="true" className="pointer-events-none absolute top-(--ds-layout-section) right-0 -z-1 hidden h-[48%] w-[min(20%,var(--ds-page-close-drift-high-w))] select-none lg:block" style={asciiDriftStyleObject('scatter', 'right')} />
        </>
      ) : null}
      <div className="mx-auto flex w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] flex-col items-center gap-6 px-(--ds-layout-gutter) text-center">
        <h2 id={`${id}-heading`} className="type-section [text-box:trim-start_cap_alphabetic]">
          {lines.map((line, i) => <span key={`${i}-${line}`} className="block">{line}{i < lines.length - 1 ? ' ' : null}</span>)}
        </h2>
        {note ? <p className="type-body text-fg-soft">{note}</p> : null}
        <div className="mt-4 flex flex-wrap justify-center gap-3 max-md:flex-col max-md:self-stretch">
          {control ? (
            <>
              <div className="contents max-md:hidden">{control}</div>
              <div className="contents max-md:hidden"><Button href={primary.href} variant="secondary">{primary.label}</Button></div>
              <div className="contents md:hidden"><Button href={primary.href}>{primary.label}</Button></div>
            </>
          ) : (
            <>
              <Button href={primary.href}>{primary.label}</Button>
              <Button href={secondary.href} variant="secondary">{secondary.label}</Button>
            </>
          )}
        </div>
      </div>
    </section>
  )
}

export default PageClose
react/lib/cn.ts
// 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(' ')
}
elements/components/site/page-close.ts
import { html, nothing } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { asciiDriftStyle } from '@/lib/ascii-drift'
import '@/elements/components/site/connect-menu'
import '@/elements/components/ui/button'
import styles from 'virtual:tw'

// PageClose.tsx as <spyglass-page-close>: the centered closing section, its lines, the note and the actions (the
// connect menu with a quiet button by default, your own control in the `control` slot, or with connect="false" a White
// and a quiet button), and from 1024 two ASCII drifts at the corners. Nothing moves.
export interface PageAction { label: string; href: string }

/**
 * @summary The closing section: a last head, a note and the main actions.
 * @slot control - The main control in place of the connect menu.
 */
export class PageClose extends DsElement {
	static styles = [DsElement.styles, styles]
	protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="page-close"]'))
	static properties = {
		closeId: { attribute: 'close-id' },
		lines: { type: Array },
		note: {},
		primary: { type: Object },
		secondary: { type: Object },
		connect: { type: Boolean, converter: { fromAttribute: (v: string | null) => v !== 'false' } },
		texture: { type: Boolean, converter: { fromAttribute: (v: string | null) => v !== 'false' } },
	}
	/** The section's id (React's `id`); names its heading. */
	closeId = 'close'
	lines: string[] = ['Give your agents', 'the social internet']
	note = '500 free credits every month. No card required.'
	/** The White button ({ label, href }); quiet beside a control. */
	primary: PageAction = { label: 'Get a free API key', href: '#' }
	/** The quiet button when there is no control. */
	secondary: PageAction = { label: 'Talk to us', href: '#' }
	/** The connect menu as the main control when the control slot is empty (React's default `control`). */
	connect = true
	/** The two ASCII drifts from 1024. */
	texture = true

	render() {
		const lines = this.lines ?? []
		const slotted = this.hasSlot('control')
		const control = slotted ? html`<slot name="control"></slot>` : this.connect ? html`<spyglass-connect-menu></spyglass-connect-menu>` : null
		return html`<section data-ds="page-close" id=${this.closeId} aria-labelledby=${`${this.closeId}-heading`} class="relative isolate overflow-x-clip py-(--ds-layout-section) text-fg">${this.texture ? html`<span aria-hidden="true" class="pointer-events-none absolute bottom-(--ds-layout-section) left-0 -z-1 hidden h-[64%] w-[min(calc(50%-var(--ds-page-head-drift-clear)),var(--ds-page-close-drift-w))] select-none lg:block" style=${asciiDriftStyle('mass', 'left')}></span><span aria-hidden="true" class="pointer-events-none absolute top-(--ds-layout-section) right-0 -z-1 hidden h-[48%] w-[min(20%,var(--ds-page-close-drift-high-w))] select-none lg:block" style=${asciiDriftStyle('scatter', 'right')}></span>` : nothing}<div class="mx-auto flex w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] flex-col items-center gap-6 px-(--ds-layout-gutter) text-center"><h2 id=${`${this.closeId}-heading`} class="type-section [text-box:trim-start_cap_alphabetic]">${lines.map((line, i) => html`<span class="block">${line}${i < lines.length - 1 ? ' ' : nothing}</span>`)}</h2>${this.note ? html`<p class="type-body text-fg-soft">${this.note}</p>` : nothing}<div class="mt-4 flex flex-wrap justify-center gap-3 max-md:flex-col max-md:self-stretch">${control ? html`<div class="contents max-md:hidden">${control}</div><div class="contents max-md:hidden"><spyglass-button href=${this.primary.href} variant="secondary">${this.primary.label}</spyglass-button></div><div class="contents md:hidden"><spyglass-button href=${this.primary.href}>${this.primary.label}</spyglass-button></div>` : html`<spyglass-button href=${this.primary.href}>${this.primary.label}</spyglass-button><spyglass-button href=${this.secondary.href} variant="secondary">${this.secondary.label}</spyglass-button>`}</div></div></section>`
	}
}

define('page-close', PageClose)

Reference: Site pages/PageClose (PageClose.tsx, PageClose.module.css, content/home closing): .section padding, 24px between the head, the note and the actions, the actions 16px further and 12px apart, stacked at full width under 768; drifts from 1024: the mass crop from the left, bottom at the section padding, min(50% - 320px, 480px) by 64%; the scatter crop from the right, top at the section padding, min(20%, 320px) by 48%.