Skip to content

feat(sidebar): flatten the top-level nav heading - #66

Merged
mhenrixon merged 1 commit into
mainfrom
issue-65-flatten-sidebar-heading
Aug 3, 2026
Merged

feat(sidebar): flatten the top-level nav heading#66
mhenrixon merged 1 commit into
mainfrom
issue-65-flatten-sidebar-heading

Conversation

@mhenrixon

Copy link
Copy Markdown
Collaborator

Closes #65

Summary

The sidebar rendered its top-level heading as a collapsible <details> wrapping every subgroup, so a one-registry site (every current consuming site) got a redundant chevroned "DOCUMENTATION" level and one extra indent on the whole nav.

Now subgroups are the top level of the menu:

  • One non-empty heading → the heading is not rendered at all; "Getting started", "REST API", … sit directly in the menu.
  • Several headings → each renders as a static daisyUI menu-title label with mt-4 first:mt-0 breathing room — no fold; only subgroups collapse.
  • Landing doc index gets the same rule: the per-group h3 is skipped when there is exactly one heading, fixing the stacked "DOCUMENTATION / DOCUMENTATION" duplicate under the hero.

Intentionally unconditional (settled in the plan interview): no config knob — all consuming sites get the flattened chrome on upgrade.

What did NOT change

  • nav_groups keeps its { "Heading" => { "Subgroup" => [NavItem] } } shape — explicit c.nav lambdas work verbatim.
  • No JS change: docs-nav keys collapse persistence by summary text, so the removed top-level <details> just orphans one harmless localStorage key.
  • No CSS-contract change: menu-title was already @source inline'd in the generated stylesheet, and the new utilities are literals in gem Ruby scanned by the bin/build-css globs.

Test Coverage

  • spec/docs_ui/sidebar_spec.rb — single heading dropped; subgroups render as top-level <details open>; multiple headings render as menu-title <li>s (never <summary>s) with the spacing classes; empty headings excluded from the count; every <details> stays open (JS-off regression guard).
  • spec/docs_ui/landing_spec.rb (new) — single heading: "Documentation" appears once, no h3; multiple headings: both h3 labels render.

Verification

  • bundle exec rspec — 806 examples, 0 failures (94.0% line coverage)
  • bundle exec rubocop — no offenses
  • CSS contract checked by inspection — no new @source needed

Deviations & judgment calls

  • Sidebar single-heading count: an explicit c.nav lambda can contain empty headings (e.g. { "Docs" => {…}, "Empty" => {} }), which the registry-derived path never produces. Empty headings are excluded from the count, so one real + one empty heading still gets the single-heading rule (heading dropped). Covered by a spec.
  • Landing spacing: when the per-group h3 is skipped, the column ul also drops its mt-3 top margin — otherwise the links float an extra 12px below the h2 for no reason. Both class lists stay fully literal for the Tailwind scanner.
  • Discovery: the plan's prediction held — menu-title and all utilities were already covered by the generated CSS contract, so no generator/template change was needed.

A single top-level heading (the common one-registry site) rendered as a
collapsible <details> wrapping every subgroup, indenting the whole nav one
level too deep and adding a redundant "DOCUMENTATION" fold. Now subgroups
are the menu's top level: a lone heading is dropped entirely, and several
headings render as static `.menu-title` labels (mt-4 spacing, no fold) —
only subgroups collapse.

Same rule for the Landing doc index, which printed its "Documentation" h2
directly above a same-text per-group h3 on single-heading sites.

No config, JS, or CSS-contract change: nav_groups keeps its shape, docs-nav
keys persistence by summary text (the removed details just orphans one stale
localStorage key), and menu-title was already @source inline'd.

Refs #65
@mhenrixon
mhenrixon merged commit f942145 into main Aug 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sidebar): flatten the top-level nav heading — drop it when single, static label when multiple

1 participant