Skip to content

Schedule

A program by day and time slot, with overlapping sessions as named parallel tracks.

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

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/schedule.css";
import { groupByDay, dayRange, dayKeys } from "capsomer/behavior/schedule";

Usage

<div class="cap-schedule-daybar">
  <nav class="cap-schedule-daynav" aria-label="Meeting days">
    <ul>
      <li><a class="cap-schedule-day-link" href="?day=2027-03-05" aria-current="page"><time datetime="2027-03-05">Friday, March 5</time></a></li>
      <li><a class="cap-schedule-day-link" href="?day=2027-03-06"><time datetime="2027-03-06">Saturday, March 6</time></a></li>
    </ul>
  </nav>
  <div class="cap-schedule-daybar-extra">[an "Add a day" field]</div>
</div>

<div class="cap-schedule">
  <p class="cap-schedule-zone">Times are in UTC.</p>
  <section class="cap-schedule-day" id="day-2027-03-05">
    <h2 class="cap-schedule-day-title"><time datetime="2027-03-05">Friday, March 5</time></h2>
    <ol class="cap-schedule-slots">
      <li class="cap-schedule-slot" data-parallel>
        <div class="cap-schedule-when">
          <h3 class="cap-schedule-time"><time datetime="2027-03-05T14:45:00.000Z">2:45 PM</time> to <time datetime="2027-03-05T16:00:00.000Z">4:00 PM</time></h3>
          <p class="cap-schedule-count">2 parallel tracks</p>
        </div>
        <div class="cap-schedule-body">
          <ul class="cap-schedule-tracks" role="list">
            <li class="cap-schedule-track">
              <p class="cap-schedule-track-name">Room A</p>
              <article class="cap-schedule-session">
                <h4 class="cap-schedule-session-title">Field notes</h4>
                <div class="cap-schedule-session-meta"><p>Chaired by Sam Lee</p></div>
                <ol class="cap-schedule-talks"><li>Notes from the spring survey</li></ol>
              </article>
            </li>
            <li class="cap-schedule-track">[Room B]</li>
          </ul>
        </div>
      </li>
      <li class="cap-schedule-slot">
        <div class="cap-schedule-when">
          <h3 class="cap-schedule-time"><time datetime="2027-03-05T16:30:00.000Z">4:30 PM</time> to <time datetime="2027-03-05T17:15:00.000Z">5:15 PM</time></h3>
        </div>
        <div class="cap-schedule-body">
          <div class="cap-schedule-track">[one session: its article, with no list around it]</div>
        </div>
      </li>
    </ol>
  </section>
</div>
const days = groupByDay(sessions, (s) => ({ start: s.startsAt, end: s.endsAt, day: s.sessionDate, track: s.location, order: s.sortOrder }), "America/Chicago");
const keys = dayKeys(days, dayRange(meeting.startsAt, meeting.endsAt, "America/Chicago"), url.searchParams.get("day"));
const day = pickDay(keys, url.searchParams.get("day"));
<ScheduleDayNav days={keys} current={day} hrefFor={(k) => `?day=${k}`} label="Meeting days" renderLink={renderLink}>
  [Add a day]
</ScheduleDayNav>
<Schedule days={days} zone="America/Chicago" keyOf={(s) => s.id} trackOf={(s) => s.location}
  renderItem={(s, level) => <ScheduleSession title={s.title} level={level} meta={<p>Chaired by {s.moderator}</p>}>[talks]</ScheduleSession>} />

Examples

One day at a time, from the day nav, with a field to add a day

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

In the meeting's own zone

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

A day with nothing on it yet

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

Phone width: the tracks stack, in order

<div class="schedule-narrow" data-mount="narrow"></div>

API reference

ScheduleDayNav

PropTypeRequiredDoes
daysreadonly string[]YesThe day keys to offer, from dayKeys().
currentstring | nullYesThe day shown now: aria-current="page".
hrefFor(key: string) => stringYesThe address of a day: "?day=2027-03-06", or "#day-2027-03-06" on a page that shows every day.
labelstring
noDatestringThe word for NO_DATE.
yearbooleanSay each day's year: "Saturday, March 6, 2027", for a meeting that is not this year's.
childrenReactNodeControls beside the days (an "Add a day" date field).
renderLink(props: ScheduleLinkProps) => ReactNode

Schedule

