Canvas Design System
Main Site Tokens

Run Clock

The time left on the running block, readable across a room. It counts down, then counts up past the plan with a plus sign.

When to Use

Use when: A block is running and the facilitator needs the time left at a glance: the cockpit, the run screen, Sidekick. Give it endsAt and the clock keeps itself right from that timestamp.
Don't use when: The duration does not move. A planned length is the duration in an Agenda or a Badge; a proportion of a whole is a Progress bar; a headline number is a Stat.

Variants

Sizes

md is the run bar's size, lg (the default) the side panel's, xl the wide cockpit's.

07:20 left of 20 min
07:20 left of 20 min
07:20 left of 20 min
<?= ws_run_clock(['seconds' => 440, 'planned' => 20, 'size' => 'md']) ?>
<?= ws_run_clock(['seconds' => 440, 'planned' => 20]) ?>
<?= ws_run_clock(['seconds' => 440, 'planned' => 20, 'size' => 'xl']) ?>

The four states

Pass seconds and the state follows: the last two minutes are ending, anything below zero is over. Only paused is ever passed by hand.

07:20 left of 20 min
01:30 left of 20 min
+5:10 over its 20 min
07:20 Paused
<?= ws_run_clock(['seconds' => 440, 'planned' => 20]) ?>   // running
<?= ws_run_clock(['seconds' => 90, 'planned' => 20]) ?>    // ending
<?= ws_run_clock(['seconds' => -310, 'planned' => 20]) ?>  // over
<?= ws_run_clock(['seconds' => 440, 'planned' => 20, 'state' => 'paused']) ?>

States

StateBehavior
RunningCounts down in --text-dark, labelled "left of 20 min".
EndingThe last two minutes, in --color-warning-ink. The live region says "Two minutes left" once.
OverCounts up with a plus sign in --brand-ink, labelled "over its 20 min". The live region says so, then once for each further minute.
PausedThe value in --text-muted, labelled "Paused". Remove data-ends-at and the script stops moving it.

Real-World Usage

The cockpit's Now card. The server sends when the block is due to end; /js/ws-run-clock.js does the rest. This one is live.

Exercise

Sailboat Retrospective

07:20 left of 20 min
<?= ws_run_clock(['seconds' => $left, 'planned' => 20, 'endsAt' => $endsAtMs]) ?>
<script src="/js/ws-run-clock.js?v=2"></script>

Options

OptionTypeDefaultPurpose
secondsintnullSeconds left on the block; negative means over. Builds the value, the label, the state and the accessible name.
valuestring''The text shown when seconds is not given
plannedintnullThe block's planned minutes, for the label
labelstringderivedReplaces the derived label; the script then leaves it alone
statestringderivedrunning, ending, over or paused
sizestring'lg'md, lg or xl
endsAtintnullEpoch milliseconds the block is due to end. With it the script keeps the clock moving.
idstring''Element ID
classstring''Additional CSS classes
attrsarray[]Extra HTML attributes

Accessibility

ConcernBehavior
Semanticsrole="timer", which is aria-live="off", so a second ticking by is never read out.
NameThe accessible name says the time in words ("7 minutes 20 seconds left of 20 minutes") and follows the clock to the second, so 07:20 is never spelled out. A timer is never read aloud on its own, so the name can change without speaking.
AnnouncementsA polite live region inside the clock speaks on entering the last two minutes, on going over, and once for each further minute over. Never on page load.
ColourState is in the text (the plus sign and the label), never colour alone. --brand-ink and --color-warning-ink pass AA on white and on paper.
MotionNo pulse or flash in any state.

Tokens

TokenUsed for
--text-h1 / --text-display-lg / --text-display-xlThe value at md, lg and xl
--font-body, --font-bold, --tracking-tightThe value: Inter, bold, tight, with tabular figures
--text-darkRunning
--color-warning-inkEnding
--brand-inkOver
--text-mutedPaused
--text-small, --text-defaultThe label

CSS Classes

ClassPurpose
.ws-run-clockThe clock. Carries data-ws-run-clock, data-state, and data-planned / data-ends-at when given.
.ws-run-clock--md / --lg / --xlSize
.ws-run-clock--running / --ending / --over / --pausedState; the script swaps it as time passes
.ws-run-clock__valueThe readout
.ws-run-clock__labelThe label beside it

Files

FilePurpose
includes/components/helpers.phpws_run_clock() and its formatting helpers
includes/components/run-clock.phpTemplate: the clock, its label and its live region
includes/components/components.cssStyles (.ws-run-clock rules)
js/ws-run-clock.jsKeeps clocks with data-ends-at right from the timestamp