Skip to main content

MapChrome

The one owner of everything floating over the map. It draws the map full-bleed inside main, lays the slots out with flow layout, and keeps the bottom slots clear of the sheet, the side panel and the measure toolbar.

This is a function exported by @mapcairn/map, checked against version 0.2.0.

Signature​

import { MapChrome } from "@mapcairn/map";

function MapChrome(input: MapChromeProps): JSX.Element;

Parameters​

  • { background, topStart, endStack, bottomStart, bottomEnd, bottomCentre, tour, tourSide, mapKey, sheet, modal, mainLandmark, onViewportChange, }
  • input (MapChromeProps)

Returns​

JSX.Element

Remarks​

  • DOM order is reading order: top-start, tour, end-stack, the sheet, the map (main), the map key, then bottom-start, bottom-centre and bottom-end. The app renders the skip link before this component and the page's h1 itself.
  • While modal, every group except the sheet gets inert. That is one inert attribute per group rather than one wrapper, because the sheet sits between the groups in reading order.
  • The container ignores the pointer; each slot takes it back, so the map stays draggable in every gap. Every slot wrapper has data-chrome with its slot name; the sheet carries its own data-chrome="sheet".
  • A ResizeObserver measures the container (which already reflects the visual viewport) and the slots. From that it chooses the layout, gives ChromeLayoutProvider the viewport and the pointer preference, and sets the chromeVars on the root with CSSOM: never a style attribute, because production CSP is style-src 'self'.
  • The sheet publishes its top edge (publishSheetTop) and detent, and the side panel its right edge. Whatever is shown in bottom-centre, a toolbar first, is an obstruction too, measured from its slot. computeBottomSlotLayout turns these into the lift and shift of the bottom slots, which hide at the full detent.
  • The bottom row rides above the sheet with a transform, which slides, and above the bottom-centre slot with the separate translate property (bottomStartRaise, bottomEndRaise and mapKeyRaise, each zero for a slot that shares no width with the bottom-centre slot), which does not, and which the measuring observer sets in its own callback. A toolbar that changes height therefore never has the row over it, in any frame, with motion or without.
  • Before the first measurement (and in server rendering) the layout is the bottom sheet, the narrow-screen default.

See also​

Source: packages/map/src/chrome/MapChrome/MapChrome.tsx:513