Class: PhlexKit::TooltipTrigger
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::TooltipTrigger
- 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
-
#initialize(focusable: true, **attrs) ⇒ TooltipTrigger
constructor
A new instance of TooltipTrigger.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
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 |