noesya/osuny

View on GitHub
app/views/admin/application/components/_nav.html.erb

Summary

Maintainability
Test Coverage
<%
languages = current_university.languages.ordered
%>
<nav class="navbar navbar-main navbar-dark bg-black p-2" aria-label="Navigation">
  <div>
    <button class="btn btn--main"
            type="button"
            data-bs-toggle="collapse"
            data-bs-target="#menu-main"
            aria-expanded="false"
            aria-label="Afficher la navigation">
      <%= lucide_icon('chevrons-up-down') %>
      Osuny
    </button>
  </div>
  <div class="d-flex justify-content-end">
    <% if languages.many? %>
      <button class="btn btn--language"
              type="button"
              data-bs-toggle="collapse"
              data-bs-target="#menu-language"
              aria-expanded="fa‡se"
              aria-label="Afficher le choix de langues">
        <%= lucide_icon('languages') %>
        <span class="px-2">
          <%= current_language.iso_code.upcase %>
        </span>
        <%= lucide_icon('chevron-down') %>
      </button>
    <% end %>
    <button class="btn btn--profile"
        type="button"
        data-bs-toggle="collapse"
        data-bs-target="#menu-profile"
        aria-expanded="false"
        aria-label="Afficher le profil">
      <%= lucide_icon('user') %>
    </button>
  </div>
</nav>

<div id="popins">
  <div class="collapse popin-menu" id="menu-main" data-bs-parent="#popins">
    <% if current_university.is_really_a_university? %>
      <div class="menu-content">
        <div class="row">
          <%= render_navigation context: 'navigation/admin_university' %>
        </div>
      </div>
    <% else %>
      <%= render_navigation context: 'navigation/admin' %>
    <% end %>
  </div>

  <% if languages.many? %>
    <div class="collapse popin-menu" id="menu-language" data-bs-parent="#popins">
      <ul class="list-unstyled">
        <% languages.each do |language| %>
          <%
          name = language_name(language.iso_code)
          url = url_for(request.params.merge(lang: language.iso_code))
          current = language == current_language
          %>
          <li<% if current %> class="active"<% end %>>
            <%= link_to_if !current, name, url %>
          </li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <div class="collapse popin-menu" id="menu-profile" data-bs-parent="#popins">
    <div class="text-center pt-3 pb-2">
      <%= link_to admin_profile_path do %>
        <% if current_user.picture.attached? %>
          <%= kamifusen_tag current_user.picture, width: 100, height: 100, class: 'image' %>
        <% else %>
          <%= image_tag 'avatar.jpg', class: 'image', loading: :lazy %>
        <% end %>
      <% end %>
      <p class="profile__name"><%= link_to current_user.to_s, admin_profile_path %></h2>
      <p class="profile__email"><%= current_user.email %></p>
    </div>
    <hr>
    <p class="section"><%= t('admin.directory') %></p>
    <%= render_navigation context: 'navigation/admin_directory' %>
    <hr>
    <% if current_user.server_admin?  %>
      <%= link_to t('menu.server_admin'), server_root_path %>
      <hr>
    <% end %>
    <%= link_to t('menu.sign_out'), destroy_user_session_path, method: :delete %>
  </div>
</div>