2021-07-07 20:32:49 +08:00
|
|
|
defmodule LivebookWeb.SidebarHelpers do
|
|
|
|
use Phoenix.Component
|
|
|
|
|
|
|
|
import LivebookWeb.Helpers
|
|
|
|
import LivebookWeb.UserHelpers
|
|
|
|
|
|
|
|
alias LivebookWeb.Router.Helpers, as: Routes
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Renders sidebar container.
|
|
|
|
|
|
|
|
Other functions in this module render sidebar
|
|
|
|
items of various type.
|
|
|
|
"""
|
|
|
|
def sidebar(assigns) do
|
|
|
|
~H"""
|
|
|
|
<div class="w-16 flex flex-col items-center space-y-5 px-3 py-7 bg-gray-900">
|
2021-11-02 02:33:43 +08:00
|
|
|
<%= render_slot(@inner_block) %>
|
2021-07-07 20:32:49 +08:00
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
|
|
|
|
def logo_item(assigns) do
|
|
|
|
~H"""
|
|
|
|
<span>
|
2021-11-02 01:20:56 +08:00
|
|
|
<%= live_patch to: Routes.home_path(@socket, :page), aria_label: "go to homepage" do %>
|
|
|
|
<img src="/images/logo.png" height="40" width="40" alt="" />
|
2021-07-07 20:32:49 +08:00
|
|
|
<% end %>
|
|
|
|
</span>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
|
|
|
|
def button_item(assigns) do
|
|
|
|
~H"""
|
2021-11-02 01:20:56 +08:00
|
|
|
<span class="tooltip right distant" data-tooltip={@label}>
|
2021-07-07 20:32:49 +08:00
|
|
|
<button class="text-2xl text-gray-400 hover:text-gray-50 focus:text-gray-50 rounded-xl h-10 w-10 flex items-center justify-center"
|
2021-11-02 01:20:56 +08:00
|
|
|
aria-label={@label}
|
2021-07-07 20:32:49 +08:00
|
|
|
data-element={@data_element}>
|
|
|
|
<.remix_icon icon={@icon} />
|
|
|
|
</button>
|
|
|
|
</span>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
|
|
|
|
def link_item(assigns) do
|
|
|
|
~H"""
|
2021-11-02 01:20:56 +08:00
|
|
|
<span class="tooltip right distant" data-tooltip={@label}>
|
2021-07-07 20:32:49 +08:00
|
|
|
<%= live_patch to: @path,
|
2021-11-02 01:20:56 +08:00
|
|
|
class: "text-gray-400 hover:text-gray-50 focus:text-gray-50 rounded-xl h-10 w-10 flex items-center justify-center #{if(@active, do: "text-gray-50 bg-gray-700")}",
|
|
|
|
aria_label: @label do %>
|
2021-07-07 20:32:49 +08:00
|
|
|
<.remix_icon icon={@icon} class="text-2xl" />
|
|
|
|
<% end %>
|
|
|
|
</span>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
|
|
|
|
def break_item(assigns) do
|
|
|
|
~H"""
|
|
|
|
<div class="flex-grow"></div>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_item(assigns) do
|
|
|
|
~H"""
|
2021-11-02 01:20:56 +08:00
|
|
|
<span class="tooltip right distant" data-tooltip="User profile">
|
|
|
|
<%= live_patch to: @path,
|
|
|
|
class: "text-gray-400 rounded-xl h-8 w-8 flex items-center justify-center",
|
|
|
|
aria_label: "user profile" do %>
|
2021-07-07 20:32:49 +08:00
|
|
|
<.user_avatar user={@current_user} text_class="text-xs" />
|
|
|
|
<% end %>
|
|
|
|
</span>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
end
|