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(record, alt: nil, class: "", size: 64, avatar_options: {}) ⇒ AvatarComponent

Returns a new instance of AvatarComponent.

Parameters:

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

    text for the alt tag

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

    custom CSS class(es)

  • size (Integer) (defaults to: 64)

    size in pixel

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


12
13
14
15
16
17
18
# File 'app/components/pajamas/avatar_component.rb', line 12

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