Class: Ui::Avatar::Component

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/uikit_rails/templates/components/avatar/component.rb

Overview

Circular avatar with image or fallback initials.

Constant Summary collapse

SIZES =
%i[sm md lg].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src: nil, alt: "", fallback: nil, size: :md, **html_attrs) ⇒ Component

Returns a new instance of Component.



11
12
13
14
15
16
17
18
# File 'lib/uikit_rails/templates/components/avatar/component.rb', line 11

def initialize(src: nil, alt: "", fallback: nil, size: :md, **html_attrs)
  @src = src
  @alt = alt
  @fallback = fallback || initials_from(alt)
  @size = size.to_sym
  @html_attrs = html_attrs
  super()
end

Instance Attribute Details

#altObject (readonly)

Returns the value of attribute alt.



9
10
11
# File 'lib/uikit_rails/templates/components/avatar/component.rb', line 9

def alt
  @alt
end

#fallbackObject (readonly)

Returns the value of attribute fallback.



9
10
11
# File 'lib/uikit_rails/templates/components/avatar/component.rb', line 9

def fallback
  @fallback
end

#html_attrsObject (readonly)

Returns the value of attribute html_attrs.



9
10
11
# File 'lib/uikit_rails/templates/components/avatar/component.rb', line 9

def html_attrs
  @html_attrs
end

#sizeObject (readonly)

Returns the value of attribute size.



9
10
11
# File 'lib/uikit_rails/templates/components/avatar/component.rb', line 9

def size
  @size
end

#srcObject (readonly)

Returns the value of attribute src.



9
10
11
# File 'lib/uikit_rails/templates/components/avatar/component.rb', line 9

def src
  @src
end