denise-oneill-inbox-ru's picture
D8 staging from 92665ef4298ecff6735b080ff7901f2c19f719a7
5010ad7 verified
Raw History Blame Contribute Delete
4.01 kB
<nav class="fixed top-0 left-0 right-0 bg-white/80 backdrop-blur-md border-b border-slate-200 z-50">
<div class="container mx-auto px-5">
<div class="flex items-center justify-between h-16">
<div class="flex items-center gap-6">
<%= link_to t("brand.name"), root_path(locale: I18n.locale), class: "text-lg font-bold text-slate-800 hover:text-indigo-600 transition" %>
<div class="hidden md:flex items-center gap-4">
<%= link_to t("nav.home"), root_path(locale: I18n.locale), class: "text-sm text-slate-600 hover:text-indigo-600 transition" %>
<%= link_to t("nav.posts"), posts_path(locale: I18n.locale), class: "text-sm text-slate-600 hover:text-indigo-600 transition" %>
<%= link_to t("nav.categories"), categories_path(locale: I18n.locale), class: "text-sm text-slate-600 hover:text-indigo-600 transition" %>
<%= link_to t("nav.tags"), tags_path(locale: I18n.locale), class: "text-sm text-slate-600 hover:text-indigo-600 transition" %>
<% if user_signed_in? && current_user.admin? %>
<%= link_to t("nav.admin"), admin_root_path(locale: I18n.locale), class: "text-sm text-slate-600 hover:text-indigo-600 transition" %>
<% end %>
</div>
</div>
<div class="flex items-center gap-4">
<div class="relative" data-controller="locale-dropdown" data-action="keydown.esc@window->locale-dropdown#close">
<button type="button" data-locale-dropdown-target="button" data-action="click->locale-dropdown#toggle" aria-label="<%= t("locale.switch") %>" aria-controls="locale-navigation-menu" aria-expanded="false" class="inline-flex items-center gap-2 px-3 py-2 text-sm text-slate-600 bg-white border border-slate-200 rounded-lg hover:bg-slate-50 transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
<svg aria-hidden="true" class="size-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"/>
</svg>
<span><%= locale_flag_code(I18n.locale) %></span>
<svg aria-hidden="true" class="size-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
</svg>
</button>
<div id="locale-navigation-menu" data-locale-dropdown-target="menu" class="hidden absolute right-0 mt-2 w-48 bg-white border border-slate-200 rounded-lg shadow-lg py-1 z-50" tabindex="-1">
<% available_locales.each do |locale_code, _| %>
<% is_current = I18n.locale.to_sym == locale_code %>
<%= link_to switch_locale_url(locale_code), class: "flex items-center justify-between px-4 py-2 text-sm #{is_current ? 'text-indigo-600 bg-indigo-50 font-medium' : 'text-slate-600 hover:bg-slate-50'}" do %>
<span><%= locale_name(locale_code) %></span>
<span class="text-xs text-slate-400"><%= locale_flag_code(locale_code) %></span>
<% end %>
<% end %>
</div>
</div>
<% if user_signed_in? %>
<div class="flex items-center gap-3">
<span class="text-sm text-slate-600 hidden sm:inline"><%= current_user.email %></span>
<%= button_to t("shared.sign_out"),
destroy_user_session_path,
method: :delete,
class: "text-sm text-slate-600 hover:text-indigo-600 transition" %>
</div>
<% else %>
<%= link_to t("shared.sign_in"),
new_user_session_path(locale: I18n.locale),
class: "text-sm text-indigo-600 hover:text-indigo-700 font-medium" %>
<% end %>
</div>
</div>
</div>
</nav>