@eldrajs/ui 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ Release-please writes the generated notes from commit messages and does not repl
7
7
 
8
8
  ### Added
9
9
 
10
+ - **`Image` exact crops.** `zoomOrigin: 'focal'` zooms around the focal point itself, so a crop can reach the edges of the picture; the default, `'band'`, keeps the origin in the band the page builder's framing clamps to, so stored framings render as before and as Studio previews them. `crops: ImageCrop[]` art-directs the one `<img>`: a `ratio`, `focal`, `zoom` and `sizes` per media condition, first match first, with `sizes` scoped and scaled per crop, so a phone gets its own crop without a second download. `ratio` also takes a number (width ÷ height). New type `ImageCrop`.
11
+ - **`NavMenu`** — the header navigation: top-level links, and buttons opening a `dropdown` panel or a `mega` panel of columns (entries with `description`, `badge`, `current`, `newTab`). Disclosure pattern: `Enter`/`Space` open, `Tab` walks through, `Escape` closes and returns focus, an outside click or focus leaving closes, one panel at a time; plus the APG arrow keys (`←`/`→`/`Home`/`End` along the bar, `↓`/`↑` into and through a panel, never wrapping). Optional `openOnHover`, opening after a 150ms rest and closing 150ms after the pointer leaves; a closing panel fades out. Below `collapseBelow` (default `lg`; also `md`, `xl`, the container breakpoints `@tablet`/`@content`/`@wide`, `never` and `always`) it becomes a menu button and a left `Drawer` with accordion rows. Takes a resolved Studio link tree as it is. `variant`: `ghost` (default; text colour with a fill on hover and while open) or `muted` (muted text turning the text colour on hover, while open and on the current page, no fill), for the bar and its panels alike. `linkAs`, `classes`, slots `panelItem`/`groupHeading`/`panelFooter`/`toggle`/`drawerFooter`, `v-model` (open panel) and `v-model:drawerOpen`, exposed `close()`. New messages `navMenuLabel`, `navMenuOpen`, `navMenuDrawer`, `navMenuOverview`; new CSS variables `--eldra-nav-menu-offset`, `--eldra-nav-menu-dropdown-min`/`-max`, `--eldra-nav-menu-column-min`.
12
+ - **`NavMenu`'s phone menu**: `drawerLayout` (`accordion`, the default, or `sections`, each panel listed open under its label, the new `drawerSectionHeading` part naming its list, group headings kept where a panel has them); `drawerItems`, the drawer's own entries when they differ from the bar's (a mega panel's area pages, a bar panel's footer links as rows); the `drawerHeader` slot (`{ close }`) for a logo and a call to action in the drawer's header row; the `triggerIcon` slot (`{ item, open }`) replacing the panel buttons' chevron, still turned over while open; `placement` (`bar` or `drawer`) in the `panelItem` and `groupHeading` slot props; new parts `drawerRoot`, `drawerHeader`, `drawerClose`, `drawerBody`, `drawerSectionHeading`. New types `NavMenuDrawerLayout`, `NavMenuPlacement`, `NavMenuPanelPart`, `NavMenuDrawerPanelPart`, `NavMenuPanelItemSlotProps`, `NavMenuGroupHeadingSlotProps`.
13
+ - **`Drawer`'s `header` slot**: content for the header row, after the title and before the close button.
14
+ - **`@eldrajs/ui/components.css`** — `style.css` without Tailwind's preflight, whose reset reached every element on the page (rich-text headings, lists, links and paragraphs lost their browser defaults). Same theme and utilities; the reset only touches elements inside a component: every component's outermost element, and every panel, bubble or toast region it teleports, now carries the public `data-eldra-ui` marker, and the reset reaches those and the `data-part` elements within them, so a site's own `data-part` elements (Ark UI and Zag included) keep their defaults. `Rating`'s stars, `FilterPanel`'s colour ring, `SearchBar`'s no-results text and `SearchModal`'s key hints no longer lean on the global reset, so they draw the same under either stylesheet.
15
+ - **`zoomSizes(sizes, zoom)`** — multiplies every length in an `<img sizes>` list by `zoom`, keeping its media conditions (`(min-width: 1024px) 50vw, 100vw` at zoom 3 is `(min-width: 1024px) calc(50vw * 3), calc(100vw * 3)`); a zoom of 1 or less, `auto` and a size-less condition are left as given. What `Image` now does to its own `sizes`, for a renderer that draws a zoomed crop itself.
10
16
  - **`Breadcrumb`'s `structuredData` prop** (default `true`, so nothing changes by default). `false` omits the component's own `BreadcrumbList` JSON-LD `<script>`, for a page whose theme already writes one at page level (`@eldrajs/theme-core`'s `buildBreadcrumbLd`); two on one page is duplicate markup.
11
17
  - **`RangeSlider`** — the design spec's new "Range slider" section: two thumbs on one track for a numeric span, `modelValue: [number, number]` that cannot cross, `min`/`max`/`step`/`largeStep`, an optional `inputs` row of typed min / "to" / max fields, `formatValue` for every number the control speaks or prints, `disabled`, `label` with `minLabel`/`maxLabel` for the two ends, per-part `classes` and the `messages` prop (five new keys: `minimum`, `maximum`, `minimumOf`, `maximumOf`, `to`). Each thumb is a `role="slider"` reporting **its own** limits — the minimum thumb's `aria-valuemax` is the maximum thumb's current value — with an `aria-valuetext` run through `formatValue`, so a price filter announces "$1,200" rather than "1200", and both ends are their own tab stop because both have to be reachable. `←`/`↓`/`→`/`↑` move by `step`, `Shift` with any of them and `PageUp`/`PageDown` by `largeStep`, `Home`/`End` to the focused thumb's own limits. A pointer press anywhere on the rail moves the **nearer** thumb and keeps dragging it, parking it against its neighbour rather than swapping; the rail is `target-touch` tall below its container's tablet width (`target-min` from it) and each thumb's hit area follows. A typed value commits on **blur or `Enter` only**, never on a keystroke, snapped and clamped to the bounds and to the other thumb, with an emptied field falling back to that end of the range. `update:modelValue` reports every move, `change` once the move is over (pointer release, key release, field commit, and a pointer capture lost without either) — the one anything that costs a request should listen to. The typed fields are the same box as `Input`, in the same states, drawn from the shared field recipes rather than a copy of them, and they ask for the decimal keypad when the step has fraction digits. A slider nobody binds `v-model` to **follows its bounds** until something moves it, so a price filter whose `facets.price` arrives after the first render spans the catalogue instead of collapsing at its cheapest product; a `max` below `min` is treated as an empty range at `min` (with a dev-only warning) rather than reporting a value outside its own thumb limits. Both bounds are stops of their own alongside the step grid, so a catalogue's off-grid highest price can still be chosen, and every result is rounded to the digits the step is written with (a `0.1` step twenty times is `2`, not `1.9999999999999998`).
12
18
  - **`RangeSlider`'s `inputs` slot** — the typed min / "to" / max row is replaceable, and the value is not. A store filtering by price wants its *own* currency field (the symbol, the store's grouping, the caret behaviour a money field has), which the built-in generic number fields cannot be without this package deciding a consumer's money formatting for them. The slot is handed `{ value, min, max, step, disabled, labels, commit }`: `labels` is the two names the thumbs already carry plus the word between the fields (name a replacement field with the same string its thumb uses, or a screen reader hears two names for one end), and `commit(end, next)` — `end` being `0` or `1` — applies that end exactly as a built-in field's blur does: snapped to the step grid, clamped to `[min, max]`, clamped against the other thumb, then `change` emitted once. It returns the number actually applied, which is what a controlled field should show (the parent has not written back yet, and an `Enter` commit leaves the field focused), and `null` is an emptied field, falling back to that end of the range. Call it on **blur or `Enter`**, never per keystroke — a commit per character would snap and clamp a half-typed number. The built-in fields are the slot's default content, so nothing changes for a consumer that does not fill it, and the `inputs` prop still decides whether the row exists at all. New exported types: `RangeSliderInputsSlotProps`, `RangeSliderEnd`.
