Class: DocsUI::Sidebar

Inherits:
Phlex::HTML
  • Object
show all
Includes:
DaisyUI, Phlex::Rails::Helpers::Request
Defined in:
app/components/docs_ui/sidebar.rb

Overview

The drawer sidebar: a brand header (with an optional version badge) over the nav, driven entirely by DocsKit.configuration.nav_groups. Renders inside the daisyUI drawer-side (DocsUI::Shell owns responsive visibility), so this is just the panel content.

nav_groups is an ordered Hash:

{ "Heading" => { "Subgroup" => [DocsKit::NavItem, ...] } }

Subgroups are the top level of the rendered menu. A lone heading (the common single-registry site) is not rendered at all — the brand masthead already labels the sidebar; with several headings, each renders as a STATIC .menu-title label (no fold) and only subgroups collapse.

Constant Summary collapse

MARKER_RESET =

Suppress the browser's native

disclosure triangle on nav summaries. daisyUI draws its OWN rotating chevron (li>details>summary::after), so the native marker would render a SECOND, non-rotating caret stacked next to it. daisyUI only hides the old ::-webkit-details-marker; modern browsers (and Safari) also need list-none + the standard ::marker reset. Literal classes — Tailwind tree-shakes interpolated ones.

"list-none [&::-webkit-details-marker]:hidden [&::marker]:content-none"

Instance Method Summary collapse

Instance Method Details

#view_templateObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/docs_ui/sidebar.rb', line 28

def view_template
  # The docs-nav Stimulus controller lives on <body> (DocsUI::Shell) so it spans
  # this sidebar AND the content column. Here it drives collapse persistence
  # and, in :sidebar mode, hosts the injected page TOC. With JS off the server
  # renders every <details open>, so the sidebar is simply fully expanded.
  div(class: "bg-base-200 flex min-h-full w-72 flex-col") do
    header_section
    div(class: "flex-1 overflow-y-auto px-2 pb-6") do
      Menu(class: "w-full gap-1") do
        groups = nav_groups.reject { |_, grouped| grouped.nil? || grouped.empty? }
        groups.each { |heading, grouped| nav_group(heading, grouped, labeled: groups.size > 1) }
      end
    end
  end
end