defmodule LivebookWeb.SidebarHelpers do use Phoenix.Component import LivebookWeb.LiveHelpers import LivebookWeb.UserHelpers alias Phoenix.LiveView.JS alias LivebookWeb.Router.Helpers, as: Routes @doc """ Renders the mobile toggle for the sidebar. """ def toggle(assigns) do assigns = assign_new(assigns, :inner_block, fn -> [] end) ~H"""
""" end @doc """ Renders sidebar container. """ def sidebar(assigns) do ~H""" """ end defp sidebar_link(assigns) do ~H""" <%= live_redirect to: @to, class: "h-7 flex items-center hover:text-white #{sidebar_link_text_color(@to, @current)} border-l-4 #{sidebar_link_border_color(@to, @current)} hover:border-white" do %> <.remix_icon icon={@icon} class="text-lg leading-6 w-[56px] flex justify-center" /> <%= @title %> <% end %> """ end defp hub_section(assigns) do ~H""" <%= if Application.get_env(:livebook, :feature_flags)[:hub] do %>
HUBS
<%= live_redirect to: Routes.hub_path(@socket, :page), class: "flex absolute right-5 items-center justify-center text-gray-400 hover:text-white hover:border-white" do %> <.remix_icon icon="add-line" /> <% end %>
<%= for hub <- @hubs do %> <%= live_redirect to: Routes.hub_path(@socket, :edit, hub.id), class: "h-7 flex items-center cursor-pointer text-gray-400 hover:text-white" do %> <.remix_icon class="text-lg leading-6 w-[56px] flex justify-center" icon="checkbox-blank-circle-fill" style={"color: #{hub.color}"} /> <%= hub.name %> <% end %> <% end %>
<%= live_redirect to: Routes.hub_path(@socket, :page), class: "h-7 flex items-center cursor-pointer text-gray-400 hover:text-white" do %> <.remix_icon class="text-lg leading-6 w-[56px] flex justify-center" icon="add-line" /> Add Hub <% end %>
<% end %> """ end defp sidebar_link_text_color(to, current) when to == current, do: "text-white" defp sidebar_link_text_color(_to, _current), do: "text-gray-400" defp sidebar_link_border_color(to, current) when to == current, do: "border-white" defp sidebar_link_border_color(_to, _current), do: "border-transparent" end