@@ -31,6 +37,7 @@ Release-please writes the generated notes from commit messages and does not repl
31
37
 
32
38
  ### Changed
33
39
 
40
+ - **`NavMenu`'s drawer names its copies of the panel parts with a `drawer` prefix** (`drawerPanelLink`, `drawerGroupHeading`, `drawerOverview`, `drawerBadge`…), in `data-part` and in `classes` alike, so a bar panel's classes (`panelLink`, `columns`, `groupHeading`…) no longer reach the drawer's rows; move any drawer styling onto the prefixed keys. The `triggerIcon` part is now a `<span>` around the icon rather than the `<svg>` itself, so the `triggerIcon` slot's icon turns with it.
34
41
  - **Icelandic prints the same everywhere.** Every number, price, date and list now formats through `@eldrajs/sdk/format`, a new dependency on `@eldrajs/sdk`, so Chrome and Cloudflare Workers (which ship without Icelandic locale data) print `2.800 kr.` and `12. sep. 2026` exactly as Node, Safari and Firefox do, and a server-rendered page hydrates without a mismatch. This replaces the Danish (`da-DK`) fallback, which matched Icelandic only for narrow currency signs and plain decimals. `formatDate` now builds and formats its date in UTC.
35
42
  - **The wide currency sign is the default.** `Price`, `CurrencyInput` and `UnitInput` default `narrowSymbol` to `false`, and `RangeFacet` passes `false`: an English price reads `ISK 2,800`, not `kr 2,800`, which is also the Danish, Norwegian and Swedish krone. `is-IS` is unaffected (`2.800 kr.` either way). `formatCurrency` and `currencySymbol` keep the private library's narrow default.
