'use client'; /** * NavRail — the destinations of a product down one side, folded to icons when * the screen is narrow or the work needs the room. * * ```tsx * * * }>Meridian * * * * }>Overview * }> * Inbox 12 * * * … * * ``` * * ## One pill, and it travels * * The chosen destination sits on a tonal pill in the primary colour, with a * short accent on its leading edge. There is one pill for the whole rail, not * one per group, so it crosses the gap between groups when the choice does: * going from Inbox to Settings reads as one move down the rail rather than as * one row dimming while another lights. * * The pill is placed by measuring the active row in a layout effect, and kept * on it with a `ResizeObserver` and a `MutationObserver` as the rail changes * width, a label wraps or the active item changes. It is measured before paint * and does not animate on the first placement, so a page never opens with the * pill sliding in from the corner. With reduced motion the travel is skipped * and it is simply there. * * ## Folded, it is still a rail * * Collapsed, the rows become 40px icon squares. The active pill becomes the * square, the group labels become dividers, and a badge becomes a dot on the * corner of its icon rather than disappearing with the label. The rail's width * follows the state, so an app can put it in a flex row and let the content * take the room it gives up. * * A folded item keeps its accessible name through `label` (or its text * children when they are plain text), and shows the same name in a small * flyout on hover and focus. The visible label is `aria-hidden` while folded, * so a screen reader hears the row once rather than twice. * * ## Nested destinations * * A destination can own a child list with `NavRail.Sub`. The parent stays an * ordinary row — a link when it has an `href` — and the list is indented under * it, with a disclosure button that says whether it is open. Zoomed in, the * child rows are part of the rail's single pill and its arrow-key order; when * the child that is active is folded away inside a closed list, the parent * holds the pill so the rail still shows a place. * * Folded, the same list becomes a flyout to the side of the rail, opened by * hover or focus and kept out of the rail's clipping so a narrow column can * still show names. The parent is not the flyout's trigger in the sense a menu * is: the child rows are links in a real `