Class: PhlexKit::TooltipContent

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/tooltip/tooltip_content.rb

Overview

The tooltip bubble. side: picks the edge it opens from (:top default, :bottom/:left/:right — shadcn's side prop). See tooltip.rb.

Constant Summary collapse

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

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(side: :top, **attrs) ⇒ TooltipContent

Returns a new instance of TooltipContent.



7
8
9
10
# File 'app/components/phlex_kit/tooltip/tooltip_content.rb', line 7

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

Instance Method Details

#view_templateObject



12
13
14
15
# File 'app/components/phlex_kit/tooltip/tooltip_content.rb', line 12

def view_template(&)
  classes = [ "pk-tooltip-content", fetch_option(SIDES, @side, :side) ].compact.join(" ")
  div(**mix({ class: classes, role: "tooltip" }, @attrs), &)
end