36
43
  - **`FilterPanel`'s price range fills its panel, and the en dash sits between the fields.** The track and histogram are inset by the thumb's radius (new `eldra-range-gutter-thumb` utility, swappable against `eldra-range-gutter` through `classes.group`) rather than by half a touch target, and the separator is a control-height box on the fields' own baseline.
@@ -82,6 +89,9 @@ Release-please writes the generated notes from commit messages and does not repl
82
89
 
83
90
  ### Fixed
84
91
 
92
+ - **`Image` with a `zoom` above 1 is sharp.** Under `fit: 'cover'` (the default) it multiplies every length in its effective `sizes` (the prop, else `media.sizes`) by the zoom, so the browser picks a `srcset` candidate for the magnified crop rather than for the frame, whose variant was up to `zoom` times too narrow. Write `sizes` for the frame as before; `fit: 'contain'` and a zoom of 1 leave it unchanged. See `docs/images.md`, "An art-directed crop".
93
+ - **A weight utility beside a type style now applies.** Most `text-*` type styles set the `font` shorthand, which Tailwind cannot place in its property order and so emits after every `font-*` weight utility: `text-body font-medium` rendered at 400. The type styles now set longhands and read their weight as `var(--tw-font-weight, <token>)`, so the weight utility wins in any order, a consumer's `classes` weight override included. Visible changes, each now the weight the component asks for: `NavMenu`'s bar entries and panel labels (500) and panel overview link (600); `Breadcrumb`'s current page (500) and ellipsis (600); `Rating`'s value, `Toast`'s action, `EditorPlaceholder`'s label, the search results' **See all** row, a selected single-`Select` option and a warning/danger option meta, `FilterPanel`'s checked colour and list labels (600); `SearchModal`'s **Cancel** and a selected `MultiSelect` option (500). `tabular-nums` beside a type style is no longer reset either: `QuantityStepper`'s value, `RadioGroup`'s card meta, the compact `Pagination` and the `CurrencyInput`/`UnitInput`/`RangeSlider` fields now print tabular figures. `LoadMore`'s button drops a `font-medium` the shorthand used to hide, so it stays at the outline button's 600.
94
+ - **`cx` merges the kit's own theme keys.** `shadow-float` and the `narrow`/`content`/`wide`/`tablet`/`two-col` container widths (`w-*`, `min-w-*`, `max-w-*`, `basis-*`) were unknown to `tailwind-merge`, so `cx('shadow-md', 'shadow-float')` kept both and a `classes` override landed beside the default instead of replacing it.
85
95
  - **`Lightbox`** — the image sits centred with equal space above and below. Without a thumbnail strip the stage now has bottom padding matching the bar's height (4rem, 4.25rem below 48rem), where the image used to run to the bottom edge of the viewport.
