Class: Pajamas::AvatarComponent

Inherits:
Component
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/components/pajamas/avatar_component.rb

Constant Summary collapse

SIZE_OPTIONS =
[16, 24, 32, 48, 64, 96].freeze

Instance Method Summary collapse

Constructor Details

#initialize(item, alt: nil, class: "", size: 64, avatar_options: {}) ⇒ AvatarComponent

Returns a new instance of AvatarComponent.

Parameters:

  • item (User, Project, Group, AvatarEmail, String)
  • alt (String) (defaults to: nil)

    text for the alt attribute

  • class (String) (defaults to: "")

    custom CSS class(es)

  • size (Integer) (defaults to: 64)

    size in pixel

  • avatar_options (Hash) (defaults to: {})


19
20
21
22
23
24
25
# File 'app/components/pajamas/avatar_component.rb', line 19

def initialize(item, alt: nil, class: "", size: 64, avatar_options: {})
  @item = item
  @alt = alt
  @class = binding.local_variable_get(:class)
  @size = filter_attribute(size.to_i, SIZE_OPTIONS, default: 64)
  @avatar_options = avatar_options
end