session.html 71 lignes · 3661 octets
{# C-020 avec session : burger (sous lg), nom de l'organisation, C-022 Menu de l'utilisateur et C-021
   Sidebar. La page fournit `session` (VueSession), `organisation` (Option<String>) et `actif`
   (entrée courante de C-021). #}
{% extends "layouts/console.html" %}

{% macro entrees(actif) %}
<ul class="flex flex-col gap-xxs">
  <li>
    <a href="/console"
       class="flex items-center rounded-sm border-l-4 px-md py-sm text-sm {% if actif == "tableau" %}border-l-primary bg-muted text-foreground{% else %}border-l-transparent text-muted-foreground hover:bg-muted{% endif %}"
       {%- if actif == "tableau" %} aria-current="page"{% endif %}>Tableau de bord</a>
  </li>
</ul>
{% endmacro %}

{% block burger %}
<button type="button" x-data="navigationConsole" x-on:click="ouvrir"
        class="inline-flex h-10 w-10 items-center justify-center rounded-sm text-foreground hover:bg-muted lg:hidden"
        aria-label="Ouvrir la navigation" aria-controls="navigation-console" aria-expanded="false">
  <span aria-hidden="true">☰</span>
</button>
{% endblock %}

{% block organisation %}
{% if let Some(o) = organisation %}<span class="hidden text-sm text-muted-foreground md:inline">{{ o }}</span>{% endif %}
{% endblock %}

{% block utilisateur %}
{# C-022 Menu de l'utilisateur : Échap, clic extérieur et focus sorti ferment ; flèches haut et bas parcourent. #}
<div class="relative ml-auto" x-data="menuUtilisateur" x-on:keydown.escape="fermer" x-on:click.outside="fermerDehors"
     x-on:focusout="focusSorti">
  <button type="button" id="menu-utilisateur-bouton" x-ref="bouton" x-on:click="basculer"
          aria-haspopup="menu" aria-controls="menu-utilisateur" aria-expanded="false" x-bind:aria-expanded="ouvertTexte"
          class="inline-flex h-10 items-center gap-xs rounded-sm px-sm text-sm text-foreground hover:bg-muted">
    {{ session.nom }}<span aria-hidden="true">▾</span>
  </button>
  <div x-show="ouvert" x-cloak
       class="absolute right-0 z-40 mt-xs w-72 rounded-sm border border-border bg-card p-xs text-sm">
    <div class="px-md py-sm">
      <p class="text-foreground">{{ session.nom }}</p>
      {% if let Some(u) = session.uid %}<p class="font-mono text-muted-foreground">{{ u }}</p>{% endif %}
      <p class="mt-xs text-muted-foreground">Mot de passe et second facteur</p>
      <p class="text-muted-foreground">Fin de session au plus tard à {{ session.fin }}</p>
    </div>
    <div id="menu-utilisateur" role="menu" aria-labelledby="menu-utilisateur-bouton"
         x-on:keydown.down.prevent="suivant" x-on:keydown.up.prevent="precedent">
      <button type="button" role="menuitem" hx-post="/console/deconnexion"
              class="w-full rounded-sm px-md py-sm text-left text-primary hover:bg-muted">Se déconnecter</button>
    </div>
  </div>
</div>
{% endblock %}

{% block navigation %}
{# C-021 Sidebar : déployée à partir de lg ; en dessous, le burger l'ouvre dans un dialogue. #}
<nav aria-label="Console" class="hidden w-60 shrink-0 lg:block">
  {% call entrees(actif) %}{% endcall %}
</nav>
<dialog id="navigation-console" x-data="panneauNavigation" x-on:click="clicFond"
        class="m-0 h-full max-h-none w-72 max-w-[85vw] border-r border-border bg-card p-md backdrop:bg-black/40"
        aria-label="Navigation de la console">
  <form method="dialog" class="mb-md flex justify-end">
    <button class="inline-flex h-10 w-10 items-center justify-center rounded-sm hover:bg-muted" aria-label="Fermer la navigation">
      <span aria-hidden="true">✕</span>
    </button>
  </form>
  <nav aria-label="Console">
    {% call entrees(actif) %}{% endcall %}
  </nav>
</dialog>
{% endblock %}