Skip to the content

Kongens Nytorv

Metro M1, M2 and M3.

Delays

Props

NameTypeDefaultDescription
severity*'delay' | 'data' | 'diversion' | 'planned' | 'notice'(required)The kind of disruption: delay for vehicles running late, diversion for a changed route, planned for planned works, data for a problem with the real-time data feed, notice for a service notice whose message does not say which of the others it is.
delaysLabelstringThe locale'sOverrides "Delays", the name shown for severity='delay'
diversionsLabelstringThe locale'sOverrides "Diversions", the name shown for severity='diversion'
plannedWorksLabelstringThe locale'sOverrides "Planned works", the name shown for severity='planned'
dataFeedProblemsLabelstringThe locale'sOverrides "Data feed problems", the name shown for severity='data'
serviceNoticeLabelstringThe locale'sOverrides "Service notice", the name shown for severity='notice'
refRef<HTMLSpanElement>—Reaches the root element
severity (required)'delay' | 'data' | 'diversion' | 'planned' | 'notice', default (required)
The kind of disruption: delay for vehicles running late, diversion for a changed route, planned for planned works, data for a problem with the real-time data feed, notice for a service notice whose message does not say which of the others it is.
delaysLabelstring, default The locale's
Overrides "Delays", the name shown for severity='delay'
diversionsLabelstring, default The locale's
Overrides "Diversions", the name shown for severity='diversion'
plannedWorksLabelstring, default The locale's
Overrides "Planned works", the name shown for severity='planned'
dataFeedProblemsLabelstring, default The locale's
Overrides "Data feed problems", the name shown for severity='data'
serviceNoticeLabelstring, default The locale's
Overrides "Service notice", the name shown for severity='notice'
refRef<HTMLSpanElement>, default —
Reaches the root element

Use it

import { SeverityLabel } from '@mylder/perron'

Ask your agent

search_docs({ query: "SeverityLabel" })

Keyboard and ARIA

SeverityLabel is text: it takes no focus, and no key does anything. render swaps its element for another text element, never a link or button: it is smaller than size.target-min, so the control is the card around it, as Do and don't says.

KeyDoesFrom
noneSeverityLabel 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 card or row it headsnone
iconhidden, aria-hidden="true"Not read: the label beside it says the samenone
labeltextThe owned string for the kind: "Delays", "Diversions", "Planned works", "Data feed problems", "Service notice"none

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 the icon say the kind, and the label says it in words for every severity; the icon is aria-hidden because the word beside it carries the same meaning. In forced colours the colour goes, and the icon and the word still carry it.
  • Every landmark and named region has an accessible name: none here; SeverityLabel is inline text.
  • Every default label can be overridden: delaysLabel, diversionsLabel, plannedWorksLabel, dataFeedProblemsLabel and serviceNoticeLabel.
  • Every shape the type accepts renders, in every variant: severity is one of five strings, and each has its story; a *Label string replaces only its own kind's word, and an undefined one keeps the locale's (CR-5).
  • A hidden copy kept for animation is aria-hidden, and a collapsed region is inert: none here; SeverityLabel does not animate. The icon is aria-hidden because the word speaks for it, not for animation.
  • Native semantics first: a <span> with a <span> of text and an <svg>, no role, and no ARIA beyond aria-hidden and focusable="false" on the icon.
  • Focus moves in reading order and returns on close: SeverityLabel takes no focus.
  • Every target is at least size.target-min square: no target; SeverityLabel is not pressed.
  • Loops stop when the system asks for less motion: none here; SeverityLabel has no motion.

Owned strings

Every word SeverityLabel shows is its own; the caller gives only severity. The names are the kinds of disruption as packages/perron/icons/icons.json and Data states name them, set in sentence case.

The five names are "Delays", "Diversions", "Planned works", "Data feed problems" and "Service notice": the names the icons and the tokens already give, plural as names of a kind rather than of one event, but for "Service notice", which names what each such message is, as Rejseplanen's own messages do. They reuse the existing delays key, its JSDoc widened to "A line's delays: a heading, and the name of the delay kind of disruption", and add diversions, plannedWorks, dataFeedProblems and serviceNotice. All five join the data-state, delay and disruption words table of docs/content-design.md, so every screen names a disruption the same way in all four languages: "Service notice" is "Driftsmeddelelse", "Trafikmeddelande" and "Driftsmelding".

KeyEnglishOverrideSeen or heard where
delays"Delays"delaysLabellabel when severity='delay', seen and read as shown; the key en.ts has
diversions"Diversions"diversionsLabellabel when severity='diversion', seen and read as shown; new
plannedWorks"Planned works"plannedWorksLabellabel when severity='planned', seen and read as shown; new
dataFeedProblems"Data feed problems"dataFeedProblemsLabellabel when severity='data', seen and read as shown; new
serviceNotice"Service notice"serviceNoticeLabellabel when severity='notice', seen and read as shown; new

Each new key gets a JSDoc line like its neighbours in packages/perron/src/locale/en.ts, and its Danish, Swedish and Norwegian in da.ts, sv.ts and nb.ts.

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-1mustHead a disruption with SeverityLabel, then say what is happening in a plain sentence beside it, as content design asks.Let the label stand for the disruption: "Delays" says the kind, not where, why or how long.review
DD-2mustUse SeverityLabel wherever a kind of disruption is named, so its icon, colour and word always come together.Set your own text in a color.transit.severity.* colour, or show a disruption icon alone: colour and icons never carry meaning alone.review
DD-3mustUse Delay for how late one vehicle or departure runs.Use SeverityLabel with severity='delay' for one late vehicle: it names a disruption on a line.review
DD-4mustUse severity='data' for a problem with the real-time feed across a line or the network.Use it for one silent vehicle: that is the vehicle dot's "No signal" state, said with its own word.review
DD-5mustShow a line running normally with the "Running normally" word, and no SeverityLabel.Invent a kind, such as a success severity, for good news: the five kinds are disruptions and notices about the service.types
DD-6mustUse severity='notice' for a message whose fields don't say which kind it is, and say what it is in the sentence beside it.Guess a kind from a message's words, or show an unread kind as planned works: the label would claim what the message never said.review
DD-7mustMake the whole disruption card the link or button, with the label inside it.Make SeverityLabel itself a filter control through render: it is a label, smaller than size.target-min, and has no pressed state.review