Class: Ui::Avatar::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Ui::Avatar::Component
- 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
-
#alt ⇒ Object
readonly
Returns the value of attribute alt.
-
#fallback ⇒ Object
readonly
Returns the value of attribute fallback.
-
#html_attrs ⇒ Object
readonly
Returns the value of attribute html_attrs.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Instance Method Summary collapse
-
#initialize(src: nil, alt: "", fallback: nil, size: :md, **html_attrs) ⇒ Component
constructor
A new instance of Component.
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
#alt ⇒ Object (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 |
#fallback ⇒ Object (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_attrs ⇒ Object (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 |
#size ⇒ Object (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 |
#src ⇒ Object (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 |