Module: UI::TooltipBehavior
- Included in:
- Tooltip, TooltipComponent
- Defined in:
- app/behaviors/ui/tooltip_behavior.rb
Overview
UI::TooltipBehavior
Instance Method Summary collapse
-
#tooltip_data_attributes ⇒ Object
Returns data attributes for the tooltip controller.
-
#tooltip_html_attributes ⇒ Object
Returns HTML attributes for the tooltip root element When as_child is true, don’t include the “contents” class since the parent element will handle its own styling.
Instance Method Details
#tooltip_data_attributes ⇒ Object
Returns data attributes for the tooltip controller
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/behaviors/ui/tooltip_behavior.rb', line 42 def tooltip_data_attributes attributes_value = respond_to?(:attributes, true) ? attributes : @attributes base_data = attributes_value&.fetch(:data, {}) || {} # Add tooltip controller controllers = [base_data[:controller], "ui--tooltip"].compact.join(" ") base_data.merge({ controller: controllers }).compact end |
#tooltip_html_attributes ⇒ Object
Returns HTML attributes for the tooltip root element When as_child is true, don’t include the “contents” class since the parent element will handle its own styling
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/behaviors/ui/tooltip_behavior.rb', line 27 def tooltip_html_attributes attrs = { data: tooltip_data_attributes } # Only add "contents" class when not using asChild # asChild mode passes data attributes to parent, which handles its own styling unless instance_variable_defined?(:@as_child) && @as_child attrs[:class] = "contents" end attrs.compact end |