Class: Shadcn::ItemMediaComponent

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

Overview

Item Media component - displays icons, images, or avatars

Constant Summary collapse

VARIANTS =
{
  default: "shrink-0",
  icon: "flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted [&>svg]:size-5 [&>svg]:text-muted-foreground",
  image: "shrink-0 overflow-hidden rounded-lg"
}.freeze

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(variant: :default, **options) ⇒ ItemMediaComponent



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

def initialize(variant: :default, **options)
  super(**options)
  @variant = variant.to_sym
end

Instance Method Details

#callObject



18
19
20
# File 'app/components/shadcn/item_media_component.rb', line 18

def call
  (:div, content, class: merge_classes(VARIANTS[@variant]), **html_options.merge(build_data))
end