defmodule SpazioSolazzoWeb.Layouts do @moduledoc """ This module holds layouts and related functionality used by your application. """ use SpazioSolazzoWeb, :html # Embed all files in layouts/* within this module. # The default root.html.heex file contains the HTML # skeleton of your application, namely HTML headers # and other static content. embed_templates "layouts/*" @doc """ Renders your app layout. This function is typically invoked from every template, and it often contains your application menu, sidebar, or similar. ## Examples

Content

""" attr :flash, :map, required: true, doc: "the map of flash messages" attr :current_scope, :map, default: nil, doc: "the current [scope](https://hexdocs.pm/phoenix/scopes.html)" attr :current_user, :map, default: nil, doc: "the current authenticated user" slot :inner_block, required: true def app(assigns) do ~H""" <.app_header current_user={@current_user} />
{render_slot(@inner_block)}
<.flash_group flash={@flash} /> <.footer /> """ end @doc """ Shows the flash group with standard titles and content. ## Examples <.flash_group flash={@flash} /> """ attr :flash, :map, required: true, doc: "the map of flash messages" attr :id, :string, default: "flash-group", doc: "the optional id of flash container" def flash_group(assigns) do ~H"""
<.flash kind={:info} flash={@flash} /> <.flash kind={:error} flash={@flash} /> <.flash id="client-error" kind={:error} title={gettext("We can't find the internet")} phx-disconnected={show(".phx-client-error #client-error") |> JS.remove_attribute("hidden")} phx-connected={hide("#client-error") |> JS.set_attribute({"hidden", ""})} hidden > {gettext("Attempting to reconnect")} <.icon name="hero-arrow-path" class="ml-1 size-3 motion-safe:animate-spin" /> <.flash id="server-error" kind={:error} title={gettext("Something went wrong!")} phx-disconnected={show(".phx-server-error #server-error") |> JS.remove_attribute("hidden")} phx-connected={hide("#server-error") |> JS.set_attribute({"hidden", ""})} hidden > {gettext("Attempting to reconnect")} <.icon name="hero-arrow-path" class="ml-1 size-3 motion-safe:animate-spin" />
""" end @doc """ Provides dark vs light theme toggle based on themes defined in app.css. See in root.html.heex which applies the theme before page load. """ def theme_toggle(assigns) do ~H""" """ end defp app_header(assigns) do ~H"""
<.link navigate="/" class="flex items-center gap-4 text-slate-900 dark:text-slate-100 hover:opacity-80 transition-opacity" >
<.icon name="hero-squares-2x2" class="size-5" />

Spazio Solazzo

<.theme_toggle /> <%= if @current_user do %> <%!-- Desktop menu --%> <%!-- Mobile menu button --%> <% else %> <.link navigate={~p"/sign-in"} id="sign-in-link" class="px-4 py-2 text-sm font-medium text-white bg-sky-500 hover:bg-sky-600 rounded-lg transition-colors shadow-sm" > Sign In <% end %>
<%!-- Mobile dropdown menu --%> <%= if @current_user do %> <% end %>
""" end defp footer(assigns) do current_year = Date.utc_today().year assigns = assign(assigns, :current_year, current_year) ~H""" """ end end