live_beats/lib/live_beats_web/components/layouts.ex

110 lines
3.5 KiB
Elixir
Raw Normal View History

2022-11-17 15:01:20 +00:00
defmodule LiveBeatsWeb.Layouts do
use LiveBeatsWeb, :html
2021-11-12 15:10:04 +00:00
2022-11-17 15:01:20 +00:00
embed_templates "layouts/*"
attr :id, :string
attr :users, :list
2021-11-12 15:10:04 +00:00
def sidebar_active_users(assigns) do
~H"""
<div class="mt-8">
<h3 class="px-3 text-xs font-semibold text-gray-500 uppercase tracking-wider" id={@id}>
Active Users
</h3>
2024-06-05 17:32:44 +00:00
<div id={"#{@id}-stream"} phx-update="stream" class="mt-1 space-y-1" role="group" aria-labelledby={@id}>
<.link
:for={{id, user} <- @users}
id={id}
navigate={profile_path(user)}
class="group flex items-center px-3 py-2 text-base leading-5 font-medium text-gray-600 rounded-md hover:text-gray-900 hover:bg-gray-50"
>
<span class="w-2.5 h-2.5 mr-4 bg-indigo-500 rounded-full" aria-hidden="true"></span>
<span class="truncate">
<%= user.username %>
</span>
</.link>
2021-11-12 15:10:04 +00:00
</div>
</div>
"""
end
2022-11-17 15:01:20 +00:00
attr :id, :string
attr :current_user, :any
attr :active_tab, :atom
2021-11-12 15:10:04 +00:00
def sidebar_nav_links(assigns) do
~H"""
<div class="space-y-1">
<%= if @current_user do %>
<.link
2021-11-23 14:34:34 +00:00
navigate={profile_path(@current_user)}
2022-08-03 13:40:11 +00:00
class={
"text-gray-700 hover:text-gray-900 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :profile, do: "bg-gray-200", else: "hover:bg-gray-50"}"
}
aria-current={if @active_tab == :profile, do: "true", else: "false"}
2021-11-12 15:10:04 +00:00
>
2022-08-03 13:40:11 +00:00
<.icon
name={:music_note}
outlined
class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"
/> My Songs
2021-11-12 15:10:04 +00:00
</.link>
<.link
2022-11-17 20:36:58 +00:00
navigate={~p"/profile/settings"}
2022-08-03 13:40:11 +00:00
class={
"text-gray-700 hover:text-gray-900 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :settings, do: "bg-gray-200", else: "hover:bg-gray-50"}"
}
aria-current={if @active_tab == :settings, do: "true", else: "false"}
2021-11-12 15:10:04 +00:00
>
2022-08-03 13:40:11 +00:00
<.icon
name={:adjustments}
outlined
class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"
/> Settings
2021-11-12 15:10:04 +00:00
</.link>
<% else %>
2022-08-03 13:40:11 +00:00
<.link
2022-11-17 20:36:58 +00:00
navigate={~p"/signin"}
2021-11-12 15:10:04 +00:00
class="text-gray-700 hover:text-gray-900 hover:bg-gray-50 group flex items-center px-2 py-2 text-sm font-medium rounded-md"
>
2022-08-03 13:40:11 +00:00
<svg
class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
>
</path>
2021-11-12 15:10:04 +00:00
</svg>
Sign in
</.link>
<% end %>
</div>
"""
end
2022-11-17 15:01:20 +00:00
attr :id, :string
attr :current_user, :any
2021-11-12 15:10:04 +00:00
def sidebar_account_dropdown(assigns) do
~H"""
2022-11-17 15:01:20 +00:00
<.dropdown id={@id}>
2022-08-03 13:40:11 +00:00
<:img src={@current_user.avatar_url} />
2021-11-22 16:21:01 +00:00
<:title><%= @current_user.name %></:title>
<:subtitle>@<%= @current_user.username %></:subtitle>
2021-11-23 14:34:34 +00:00
<:link navigate={profile_path(@current_user)}>View Profile</:link>
2022-11-17 20:36:58 +00:00
<:link navigate={~p"/profile/settings"}>Settings</:link>
<:link href={~p"/signout"} method={:delete}>Sign out</:link>
2021-11-22 16:21:01 +00:00
</.dropdown>
2021-11-12 15:10:04 +00:00
"""
end
2021-09-02 18:00:57 +00:00
end