Bruno DelorenceBruno
Appearance
Appearance

Choose your reading theme.

Contact

Consist planner

New

A high-speed train’s pre-departure screen: the sixteen cars on one track, each car’s seat map, six figures and the car sequence.

consist-planner/consist-planner.tsx
Live · interactive

Consist Planner

Car occupancy, seat map and pre-departure checks for high-speed services.

Express consistH-12
Service
Kazehaya 23
Route
Tokyo → Shin-Osaka
Departure
14:40 · Track 18
Pre-departure check
Power
14 motor cars
Pantographs 05 · 13 up
Crew
Kenji Arai
Conductor · Yui Takeda
Load
1,212 / 1,399 seats
187 seats free
Position
Tokyo · track 18
Boarding opens 14:28
ETA
Shin-Osaka 17:05
2 h 25 min run
Next action
Fix HVAC in car 05
Before 14:30
  • Selected seat
  • Booked
  • Free
  • Luggage
Car 04 of 16 · M-1204

04M-120492 of 98 seats booked · 94% · 1 selected

Car sequence

Lead car at the Shin-Osaka end · car 04 in focus · use ‹ › or pick a car.

Selected · M-1204

The live component, numbered part by part. Every measurement is read from it as it is drawn. Point at a row to outline its part, or at a part to find its row.

The choices it offers, each value drawn live and the default marked, with how to pick one.

When to use

  • Checking one train before it leaves: which cars it runs with, how full each one is, and what still has to be fixed.
  • A seat-level task inside a car, such as holding seats for a group or moving passengers out of a car with a fault.
  • Fixed-formation trains, where the car order is known and every car has a seat plan: high-speed sets, intercity units.
  • An operations desk where people work through the day on a wide screen, and still need to glance at it on a phone.

When not to use

  • Selling tickets to passengers. A booking flow needs fares, one seat per traveller and a checkout; this is a staff view of the whole car.
  • Freight trains or wagons without seats. Show the car sequence with loads and weights instead of a seat map.
  • Watching many trains at once. Use a timetable board or a line diagram; this planner looks at one consist at a time.
  • Live tracking while the train runs. The figures here are a plan before departure, not a feed.

Layout

  • Wide: sidebar at 252 px, the main column beside it, the six figures in one row.
  • Under 1000 px of its own width the sidebar becomes a drawer behind a menu button; Escape or the scrim closes it.
  • On a phone the figures fold to two columns, and the seat map and the car cards scroll inside their own boxes, so the page never scrolls sideways.

Moving through the train

  • Prev and next step one car; the train slides 700 ms and the car in focus brightens.
  • A car card jumps to that car; the arrows move along the cards, Home and End go to the ends.
  • The alert pill and Validate consist go to the car with the open defect.
  • Reset puts back the opening car and selection.

Each one drawn with the component itself, used well or badly.

The words are operational: codes, times and counts, short enough for one line each.

  • Car numbers with two digits (04) and the car code beside them (M-1204), the same in the viewer, the caption and the card.
  • Seat counts as booked of total (92 / 98 seats), with the percentage only in the caption.
  • The next action as a verb (Fix HVAC in car 05) and its deadline under it.

You can add this component with the shadcn CLI or by hand:

Into components/consist-planner of any React project, with no setup:

Terminal
npx shadcn@latest add https://brunodelorence.com/r/consist-planner.json

Either way it needs React 19.2 and a bundler that supports CSS Modules, such as Next.js or Vite. It has a dark colour scheme: it follows your page’s color-scheme, light unless the page sets one, or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.

Usage

departure-planner.tsx
import { ConsistPlanner } from './consist-planner';export function DeparturePlanner() {  return (    <ConsistPlanner      defaultCar={4}      onCarChange={(car) => console.log('car', car)}      onSeatToggle={(car, seat, selected) => console.log(car, seat, selected)}      autoplay={false}    />  );}

Each state below is a live instance, locked so you can study it.

The pieces it is built from, each with its measurements read live.

