comfycamp/lib/comfycamp_web/components/navbar.ex

49 lines
1.1 KiB
Elixir
Raw Normal View History

defmodule ComfycampWeb.NavBar do
use Phoenix.Component
2024-07-28 18:03:48 +05:00
use ComfycampWeb, :verified_routes
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">
2024-07-28 18:03:48 +05:00
<.link href={~p"/"}>Главная</.link>
2024-07-29 18:07:44 +05:00
<.link href={~p"/notes"}>Заметки</.link>
<.link href={~p"/cinema"}>Кинотеатр</.link>
<div class="space" />
<%= if @current_user do %>
<.link :if={@current_user.is_admin} href={~p"/admin"}>
Админка
</.link>
<.link navigate={~p"/users/settings"}>
Настройки
</.link>
2024-07-28 18:03:48 +05:00
<.link href={~p"/users/log_out"} method="delete">
Выйти
</.link>
<% else %>
<.link navigate={~p"/users/register"}>
Зарегистрироваться
</.link>
<.link navigate={~p"/users/log_in"}>
Войти
</.link>
<% end %>
</nav>
"""
end
end