Class: Shadcn::Tabs::Component

Inherits:
ApplicationViewComponent show all
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

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

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

#activationObject (readonly)

Returns the value of attribute activation.



16
17
18
# File 'app/components/shadcn/tabs/component.rb', line 16

def activation
  @activation
end

#orientationObject (readonly)

Returns the value of attribute orientation.



16
17
18
# File 'app/components/shadcn/tabs/component.rb', line 16

def orientation
  @orientation
end

#valueObject (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

#callObject



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