Class: PartyAvatarComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- PartyAvatarComponent
- Defined in:
- app/components/party_avatar_component.rb
Overview
Displays a party's profile image or initials fallback.
Wraps Railsboot::AvatarComponent with party-specific logic.
Constant Summary collapse
- SIZES =
{ xs: 24, sm: 32, md: 48, lg: 80, xl: 120 }.freeze
- DEFAULT_SIZE =
:md
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(party:, size: DEFAULT_SIZE, link: false, shape: 'circle', **html_attributes) ⇒ PartyAvatarComponent
constructor
A new instance of PartyAvatarComponent.
Methods inherited from ApplicationComponent
#cms_link, #fetch_or_fallback, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags
Constructor Details
#initialize(party:, size: DEFAULT_SIZE, link: false, shape: 'circle', **html_attributes) ⇒ PartyAvatarComponent
Returns a new instance of PartyAvatarComponent.
31 32 33 34 35 36 37 38 |
# File 'app/components/party_avatar_component.rb', line 31 def initialize(party:, size: DEFAULT_SIZE, link: false, shape: 'circle', **html_attributes) super() @party = party @size = SIZES[size] || size.to_i @link = link @shape = shape @html_attributes = html_attributes end |
Instance Method Details
#call ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/components/party_avatar_component.rb', line 40 def call if profile_image? render_with_image else render_with_initials end end |