Layout and slots
Part of Design system, which is built from DESIGN.md in the repository, where it is edited.
Where each control sits on the screen, and which part of the code owns its place.
MapChrome owns the position of everything floating over the map. It is pointer-events: none, and each slot's contents are pointer-events: auto. The cursor coordinates remain on screen while a pointer rests over the readout after it grows, so the coordinates can be copied; they clear after the pointer leaves both the map and the readout.
MapChrome wraps the map in the page's main landmark unless its mainLandmark prop is false, which a page with its own main or with several maps sets. The landmarks the interface draws (the map region, the search, "Map tools", "Map scale", "Measurement", "Drawing" and "Map credits") take their names from useLandmarkName: the landmark's own name, or, when the MapView has a label, the name and the label together through the host.map.named message ("Map (Pine)"). One map with no label keeps the bare names. A new landmark takes its name the same way, so two maps never repeat it, and the sheet is named by the title its host writes.
The side panel sits at inline-start: on the right in a right-to-left layout. Feature reveals, imported shapes, directions and free-centre targets use the measured panel edge on that side; route, shape and layer-feature fits also keep the end-stack clearance on inline-end, and layer-feature fits stay above the visible map key.
| Slot | Contents |
|---|---|
| top-start | search pill |
| end-stack | compass (when the map is rotated), main control group (Map options, Measure, Directions when the host has a routing service, Draw shapes, Locate me, Settings), zoom control group (when shown) |
| bottom-start | scale readout, cursor coordinates and zoom level (desktop) |
| bottom-end | attribution: the credits button, and the credits popover, which rises a gap above the top of the whole bottom row (not only the button), so it clears the readout beside it, whatever the readout's height (that rise is a transform, so when the cursor coordinates change the readout's height as the pointer enters or leaves the map the popover slides over the base motion duration instead of jumping, and follows at once under reduced motion; opening never slides it), unless the two share no width: where the popover starts a gap after the readout's end edge (data-readout-clear, measured by Attribution as the popover, the readout and the chrome change size, and again when the readout slides sideways as the side panel opens or closes), it sits a step above the button instead, so on a wide screen it stays next to its button with the cursor coordinates showing or not. It also rises a step above the top of the bottom-centre slot (a toolbar, a message) where it shares width with that slot, even though the button does not (--chrome-popover-centre-rise; the button itself holds still, see "Layout and slots"), and stays next to the button where it does not. If the room above the row is then too small for the credits, the popover moves beside the end stack, and scrolls only if that is not enough either. Above the row or beside the end stack, its top stops a gap below the end stack or the search pill: its height cap is that room less the step it sits above the row |
| bottom-centre | measure toolbar or draw toolbar, the "Looking up what is here" line, toasts, connection notice, tile-error banner |
| tour | the first-visit tour card: under the search pill beside the end stack on a narrow screen, and between the search column and the end stack in the panel layout (against the end stack when the step's control is there); hidden with the bottom slots at the full detent, and while the bottom row, lifted above the sheet or a toolbar, would reach it, or a toolbar or message in the bottom row that shares its width does (a short screen with the sheet open, or a tall toolbar or message), and back when there is room. The credits' first showing waits while the tour is on screen, in every layout, so the two are not on the map together; the wait ends when the tour is answered, on the first zoom or move of the map, or after 30 seconds. The one thing allowed over it is the credits popover: on a short landscape phone it rises beside the end stack into the card's cell, on the popover layer, both when it shows itself for the first five seconds and when the person opens it later, and it may then cover the card's lower right (step 2's Skip tour at 844 by 390). Closing it with Escape or its button uncovers the card, and the credits must stay readable first |
| map-key | the map key (MapKey), in the grid cell above the scale bar, aligned to its bottom edge. MapChrome rests it a gap above the bottom row, lifted with that row above the sheet, and above a toolbar only where the readout or the key itself shares width with it (the key can be wider than the readout, so it decides for itself) and moved with the scale bar clear of the side panel, from the slot's own measured position. A toolbar lift is written by the slot observer in the same frame as the toolbar changes, without a second render. The key's height is capped at the room between the search pill (or the tour card, while it shows) and that row, so it scrolls inside its own height and never grows over another control. It is not counted in the end stack's height. With less than 48 px of room it gives way: its slot is hidden and inert (data-crowded="true"), as the tour card does. It is also hidden at the full detent and while the credits popover is open, because the popover grows over this corner and the credits must stay readable; the key returns when the popover closes (so on a page opened with layers on, it appears once the credits' first showing ends) |
| sheet or side panel | one of three. Map options (title "Map options"), from its button, a dropped pin or a tapped feature: basemap, pin, layers (with the open feature card at the top), shapes, save image. Settings (title "Settings and help", so it does not repeat the "Settings" section heading inside it), from its button: settings and help. Directions (title "Directions"), from its button: the directions panel |
Before the app mounts, the server renders a decorative skeleton of this chrome (ChromeSkeleton) on the map's background colour: the search pill, the Map options, Measure, Directions (when the host has a routing service, which ChromeSkeleton is told with its directions prop), Draw shapes (its draw prop), Locate me and Settings group, the zoom group where the device has a fine pointer, and the credits button, in their final slots. It reuses the MapChrome grid and the real controls' own classes, so the live chrome replaces it in the same boxes with no layout shift (e2e/skeleton.spec.ts compares every control's box before and after at 390 by 844 and 1280 by 720). It is aria-hidden and inert, writes no style attribute and uses only tokens. It uses no hook or provider, so its words arrive as a required copy prop, built from the host's default-language catalogue by chromeSkeletonCopy with the keys the live controls use. Because the server cannot measure the container, its sheet or side panel layout follows a media query built from the same constants as chooseLayout, and its zoom group follows (hover: hover) and (pointer: fine); a stored "show zoom buttons" choice is applied once the app mounts. Where scripts do not run (@media (scripting: none)), nothing would ever bring the controls to life, so the placeholder draws neither the skeleton nor its loading text and the skip link is hidden; NoScriptNotice shows instead, a card in the middle of the placeholder, inside the main landmark so it is not empty, that says "The map needs JavaScript. You can still read about MapCairn, its source code and its privacy policy." with links to the product page, the source and the privacy policy. The server renders it in English, because without scripts the page cannot read the visitor's stored language.
Slots use flow layout with gaps from the spacing scale, so neighbours push apart instead of overlapping. On narrow screens the sheet is a bottom sheet with peek, half and full detents. From 768px wide, and on any screen shorter than about 500px, it is a floating side panel at inline-start. The bottom slots ride above the sheet and hide at the full detent. They clear only what is in the bottom-centre slot (the toolbars, toasts, the connection notice and the tile-error banner), so a host puts its own toolbar there, and each slot rides above it by that slot's own height only when the two share width (within a gap), in the same frame the slot changes height: a control moves only when a surface that opens would cover it, and then by the least that clears it, and otherwise holds still. A centred toolbar on a tablet or desktop therefore leaves the credits at the end of the row and the readout at the start where they rest, and on a phone, where the toolbar spans the row, both rise. MapChrome measures each slot's horizontal extent as it will rest (counting the sideways shift of the side panel), and writes --chrome-bottom-start-raise (the readout), --chrome-map-key-raise (the map key, which rests above the readout but can be wider than it, so it has its own span and rises to clear a toolbar that reaches it alone) and --chrome-bottom-end-raise (the credits) in the callback of the observer that sees the slot change size, and the slots apply them with the translate property, which no transition covers, while the sheet's lift (--chrome-bottom-lift) is a transform that slides with the sheet. A toolbar that changes height (opening, a first measure, a larger text size) therefore never has the credits or the readout over it for a frame, with motion or with reduced motion, and e2e/toolbarLift.spec.ts records every frame to check it. The credits button holds still where the toolbar shares no width with it, but its open popover is wider than the button and can reach under a toolbar or message that the button does not, so MapChrome also writes --chrome-popover-centre-rise in that same callback, from the popover's own box (also when it opens or moves beside the end stack), and the popover applies it with translate: it is clear of the slot in the frame the slot appears and never slides over it, while its rise over the readout, a transform, still slides. The tour card, which sits at the top of the free space, gives way to a toolbar that shares its width and reaches up to it. MapChrome measures the bottom row, so the credits popover rises above its tallest slot (unless it shares no width with the readout, see the bottom-end row) and its height is capped at the room between that row and the end stack (--chrome-bottom-end-rise, --chrome-bottom-end-room); a slot added to the row, or a readout that grows, therefore cannot overlap the popover. The end stack is capped at the height MapChrome measures for it and scrolls inside that height on a screen too short for every control, with no scrollbar. It is a scroll container only while it has more to show (data-scroll-more is not none): with every control in view it does not clip, because a clip would cut the groups' shadows at its box and leave a hard-edged band that dims the map beside the controls on the dark theme. Text size counts as screen size: controls and the search pill are in rem, so at 200 percent text (WCAG 2.2 1.4.4) or 320 px wide (1.4.10) every control must still be reachable, by scrolling where it cannot fit, and never cut off with no way to reach it. The one residual: on a 320 by 568 screen at 200 percent text with the draw tool open, the end stack's window is about 120 px against 96 px buttons, so the second button shows only in part, inside the fade band, until it is scrolled to. A scroll container with a hidden scrollbar says it has more by fading the edge that has more behind it (scrollFade, driven by data-scroll-more from useScrollEdges: below, above, both or none), a control brought into view by Tab stops clear of the fade, and a fade is a mask, so it takes no room and is removed in forced colours (forced-colors: active). The draw toolbar takes at most half the screen height, and less where the end stack would be left without room for one button (its cap is the screen height minus what the rest of the chrome needs, in the same rem units, so it follows the text size); beyond the cap it scrolls inside its surface the same way, and the shape switch wraps onto a second line instead of its words overlapping. The primary button does not stick: the surface is translucent, so a pinned row would show the scrolled controls through it, and at large text the button row wraps to several lines, which would pin most of the toolbar. The browser test text-size.spec.ts checks 100, 150 and 200 percent text at 320 by 568, 390 by 844 and 820 by 1180, in English and Afrikaans. By default the zoom group yields to a short stack. When the user has chosen to show zoom buttons it stays, and scrolls into view with the rest of the stack. e2e/bottomCorners.spec.ts records the box of the credits, the readout and the map key at a phone, a tablet and a desktop size before and after each tool opens, and fails a control that moves when nothing would cover it, or that does not clear what would. A layout collision test checks every viewport and state, including, on a desktop pointer, the readout with the cursor coordinates at their widest, imperial units and a key of six layers, from 320 by 568 up.
Map options and Settings open the same sheet or side panel, each at its own sections, so the sheet shows either the Map options group or the Settings group, never both. Settings is always the last button of the main group. Each button is an expanded toggle (aria-expanded, aria-controls the sheet) that is true only while its own group is the open surface (a pin card in the sheet counts for neither). Pressing a button while the other group is open switches to its group without closing the sheet, and pressing it while its own group is open closes the sheet. Closing returns focus to the button that opened the open group (Map options or Settings), or to the Shapes button of a drawing the sheet was opened over. Shapes and export, a tap on a feature and a dropped pin's card all land on the Map options group, whichever group was open. A sheet opened over Measure or Draw returns to that tool when it closes, with its points or shape kept and focus on the Measure button or the Shapes button.