An operations screen for one sixteen-car bullet-train set before it leaves Tokyo for Shin-Osaka. The sidebar holds the terminal, search, the sets, a watchlist and the next departure. The planner card shows the consist’s service and route, power, crew, load, position, ETA and the next thing to fix, then a line drawing of the train: the car in focus centred on the rails, its neighbours fading at the edges, the long nose cars at both ends. Under it is that car’s seat map, booked, free, selected or kept for luggage, and below that a strip of car cards with silhouettes and load bars. Step through the cars and the train slides along the track.

  • The viewer is a camera on the whole train: 16 cars (and a stretch of bare track at each end) stand side by side, each 77% of the viewer wide, and the strip moves by translateX(50% − (car + 1.5) × 77%) over 700 ms on cubic-bezier(0.65, 0, 0.25, 1). The cars beside the one in focus drop to 40% opacity in 500 ms, and a mask fades the strip to nothing over its outer 13%.
  • Each car is one SVG on a 1027 × 250 grid: a 1000-unit body and 27 units of gangway shared with the next car, so the cars meet at their bellows and their rails and 40 sleepers per car join into one track. The track height follows the viewer’s width with a container unit: 0.77 × 0.2434 × its width.
  • The nose car draws its front 330 units out into a long, low curve with a canopy set into it and the livery stripe sweeping down to the tip; the tail car is the same drawing mirrored. Ordinary cars have a ribbon window band with one window per seat row, a plug door at each end and the stripe below; premier cars add a gold line, cars 05 and 13 a pantograph on a roof fairing.
  • Strokes stay 1 px at every scale (vector-effect: non-scaling-stroke), so the same drawing is the 700 px car on the rails and the 116 px silhouette on a card, which leaves out the windows and the small parts.
  • The seat map is a grid of rows A to E across a 3 + 2 car (A to D in a 2 + 2 premier car), the aisle a 12 px gap. Seats share the width from 44 down to 28 px each, then the map scrolls in its own box. Bookings come from a seeded generator, so server and browser agree.
  • Layout follows the component’s own width: a ResizeObserver turns the 252 px sidebar into a drawer under 1000 px (260 ms slide, Escape or the scrim closes it), and container queries fold the six figures to three columns under 900 px and two under 560. The car cards, 138 px each, scroll and snap in their strip, which follows the car in focus.
  • While on screen and untouched, a demo pointer steps to car 05, picks two seats, jumps to a premier car, steps back and returns to car 04, then puts its seats back. Any input of the reader’s stops it for good; with reduced motion it does not play and the train jumps instead of sliding.
  • Every colour is a token on the root, light-dark() where the two schemes differ: graphite panels and dim grey lines at night, pale greys by day; the stripe and the selection stay blue, faults amber, luggage red.
PropTypeDefaultDescription
defaultCarnumber4The car in focus at first, 1 to 16.
onCarChange(car: number) => void—Called with the car number when the car in focus changes.
onSeatToggle(car: number, seat: string, selected: boolean) => void—Called when a seat is selected or cleared, with its car and its number ("7C").
autoplaybooleantrueWhile on screen and untouched, a demo pointer steps through cars and seats; any input from the reader stops it.
colorScheme'light' | 'dark' | 'system'—Light or dark colours, or the reader’s; without it, the page’s color-scheme.
classNamestring—A class for the root.

Keyboard

  • The seat map is one tab stop: the arrows move between seats, Home and End go along a row (with Ctrl, to the corners), Enter or Space toggles a seat.
  • The car cards are one tab stop too: the arrows change the car and follow it with the focus.
  • The service tabs move with the arrows; the terminal menu opens with Enter and closes with Escape; / goes to the search.

Screen readers

  • Each seat is a toggle button named with its number, window, booked or free, and selected; luggage spaces are named and disabled.
  • A polite live region says the new car and its load (“Car 05 of 16, M-1205: 72 of 88 seats booked. Open defect: HVAC degraded.”) or the seat toggled.
  • The train drawing is hidden from screen readers: the counter and the caption say the same in words.

Motion

With reduced motion the train jumps to the car without sliding, the drawer appears at once and the demo does not play.

In this build

  • The seat map is a grid with one tab stop: the arrows move between seats, Home and End along a row (with Ctrl, to the corners), Enter or Space toggles. Each seat is a toggle button named with its number, window, booked or free and selected; luggage spaces are named and disabled.
  • The car cards are one tab stop: the arrows, Home and End change the car and move the focus with it. Prev and next are buttons, disabled at the ends.
  • A polite live region says the new car and its load, any open defect, or the seat toggled; Validate consist says what it found.
  • The service tabs are a tablist moved with the arrows; the terminal picker is a menu of radio items that closes with Escape; “/” goes to the search.
  • Under 1000 px the sidebar is a drawer: inert while closed, it takes the focus when opened and gives it back to the menu button; Escape closes it.
  • The train drawing and the silhouettes are hidden from screen readers; the counter and the caption say the same in words. Every control shows a focus ring.
  • With reduced motion the train and the drawer move at once and the demo does not play.

The complete source behind this demo. Open source under the MIT license, © 2026 Bruno Delorence: copy it, change it, ship it.

