Class: PhlexKit::AvatarBadge
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::AvatarBadge
- Defined in:
- app/components/phlex_kit/avatar/avatar_badge.rb
Overview
Status dot pinned to a PhlexKit::Avatar's bottom-right corner, ported from shadcn/ui's AvatarBadge. Empty for a plain presence dot, or wrap a small svg glyph (hidden automatically on xs/sm avatars). Recolor via style/class — defaults to the brand fill. See avatar.rb.
Instance Method Summary collapse
-
#initialize(label: nil, **attrs) ⇒ AvatarBadge
constructor
label: gives the color-only presence dot an accessible alternative (a .pk-sr-only span, like AttachmentAction's).
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(label: nil, **attrs) ⇒ AvatarBadge
label: gives the color-only presence dot an accessible alternative (a .pk-sr-only span, like AttachmentAction's). No default — a purely decorative dot stays silent.
10 11 12 13 |
# File 'app/components/phlex_kit/avatar/avatar_badge.rb', line 10 def initialize(label: nil, **attrs) @label = label @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
15 16 17 18 19 20 |
# File 'app/components/phlex_kit/avatar/avatar_badge.rb', line 15 def view_template(&block) span(**mix({ class: "pk-avatar-badge" }, @attrs)) do span(class: "pk-sr-only") { @label } if @label block&.call end end |