Class: UI::Tooltip
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::Tooltip
- Includes:
- TooltipBehavior
- Defined in:
- app/components/ui/tooltip.rb
Overview
Tooltip - Phlex implementation
Root container for tooltip. Manages tooltip state via Stimulus controller.
Supports asChild pattern for composition without wrapper elements.
Instance Method Summary collapse
-
#initialize(as_child: false, **attributes) ⇒ Tooltip
constructor
A new instance of Tooltip.
- #view_template(&block) ⇒ Object
Methods included from TooltipBehavior
#tooltip_data_attributes, #tooltip_html_attributes
Constructor Details
#initialize(as_child: false, **attributes) ⇒ Tooltip
Returns a new instance of Tooltip.
37 38 39 40 |
# File 'app/components/ui/tooltip.rb', line 37 def initialize(as_child: false, **attributes) @as_child = as_child @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/components/ui/tooltip.rb', line 42 def view_template(&block) tooltip_attrs = tooltip_html_attributes.deep_merge(@attributes) if @as_child # Yield data attributes to block - child receives controller setup yield(tooltip_attrs) if block_given? else # Default: render wrapper div with controller div(**tooltip_attrs) do yield if block_given? end end end |