{# @description The app sidebar: django-mvp-layout's left sidebar holding the brand header, AppMenu and a fixed footer. #} {# @prop bg:text | default:"mvp-sidebar-bg" | description:"Background class, passed to the header and footer." #} {# @prop brand-url:text | default:"/" | description:"URL the brand mark links to." #} {# @prop class:text | description:"Extra classes on the sidebar's aside." #} {# @prop menu:text | default:"" | description:"Menu name to render. Empty renders AppMenu (or the mounted app's menu) with no back link." #} {# @prop :collapse:text | description:"How the sidebar collapses: icons for an icon rail, none to keep it open at/above the breakpoint, otherwise the default drawer behaviour." #} {# @prop :title:text | description:"Title text shown in the sidebar header." #} {# @prop :boost:boolean | description:"Set hx-boost on the sidebar root so every link inside it — menu items, brand link, footer actions — navigates with htmx." #} {# @slot:header — Replaces the top strip: brand icon, title, collapse toggle. #} {# @slot:body — Replaces the scrolling middle: the back link for a mounted app, then the menu. #} {# @slot:footer — Replaces the fixed bottom strip: the account button, or log-in. #} {% load i18n flex_menu %} {# The slots are declared so that an unfilled one is empty, rather than a #} {# page variable that happens to be called `header`, `body` or `footer`. #} {# The sidebar lives inside , and htmx swaps the body's innerHTML, so a #} {# boosted click draws it afresh in the state its cookie remembers. #} {# This is django-mvp-layout's left sidebar. view="HbF" stacks the header, #} {# the menu and the footer straight inside its panel, and keeps the header #} {# and the footer in place while the panel scrolls. #} {% with sb=mvp_config.layout.sidebar %} {% if header.strip %} {{ header }} {% else %} {% endif %} {# mounted_app / mounted_menu come from mvp.context_processors.mvp_config, #} {# which also runs inside Cotton's isolated context because Cotton builds a #} {# request context for the component. #}
{% if body.strip %} {{ body }} {% elif menu is None or menu == "" %} {% if mounted_app %}{% endif %}
{% if mounted_menu %} {% render_menu mounted_menu renderer="sidebar" %} {% else %} {% render_menu "AppMenu" renderer="sidebar" %} {% endif %}
{% else %}
{% render_menu menu renderer="sidebar" %}
{% endif %}
{% if footer.strip %} {{ footer }} {% else %} {% endif %}
{% endwith %}