Class: Daisy::DataDisplay::AvatarComponent

Inherits:
LocoMotion::BaseComponent show all
Includes:
LocoMotion::Concerns::IconableComponent, LocoMotion::Concerns::LinkableComponent, LocoMotion::Concerns::TippableComponent
Defined in:
app/components/daisy/data_display/avatar_component.rb

Constant Summary

Constants inherited from LocoMotion::BaseComponent

LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS

Instance Attribute Summary

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

Methods included from LocoMotion::Concerns::IconableComponent

#has_icons?, #left_icon_html, #render_left_icon, #render_right_icon, #right_icon_html

Methods inherited from LocoMotion::BaseComponent

build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces

Methods included from LocoMotion::Concerns::InspectableComponent

#build_inspect_string

Constructor Details

#initialize(**kws, &block) ⇒ AvatarComponent

Create a new avatar component.

Parameters:

  • kws (Hash)

    The keyword arguments for the component.

Options Hash (**kws):

  • src (String)

    URL to the avatar image. If not provided, the component will display an icon or placeholder content.

  • icon (String)

    Name of the Heroicon to display when no image is provided. If neither src nor icon is provided, placeholder content from the block will be shown.

  • tip (String)

    The tooltip text to display when hovering over the component.

  • alt (String)

    The alt text for the image, used by screen readers and shown when the image fails to load. Omitted when not provided.



75
76
77
78
79
80
# File 'app/components/daisy/data_display/avatar_component.rb', line 75

def initialize(**kws, &block)
  super

  @src = config_option(:src)
  @alt = config_option(:alt)
end

Instance Method Details

#before_renderObject



82
83
84
85
86
87
# File 'app/components/daisy/data_display/avatar_component.rb', line 82

def before_render
  # Run component setup *before* super to allow BaseComponent hooks to run last
  setup_component

  super
end