Module: UI::HoverCardContentBehavior

Included in:
HoverCardContent, HoverCardContentComponent
Defined in:
app/behaviors/ui/hover_card_content_behavior.rb

Overview

Shared behavior for HoverCardContent component Provides HTML attributes and styling for the content element

Instance Method Summary collapse

Instance Method Details

#content_classesObject

Returns combined CSS classes for the hover card content



16
17
18
19
20
21
22
# File 'app/behaviors/ui/hover_card_content_behavior.rb', line 16

def content_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  TailwindMerge::Merger.new.merge([
    content_base_classes,
    classes_value
  ].compact.join(" "))
end

#content_data_attributesObject

Returns data attributes for the hover card content



25
26
27
28
29
30
31
32
# File 'app/behaviors/ui/hover_card_content_behavior.rb', line 25

def content_data_attributes
  {
    ui__hover_card_target: "content",
    align: @align,
    side_offset: @side_offset,
    action: "mouseenter->ui--hover-card#keepOpen mouseleave->ui--hover-card#scheduleHide"
  }
end

#content_html_attributesObject

Returns HTML attributes for the hover card content element



7
8
9
10
11
12
13
# File 'app/behaviors/ui/hover_card_content_behavior.rb', line 7

def content_html_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  {
    class: content_classes,
    data: content_data_attributes
  }.merge(attributes_value)
end