{#- chirp-ui: Sidebar component Vertical sidebar navigation for dashboards and admin panels. Boosted links use hx-select="#page-content" so full-page GET responses only swap the page content inside #main (avoids nesting a second shell). Active state: use match= for automatic path comparison (requires current_path in template context), or active= for explicit control. match="exact" — active when current_path == href match="prefix" — active when current_path starts with href (or equals it) active=true — always active (explicit override) Named slots: header, footer, default (nav content). Usage: from "chirpui/sidebar.html" import sidebar, sidebar_link, sidebar_section, shell_brand_link, shell_boosted_link call sidebar() {% slot header %}
{% end %} call sidebar_section("Main") sidebar_link("/", "Home", match="exact") sidebar_link("/dashboard", "Dashboard", match="prefix") sidebar_link("/admin", "Admin", active=is_admin) end {% slot footer %}v1.0{% end %} end -#} {% def sidebar(cls="") %} {% end %} {% def sidebar_section(title="", collapsible=false, cls="") %} {% if collapsible %} {% else %} {% end %} {% end %} {% def sidebar_link(href, label, icon="", active=false, match="", boost=true, cls="") %} {% set _cp = current_path | default("") if match else "" %} {% set _active = active if not match else ((_cp == href) if match == "exact" else (_cp == href or _cp.startswith(href ~ "/")) if match == "prefix" else active) %} {% if icon %}{% end %} {% end %} {# Topbar brand — same HTMX contract as sidebar_link (full-page GET + select #page-content). #} {% def shell_brand_link(href="/", cls="", boost=true) %} {% slot %} {% end %} {# In-page boosted nav (buttons, evolution links) — same contract; slot for HTML labels. #} {% def shell_boosted_link(href, cls="", boost=true) %} {% slot %} {% end %} {% def sidebar_toggle(cls="") %} {% end %}