Backpex.HTML.Layout (Backpex v0.13.0)

View Source

Contains all Backpex layout components.

Summary

Components

Renders an alert.

Renders an app shell representing the base of your layout.

Get the Backpex logo SVG.

Renders the form label and input with corresponding margin and alignment.

Renders flash messages.

Renders a footer. It provides a default look when no content is provided.

Renders a text to be used as a label for an input.

Container to wrap main elements and add margin.

Renders a title.

Renders a modal.

Renders a sidebar item. It uses Phoenix.Component.link/1 component, so you can can use link and href navigation.

Renders a sidebar section.

Renders a theme selector.

Renders a topbar.

Renders the topbar branding.

Renders a topbar dropdown.

Components

alert(assigns)

Renders an alert.

Attributes

  • class (:string) - additional class to be added to the component. Defaults to nil.
  • kind (:atom) - used for styling. Must be one of :info, :success, :warning, or :error.
  • closable (:boolean) - show or hide the close button. Defaults to true.
  • on_close (Phoenix.LiveView.JS) - event triggered on alert close. Defaults to %Phoenix.LiveView.JS{ops: []}.
  • close_label (:string) - Defaults to "Close alert".
  • title (:string) - title for the alert. Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block
  • icon

app_shell(assigns)

Renders an app shell representing the base of your layout.

Attributes

  • class (:string) - class added to the app shell container. Defaults to nil.
  • fluid (:boolean) - toggles fluid layout. Defaults to false.

Slots

  • inner_block
  • topbar - content to be displayed in the topbar. Accepts attributes:
    • class (:string) - additional class that will be added to the component.
  • sidebar - content to be displayed in the sidebar. Accepts attributes:
    • class (:string) - additional class that will be added to the component.
  • footer - content to be displayed in the footer.

backpex_logo(assigns)

Get the Backpex logo SVG.

Attributes

  • class (:string) - class that will be added to the SVG element. Defaults to nil.

field_container(assigns)

Renders the form label and input with corresponding margin and alignment.

Attributes

  • class (:string) - extra classes to be added. Defaults to "".

Slots

  • label (required) - Accepts attributes:
    • align (:atom) - Must be one of :top, :center, or :bottom.
  • inner_block

flash_messages(assigns)

Renders flash messages.

Attributes

  • flash (:map) (required) - flash map that will be passed to Phoenix.Flash.get/2.
  • close_label (:string) - Defaults to "Close alert".

footer(assigns)

Renders a footer. It provides a default look when no content is provided.

Attributes

  • class (:string) - additional class that will be added to the component. Defaults to "".

Slots

  • inner_block

input_label(assigns)

Renders a text to be used as a label for an input.

Attributes

  • text (:string) - text of the label.

main_container(assigns)

Container to wrap main elements and add margin.

Attributes

  • class (:string) - additional class that will be added to the component. Defaults to "".

Slots

  • inner_block

main_title(assigns)

Renders a title.

Attributes

  • class (:string) - additional class that will be added to the component. Defaults to "".

Slots

  • inner_block

modal(assigns)

Renders a modal.

Attributes

  • id (:string) (required) - modal ID.
  • class (:string) - class for the modal wrapper. Defaults to nil.
  • box_class (:string) - class for the modal box. Defaults to "max-w-xl".
  • title (:string) - modal title. Defaults to nil.
  • close_label (:string) - Defaults to "Close modal".
  • open (:boolean) - modal open. Defaults to true.
  • on_cancel (Phoenix.LiveView.JS) - event triggered on modal close. Defaults to %Phoenix.LiveView.JS{ops: []}.
  • Global attributes are accepted.

Slots

  • inner_block (required)

theme_selector(assigns)

Renders a theme selector.

Attributes

  • socket (:any) (required)
  • class (:string) - Defaults to nil.
  • label (:string) - Defaults to "Theme".
  • themes (:list) - A list of tuples with {theme_label, theme_name} format. Examples include [{"Light", "light"}, {"Dark", "dark"}].

topbar(assigns)

Renders a topbar.

Attributes

  • class (:string) - additional class to be added to the component. Defaults to "".

Slots

  • inner_block

topbar_branding(assigns)

Renders the topbar branding.

Attributes

  • class (:string) - additional class that will be added to the component. Defaults to "".
  • title (:string) - title that will be displayed next to the logo. Defaults to "Backpex".
  • hide_title (:boolean) - if the title should be hidden. Defaults to false.

Slots

  • logo - the logo of the branding.

topbar_dropdown(assigns)

Renders a topbar dropdown.

Attributes

  • class (:string) - additional class that will be added to the component. Defaults to nil.

Slots

  • label (required) - label of the dropdown.

Functions

close_modal(js \\ %JS{}, id)

noreply(socket)

ok(socket)

open_modal(js \\ %JS{}, id)

visible_fields_by_panel(fields, panel, assigns)

Filters fields by certain panel.

Examples

iex> Backpex.HTML.Layout.visible_fields_by_panel([field1: %{panel: :default}, field2: %{panel: :panel}], :default, nil)
[field1: %{panel: :default}]

iex> Backpex.HTML.Layout.visible_fields_by_panel([field1: %{panel: :default, visible: fn _assigns -> false end}, field2: %{panel: :panel}], :default, nil)
[]

iex> Backpex.HTML.Layout.visible_fields_by_panel([field1: %{panel: :default}], :panel, nil)
[]