Files
road-compiler/.trellis/spec/frontend/component-guidelines.md
T

1.2 KiB

Component Guidelines

Use typed React function components. App.tsx owns session/editor composition, while reusable map and UI concerns live in named components. Prefer the shared ui/button.tsx primitive for commands. Do not create business UI with querySelector or innerHTML.

Components expose explicit props for values and callbacks. A form component may own presentation-local state such as a select value, but it must not import api, mutate WorkbenchState directly, or implement save/preview/undo behavior. The composition root passes commands such as stage, updateSignal, or onAccept.

The inspector is composed from independent sections. Section components must preserve existing write semantics: ordinary v1 forms stage overrides, lane-maneuver uses the v2 session, and signal forms update the signal draft command. Do not make a generic form abstraction that hides these boundaries.

Forms use controlled inputs and submit handlers. Keep map canvas DOM owned by OpenLayers and surrounding controls owned by React. Extracting a component must preserve labels, default values, event ordering, and the current accordion behavior unless a separate product task approves a change.