86
96
  - **`Drawer`** — the open dialog stretches between its pinned top and bottom edges instead of taking `100%` of the layout viewport, so a foot pinned to the panel's bottom edge (the filter drawer's **Clear all** / **Show N products**, the cart's **Check out**) sits at the bottom of the visible area on a phone — not under the browser's toolbar, and not above a strip of page.
87
97
  - **`Tabs` no longer clips a focused pill's focus ring at the scrolling list's edge.** The tab list is `overflow-x-auto`, which forces `overflow-y` to compute `auto` as well, so it clips anything a tab paints outside its own border box — on every side, not just the two it scrolls on. The design spec's answer is padding on the list with a matching negative margin, and that was written as the literal `0.25rem` the two ring tokens add up to by default, leaving the ring flush against the clip edge with no slack: raise `--eldra-focus-offset` or `--eldra-focus-width` — a restyle, or simply a `Tabs` inside a `Carousel` slide, since the track sets `--eldra-focus-offset: 4px` and custom properties inherit — and the ring was cut off flat by the difference on three edges at once. The reservation is now `calc(var(--eldra-focus-offset) + var(--eldra-focus-width))`, per axis, with `scroll-padding` to match so the inline half cannot be scrolled out of the visible box; the list's rendered footprint is unchanged. The underline variant is untouched and reserves nothing, its tabs carrying the spec's own inset ring. Measured in a real browser with real `Tab` presses, in pixels (`tabsRing.browser.spec.ts`) — it needs Chromium, like the kit's other browser specs.
package/README.md CHANGED
@@ -27,7 +27,7 @@ entry needs it, and nothing else in the package imports it.
27
27
 
28
28
  ## Styles
29
29
 
30
- Three CSS entries ship; pick the one that matches how the consumer builds CSS. Every one of them
30
+ Four CSS entries ship; pick the one that matches how the consumer builds CSS. Every one of them
31
31
  starts from the same `--eldra-*` variables, so nothing here is a different theme, only a different
32
32
  delivery shape.
33
33
 
@@ -47,6 +47,15 @@ delivery shape.
47
47
  @import '@eldrajs/ui/tailwind.css';
