tetratto/crates/app/src/public/html/macros.html

87 lines
3 KiB
HTML
Raw Normal View History

{% macro nav(selected="", show_lhs=true) -%}
<nav>
<div class="content_container">
<div class="flex nav_side">
<a href="/" class="button desktop title">
<b>{{ config.name }}</b>
</a>
{% if show_lhs %}
<a
href="/"
class="button {% if selected == 'home' %}active{% endif %}"
>
{{ icon "house" }}
2025-03-23 16:37:43 -04:00
<span class="desktop">{{ text "general:link.home" }}</span>
</a>
{% endif %}
</div>
<div class="flex nav_side">
{% if user %}
<div class="dropdown">
<!-- prettier-ignore -->
<button
class="flex-row title"
onclick="trigger('atto::hooks::dropdown', [event])"
exclude="dropdown"
style="gap: 0.25rem !important"
>
{{ macros::avatar(username=user.username, size="24px") }}
{{ icon "chevron-down" c(dropdown-arrow) }}
</button>
2025-03-23 16:37:43 -04:00
<div class="inner">
<b class="title">{{ user.username }}</b>
<a href="/user/{{ user.username }}">
2025-03-23 16:37:43 -04:00
{{ icon "book-heart" }}
<span>{{ text "auth:link.my_profile" }}</span>
</a>
<a href="/settings">
{{ icon "settings" }}
<span>{{ text "auth:link.settings" }}</span>
</a>
2025-03-23 16:37:43 -04:00
<div class="title"></div>
<button class="red" onclick="trigger('me::logout')">
{{ icon "log-out" }}
<span>{{ text "auth:action.logout" }}</span>
</button>
</div>
</div>
{% else %}
<div class="dropdown">
<button
class="title"
onclick="trigger('atto::hooks::dropdown', [event])"
exclude="dropdown"
>
{{ icon "chevron-down" c(dropdown-arrow) }}
</button>
<div class="inner">
<a href="/auth/login" class="button">
{{ icon "log-in" }}
2025-03-23 16:37:43 -04:00
<span>{{ text "auth:action.login" }}</span>
</a>
<a href="/auth/register" class="button">
{{ icon "user-plus" }}
2025-03-23 16:37:43 -04:00
<span>{{ text "auth:action.register" }}</span>
</a>
</div>
</div>
{% endif %}
</div>
</div>
</nav>
{%- endmacro %} {% macro avatar(username, size="24px") -%}
<img
title="{{ username }}'s avatar"
src="/api/v1/auth/profile/{{ username }}/avatar"
alt="@{{ username }}"
class="avatar shadow"
style="--size: {{ size }}"
/>
{%- endmacro %}