PureAdmin.Components.Layout (PureAdmin v1.1.0)

Copy Markdown View Source

Layout components for Pure Admin.

Provides the full page structure: navbar, layout wrapper, sidebar, main content, and footer.

Summary

Functions

Renders a visual divider/separator.

Renders the footer with three-section layout.

Inline script that reads persisted UI preferences from localStorage and applies the corresponding classes before the page paints, preventing a flash of unstyled content.

Renders the main layout container (below navbar).

Renders the layout content wrapper.

Renders the layout inner container (sidebar + content).

Renders the main content area.

Renders the top navbar.

Renders the brand/logo section in the navbar.

Renders the burger menu button for sidebar toggle.

Renders a dropdown menu for a navbar_nav_item.

Renders a navigation link group in the navbar.

Renders a navigation item within navbar_nav.

Renders the profile button in the navbar.

Renders the search widget in the navbar.

Renders the page title in the navbar center section.

Renders a single notification item within notifications.

Renders a notifications bell button with dropdown panel.

Renders a hidden input containing the page context as JSON.

Renders a content section with optional heading.

Renders the sidebar navigation.

Renders a sidebar menu item (link).

Renders a collapsible sidebar submenu item.

JS command to toggle the notifications panel.

JS command to toggle the sidebar visibility.

JS command to toggle a submenu open/closed.

Functions

divider(assigns)

Renders a visual divider/separator.

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

footer(assigns)

Renders the footer with three-section layout.

When no slots are provided, auto-populates from config:

  • :start falls back to config :copyright
  • :end_ falls back to config :app_version

Examples

<%!-- Minimal: reads from config --%>
<.footer />

<%!-- Explicit content --%>
<.footer>
  <:start>&copy; 2026 My App</:start>
  <:end_>v1.0.0</:end_>
</.footer>

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • start - Left section (falls back to config :copyright).
  • center - Center section.
  • end_ - Right section (falls back to config :app_version).

fouc_prevention_script(assigns)

Inline script that reads persisted UI preferences from localStorage and applies the corresponding classes before the page paints, preventing a flash of unstyled content.

default_mode is the mode used on first visit, when localStorage has no theme-mode entry yet. Must be "light", "dark", or "auto". "auto" resolves to light/dark via prefers-color-scheme at runtime.

Examples

<.fouc_prevention_script />
<.fouc_prevention_script default_mode="auto" />

Attributes

  • default_mode (:string) - Defaults to "light". Must be one of "light", "dark", or "auto".

layout(assigns)

Renders the main layout container (below navbar).

Examples

<.layout>
  <.sidebar>...</.sidebar>
  <.main>...</.main>
  <.footer>...</.footer>
</.layout>

Attributes

  • id (:string) - Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

layout_content(assigns)

Renders the layout content wrapper.

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

layout_inner(assigns)

Renders the layout inner container (sidebar + content).

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

main(assigns)

Renders the main content area.

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

notification_item(assigns)

Renders a single notification item within notifications.

Examples

<.notification_item variant="success" icon="fa-solid fa-check">
  <:title>Build completed</:title>
  <:text>Production deployment finished</:text>
  <:time>15 minutes ago</:time>
</.notification_item>

Attributes

  • variant (:string) - Defaults to nil.Must be one of nil, "primary", "secondary", "success", "warning", "danger", or "info".
  • icon (:string) - Icon class (e.g. 'fa-solid fa-check'). Defaults to nil.
  • is_unread (:boolean) - Defaults to false.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • title - Notification title.
  • text - Notification body text.
  • time - Timestamp text.

notifications(assigns)

Renders a notifications bell button with dropdown panel.

Examples

<.notifications count={3}>
  <.notification_item variant="primary" icon="fa-solid fa-file-pen">
    <:title>New task assigned</:title>
    <:text>Review the Q4 report by end of week</:text>
    <:time>2 minutes ago</:time>
  </.notification_item>
</.notifications>

Attributes

  • id (:string) - Defaults to "notifications".
  • count (:integer) - Badge count (nil = no badge). Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block - Notification items.
  • footer_ - Footer content (e.g. 'View all' link).

page_context(assigns)

Renders a hidden input containing the page context as JSON.

JS hooks read this synchronously via getPageContext() instead of fetching from APIs. CSP-safe (no inline scripts with data).

Examples

<.page_context />

<.page_context extra={%{"user" => %{"id" => 1}}} />

Attributes

  • extra (:map) - Additional context to merge (from app assigns). Defaults to %{}.
  • Global attributes are accepted.

section(assigns)

Renders a content section with optional heading.

Examples

<.section title_text="My Section">
  Section content here.
</.section>

Attributes

  • title_text (:string) - Section heading text (renders as h3). Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

sidebar(assigns)

Renders the sidebar navigation.

Examples

<.sidebar>
  <.sidebar_item href="/" icon="📊" label="Dashboard" is_active />
  <.sidebar_item href="/users" icon="👥" label="Users" />
</.sidebar>

Attributes

  • id (:string) - Defaults to "sidebar".
  • is_sticky (:boolean) - Defaults to false.
  • is_icon_collapse (:boolean) - Defaults to false.
  • is_resizable (:boolean) - Defaults to false.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

toggle_notifications(id \\ "notifications")

@spec toggle_notifications(String.t()) :: Phoenix.LiveView.JS.t()

JS command to toggle the notifications panel.

toggle_sidebar(id \\ "sidebar")

@spec toggle_sidebar(String.t()) :: Phoenix.LiveView.JS.t()

JS command to toggle the sidebar visibility.

toggle_submenu(submenu_id)

@spec toggle_submenu(String.t()) :: Phoenix.LiveView.JS.t()

JS command to toggle a submenu open/closed.