Class: Shadcn::AvatarComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Shadcn::AvatarComponent
- Defined in:
- app/components/shadcn/avatar_component.rb
Overview
Avatar component for user profile images Matches shadcn/ui Avatar component
Constant Summary collapse
- SIZES =
{ sm: "h-8 w-8 text-xs", default: "h-10 w-10 text-sm", lg: "h-12 w-12 text-base", xl: "h-16 w-16 text-lg" }.freeze
- BASE_CLASSES =
"relative flex shrink-0 overflow-hidden rounded-full"- IMAGE_CLASSES =
"aspect-square h-full w-full"- FALLBACK_CLASSES =
"flex h-full w-full items-center justify-center rounded-full bg-muted"
Instance Attribute Summary
Attributes inherited from BaseComponent
#class_name, #data, #html_options
Instance Method Summary collapse
-
#initialize(src: nil, alt: "", fallback: nil, size: :default, **options) ⇒ AvatarComponent
constructor
A new instance of AvatarComponent.
Methods inherited from BaseComponent
Methods included from Rails::Helpers::ClassNameHelper
Constructor Details
#initialize(src: nil, alt: "", fallback: nil, size: :default, **options) ⇒ AvatarComponent
Returns a new instance of AvatarComponent.
41 42 43 44 45 46 47 |
# File 'app/components/shadcn/avatar_component.rb', line 41 def initialize(src: nil, alt: "", fallback: nil, size: :default, **) super(**) @src = src @alt = alt @fallback = fallback || generate_fallback(alt) @size = size.to_sym end |