consist-planner.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import {  useEffect,  useEffectEvent,  useId,  useLayoutEffect,  useRef,  useState,  type CSSProperties,  type KeyboardEvent as ReactKeyboardEvent,} from 'react';import {  CARS,  CATEGORIES,  LAYOUTS,  SEATS,  START_CAR,  START_SEATS,  TERMINALS,  WATCHLIST,  bookedIn,
consist-planner.module.css
/* Consist planner (consist-planner.tsx): an operations screen in graphite at night and in pale   greys by day, blue for the selection and the actions, amber for what needs doing, red for   luggage spaces and faults. The train is drawn in 1 px lines with one blue livery stripe.   Colours are the tokens below, light-dark(light, dark) where the two differ: the planner takes   the color-scheme it inherits from the page, or the one its colorScheme prop sets.   Layout. The sidebar's mode comes from the script (data-narrow, under 1000 px of the   component's own width: a drawer); everything else from container queries on the main column   and the viewer: the six figures fold to three columns under 900 px and two under 560, the seat   map and the car cards scroll inside their own boxes.   Motion. Only transform and opacity move: the train strip slides 700 ms on   cubic-bezier(0.65, 0, 0.25, 1), the cars beside the one in focus dim in 500 ms, the drawer   slides in 260 ms. With reduced motion all of it is immediate. */.root {  --bg: #fff;  --side: #f7f7f8;  --panel: #fbfbfc;  --viewer: #f2f3f5;  --card: #fff;  --card-on: #f1f5ff;  --group: #f0f1f3;
train-art.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.import type { Car } from './data';import styles from './consist-planner.module.css';/* * The cars, drawn as lines: a side view of each car of a high-speed set on a 1027 × 250 grid. * The body is 1000 units long (x 14 to 1013) and the 27 units left over hold the gangway * bellows, half at each end, so cars laid side by side at the grid's width meet at their * gangways and their rails join into one track. * * - The ordinary car: a smooth body with soft roof shoulders, a ribbon of windows (one per seat *   row) in a dark band, a plug door at each end, the livery stripe under the band, the skirt *   hiding most of two bogies. * - The nose car: the same body with its front 330 units drawn out into a long, low nose, its *   canopy set into the curve and the stripe sweeping down to the tip. The lead car points *   left; the tail car is the same drawing mirrored. * - The premier car adds a thin gold line under its windows; cars with a pantograph carry it on *   a roof fairing. * * Strokes keep 1 px whatever the scale (vector-effect in the stylesheet), so the same drawing is * the big car in the viewer and the 110 px silhouette on the car cards (mini: no windows, no * track, no small parts). */
data.ts
// Copyright (c) 2026 Bruno Delorence. MIT License./* * The consist the planner shows: one sixteen-car high-speed set, H-12, on the 14:40 Kazehaya 23 * from Tokyo to Shin-Osaka. Each car has a kind (the two nose cars, ordinary cars in a 3 + 2 * layout, premier cars in 2 + 2), a number of seat rows, its luggage spaces and its bookings. * * The bookings are drawn from a seeded generator, so every render (server and browser) gets the * same seat map without storing 1,400 seats by hand. */export type CarKind = 'lead' | 'ordinary' | 'premier' | 'tail';export type Car = {  /** 1 to 16, from the Shin-Osaka end. */  n: number;  code: string;  kind: CarKind;  /** Seat rows along the car: 1 to rows. */  rows: number;  /** Seats that are luggage spaces instead, as "20D". */  luggage: string[];  /** The share of seats booked. */  load: number;
icons.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License./* * The planner's icons, drawn on a 20-unit grid in 1.5-unit strokes of the current colour, so each * takes its control's colour in both schemes. All are decorative: the control beside them names * what it does. */export type IconName =  | 'mark'  | 'pin'  | 'updown'  | 'search'  | 'home'  | 'train'  | 'grid'  | 'box'  | 'route'  | 'signal'  | 'wrench'  | 'chart'  | 'gear'  | 'help'  | 'chevron-right'
demo-pointer.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import type { CSSProperties, Ref } from 'react';/* * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, or * glide the pointer somewhere. Stopping the demo (the reader takes over, or it scrolls away) ends * the step in progress at once: its promise rejects, which ends the script right there, and the * pointer fades out. * * Each glide is a curved flight played by the Web Animations API, so nothing runs frame by frame. * The points of the flight are handed to whoever wants to move along with it (nothing here uses * them yet). The arrow and the hand are HTML boxes * that swap by their visibility: a change of style inside an SVG would lay the SVG out again. */export type Point = { x: number; y: number };/** A glide's path and timing, for an animation that plays along with it. */export type Flight = { points: Point[]; timing: KeyframeAnimationOptions };export type Demo = {
use-autoplay.ts
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import { useCallback, useEffect, useRef, useState } from 'react';/* * When a demo may play on its own: while part of it is on screen and the tab is visible, never * under reduced motion, and never again once the reader has used it: `take()` hands it to the * reader for good (until the component mounts again), so it can't come back on its own. */export function useAutoplay<T extends HTMLElement>() {  const ref = useRef<T>(null);  const [visible, setVisible] = useState(false);  const [reduced, setReduced] = useState(true);  const [taken, setTaken] = useState(false);  useEffect(() => {    const element = ref.current;    if (!element) return;    let onScreen = false;    const update = () => setVisible(onScreen && !document.hidden);    const observer = new IntersectionObserver(      ([entry]) => {