Class: Shadcn::Tabs::List::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/tabs/list/component.rb

Overview

TabsList

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, #tag_name

Constructor Details

#initialize(variant: :default, **attributes) ⇒ Component

Returns a new instance of Component.



32
33
34
35
# File 'app/components/shadcn/tabs/list/component.rb', line 32

def initialize(variant: :default, **attributes)
  @variant = variant&.to_sym || :default
  super(**attributes)
end

Instance Attribute Details

#variantObject (readonly)

Returns the value of attribute variant.



30
31
32
# File 'app/components/shadcn/tabs/list/component.rb', line 30

def variant
  @variant
end

Instance Method Details

#callObject



45
46
47
# File 'app/components/shadcn/tabs/list/component.rb', line 45

def call
  render_element(body: safe_join([ triggers, content ].flatten.compact))
end

#element_attributes(**defaults) ⇒ Object



41
42
43
# File 'app/components/shadcn/tabs/list/component.rb', line 41

def element_attributes(**defaults)
  super(**{ role: "tablist", "data-variant" => variant }.merge(defaults))
end

#style_variantsObject



37
38
39
# File 'app/components/shadcn/tabs/list/component.rb', line 37

def style_variants
  { variant: }
end