Skip to content

Series nav

Where a post sits in its series, as a ruled box with its part number and every part listed.

<nav class="cap-series" aria-labelledby="series-middle" id="sample-middle">
  <h2 class="cap-series-title" id="series-middle">Part 2 of 3: <a href="#series">Field notes</a></h2>
  <ol class="cap-series-parts">
    <li><a href="#part-1">Field notes, part 1: choosing the sites</a></li>
    <li aria-current="page"><span>Field notes, part 2: walking the transects</span></li>
    <li><a href="#part-3">Field notes, part 3: what the samples showed</a></li>
  </ol>
  <nav class="cap-signs cap-series-steps" aria-label="Parts of Field notes"><a class="cap-sign" rel="prev" href="#part-1"><span class="cap-sr-only">Previous part: </span>Field notes, part 1: choosing the sites</a><a class="cap-sign" rel="next" href="#part-3"><span class="cap-sr-only">Next part: </span>Field notes, part 3: what the samples showed</a></nav>
</nav>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/series-nav.css";
import { seriesPlace, seriesPlace, seriesPlace } from "capsomer/behavior/series-nav";

Usage

<nav class="cap-series" aria-labelledby="series">
  <h2 class="cap-series-title" id="series">Part 2 of 3: <a href="/writing/series/field-notes">Field notes</a></h2>
  <ol class="cap-series-parts">
    <li><a href="/writing/field-notes-1">Field notes, part 1</a></li>
    <li aria-current="page"><span>Field notes, part 2</span></li>
    <li><a href="/writing/field-notes-3">Field notes, part 3</a></li>
  </ol>
  <nav class="cap-signs cap-series-steps" aria-label="Parts of Field notes">
    <a class="cap-sign" rel="prev" href="/writing/field-notes-1"><span class="cap-sr-only">Previous part: </span>Field notes, part 1</a>
    <a class="cap-sign" rel="next" href="/writing/field-notes-3"><span class="cap-sr-only">Next part: </span>Field notes, part 3</a>
  </nav>
</nav>
import { SeriesNav } from "capsomer/react/series-nav";

<SeriesNav name="Field notes" href="/writing/series/field-notes" parts={parts} current="/writing/field-notes-2" />

Examples

The first part

<nav class="cap-series" aria-labelledby="series-first" id="sample-first">
  <h2 class="cap-series-title" id="series-first">Part 1 of 2: <a href="#series">Release notes</a></h2>
  <ol class="cap-series-parts">
    <li aria-current="page"><span>Release notes, part 1: the spring update</span></li>
    <li><a href="#part-2">Release notes, part 2: the annual report</a></li>
  </ol>
  <nav class="cap-signs cap-series-steps" aria-label="Parts of Release notes"><a class="cap-sign" rel="next" href="#part-2"><span class="cap-sr-only">Next part: </span>Release notes, part 2: the annual report</a></nav>
</nav>

The last part

<nav class="cap-series" aria-labelledby="series-last" id="sample-last">
  <h2 class="cap-series-title" id="series-last">Part 2 of 2: <a href="#series">Release notes</a></h2>
  <ol class="cap-series-parts">
    <li><a href="#part-1">Release notes, part 1: the spring update</a></li>
    <li aria-current="page"><span>Release notes, part 2: the annual report</span></li>
  </ol>
  <nav class="cap-signs cap-series-steps" aria-label="Parts of Release notes"><a class="cap-sign" rel="prev" href="#part-1"><span class="cap-sr-only">Previous part: </span>Release notes, part 1: the spring update</a></nav>
</nav>

API reference

SeriesNav

PropTypeRequiredDoes
namestringYesThe series' name, and its own page (every part, in order).
hrefstringYes
partsreadonly SeriesPart[]YesEvery part, in reading order.
currentstringYesThe href of the part this page is.

Functions

FunctionSignatureDoes
seriesPlace(parts: readonly SeriesPart[], current: string): SeriesPlace<SeriesPart>Where current sits among parts, in their order: a part's href, or the key keyOf reads (a document's slug). A key not in the list has no neighbors, never someone else's.

Parts and data attributes

ClassIs
.cap-seriesthe root
.cap-series-partsa part
.cap-series-stepsa part
.cap-series-titlea part
StateRead from
[aria-current]an attribute

Accessibility

KeyDoes
TabMoves through the series link, the other parts and the signs, in reading order. The current part is text and takes no focus.
  • A nav named by its heading ("Part 2 of 3: Field notes"); the signs are a nav of their own named "Parts of" the series.
  • The current part carries aria-current="page".
  • Screen readers: no manual run, by decision; the axe scan and a front-end review stand in.