Class: Shadcn::Separator::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Separator::Component
- Defined in:
- app/components/shadcn/separator/component.rb
Overview
Port of registry/new-york-v4/ui/separator.tsx
Reproduces Radix's semantics: a decorative separator is role="none",
a meaningful one is role="separator" and only advertises
aria-orientation when vertical.
Direct Known Subclasses
ButtonGroup::Separator::Component, Item::Separator::Component, Shadcn::Sidebar::Separator::Component
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#decorative ⇒ Object
readonly
Returns the value of attribute decorative.
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #element_attributes(**defaults) ⇒ Object
-
#initialize(orientation: :horizontal, decorative: true, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(orientation: :horizontal, decorative: true, **attributes) ⇒ Component
Returns a new instance of Component.
23 24 25 26 27 |
# File 'app/components/shadcn/separator/component.rb', line 23 def initialize(orientation: :horizontal, decorative: true, **attributes) @orientation = orientation.to_sym @decorative = decorative super(**attributes) end |
Instance Attribute Details
#decorative ⇒ Object (readonly)
Returns the value of attribute decorative.
21 22 23 |
# File 'app/components/shadcn/separator/component.rb', line 21 def decorative @decorative end |
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
21 22 23 |
# File 'app/components/shadcn/separator/component.rb', line 21 def orientation @orientation end |
Instance Method Details
#element_attributes(**defaults) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'app/components/shadcn/separator/component.rb', line 29 def element_attributes(**defaults) semantics = if decorative { role: "none" } else { role: "separator", "aria-orientation" => (orientation.to_s if orientation == :vertical) } end super(**{ "data-orientation" => orientation }.merge(semantics).merge(defaults)) end |