if Mix.env() != :prod do defmodule AccrueAdmin.Dev.ComponentKitchenLive do @moduledoc false use Phoenix.LiveView alias AccrueAdmin.Components.{ AppShell, Breadcrumbs, Button, FlashGroup, KpiCard, StatusBadge, Tabs } @impl true def mount(_params, session, socket) do admin = Map.get(session, "accrue_admin", %{}) if fake_processor?() do {:ok, socket |> assign_shell(admin, "/dev/components", "Component Kitchen") |> assign(:available?, true) |> assign(:flashes, [ %{ kind: :info, message: "Previewing shared admin components against the shipped package CSS." } ])} else {:ok, socket |> assign_shell(admin, "/dev/components", "Component Kitchen") |> assign(:available?, false) |> assign(:flashes, [])} end end @impl true def render(assigns) do ~H"""

Shared primitives

One dev page to sanity-check the admin component layer

Unavailable

Dev tools require `Accrue.Processor.Fake` as the configured processor.

<:meta>Sample money formatting in the packaged shell <:meta>Visual check for operator-heavy status cards
Primary action Secondary action "/webhooks"}>Ghost link
""" end defp assign_shell(socket, admin, path, title) do socket |> assign(:page_title, title) |> assign(:brand, admin["brand"] || default_brand()) |> assign(:theme, admin["theme"] || "system") |> assign(:csp_nonce, admin["csp_nonce"]) |> assign(:brand_css_path, admin["brand_css_path"]) |> assign(:assets_css_path, admin["assets_css_path"]) |> assign(:assets_js_path, admin["assets_js_path"]) |> assign(:admin_mount_path, admin["mount_path"] || "/billing") |> assign(:current_path, (admin["mount_path"] || "/billing") <> path) end defp fake_processor? do Application.get_env(:accrue, :processor, Accrue.Processor.Fake) == Accrue.Processor.Fake end defp default_brand do %{app_name: "Billing", logo_url: nil, accent_hex: "#5D79F6", accent_contrast_hex: "#FAFBFC"} end end end