Class: PhlexKit::HoverCardContent

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/hover_card/hover_card_content.rb

Overview

The floating panel of a PhlexKit::HoverCard. side: picks the edge it opens from (:bottom default, :top/:left/:right — shadcn's side prop).

Constant Summary collapse

SIDES =
{ bottom: nil, top: "top", left: "left", right: "right" }.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(side: :bottom, **attrs) ⇒ HoverCardContent

Returns a new instance of HoverCardContent.



7
8
9
10
# File 'app/components/phlex_kit/hover_card/hover_card_content.rb', line 7

def initialize(side: :bottom, **attrs)
  @side = side.to_sym
  @attrs = attrs
end

Instance Method Details

#view_templateObject



12
13
14
15
# File 'app/components/phlex_kit/hover_card/hover_card_content.rb', line 12

def view_template(&)
  classes = [ "pk-hover-card-content", fetch_option(SIDES, @side, :side) ].compact.join(" ")
  div(**mix({ class: classes, popover: "manual", data: { phlex_kit__hover_card_target: "content", state: "closed" } }, @attrs), &)
end