Skip to content

Author list

A byline of names with the site owner's marked, folded when long, and names that can link.

<div data-mount="short"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/author-list.css";
import { foldAuthors } from "capsomer/behavior/author-list";

Usage

<p class="cap-author-list">
  <span>Sam Lee</span><span>, <strong class="cap-author-list-owner">Alex Rivera</strong></span><span>, Jordan Park</span>
</p>

<details class="cap-author-list">
  <summary class="cap-author-list-summary">
    <span>Sam Lee</span><span>, Jordan Park</span><span class="cap-author-list-more">, ... </span><strong class="cap-author-list-owner">Alex Rivera</strong><span class="cap-author-list-more"> and 5 more</span>
  </summary>
  <p class="cap-author-list-full">Every name, as in the first form.</p>
</details>

Examples

Names that link

<div data-mount="linked"></div>

Folded, the owner among the first three

<div data-mount="folded"></div>

Folded, the owner further down

<div data-mount="owner-late"></div>

Folded and opened

<div data-mount="open"></div>

API reference

AuthorList

PropTypeRequiredDoes
authorsreadonly Author[]YesThe names in byline order: strings, or { name, href } for a name that links.
isOwner(name: string) => booleanMarks the site owner's own name (by the name as given). Without it no name is marked.
collapsenumberFold a list longer than this many names into a disclosure ("A, B, C and 9 more"). Leave it out to show every name.
format(name: string) => ReactNodeHow a name is shown, for a site that decodes entities or italicizes; the owner check still reads the name as given.

Functions

FunctionSignatureDoes
foldAuthors<A extends Author>(authors: readonly A[], isOwner?: (name: string) => boolean, keep?: number): Fold<A>Folds a long list to its first keep names and "and N more". Author order varies, so when the owner falls outside the first keep, the fold shows one name fewer, then the owner after an ellipsis: the owner is always in view. keep under 1 is taken as 1; a list no longer than keep is not folded.
nameOf(a: Author): string

Parts and data attributes

ClassIs
.cap-author-listthe root
.cap-author-list-fulla part
.cap-author-list-ownera part
.cap-author-list-summarya part

Accessibility

KeyDoes
TabMoves to the folded list's summary, then to each linked name in the opened list
Enter or SpaceOn the summary, opens or closes the full list (native details)
  • The list reads as one sentence: "Sam Lee, Jordan Park, ..., Alex Rivera and 5 more".
  • The names are --muted at 4.5:1; the owner's is --text, semibold.
  • The summary is at least --target tall and has the focus ring.