gettext topbar

This commit is contained in:
2022-02-08 23:38:20 -05:00
parent 185d8598da
commit e3b94477db
8 changed files with 86 additions and 30 deletions

View File

@ -32,32 +32,32 @@ defmodule CanneryWeb.Component.Topbar do
space-x-4 text-lg text-white text-ellipsis">
<%= if @current_user do %>
<li>
<%= link("Tags",
<%= link(gettext("Tags"),
class: "hover:underline",
to: Routes.tag_index_path(CanneryWeb.Endpoint, :index)
) %>
</li>
<li>
<%= link("Containers",
<%= link(gettext("Containers"),
class: "hover:underline",
to: Routes.container_index_path(CanneryWeb.Endpoint, :index)
) %>
</li>
<li>
<%= link("Ammo",
<%= link(gettext("Ammo"),
class: "hover:underline",
to: Routes.ammo_type_index_path(CanneryWeb.Endpoint, :index)
) %>
</li>
<li>
<%= link("Manage",
<%= link(gettext("Manage"),
class: "hover:underline",
to: Routes.ammo_group_index_path(CanneryWeb.Endpoint, :index)
) %>
</li>
<%= if @current_user.role == :admin do %>
<li>
<%= link("Invites",
<%= link(gettext("Invites"),
class: "hover:underline",
to: Routes.invite_index_path(CanneryWeb.Endpoint, :index)
) %>
@ -72,7 +72,7 @@ defmodule CanneryWeb.Component.Topbar do
<li>
<%= link to: Routes.user_session_path(CanneryWeb.Endpoint, :delete),
method: :delete,
data: [confirm: "Are you sure you want to log out?"] do %>
data: [confirm: dgettext("prompts", "Are you sure you want to log out?")] do %>
<i class="fas fa-sign-out-alt"></i>
<% end %>
</li>
@ -86,14 +86,14 @@ defmodule CanneryWeb.Component.Topbar do
<% else %>
<%= if Accounts.allow_registration?() do %>
<li>
<%= link("Register",
<%= link(dgettext("actions", "Register"),
class: "hover:underline",
to: Routes.user_registration_path(CanneryWeb.Endpoint, :new)
) %>
</li>
<% end %>
<li>
<%= link("Log in",
<%= link(dgettext("actions", "Log in"),
class: "hover:underline",
to: Routes.user_session_path(CanneryWeb.Endpoint, :new)
) %>
@ -102,16 +102,6 @@ defmodule CanneryWeb.Component.Topbar do
</ul>
</div>
</nav>
<%= if @flash && @flash |> Map.has_key?(:info) do %>
<p class="alert alert-info" role="alert" phx-click="lv:clear-flash" phx-value-key="info">
<%= live_flash(@flash, :info) %>
</p>
<% end %>
<%= if @flash && @flash |> Map.has_key?(:error) do %>
<p class="alert alert-danger" role="alert" phx-click="lv:clear-flash" phx-value-key="error">
<%= live_flash(@flash, :error) %>
</p>
<% end %>
</header>
"""
end

View File

@ -2,6 +2,7 @@
<header class="mb-4 px-8 py-4 w-full bg-primary-400">
<%= render("topbar.html", assigns) %>
</header>
<div class="mx-8 my-2 flex flex-col space-y-4 text-center">
<%= if get_flash(@conn, :info) do %>
<p class="alert alert-info" role="alert">
@ -14,5 +15,6 @@
</p>
<% end %>
</div>
<%= @inner_content %>
</main>

View File

@ -15,6 +15,7 @@
>
</script>
</head>
<body class="m-0 p-0 w-full h-full">
<%= @inner_content %>
</body>

View File

@ -1,34 +1,42 @@
<nav role="navigation">
<div class="flex flex-row justify-between items-center space-x-4 overflow-x-hidden">
<%= link to: Routes.live_path(CanneryWeb.Endpoint, HomeLive) do %>
<h1 class="leading-5 text-xl text-white hover:underline">Cannery</h1>
<h1 class="leading-5 text-xl text-white hover:underline">
Cannery
</h1>
<% end %>
<ul class="flex flex-col sm:flex-row flex-wrap justify-center items-center
space-x-4 text-lg text-white text-ellipsis">
<%# user settings %>
<%= if assigns |> Map.has_key?(:current_user) && @current_user do %>
<li>
<%= link @current_user.email, class: "hover:underline",
to: Routes.user_settings_path(CanneryWeb.Endpoint, :edit) %>
<%= link(@current_user.email,
class: "hover:underline",
to: Routes.user_settings_path(CanneryWeb.Endpoint, :edit)
) %>
</li>
<li>
<%= link to: Routes.user_session_path(CanneryWeb.Endpoint, :delete), method: :delete,
data: [confirm: "Are you sure you want to log out?"] do %>
<%= link to: Routes.user_session_path(CanneryWeb.Endpoint, :delete),
method: :delete,
data: [confirm: dgettext("prompts", "Are you sure you want to log out?")] do %>
<i class="fas fa-sign-out-alt"></i>
<% end %>
</li>
<% else %>
<%= if Accounts.allow_registration?() do %>
<li>
<%= link "Register", class: "hover:underline",
to: Routes.user_registration_path(CanneryWeb.Endpoint, :new) %>
<%= link(dgettext("actions", "Register"),
class: "hover:underline",
to: Routes.user_registration_path(CanneryWeb.Endpoint, :new)
) %>
</li>
<% end %>
<li>
<%= link "Log in", class: "hover:underline",
to: Routes.user_session_path(CanneryWeb.Endpoint, :new) %>
<%= link(dgettext("actions", "Log in"),
class: "hover:underline",
to: Routes.user_session_path(CanneryWeb.Endpoint, :new)
) %>
</li>
<% end %>
</ul>