Class: UI::AvatarImageComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
AvatarImageBehavior
Defined in:
app/view_components/ui/avatar_image_component.rb

Overview

Avatar Image - ViewComponent implementation

Displays the avatar image. Only renders when it has loaded successfully.

Instance Method Summary collapse

Methods included from AvatarImageBehavior

#avatar_image_classes, #avatar_image_data_attributes, #avatar_image_html_attributes

Constructor Details

#initialize(src:, alt: "", classes: "", **attributes) ⇒ AvatarImageComponent

Returns a new instance of AvatarImageComponent.

Parameters:

  • src (String)

    Image source URL

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

    Alternative text for the image

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



13
14
15
16
17
18
# File 'app/view_components/ui/avatar_image_component.rb', line 13

def initialize(src:, alt: "", classes: "", **attributes)
  @src = src
  @alt = alt
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



20
21
22
# File 'app/view_components/ui/avatar_image_component.rb', line 20

def call
  tag.img(**avatar_image_html_attributes.deep_merge(@attributes))
end