Class: Shadcn::Tabs::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Tabs::Component
- Defined in:
- app/components/shadcn/tabs/component.rb
Overview
Port of registry/new-york-v4/ui/tabs.tsx
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#activation ⇒ Object
readonly
Returns the value of attribute activation.
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(value: nil, orientation: :horizontal, activation: :automatic, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(value: nil, orientation: :horizontal, activation: :automatic, **attributes) ⇒ Component
Returns a new instance of Component.
18 19 20 21 22 23 |
# File 'app/components/shadcn/tabs/component.rb', line 18 def initialize(value: nil, orientation: :horizontal, activation: :automatic, **attributes) @value = value.to_s @orientation = orientation&.to_sym || :horizontal @activation = activation&.to_sym || :automatic super(**attributes) end |
Instance Attribute Details
#activation ⇒ Object (readonly)
Returns the value of attribute activation.
16 17 18 |
# File 'app/components/shadcn/tabs/component.rb', line 16 def activation @activation end |
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
16 17 18 |
# File 'app/components/shadcn/tabs/component.rb', line 16 def orientation @orientation end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
16 17 18 |
# File 'app/components/shadcn/tabs/component.rb', line 16 def value @value end |
Instance Method Details
#call ⇒ Object
35 36 37 |
# File 'app/components/shadcn/tabs/component.rb', line 35 def call render_element(body: safe_join([ list, panels, content ].flatten.compact)) end |
#element_attributes(**defaults) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/components/shadcn/tabs/component.rb', line 25 def element_attributes(**defaults) super(**{ "data-orientation" => orientation, "data-controller" => "shadcn--tabs", "data-shadcn--tabs-value-value" => value, "data-shadcn--tabs-orientation-value" => orientation, "data-shadcn--tabs-activation-value" => activation }.merge(defaults)) end |