mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-01-16 03:23:59 +01:00
73 lines
3.5 KiB
Django/Jinja
73 lines
3.5 KiB
Django/Jinja
{% macro render_icon_and_name(item) %}
|
|
<i class="{{ item.icon.class if item.icon is defined and item.icon.class is defined else 'fa-solid fa-link' }}"></i>
|
|
{% if item.name is defined %}
|
|
{{ item.name }}
|
|
{% else %}
|
|
Unnamed Item: {{item}}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
<!-- Template for children -->
|
|
{% macro render_children(children) %}
|
|
{% for children in children %}
|
|
{% if children.children %}
|
|
<li class="dropdown-submenu position-relative">
|
|
<a class="dropdown-item dropdown-toggle" title="{{ children.description }}">
|
|
{{ render_icon_and_name(children) }}
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
{{ render_children(children.children) }}
|
|
</ul>
|
|
</li>
|
|
{% elif children.identifier or children.warning or children.info %}
|
|
<li>
|
|
<a class="dropdown-item" onclick='openDynamicPopup({{ children|tojson|safe }})' data-bs-toggle="tooltip" title="{{ children.description }}">
|
|
{{ render_icon_and_name(children) }}
|
|
</a>
|
|
</li>
|
|
{% else %}
|
|
<li>
|
|
<a class="dropdown-item" href="{{ children.url }}" target="{{ children.target|default('_blank') }}" data-bs-toggle="tooltip" title="{{ children.description }}">
|
|
{{ render_icon_and_name(children) }}
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endmacro %}
|
|
|
|
<!-- Navigation Bar -->
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
<div class="container-fluid">
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav{{menu_type}}" aria-controls="navbarNav{{menu_type}}" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav{{menu_type}}">
|
|
<ul class="navbar-nav {% if menu_type == 'header' %}ms-auto{% endif %}">
|
|
{% for item in navigation[menu_type].children %}
|
|
{% if item.url %}
|
|
<!-- Single Item -->
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="{{ item.url }}" target="{{ item.target|default('_blank') }}" data-bs-toggle="tooltip" title="{{ item.description }}">
|
|
{{ render_icon_and_name(item) }}
|
|
</a>
|
|
</li>
|
|
{% else %}
|
|
<!-- Dropdown Menu -->
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle" id="navbarDropdown{{ loop.index }}" role="button" data-bs-toggle="dropdown" data-bs-display="dynamic" aria-expanded="false">
|
|
{% if item.icon is defined and item.icon.class is defined %}
|
|
{{ render_icon_and_name(item) }}
|
|
{% else %}
|
|
<p>Missing icon in item: {{ item }}</p>
|
|
{% endif %}
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
{{ render_children(item.children) }}
|
|
</ul>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|