Module: UI::TooltipContentBehavior
- Included in:
- TooltipContent, TooltipContentComponent
- Defined in:
- app/behaviors/ui/tooltip_content_behavior.rb
Overview
TooltipContentBehavior
Shared behavior for TooltipContent component. The content is the popup that displays tooltip information.
Instance Method Summary collapse
-
#tooltip_content_classes ⇒ Object
Returns combined CSS classes for the tooltip content.
-
#tooltip_content_data_attributes ⇒ Object
Returns data attributes for the tooltip content.
-
#tooltip_content_html_attributes ⇒ Object
Returns HTML attributes for the tooltip content element.
Instance Method Details
#tooltip_content_classes ⇒ Object
Returns combined CSS classes for the tooltip content
19 20 21 22 23 24 25 |
# File 'app/behaviors/ui/tooltip_content_behavior.rb', line 19 def tooltip_content_classes classes_value = respond_to?(:classes, true) ? classes : @classes TailwindMerge::Merger.new.merge([ tooltip_content_base_classes, classes_value ].compact.join(" ")) end |
#tooltip_content_data_attributes ⇒ Object
Returns data attributes for the tooltip content
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/behaviors/ui/tooltip_content_behavior.rb', line 28 def tooltip_content_data_attributes attributes_value = respond_to?(:attributes, true) ? attributes : @attributes base_data = attributes_value&.fetch(:data, {}) || {} side_value = respond_to?(:side, true) ? side : @side align_value = respond_to?(:align, true) ? align : @align side_offset_value = respond_to?(:side_offset, true) ? side_offset : @side_offset base_data.merge({ ui__tooltip_target: "content", state: "closed", side: side_value || "top", align: align_value || "center", ui__tooltip_side_offset_value: side_offset_value || 4 }).compact end |
#tooltip_content_html_attributes ⇒ Object
Returns HTML attributes for the tooltip content element
11 12 13 14 15 16 |
# File 'app/behaviors/ui/tooltip_content_behavior.rb', line 11 def tooltip_content_html_attributes { class: tooltip_content_classes, data: tooltip_content_data_attributes }.compact end |