Class: LightningUiKit::AvatarComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/lightning_ui_kit/avatar_component.rb

Constant Summary collapse

SIZE_CLASSES =
{
  sm: "lui:size-6",
  md: "lui:size-8",
  lg: "lui:size-10"
}

Instance Method Summary collapse

Methods inherited from BaseComponent

#merge_classes

Methods included from HeroiconHelper

#heroicon

Constructor Details

#initialize(url: nil, size: :md, initials: nil, square: false, alt: nil, **options) ⇒ AvatarComponent

Returns a new instance of AvatarComponent.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
# File 'app/components/lightning_ui_kit/avatar_component.rb', line 10

def initialize(url: nil, size: :md, initials: nil, square: false, alt: nil, **options)
  raise ArgumentError, "url or initials must be provided" if url.nil? && initials.nil?

  @url = url
  @size = size
  @initials = initials
  @square = square
  @alt = alt
  @options = options
end