Class: Shadcn::Item::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Item::Component
- Defined in:
- app/components/shadcn/item/component.rb
Overview
Port of registry/new-york-v4/ui/item.tsx
group/item is half a mechanism: ItemMedia's
group-has-[[data-slot=item-description]]/item:… classes reach back into
this named group to shift the media when a description is present. Both
halves have to stay exactly as upstream wrote them — parity checks that
each class exists, not that they still refer to each other.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #element_attributes(**defaults) ⇒ Object
-
#initialize(variant: :default, size: :default, **attributes) ⇒ Component
constructor
A new instance of Component.
- #style_variants ⇒ Object
Methods inherited from ApplicationViewComponent
#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name
Constructor Details
#initialize(variant: :default, size: :default, **attributes) ⇒ Component
Returns a new instance of Component.
41 42 43 44 45 |
# File 'app/components/shadcn/item/component.rb', line 41 def initialize(variant: :default, size: :default, **attributes) @variant = variant&.to_sym || :default @size = size&.to_sym || :default super(**attributes) end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
39 40 41 |
# File 'app/components/shadcn/item/component.rb', line 39 def size @size end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
39 40 41 |
# File 'app/components/shadcn/item/component.rb', line 39 def variant @variant end |
Instance Method Details
#element_attributes(**defaults) ⇒ Object
51 52 53 |
# File 'app/components/shadcn/item/component.rb', line 51 def element_attributes(**defaults) super(**{ "data-variant" => variant, "data-size" => size }.merge(defaults)) end |
#style_variants ⇒ Object
47 48 49 |
# File 'app/components/shadcn/item/component.rb', line 47 def style_variants { variant:, size: } end |