PropTypeRequiredDoes
daysreadonly ScheduleDay<T>[]YesFrom groupByDay(): one day (a builder's selected day) or all of them (a public program).
zonestringThe IANA zone the times are in, the meeting's own ("America/Chicago"). Default UTC.
renderItem(item: T, level: Level | 5) => ReactNodeYesDraws one item: its title, people, room and items. level is the heading level for its title, one under the slot's.
keyOf(item: T) => stringYes
trackOf(item: T) => string | null | undefinedThe track's name shown above a parallel item: its room or track ("Room 2.104"). Unnamed tracks are called "Track 1", "Track 2".
level2 | 3The level of each day's heading; the slot's is one under. Default 2.
dayHeadingsbooleanShow each day's heading (off for a builder that names the day above already).
zoneNotebooleanSay once which zone the times are in. Default on.
idPrefixstringThe day key's id prefix, for a day nav's in-page links: "day-" gives id="day-2027-03-06".
noDatestring
yearbooleanSay each day's year in its heading: "Saturday, March 6, 2027".
emptyReactNodeWhat a day with nothing on it says.
slotFooter(slot: ScheduleSlot<T>) => ReactNodeSomething after a slot's tracks (a builder's "Add to this slot" form).

ScheduleSession

PropTypeRequiredDoes
titleReactNodeYes
levelLevel | 5YesThe heading level renderItem was given.
metaReactNodeQuiet lines under the title: the room, who moderates.
childrenReactNodeWhat the session holds: its talks, as a list.

Functions

FunctionSignatureDoes
groupByDay<T>(items: readonly T[], timesOf: (item: T) => ScheduleTimes, zone?: string): ScheduleDay<T>[]Group items by day, then each day into slots. Items whose [start, end) overlap run in parallel and share a slot; an item with no time stands alone, after the timed ones. Within a day items go by start, then the app's order; parallel tracks go by track name, then order.
dayRange(from: string | number | Date | null | undefined, to: string | number | Date | null | undefined, zone?: string): string[]Every day from one moment to another, both included, in the zone: a meeting's date range, so a day with nothing on it yet still gets a tab.
dayKeys(days: readonly { key: string; }[], range?: readonly string[], extra?: string | null | undefined): string[]The days a day nav offers: the days that hold items, the days of the range, and one more (a day a person just added), in order, with NO_DATE last when any item has no date.
pickDay(keys: readonly string[], wanted?: string | null | undefined): string | nullThe day to show: the one asked for when the nav offers it, else the first, else none.
dayLabel(key: string, { year, noDate }?: { year?: boolean | undefined; noDate?: string | undefined; }): string"Saturday, March 6", with the year when asked: "Saturday, March 6, 2027". A day key is a calendar date, so it is read in UTC and never moves by the viewer's zone.
slotParts(start: number | null, end: number | null, zone?: string, none?: string): SlotPart[]
slotLabel(start: number | null, end: number | null, zone?: string, none?: string): string
zoneLine(at: number | null, zone?: string): stringThe line that says once which zone the times are in: "Times are in CDT." The zone's name at the first item's moment, so a meeting across a clock change still names the right one.
tracksLabel(n: number): string"3 parallel tracks".

Parts and data attributes

ClassIs
.cap-schedulethe root
.cap-schedule-bodya part
.cap-schedule-counta part
.cap-schedule-daya part
.cap-schedule-day-linka part
.cap-schedule-day-titlea part
.cap-schedule-daybara part
.cap-schedule-daybar-extraa part
.cap-schedule-daynava part
.cap-schedule-emptya part
.cap-schedule-sessiona part
.cap-schedule-session-metaa part
.cap-schedule-session-titlea part
.cap-schedule-slota part
.cap-schedule-slotsa part
.cap-schedule-talksa part
.cap-schedule-timea part
.cap-schedule-tracka part
.cap-schedule-track-namea part
.cap-schedule-tracksa part
.cap-schedule-whena part
.cap-schedule-zonea part
StateRead from
:hoverthe platform
:visitedthe platform
[aria-current="page"]an attribute

Accessibility

KeyDoes
Tab, Shift+TabMoves through the day links, then whatever the sessions hold
EnterFollows the focused day link
  • The day nav is a nav named by label ("Meeting days"); give a second nav on the page its own name.
  • Headings: the day at level (2 by default), each slot one under, each session's title one under that (renderItem is given the level).
  • Contrast: day links in --accent-text (4.5:1), the current day's text in --text on --sel, track names, counts and facts in --muted (4.5:1), a session's edge --line.
  • Forced colors: the current day has a 2px Highlight edge, since its tint and bar are gone.
  • Printing hides the day nav and keeps a slot on one page.