Class: Shadcn::Attachment::Component
- Inherits:
-
Shadcn::ApplicationViewComponent
- Object
- ViewComponent::Base
- Shadcn::ApplicationViewComponent
- Shadcn::Attachment::Component
- Defined in:
- app/components/shadcn/attachment/component.rb
Overview
Port of registry/new-york-v4/ui/attachment.tsx
state: is not a cva variant upstream and is not one here: it is written
as data-state and read by selectors on this element and on its children
— data-[state=idle]:border-dashed here, and
group-data-[state=error]/attachment:… on the media and the description
(attachment.tsx:9 and :49). Only size and orientation choose classes.
Constant Summary
Constants inherited from Shadcn::ApplicationViewComponent
Shadcn::ApplicationViewComponent::CONTENTS_STYLE, Shadcn::ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Attributes inherited from Shadcn::ApplicationViewComponent
Instance Method Summary collapse
- #element_attributes(**defaults) ⇒ Object
-
#initialize(state: :done, size: :default, orientation: :horizontal, **attributes) ⇒ Component
constructor
A new instance of Component.
- #style_variants ⇒ Object
Methods inherited from Shadcn::ApplicationViewComponent
#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name
Constructor Details
#initialize(state: :done, size: :default, orientation: :horizontal, **attributes) ⇒ Component
Returns a new instance of Component.
56 57 58 59 60 61 |
# File 'app/components/shadcn/attachment/component.rb', line 56 def initialize(state: :done, size: :default, orientation: :horizontal, **attributes) @state = state&.to_sym || :done @size = size&.to_sym || :default @orientation = orientation&.to_sym || :horizontal super(**attributes) end |
Instance Attribute Details
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
54 55 56 |
# File 'app/components/shadcn/attachment/component.rb', line 54 def orientation @orientation end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
54 55 56 |
# File 'app/components/shadcn/attachment/component.rb', line 54 def size @size end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
54 55 56 |
# File 'app/components/shadcn/attachment/component.rb', line 54 def state @state end |
Instance Method Details
#element_attributes(**defaults) ⇒ Object
67 68 69 70 71 72 73 |
# File 'app/components/shadcn/attachment/component.rb', line 67 def element_attributes(**defaults) super(**{ "data-state" => state, "data-size" => size, "data-orientation" => orientation }.merge(defaults)) end |
#style_variants ⇒ Object
63 64 65 |
# File 'app/components/shadcn/attachment/component.rb', line 63 def style_variants { size:, orientation: } end |