LedgerUI.Components.Popover (LedgerUI v0.2.0)

Copy Markdown View Source

A card with an arrow next to its trigger (<.popover>), for more than a tooltip holds.

<.popover id="lesson">
  <:trigger><.button variant="primary">Lessons</.button></:trigger>
  <:title>Group Lesson</:title>
  <p class="mt-2">Lorem ipsum dolor sit amet.</p>
</.popover>

<.popover id="john" trigger_on="hover" placement="top" width="192px">...</.popover>

Opens and closes from the browser (LedgerUI.toggle("lesson")), from the server (LedgerUI.close(socket, "lesson")) or from open; a click outside and Esc close it. The LedgerUI.Float hook (priv/static/ledger_ui/hooks/float.js) places it (placement, fallbacks when there is no room, offset), draws the arrow and runs on_open / on_close (an event name with payload %{"id" => id} to target, or a %JS{}).

The panel is a role="dialog" named by its :title or by label. width is the card's width (272px by default; nil leaves it to its content).

Summary

Functions

popover(assigns)

Attributes

  • id (:string) (required)
  • open (:boolean) - Defaults to false.
  • placement (:string) - Defaults to "right-start". Must be one of "bottom-start", "bottom", "bottom-end", "top-start", "top", "top-end", "left-start", "left", "left-end", "right-start", "right", or "right-end".
  • fallbacks (:list) - Defaults to ["bottom", "top"].
  • offset (:integer) - Defaults to 12.
  • trigger_on (:string) - Defaults to "click". Must be one of "click", or "hover".
  • arrow (:boolean) - Defaults to true.
  • on_open (:any) - Defaults to nil.
  • on_close (:any) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • label (:string) - Defaults to nil.
  • class (:any) - Merged into the card. Defaults to nil.
  • width (:string) - The card's width; nil for its content's. Defaults to "272px".
  • Global attributes are accepted.

Slots

  • inner_block
  • title
  • trigger (required)