The kind of a disruption on a line, as its icon and its name in its colour, such as a warning triangle and "Delays", heading a disruption card or a row in a list of disruptions.
When to use
Use SeverityLabel to name the kind of a disruption on a line, as its icon and its word in its colour, such as "Delays", heading a disruption card or a row in a list of disruptions.
| Use instead | When |
|---|---|
| DisruptionCard | The whole disruption shows as a card: its kind, the lines it touches, a title and a sentence on what is happening |
| Delay | The figure is how late one vehicle or departure runs |
| NormalService | The line runs normally, with no disruption to name |
| VehicleDotLabel | One vehicle is silent: its dot and its word, "No signal", say so |
| Tag | A word or two marks a property of a departure or a vehicle, such as "Cancelled" |
Kongens Nytorv
Metro M1, M2 and M3.
Props
| Name | Type | Default | Description |
|---|---|---|---|
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. |
delaysLabel | string | The locale's | Overrides "Delays", the name shown for severity='delay' |
diversionsLabel | string | The locale's | Overrides "Diversions", the name shown for severity='diversion' |
plannedWorksLabel | string | The locale's | Overrides "Planned works", the name shown for severity='planned' |
dataFeedProblemsLabel | string | The locale's | Overrides "Data feed problems", the name shown for severity='data' |
serviceNoticeLabel | string | The locale's | Overrides "Service notice", the name shown for severity='notice' |
ref | Ref<HTMLSpanElement> | — | Reaches the root element |
severity (required)'delay' | 'data' | 'diversion' | 'planned' | 'notice', default (required)- The kind of disruption:
delayfor vehicles running late,diversionfor a changed route,plannedfor planned works,datafor a problem with the real-time data feed,noticefor 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.
| Key | Does | From |
|---|---|---|
| none | SeverityLabel is not focusable or operable | Perron |
| Element | Role | Accessible name from | States announced |
|---|---|---|---|
root | none: a generic <span> | Not named; its text is read in place, as part of the card or row it heads | none |
icon | hidden, aria-hidden="true" | Not read: the label beside it says the same | none |
label | text | The 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
labelsays it in words for everyseverity; the icon isaria-hiddenbecause 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,dataFeedProblemsLabelandserviceNoticeLabel. - Every shape the type accepts renders, in every variant:
severityis one of five strings, and each has its story; a*Labelstring 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 isinert: none here; SeverityLabel does not animate. The icon isaria-hiddenbecause 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 beyondaria-hiddenandfocusable="false"on the icon. - Focus moves in reading order and returns on close: SeverityLabel takes no focus.
- Every target is at least
size.target-minsquare: 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".
| Key | English | Override | Seen or heard where |
|---|---|---|---|
delays | "Delays" | delaysLabel | label when severity='delay', seen and read as shown; the key en.ts has |
diversions | "Diversions" | diversionsLabel | label when severity='diversion', seen and read as shown; new |
plannedWorks | "Planned works" | plannedWorksLabel | label when severity='planned', seen and read as shown; new |
dataFeedProblems | "Data feed problems" | dataFeedProblemsLabel | label when severity='data', seen and read as shown; new |
serviceNotice | "Service notice" | serviceNoticeLabel | label 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.
| Rule | Level | Do | Don't | Checked by |
|---|---|---|---|---|
| DD-1 | must | Head 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-2 | must | Use 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-3 | must | Use 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-4 | must | Use 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-5 | must | Show 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-6 | must | Use 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-7 | must | Make 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 |