Add nav-tree, auth-menu, cart-mini fragment slots to shared header

The shared _header.html template now checks for pre-fetched fragment
HTML (nav_tree_html, auth_menu_html, cart_mini_html) before falling
back to local includes. This lets consumer apps render cross-app
UI via the fragment composition system.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-24 11:34:45 +00:00
parent 0d40dfaeca
commit 7e650a0ee3

View File

@@ -9,8 +9,12 @@
{% call links.menu_row(id='root-row', oob=oob) %} {% call links.menu_row(id='root-row', oob=oob) %}
<div class="w-full flex flex-row items-top"> <div class="w-full flex flex-row items-top">
{# Cart mini #} {# Cart mini #}
{% from '_types/cart/_mini.html' import mini with context %} {% if cart_mini_html %}
{{mini()}} {{ cart_mini_html | safe }}
{% else %}
{% from '_types/cart/_mini.html' import mini with context %}
{{mini()}}
{% endif %}
{# Site title #} {# Site title #}
<div class="font-bold text-5xl flex-1"> <div class="font-bold text-5xl flex-1">
@@ -20,11 +24,19 @@
{# Desktop nav #} {# Desktop nav #}
<nav class="hidden md:flex gap-4 text-sm ml-2 justify-end items-center flex-0"> <nav class="hidden md:flex gap-4 text-sm ml-2 justify-end items-center flex-0">
{% include '_types/root/_nav.html' %} {% if nav_tree_html %}
{% if not g.user %} {{ nav_tree_html | safe }}
{% include '_types/root/_sign_in.html' %}
{% else %} {% else %}
{% include '_types/root/_full_user.html' %} {% include '_types/root/_nav.html' %}
{% endif %}
{% if auth_menu_html %}
{{ auth_menu_html | safe }}
{% else %}
{% if not g.user %}
{% include '_types/root/_sign_in.html' %}
{% else %}
{% include '_types/root/_full_user.html' %}
{% endif %}
{% endif %} {% endif %}
{% include "_types/root/_nav_panel.html"%} {% include "_types/root/_nav_panel.html"%}
</nav> </nav>
@@ -33,10 +45,14 @@
{% endcall %} {% endcall %}
{# Mobile user info #} {# Mobile user info #}
<div class="block md:hidden text-md font-bold"> <div class="block md:hidden text-md font-bold">
{% if g.user %} {% if auth_menu_html %}
{% include '_types/root/mobile/_full_user.html' %} {{ auth_menu_html | safe }}
{% else %} {% else %}
{% include '_types/root/mobile/_sign_in.html' %} {% if g.user %}
{% include '_types/root/mobile/_full_user.html' %}
{% else %}
{% include '_types/root/mobile/_sign_in.html' %}
{% endif %}
{% endif %} {% endif %}
</div> </div>
{% endmacro %} {% endmacro %}