Class: UI::TooltipTriggerComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::TooltipTriggerComponent
- Includes:
- TooltipTriggerBehavior
- Defined in:
- app/view_components/ui/tooltip_trigger_component.rb
Overview
TriggerComponent - ViewComponent implementation
The interactive element that shows/hides the tooltip on hover/focus. Supports asChild pattern for composition with other components.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(as_child: false, **attributes) ⇒ TooltipTriggerComponent
constructor
A new instance of TooltipTriggerComponent.
-
#trigger_attrs ⇒ Object
Returns trigger attributes for as_child mode.
Methods included from TooltipTriggerBehavior
#tooltip_trigger_classes, #tooltip_trigger_data_attributes, #tooltip_trigger_html_attributes
Constructor Details
#initialize(as_child: false, **attributes) ⇒ TooltipTriggerComponent
Returns a new instance of TooltipTriggerComponent.
24 25 26 27 |
# File 'app/view_components/ui/tooltip_trigger_component.rb', line 24 def initialize(as_child: false, **attributes) @as_child = as_child @attributes = attributes end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/view_components/ui/tooltip_trigger_component.rb', line 34 def call if @as_child # asChild mode: yield self so caller can access trigger_attrs content else # Default mode: render as button with proper styling content_tag :button, **trigger_attrs do content end end end |
#trigger_attrs ⇒ Object
Returns trigger attributes for as_child mode
30 31 32 |
# File 'app/view_components/ui/tooltip_trigger_component.rb', line 30 def trigger_attrs tooltip_trigger_html_attributes.deep_merge(@attributes) end |