Class: PhlexKit::PopoverContent

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/popover/popover_content.rb

Overview

The floating panel of a PhlexKit::Popover — a native [popover=auto] element (top layer, browser light dismiss) anchor-positioned to the trigger with viewport-edge flipping (popover.css). align: :end flips it to the trigger's end edge (their align prop). See popover.rb.

Constant Summary collapse

ALIGNS =
{ start: nil, end: "end" }.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(align: :start, **attrs) ⇒ PopoverContent

Returns a new instance of PopoverContent.



9
10
11
12
# File 'app/components/phlex_kit/popover/popover_content.rb', line 9

def initialize(align: :start, **attrs)
  @align = align.to_sym
  @attrs = attrs
end

Instance Method Details

#view_templateObject



14
15
16
17
# File 'app/components/phlex_kit/popover/popover_content.rb', line 14

def view_template(&)
  classes = [ "pk-popover-content", fetch_option(ALIGNS, @align, :align) ].compact.join(" ")
  div(**mix({ class: classes, popover: "auto", data: { phlex_kit__popover_target: "content", state: "closed" } }, @attrs), &)
end