Module: UI::AvatarBehavior

Included in:
Avatar, AvatarComponent
Defined in:
app/behaviors/ui/avatar_behavior.rb

Overview

UI::AvatarBehavior

Instance Method Summary collapse

Instance Method Details

#avatar_classesObject

Returns combined CSS classes for the avatar



27
28
29
30
31
32
33
# File 'app/behaviors/ui/avatar_behavior.rb', line 27

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

#avatar_data_attributesObject

Returns data attributes for Stimulus controller



36
37
38
39
40
41
# File 'app/behaviors/ui/avatar_behavior.rb', line 36

def avatar_data_attributes
  {
    controller: "ui--avatar",
    slot: "avatar"
  }
end

#avatar_html_attributesObject

Returns HTML attributes for the avatar element



19
20
21
22
23
24
# File 'app/behaviors/ui/avatar_behavior.rb', line 19

def avatar_html_attributes
  {
    class: avatar_classes,
    data: avatar_data_attributes
  }
end