defmodule LivebookWeb.LayoutHelpers do use Phoenix.Component import LivebookWeb.LiveHelpers import LivebookWeb.UserHelpers alias Phoenix.LiveView.JS alias LivebookWeb.Router.Helpers, as: Routes @doc """ The layout used in the non-session pages. """ def layout(assigns) do assigns = assign_new(assigns, :topbar_action, fn -> [] end) ~H"""
<.live_region role="alert" /> <.sidebar socket={@socket} current_page={@current_page} current_user={@current_user} saved_hubs={@saved_hubs} />
<.topbar_sidebar_toggle />
<%= render_slot(@inner_block) %>
<.current_user_modal current_user={@current_user} /> """ end defp topbar_sidebar_toggle(assigns) do ~H"""
""" end defp sidebar(assigns) do ~H""" """ end defp sidebar_link(assigns) do assigns = assign_new(assigns, :icon_style, fn -> nil end) ~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" style={@icon_style} /> <%= @title %> <% end %> """ end defp hub_section(assigns) do ~H""" <%= if Livebook.Config.feature_flag_enabled?(:hub) do %>
HUBS
<%= for hub <- @hubs do %> <.sidebar_link title={hub.name} icon="checkbox-blank-circle-fill" icon_style={"color: #{hub.color}"} to={Routes.hub_path(@socket, :edit, hub.id)} current={@current_page} /> <% end %> <.sidebar_link title="Add Hub" icon="add-line" to={Routes.hub_path(@socket, :new)} current={@current_page} />
<% 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