Class: Shadcn::AvatarFallbackComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/avatar_fallback_component.rb

Overview

Avatar Fallback component for initials or placeholder

Constant Summary collapse

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

Methods inherited from BaseComponent

#content

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(class: nil, **options, &block) ⇒ AvatarFallbackComponent



8
9
10
11
# File 'app/components/shadcn/avatar_fallback_component.rb', line 8

def initialize(class: nil, **options, &block)
  super(**options, &block)
  @custom_class = binding.local_variable_get(:class)
end

Instance Method Details

#callObject



13
14
15
# File 'app/components/shadcn/avatar_fallback_component.rb', line 13

def call
  (:span, content, class: cn(FALLBACK_CLASSES, @custom_class))
end