48
48
  ```
49
49
 
50
+ The type styles (`text-body`, `text-h2`, …) set longhands, never the `font` shorthand, and read
51
+ their weight as `var(--tw-font-weight, <token>)`, the declaration Tailwind writes for its own
52
+ `--text-*--font-weight`. So a `font-medium`/`font-semibold` beside one wins whatever order the two
53
+ compile in, and a `tabular-nums` beside one is no longer reset. A base-layer
54
+ `@apply font-*` sets `--tw-font-weight` as well, so it reaches a type style on the same element.
55
+ Line height and tracking are plain longhands on purpose: the starter's own base rule
56
+ (`h1`–`h4` `@apply leading-[1.1] tracking-tight`) would otherwise override every heading's type
57
+ style.
58
+
50
59
  - **`@eldrajs/ui/style.css`** — the package's own compiled build of `tailwind.css` plus every
51
60
  component's utilities, for a consumer with no Tailwind build of their own:
52
61
 
@@ -57,6 +66,43 @@ delivery shape.
57
66
  This is also what a project whose own Tailwind build cannot share this package's utility prefix
58
67
  (a `ui:`-prefixed theme, for example) reaches for.
59
68
 
69
+ - **`@eldrajs/ui/components.css`** — `style.css` without Tailwind's preflight, for a site that has
70
+ its own stylesheet and adds a few components (a header menu, a cart drawer) to it:
71
+
72
+ ```css
73
+ @import '@eldrajs/ui/components.css';
74
+ ```
75
+
76
+ Preflight is a reset for the **whole page**: `style.css` sets every `h1`–`h6` to the surrounding
77
+ size and weight, every `ul`/`ol` to no bullets and no indent, every `a` to the surrounding colour
78
+ with no underline, every `p` and heading to no margin, and every `button` to no border or fill.
79
+ It sits in `@layer base`, so a site's own rules still win where they exist, but anything the site
80
+ left to the browser — rich text from the CMS, most often — loses its defaults. `components.css`
81
+ carries the same theme and the same utilities, byte for byte, and narrows the reset to the
82
+ elements the components render themselves, so the site's own elements keep the browser's
83
+ defaults and anything passed into a component's slot keeps the site's styling. Use `style.css`
84
+ when the page is built from this package; use `components.css` when the page is the site's own.
85
+ `src/styles/__tests__/componentsCss.browser.spec.ts` renders every component family under both,
86
+ the overlays open, and requires identical pixels.
87
+
88
+ **The `data-eldra-ui` marker.** Every component's outermost element carries `data-eldra-ui`, and
89
+ so does every element a component renders outside it: a `Select` or `MultiSelect` panel, a
90
+ `SearchBar` results panel, a `Popover` panel, a `Tooltip` bubble and the `Toaster` region, each
91
+ teleported out of its component. The reset reaches exactly those elements and the `data-part`
92
+ elements inside them, `:where([data-eldra-ui], [data-eldra-ui] [data-part])`, at zero
93
+ specificity. `data-part` alone is not enough, because it is not this package's name: a site's
94
+ own `<h2 data-part="title">`, or any Ark UI or Zag component (which put `data-part` on every
95
+ element they render), keeps the browser's defaults. The attribute is public and stable, so a
96
+ site can use it as a hook too (`a:not([data-eldra-ui], [data-eldra-ui] *)` keeps a site's global
97
+ link rule out of the components). One case stays inside the scope: an element carrying its own
98
+ `data-part` that the site passes into a component's slot (an Ark UI widget inside a `Dialog`,
99
+ say) is a `data-part` element inside a marked root, so it gets the reset as well.
100
+
101
+ Either way, the package's rules are in cascade layers and a site's **unlayered** rules beat them
102
+ regardless of specificity: a global `a { color: … }` or `button { font: … }` in the site's own CSS
103
+ restyles those elements inside the components too. Scope such rules (`.prose a`) or put the
104
+ site's stylesheet in a layer declared before the package's.
105
+
60
106
  ## Fonts
61
107
 
62
108
  The type tokens' defaults are `--eldra-font-heading: "Bricolage Grotesque", ui-sans-serif,
@@ -115,6 +161,7 @@ Every component supports all five of these; none hard-codes anything a store mig
115
161
  | `Link` | `--eldra-link-radius` (default `2px`) — the focus ring's corner radius on every variant |
116
162
  | `LoadMore` | none — the status/meter/button sizes all reuse shared tokens (`text-body-sm`, `control-h`, `text-button-md`), no per-component variable |
117
163
  | `LogoItem` | `--eldra-logo-image-max-height` (default `2.5rem`), `--eldra-logo-image-max-width` (default `9rem`) — the logo image's contain box; `--eldra-logo-wordmark-size` (default `1.25rem`) — the wordmark fallback's font size (its weight, line-height and letter-spacing reuse `h2`/`h3` tokens directly, see `text-logo-wordmark` in `tailwind.css`) |
164
+ | `NavMenu` | `--eldra-nav-menu-offset` (default `var(--eldra-space-2)`) — the gap between the bar and a panel, drawn as the panel's own top padding so a hovering pointer never leaves the menu; `--eldra-nav-menu-dropdown-min`/`-max` (defaults `14rem`/`24rem`, capped at `100vw - 2rem`) — a dropdown panel's width; `--eldra-nav-menu-column-min` (default `12rem`) — the narrowest a mega panel's column gets before the grid wraps (`classes.columns: 'grid-cols-5'` fixes the count instead). The drawer, its accordion rows and the badges are `Drawer`, `AccordionItem` and `Badge`, each restyled through its own row |
118
165
  | `MultiSelect` | everything `Select` reads, plus `--eldra-select-pill-line` (the "+N" pill's line box) and `--eldra-checkbox-radius`/`--eldra-checkbox-border-width`, shared with `Checkbox` so a consumer restyles both at once |
119
166
  | `Pagination` | none — every size (the 2.5rem page link/`control-h` previous-next, the `target-touch` compact arrows, the 0.9375rem `text-control` compact status) reuses a shared token or a shared arbitrary spacing multiple, no per-component variable |
120
167
  | `Popover` | `--eldra-z-popover` (default `30`), shared with the other popover panels — no per-component variable of its own: it has no fixed size to clamp, unlike `Select`'s panel |
@@ -161,7 +208,10 @@ Every component supports all five of these; none hard-codes anything a store mig
161
208
  `<Name>Part` type and its Storybook docs page for the exact list). Values merge onto that part's
