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. 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.



7
8
9
10
# File 'app/components/phlex_kit/popover/popover_content.rb', line 7

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

Instance Method Details

#view_templateObject



12
13
14
15
# File 'app/components/phlex_kit/popover/popover_content.rb', line 12

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