View Source Backpex.HTML.Layout (Backpex v0.9.1)

Contains all Backpex layout components.

Summary

Components

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

app_shell(assigns)

Renders an app shell representing the base of your layout.

Attributes

  • 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

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

  • title (:string) - modal title. Defaults to nil.
  • target (:string) - live component for the close event to go to. Defaults to nil.
  • close_event_name (:string) - close event name. Defaults to "close-modal".
  • max_width (:string) - modal max width. Defaults to "md".
  • open (:boolean) - modal open. Defaults to true.
  • Global attributes are accepted.

Slots

  • inner_block

theme_selector(assigns)

Renders a theme selector.

Attributes

  • socket (:any) (required)
  • 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 "".

Slots

  • label (required) - label of the dropdown.

Functions

hide_modal(target \\ nil, close_event)

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)
[]