Class: PhlexKit::TooltipTrigger

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

Overview

The element a PhlexKit::Tooltip is anchored to. tabindex: 0 so keyboard users can focus it (the bubble shows on :focus-within) — pass focusable: false when the trigger wraps something already focusable (a button, a link) so it doesn't add a redundant tab stop. See tooltip.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(focusable: true, **attrs) ⇒ TooltipTrigger

Returns a new instance of TooltipTrigger.



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

def initialize(focusable: true, **attrs)
  @focusable = focusable
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



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

def view_template(&block)
  defaults = { class: "pk-tooltip-trigger" }
  defaults[:tabindex] = 0 if @focusable
  span(**mix(defaults, @attrs), &block)
end