LedgerUI.Components.Drawer (LedgerUI v0.2.0)

Copy Markdown View Source

Side panel (<.drawer>) and its sheet parts (<.sheet_header>, <.sheet_body>, <.sheet_footer>).

<.drawer id="customer" placement="right" size="md" title="New customer" description="Who buys from you.">
  <.form for={@form} id="customer-form" phx-submit="save">...</.form>
  <:footer>
    <.button variant="ghost" phx-click={LedgerUI.close("customer")}>Cancel</.button>
    <.button type="submit" form="customer-form" variant="primary">Save</.button>
  </:footer>
</.drawer>

The title is either title="New customer" or the <:title> slot (markup).

A bare drawer is a sliding frame for a menu; with title, :header or :footer (or variant) it is a sheet: header, scrolling body and fixed footer. placement="bottom" is the phone's sheet (rounded top, grab handle). It opens and closes like LedgerUI.Components.Modal (LedgerUI.open/close/toggle, open, on_open, on_close) through the LedgerUI.Overlay hook; by default it does not lock the page's scroll (lock_scroll).

Keep class and panel_class free of transform, filter and contain, so a modal rendered inside the drawer still covers the whole viewport.

layout="page" is the sheet of the app templates: it renders only while open, as a dim lu-overlay and an aside.lu-drawer laid over the closest positioned ancestor (the app shell), with no hook; the page owns the state. The overlay, the Esc key and the × push on_close. The :header slot is then the content before the ×, :footer the <footer>:

<.drawer :if={@order} id="order" layout="page" open on_close="close_order">
  <:header><div><h3>Pedido #2495</h3><p>Criado hoje</p></div></:header>
  ...body...
  <:footer><.button>Imprimir</.button></:footer>
</.drawer>

inline renders it in the page flow (a static preview, always open, without the hook).

Summary

Functions

Same as drawer/1 (same attributes and slots), under the name the design vitrine uses.

The scrolling body of a sheet: it takes the height the header and the footer leave.

The footer of a sheet: the buttons, aligned to the end on a tinted bar.

The header of a sheet: title and description (or :content), a back arrow, buttons and the close ×.

Functions

drawer(assigns)

Attributes

  • id (:string) (required)
  • open (:boolean) - Defaults to false.
  • layout (:string) - page: the canvas-v2 sheet (lu-overlay + aside.lu-drawer with header, .bd, footer), shown only while open and closed by on_close (a LiveView event or %JS{}). Defaults to nil. Must be one of nil, "", or "page".
  • side (:string) - Defaults to "left". Must be one of "left", or "right".
  • placement (:string) - The same as side, which it overrides when given. Defaults to nil. Must be one of nil, "", "left", "right", or "bottom".
  • size (:string) - Defaults to nil.Must be one of nil, "", "sm", "md", "lg", "wide", or "xl".
  • variant (:string) - Defaults to nil.Must be one of nil, "", "float", or "flush".
  • description (:string) - Defaults to nil.
  • close_button (:boolean) - Defaults to true.
  • close_label (:string) - Defaults to "Close".
  • floating (:boolean) - A sheet that floats with margins around it, the look of variant="float"; makes a bare drawer a sheet. Defaults to false.
  • overlay (:boolean) - Defaults to true.
  • lock_scroll (:boolean) - Defaults to false.
  • prevent_close (:boolean) - Defaults to false.
  • on_open (:any) - Defaults to nil.
  • on_close (:any) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • class (:any) - Merged into the sliding frame. Defaults to nil.
  • panel_class (:any) - Defaults to nil.
  • body_class (:any) - Defaults to nil.
  • inline (:boolean) - Static preview: in the page flow, always open, no hook. Defaults to false.
  • Global attributes are accepted.

Slots

  • actions
  • back
  • title - The sheet's title (the title="..." attribute, a plain string, does the same); draws the header.
  • footer - Accepts attributes:
    • class (:any)
  • header - Accepts attributes:
    • class (:any)
    • style (:string)
  • inner_block (required)

sheet(assigns)

Same as drawer/1 (same attributes and slots), under the name the design vitrine uses.

Attributes

  • id (:string) (required)
  • open (:boolean) - Defaults to false.
  • layout (:string) - page: the canvas-v2 sheet (lu-overlay + aside.lu-drawer with header, .bd, footer), shown only while open and closed by on_close (a LiveView event or %JS{}). Defaults to nil. Must be one of nil, "", or "page".
  • side (:string) - Defaults to "left". Must be one of "left", or "right".
  • placement (:string) - The same as side, which it overrides when given. Defaults to "bottom". Must be one of nil, "", "left", "right", or "bottom".
  • size (:string) - Defaults to nil.Must be one of nil, "", "sm", "md", "lg", "wide", or "xl".
  • variant (:string) - Defaults to nil.Must be one of nil, "", "float", or "flush".
  • description (:string) - Defaults to nil.
  • close_button (:boolean) - Defaults to true.
  • close_label (:string) - Defaults to "Close".
  • floating (:boolean) - A sheet that floats with margins around it, the look of variant="float"; makes a bare drawer a sheet. Defaults to false.
  • overlay (:boolean) - Defaults to true.
  • lock_scroll (:boolean) - Defaults to false.
  • prevent_close (:boolean) - Defaults to false.
  • on_open (:any) - Defaults to nil.
  • on_close (:any) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • class (:any) - Merged into the sliding frame. Defaults to nil.
  • panel_class (:any) - Defaults to nil.
  • body_class (:any) - Defaults to nil.
  • inline (:boolean) - Static preview: in the page flow, always open, no hook. Defaults to false.
  • Global attributes are accepted.

Slots

  • actions
  • back
  • title - The sheet's title (the title="..." attribute, a plain string, does the same); draws the header.
  • footer - Accepts attributes:
    • class (:any)
  • header - Accepts attributes:
    • class (:any)
    • style (:string)
  • inner_block (required)

sheet_body(assigns)

The scrolling body of a sheet: it takes the height the header and the footer leave.

Attributes

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

Slots

  • inner_block (required)

sheet_footer(assigns)

The footer of a sheet: the buttons, aligned to the end on a tinted bar.

Attributes

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

Slots

  • inner_block (required)

sheet_header(assigns)

The header of a sheet: title and description (or :content), a back arrow, buttons and the close ×.

Attributes

  • id (:string) - The id of the title, for the drawer's aria-labelledby. Defaults to nil.
  • drawer (:string) - The id of the drawer the close button closes; the closest one when not given. Defaults to nil.
  • title (:string) - Defaults to nil.
  • description (:string) - Defaults to nil.
  • close_button (:boolean) - Defaults to true.
  • close_label (:string) - Defaults to "Close".
  • class (:any) - Defaults to nil.
  • style (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • actions
  • back
  • content