defmodule Doggo do @moduledoc """ Collection of Phoenix Components. """ use Phoenix.Component alias Phoenix.HTML.Form alias Phoenix.LiveView.JS ## Components @doc """ The action bar offers users quick access to primary actions within the application. It is typically positioned to float above other content. ## Example <.action_bar> <:item label="Edit" on_click={JS.push("edit")}> <.icon size={:small}> <:item label="Move" on_click={JS.push("move")}> <.icon size={:small}> <:item label="Archive" on_click={JS.push("archive")}> <.icon size={:small}> """ @doc type: :component attr :class, :any, default: [], doc: "Additional CSS classes. Can be a string or a list of strings." attr :rest, :global, doc: "Any additional HTML attributes." slot :item do attr :label, :string, required: true attr :on_click, JS, required: true end def action_bar(assigns) do ~H"""
<.link :for={item <- @item} phx-click={item.on_click} title={item.label}> <%= render_slot(item) %>
""" end @doc """ The app bar is typically located at the top of the interface and provides access to key features and navigation options. ## Usage <.app_bar title="Page title"> <:navigation label="Open menu" on_click={JS.push("toggle-menu")}> <.icon> <:action label="Search" on_click={JS.push("search")}> <.icon> <:action label="Like" on_click={JS.push("like")}> <.icon> """ @doc type: :component attr :title, :string, default: nil, doc: "The page title. Will be set as `h1`." attr :class, :any, default: [], doc: "Additional CSS classes. Can be a string or a list of strings." attr :rest, :global, doc: "Any additional HTML attributes." slot :navigation, doc: """ Slot for a single button left of the title, typically used for a menu button that toggles a drawer, or for a back link. """ do attr :label, :string, required: true attr :on_click, JS, required: true end slot :action, doc: "Slot for action buttons right of the title." do attr :label, :string, required: true attr :on_click, JS, required: true end def app_bar(assigns) do ~H"""
<.link :for={navigation <- @navigation} phx-click={navigation.on_click} title={navigation.label} > <%= render_slot(navigation) %>

<%= @title %>

<.link :for={action <- @action} phx-click={action.on_click} title={action.label} > <%= render_slot(action) %>
""" end @doc """ Renders a badge, typically used for drawing attention to elements like notification counts. ## Examples <.badge>8 """ @doc type: :component attr :size, :atom, values: [:small, :normal, :medium, :large], default: :normal attr :variant, :atom, values: [nil, :primary, :secondary, :info, :success, :warning, :danger], default: nil slot :inner_block, required: true def badge(assigns) do ~H""" <%= render_slot(@inner_block) %> """ end @doc """ Renders a navigation that sticks to the bottom of the screen. ## Example <.bottom_navigation current_value={@view}> <:item label="Profile" navigate={~p"/pets/\#{@pet}"} value={Profile} >