Class: Shadcn::ButtonGroup::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::ButtonGroup::Component
- Defined in:
- app/components/shadcn/button_group/component.rb
Overview
Port of registry/new-york-v4/ui/button-group.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
- #element_attributes(**defaults) ⇒ Object
-
#initialize(orientation: nil, **attributes) ⇒ Component
constructor
Left nil rather than defaulted, because upstream destructures
orientationwith no default: the classes fall back to horizontal via cva'sdefaultVariants, butdata-orientationis only emitted when the caller actually passed one. - #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(orientation: nil, **attributes) ⇒ Component
Left nil rather than defaulted, because upstream destructures
orientation with no default: the classes fall back to horizontal via
cva's defaultVariants, but data-orientation is only emitted when the
caller actually passed one.
39 40 41 42 |
# File 'app/components/shadcn/button_group/component.rb', line 39 def initialize(orientation: nil, **attributes) @orientation = orientation&.to_sym super(**attributes) end |
Instance Attribute Details
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
33 34 35 |
# File 'app/components/shadcn/button_group/component.rb', line 33 def orientation @orientation end |
Instance Method Details
#element_attributes(**defaults) ⇒ Object
48 49 50 |
# File 'app/components/shadcn/button_group/component.rb', line 48 def element_attributes(**defaults) super(**{ role: "group", "data-orientation" => orientation }.merge(defaults)) end |
#style_variants ⇒ Object
44 45 46 |
# File 'app/components/shadcn/button_group/component.rb', line 44 def style_variants { orientation: orientation || :horizontal } end |