Class: Shadcn::Field::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Field::Component
- Defined in:
- app/components/shadcn/field/component.rb
Overview
Port of registry/new-york-v4/ui/field.tsx
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(orientation: :vertical, **attributes) ⇒ Component
constructor
A new instance of Component.
- #style_variants ⇒ Object
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name
Constructor Details
#initialize(orientation: :vertical, **attributes) ⇒ Component
Returns a new instance of Component.
43 44 45 46 |
# File 'app/components/shadcn/field/component.rb', line 43 def initialize(orientation: :vertical, **attributes) @orientation = orientation&.to_sym || :vertical super(**attributes) end |
Instance Attribute Details
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
41 42 43 |
# File 'app/components/shadcn/field/component.rb', line 41 def orientation @orientation end |
Instance Method Details
#call ⇒ Object
56 57 58 |
# File 'app/components/shadcn/field/component.rb', line 56 def call render_element(body: safe_join([ label, field_content, content, description, error ].compact)) end |
#element_attributes(**defaults) ⇒ Object
52 53 54 |
# File 'app/components/shadcn/field/component.rb', line 52 def element_attributes(**defaults) super(**{ role: "group", "data-orientation" => orientation }.merge(defaults)) end |
#style_variants ⇒ Object
48 49 50 |
# File 'app/components/shadcn/field/component.rb', line 48 def style_variants { orientation: } end |