Class: PhlexKit::PopoverContent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::PopoverContent
- 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
-
#initialize(align: :start, **attrs) ⇒ PopoverContent
constructor
A new instance of PopoverContent.
- #view_template ⇒ Object
Methods inherited from BaseComponent
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_template ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# 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(" ") # `popover:` is a named default, not a merged attr: `mix` joins duplicate # attrs (a caller's `popover: "manual"` would fuse into "auto manual", # which the browser normalizes to manual — killing the native light # dismiss/Escape this controller relies on). Skip the default when the # caller sets it (mirrors MenubarContent). base = { class: classes, data: { phlex_kit__popover_target: "content", state: "closed" } } base[:popover] = "auto" unless attr_set?(:popover) div(**mix(base, @attrs), &) end |