162
209
  own classes with `tailwind-merge` (via this package's own `cx`, also exported for a consumer
163
210
  composing a wrapper the same way), so `classes.root: 'rounded-full'` replaces
164
- `eldra-button-radius` instead of landing beside it.
211
+ `eldra-button-radius` instead of landing beside it. The `@theme` keys that are not t-shirt sizes
212
+ (`shadow-float`, the `narrow`/`content`/`wide`/`tablet`/`two-col` container widths) merge the
213
+ same way, and a weight is never a conflict with a type style: `classes.label: 'font-bold'` keeps
214
+ `text-body-sm` and changes only the weight.
165
215
  4. **A slot for every part that holds content** (`label`, `description`, `error`, `leading`,
166
216
  `trailing`, `empty`, `header`, `footer`, `item`, …), named after the part it replaces.
167
217
  5. **`as`**, on the components whose spec allows a different rendered _root_ element (`Button`,
@@ -170,7 +220,7 @@ Every component supports all five of these; none hard-codes anything a store mig
170
220
  to `<span>` and is never a link; `Section` picks `<section>`/`<div>` itself from whether it is
171
221
  named (`as` overrides that choice outright, for a `<header>`/`<footer>` landmark that needs no
172
222
  name of its own). **`linkAs`**, not `as`, on `ContentCard`/`FeatureCard`/`ProductCard`/
173
- `Breadcrumb`/`Pagination`: each of these has a spec-fixed root (`<article>`/`<div>`/`<nav>`), and
223
+ `Breadcrumb`/`Pagination`/`NavMenu`: each of these has a spec-fixed root (`<article>`/`<div>`/`<nav>`), and
174
224
  `linkAs` instead picks the element for a _nested_ part — the stretched title link on the cards,
175
225
  every level's link on `Breadcrumb`, a page/previous/next control on `Pagination` — so the name
176
226
  never collides with the root-tag meaning `as` carries everywhere else (a string still takes
@@ -1151,6 +1201,26 @@ aria-pressed>` that fills `primary`/`primary-contrast` when `selected`, the same
1151
1201
  - **`frameAspectRatio`** (`src/utils/ratio.ts`) — turns an `ImageRatio` preset into the CSS
1152
1202
  `aspect-ratio` value `Image`'s frame and `Skeleton`'s `media` variant both resolve it to; exported
1153
1203
  so a consumer accepting an `ImageRatio` of their own (`ImageRatio` itself is public) can honour it.
1204
+ - **`zoomSizes(sizes, zoom)`** (`src/utils/sizes.ts`) — multiplies every length in an `<img sizes>`
1205
+ list by `zoom`, keeping its media conditions: `(min-width: 1024px) 50vw, 100vw` at zoom 3 becomes
1206
+ `(min-width: 1024px) calc(50vw * 3), calc(100vw * 3)`. `Image` applies it to its effective `sizes`
1207
+ whenever `fit` is `cover` and `zoom` is above 1, because a crop scaled by `transform: scale(zoom)`
1208
+ is drawn that many times wider than the frame `sizes` describes, and a `srcset` candidate chosen
1209
+ for the frame is soft. A zoom of 1 or less, `auto` and a size-less media condition are left as
1210
+ given. See [An art-directed crop](../../docs/images.md#an-art-directed-crop).
1211
+ - **`Image`'s `zoomOrigin`, `crops` and a numeric `ratio`** — `zoomOrigin: 'focal'` zooms around the
1212
+ focal point itself; the default `'band'` keeps the origin inside the band
1213
+ `@eldrajs/theme-core`'s image framing clamps to, so a page-builder framing renders exactly as
1214
+ Studio previews it. The band is not needed to keep the frame covered (a zoom of 1 or more around
1215
+ any point of the frame covers it), only for that parity. Under `'focal'` the zoom sizes the media
1216
+ rather than scaling it with a transform, because the browser rounds the cover's offset to a pixel
1217
+ first and a transform would multiply the rounding by the zoom. `crops` art-directs the one
1218
+ `<img>`: each `ImageCrop` (`media`, and any of `ratio`, `focal`, `zoom`, `sizes`) replaces the
1219
+ instance's values where its media condition matches, first match first, written as a `<style>`
1220
+ scoped to the instance and as `sizes` entries scoped to the condition. A condition with any character
1221
+ but letters, digits, `_`, spaces and `().:<>=/+*-`, or with `/*` or `</`, is refused with a dev
1222
+ warning. `ratio` also takes a number, width ÷ height. See
1223
+ [An exact crop](../../docs/images.md#an-exact-crop).
1154
1224
  - **`formatDate`** (`src/utils/date.ts`) — the ISO-date formatter behind `ContentCard`'s `date` prop.
1155
1225
  Never throws: a malformed, empty or calendar-invalid value (`'2026-02-30'`) returns `null` rather
1156
1226
  than a fabricated date or a thrown `RangeError`, warning once per bad value in dev.
@@ -1199,6 +1269,83 @@ aria-pressed>` that fills `primary`/`primary-contrast` when `selected`, the same
1199
1269
  inside), but `tabRedirect` is always on, since a menu's rows or a filter form's fields are exactly
1200
1270
  the real tab stops that behaviour exists for.
1201
1271
 
1272
+ - **`NavMenu`** — a site header's navigation (2026-10-22), because every Eldra site was
1273
+ hand-building its header and dropdowns. Spec 1 names mega-menus only to say they are non-modal
1274
+ popups, not dialogs, and puts the mobile menu in a left `Drawer` with accordion rows; this
1275
+ follows both. It is the disclosure-navigation pattern, not an ARIA menu: a top-level entry with
1276
+ children is a `<button aria-expanded aria-controls>` and its panel follows it in the DOM, so `Tab`
1277
+ walks straight into the panel and on to the next entry, the panel closes when focus or a pointer
1278
+ press lands outside it (`useOverlay`, unchanged), `Escape` closes it and returns focus to the
1279
+ button, following a link closes it, and one panel is open at a time. On top of that it takes the
1280
+ APG pattern's optional arrow keys, ported from the starter's header: `←`/`→` move along the bar
1281
+ (landing on another trigger carries an open panel over to it), `Home`/`End` jump to its ends,
1282
+ `↓`/`↑` on a trigger open its panel at the first or last link, and inside a panel `↓`/`↑` step
1283
+ through its links and `Home`/`End` reach its ends. Nothing wraps, every link stays in the `Tab`
1284
+ order, and a modified key or a key typed into a field is left alone. `Enter`/`Space` stay the
1285
+ button's own. Panels are never teleported:
1286
+ a `dropdown` hangs under its own item, a `mega` panel spans the menu's root, and a site whose
1287
+ header should be the panel's width makes the root `static` (`classes.root`) and its header
1288
+ `relative` (or `contents`, which makes the bar and the menu button cells of the header's own
1289
+ grid). A closing panel fades out over `--eldra-duration-fast`, unclickable while it does.
1290
+ `openOnHover` adds a resting mouse pointer to the ways of opening: a panel opens after the
1291
+ pointer rests 150ms on its trigger, so passing over one opens nothing; leaving the menu closes a
1292
+ hover-opened panel 150ms later unless the pointer comes back or focus is inside it; a click keeps
1293
+ it, and touch never hovers.
1294
+
1295
+ **Data.** `items` takes `{ label, href?, newTab?, description?, badge?, group?, current?,
1296
+ children?, layout? }`, one level of children. Children sharing a `group` form a column under that
1297
+ heading, and grouped children default the panel to `mega`. The shape is the one
1298
+ `@eldrajs/theme-core`'s `resolveLink` returns for a Studio link tree — `href`, `label` and `group`
1299
+ may be `null`, a heading with no `href` opens a panel and links nowhere, an entry without a label
1300
+ is skipped — so a resolved tree is passed in as it is, with no dependency on the theme packages
1301
+ (`navLinks.spec.ts` asserts the assignability). A top-level entry with both `href` and children
1302
+ gets its own page as the panel's first link ("Journal: overview"). A `panelFooter` that renders
1303
+ nothing for a panel takes no room in it (`empty:hidden`), and a menu with no entry to show draws
1304
+ no empty `<nav>`.
1305
+
1306
+ **Narrow screens.** Below `collapseBelow` the bar is hidden and a menu button
1307
+ (`aria-controls` the drawer) opens a left `Drawer`. `md`, `lg` (default) and `xl` are **viewport**
1308
+ breakpoints, since the menu's own width says nothing about how crowded the header is; `@tablet`,
1309
+ `@content` and `@wide` measure the nearest `@container` instead, for a header block whose own
1310
+ width is the measure; `never` keeps the bar and `always` shows only the button. The button is
1311
+ named by `messages.navMenuOpen` and the drawer by `messages.navMenuDrawer` (both "Menu").
1312
+ `v-model` is the open panel's index and `v-model:drawerOpen` the drawer; `close()` (exposed)
1313
+ closes both, for a router's navigation hook.
1314
+
1315
+ **The phone menu.** `drawerLayout` picks how the drawer shows a panel: `accordion` (default)
1316
+ folds each into an `AccordionItem` row, `sections` lists each open under its label (the
1317
+ `drawerSectionHeading` part, which names the section's list), keeping a panel's group headings
1318
+ when it has them and drawing none when it has not; plain entries are rows in both. A phone menu
1319
+ rarely wants the bar's exact entries — a mega panel's sixteen links may be five area pages on a
1320
+ phone, and the links in a bar panel's footer still need a row somewhere — so `drawerItems`, when
1321
+ given, is what the drawer draws instead of `items` (same shape, same rules; the bar keeps
1322
+ `items`). The `drawerHeader` slot fills the drawer's header row before its close button — a logo
1323
+ and a call to action, so the open menu keeps the header's own row — and is handed `close`, since
1324
+ only the menu's own links close the drawer when followed. The drawer focuses its first control
1325
+ when it opens, which is the header's first link when the slot holds one. `panelItem` and
1326
+ `groupHeading` are handed `placement` (`bar` or `drawer`), for content that differs between the
1327
+ two, and `triggerIcon` replaces the panel buttons' chevron inside the `triggerIcon` part, which
1328
+ keeps its size and turns over while its panel is open.
1329
+
1330
+ **Variants.** `variant` names the two common looks, each after the component that already has
1331
+ it: `ghost` (default) is `Button`'s ghost — text colour, the same 6% text fill on hover and while
1332
+ a panel is open — and `muted` is `Link`'s muted tone — muted text turning the text colour on
1333
+ hover, while open and on the current page, with no fill, for a header of quiet text links. Both
1334
+ reach the panels' links; neither changes the weight, so nothing shifts as a panel opens; the
1335
+ current page keeps its underline in both, since colour alone cannot mark it. The drawer's rows
1336
+ are the same under either. Spacing, size and type are left to `classes`.
1337
+
1338
+ The drawer draws a panel's content with the same parts as the bar, each named with a `drawer`
1339
+ prefix (`drawerPanelLink`, `drawerGroupHeading`, `drawerPanelLabel`…, `NavMenuDrawerPanelPart`),
1340
+ so a bar panel's classes never reach the drawer's rows. `classes.badge`/`drawerBadge`,
1341
+ `drawerRoot` (the `<dialog>`, its backdrop and entrance), `drawer`, `drawerHeader`, `drawerClose`,
1342
+ `drawerBody`, `drawerFooter`, `drawerTrigger` and `drawerPanel` restyle the composed `Badge`,
1343
+ `Drawer` and `AccordionItem`, which keep their own `data-part` names.
1344
+
1345
+ - **`Drawer`'s `header` slot** — content for the header row, after the title and before the close
1346
+ button: the logo and call to action a menu drawer repeats from the page header it covers
1347
+ (`NavMenu`'s `drawerHeader`). The spec's anatomy gives the row a title and the close button only.
1348
+
1202
1349
  - **`narrowSymbol` on `Price`, and `Price` formatting through `formatCurrency`** — `false` by
1203
1350
  default, the same default `CurrencyInput` carries, so every currency this package renders is
1204
1351
  written with the currency's **wide** sign: `"ISK 2,800"` under `en-US`/`ISK`, not `"kr 2,800"`,