fix: move account-related links to navbar

This commit is contained in:
Ivan R. 2024-07-21 22:03:50 +05:00
parent 63c28511e3
commit 0a5d70abb6
Signed by: lumin
GPG key ID: E0937DC7CD6D3817
5 changed files with 56 additions and 48 deletions

View file

@ -69,3 +69,13 @@ footer {
align-items: center;
gap: 8px;
}
.navbar {
display: flex;
gap: 16px;
padding-top: 16px;
}
.navbar .space {
flex-grow: 1;
}

View file

@ -88,6 +88,7 @@ defmodule ComfycampWeb do
import ComfycampWeb.CoreComponents
import ComfycampWeb.Flash
import ComfycampWeb.Gettext
import ComfycampWeb.NavBar
# Shortcut for generating JS commands
alias Phoenix.LiveView.JS

View file

@ -1,10 +1,4 @@
<header>
<div class="limiter">
<a href="/">Главная</a>
<a href="/services/">Сервисы</a>
<a href="/cinema/">Кинотеатр</a>
</div>
</header>
<.navbar current_user={@current_user} />
<.flash_group flash={@flash} />

View file

@ -31,47 +31,6 @@
<link rel="shortcut icon" type="image/x-icon" href={~p"/images/favicons/shortcut.ico"} />
</head>
<body>
<ul class="relative z-10 flex items-center gap-4 px-4 sm:px-6 lg:px-8 justify-end">
<%= if @current_user do %>
<li class="text-[0.8125rem] leading-6 text-zinc-900">
<%= @current_user.email %>
</li>
<li>
<.link
href={~p"/users/settings"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Settings
</.link>
</li>
<li>
<.link
href={~p"/users/log_out"}
method="delete"
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Log out
</.link>
</li>
<% else %>
<li>
<.link
href={~p"/users/register"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Register
</.link>
</li>
<li>
<.link
href={~p"/users/log_in"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Log in
</.link>
</li>
<% end %>
</ul>
<%= @inner_content %>
</body>
</html>

View file

@ -0,0 +1,44 @@
defmodule ComfycampWeb.NavBar do
use Phoenix.Component
alias Comfycamp.Accounts.User
@doc """
Navigation bar.
## Examples
<.navbar current_user={@current_user} />
"""
attr :current_user, User, required: false
def navbar(assigns) do
~H"""
<nav class="limiter navbar">
<.link href="/">Главная</.link>
<.link href="/services/">Сервисы</.link>
<.link href="/cinema/">Кинотеатр</.link>
<div class="space" />
<%= if @current_user do %>
<.link href="/users/settings">
Настройки
</.link>
<.link href="/users/log_out" method="delete">
Выйти
</.link>
<% else %>
<.link href="/users/register">
Зарегистрироваться
</.link>
<.link href="/users/log_in">
Войти
</.link>
<% end %>
</nav>
"""
end
end