Skip to the content

Kongens Nytorv

Metro M1, M2 and M3.

On time

Props

NameTypeDefaultDescription
minutes*number | null(required)The delay in minutes: positive when late, negative when early, 0 on time, null when no real-time data says (timetable only, no signal). Rounded to the nearest whole minute.
minutesUnitLabelstringThe locale'sOverrides "min", the unit after the figure
minutesLateLabelstringThe locale'sOverrides "min late", heard after the number when late
minutesEarlyLabelstringThe locale'sOverrides "min early", heard after the number when early
onTimeLabelstringThe locale'sOverrides "On time"
delayUnknownLabelstringThe locale'sOverrides "Delay unknown", heard in place of "—"
classNamestring—Reaches the root; className is merged after pn-Delay
styleCSSProperties—Reaches the root; className is merged after pn-Delay
refRef<HTMLSpanElement>—Reaches the root element
minutes (required)number | null, default (required)
The delay in minutes: positive when late, negative when early, 0 on time, null when no real-time data says (timetable only, no signal). Rounded to the nearest whole minute.
minutesUnitLabelstring, default The locale's
Overrides "min", the unit after the figure
minutesLateLabelstring, default The locale's
Overrides "min late", heard after the number when late
minutesEarlyLabelstring, default The locale's
Overrides "min early", heard after the number when early
onTimeLabelstring, default The locale's
Overrides "On time"
delayUnknownLabelstring, default The locale's
Overrides "Delay unknown", heard in place of "—"
classNamestring, default —
Reaches the root; className is merged after pn-Delay
styleCSSProperties, default —
Reaches the root; className is merged after pn-Delay
refRef<HTMLSpanElement>, default —
Reaches the root element

Use it

import { Delay } from '@mylder/perron'

Ask your agent

search_docs({ query: "Delay" })

Keyboard and ARIA

Delay is text: it takes no focus, and no key does anything. A caller who makes it a link or button through render brings that element's own keys.

KeyDoesFrom
noneDelay is not focusable or operablePerron
ElementRoleAccessible name fromStates announced
rootnone: a generic <span>Not named; its text is read in place, as part of the row or sentence it sits innone
value and unithidden, aria-hidden="true"Not read, except "On time", which is read as shown (CR-3)none
labeltextThe owned strings: "3 min late", "1 min early", "Delay unknown"none

The visible figure is aria-hidden, with a VisuallyHidden label saying the delay in words: the number without its sign and then "min late" or "min early" ("3 min late", "1 min early"), and "Delay unknown" in place of "—", while "On time" is read from the visible text. A screen reader reads "+3 min" as "plus 3 min" and skips or spells "—", so the ear would get less than the eye, and an aria-label on a role-less <span> is not allowed.

What axe won't catch, from the contract, each with how this component meets it:

  • Everything the eye is told, the ear is told, for every shape each prop accepts: the colour and sign say late, slight, early or on time; the label says "N min late" or "N min early", "On time" is read as shown, and null says "Delay unknown". In forced colours the colour goes, and the sign and words still carry it.
  • Every landmark and named region has an accessible name: none here; Delay is inline text.
  • Every default label can be overridden: minutesUnitLabel, minutesLateLabel, minutesEarlyLabel, onTimeLabel and delayUnknownLabel.
  • Every shape the type accepts renders, in every variant: minutes is a number or null; positive, negative, zero, fractional (rounded), NaN and infinite (both unknown, CR-1) all render, and a story's play test covers each kind.
  • A hidden copy kept for animation is aria-hidden, and a collapsed region is inert: none here; Delay does not animate. The visible figure is aria-hidden because the label speaks for it, not for animation.
  • Native semantics first: a <span>, with no role and no ARIA beyond aria-hidden on the figure the label replaces.
  • Focus moves in reading order and returns on close: Delay takes no focus.
  • Every target is at least size.target-min square: no target; Delay is not pressed.
  • Loops stop when the system asks for less motion: none here; Delay has no motion.

Owned strings

Every word Delay shows or announces is its own; the caller gives only minutes. The number is never part of a string: it renders as its own text run beside the word, so the dictionaries stay plain strings (CR-3).

KeyEnglishOverrideSeen or heard where
minutesUnit"min"minutesUnitLabelunit, seen after a signed figure, "+3 min"; aria-hidden
minutesLate"min late"minutesLateLabellabel, heard after the number when late: "3 min late"
minutesEarly"min early"minutesEarlyLabellabel, heard after the number when early: "1 min early"
onTime"On time"onTimeLabelvalue, seen and heard when minutes rounds to 0
delayUnknown"Delay unknown"delayUnknownLabellabel, heard in place of "—" when minutes is null

No key in packages/perron/src/locale/en.ts says any of these, so all five are new, each with a JSDoc line like its neighbours.

"On time" and "Delay unknown" join the data-state and delay words table in docs/content-design.md, with their Danish, Swedish and Norwegian, so every screen says a delay the same way; content design says delays always use the words in that table, and its test then holds the locale files to them. "min", "min late" and "min early" stay out of it, as parts of a number's phrase rather than words a screen shows on their own.

Do and don't

For a caller using the component, with the reason. Each row is a rule: a must row's Don't is never right, a should row's needs a reason, and Checked by says what catches the Don't in a caller's code.

RuleLevelDoDon'tChecked by
DD-1mustPass minutes={null} for a timetable-only or no-signal vehicle, because no real-time data says how late it is.Pass 0 when the delay is unknown: "On time" claims more certainty than the data has.review
DD-2mustPass the delay in minutes, and let Delay round, sign and colour it.Format the figure yourself and put it in a Text in a delay colour: the words for the ear and the data-delay kind go missing.review
DD-3mustSet Delay beside stronger text, such as the departure time, because color.transit.delay.unknown is too faint to stand alone.Use Delay alone as a row's only content when it may be unknown: "—" in that colour misses 4.5:1 by design.review
DD-4mustAnnounce a changed delay in the screen's own polite live region, once, when its kind changes.Wrap Delay in a live region that reads every minute's change: it floods the screen reader.review
DD-5shouldUse color.transit.severity.delay and its label for a delay disruption on a line.Use Delay for a line's disruption: it says how late one vehicle or departure runs.review