Class: Shadcn::Attachment::Media::Component

Inherits:
Shadcn::ApplicationViewComponent show all
Defined in:
app/components/shadcn/attachment/media/component.rb

Overview

AttachmentMedia — the square thumbnail: an icon, or the file itself.

Constant Summary

Constants inherited from Shadcn::ApplicationViewComponent

Shadcn::ApplicationViewComponent::CONTENTS_STYLE, Shadcn::ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary collapse

Attributes inherited from Shadcn::ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from Shadcn::ApplicationViewComponent

#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name

Constructor Details

#initialize(variant: :icon, **attributes) ⇒ Component

Returns a new instance of Component.



41
42
43
44
# File 'app/components/shadcn/attachment/media/component.rb', line 41

def initialize(variant: :icon, **attributes)
  @variant = variant&.to_sym || :icon
  super(**attributes)
end

Instance Attribute Details

#variantObject (readonly)

Returns the value of attribute variant.



39
40
41
# File 'app/components/shadcn/attachment/media/component.rb', line 39

def variant
  @variant
end

Instance Method Details

#element_attributes(**defaults) ⇒ Object



50
51
52
# File 'app/components/shadcn/attachment/media/component.rb', line 50

def element_attributes(**defaults)
  super(**{ "data-variant" => variant }.merge(defaults))
end

#style_variantsObject



46
47
48
# File 'app/components/shadcn/attachment/media/component.rb', line 46

def style_variants
  { variant: }
end