Class: PhlexKit::Avatar
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Avatar
- Defined in:
- app/components/phlex_kit/avatar/avatar.rb
Overview
Avatar, ported from ruby_ui's RubyUI::Avatar — a round image with a fallback
(initials), matched to shadcn/ui's current avatar. Keeps ruby_ui's
phlex-kit--avatar Stimulus controller (shows the image once it loads, else
the fallback). Compose AvatarImage + AvatarFallback (+ optional AvatarBadge
status dot); fallback-only is fine (the controller no-ops without an image).
Overlap several in an AvatarGroup, with AvatarGroupCount as the "+3" pill.
shadcn ships sm/default/lg; xs/xl are kit extras. SIZES.fetch fails loud.
Constant Summary collapse
- SIZES =
{ xs: "xs", sm: "sm", md: nil, lg: "lg", xl: "xl" }.freeze
Instance Method Summary collapse
-
#initialize(size: :md, **attrs) ⇒ Avatar
constructor
A new instance of Avatar.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(size: :md, **attrs) ⇒ Avatar
Returns a new instance of Avatar.
12 13 14 15 |
# File 'app/components/phlex_kit/avatar/avatar.rb', line 12 def initialize(size: :md, **attrs) @size = size.to_sym @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
17 18 19 |
# File 'app/components/phlex_kit/avatar/avatar.rb', line 17 def view_template(&block) span(**mix({ class: classes, data: { controller: "phlex-kit--avatar" } }, @attrs), &block) end |