Class: Shadcn::Tabs::Trigger::Component

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

Overview

TabsTrigger

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

#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name

Constructor Details

#initialize(value:, **attributes) ⇒ Component

Returns a new instance of Component.



46
47
48
49
# File 'app/components/shadcn/tabs/trigger/component.rb', line 46

def initialize(value:, **attributes)
  @value = value.to_s
  super(**attributes)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



44
45
46
# File 'app/components/shadcn/tabs/trigger/component.rb', line 44

def value
  @value
end

Instance Method Details

#element_attributes(**defaults) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/components/shadcn/tabs/trigger/component.rb', line 51

def element_attributes(**defaults)
  super(**{
    type: "button",
    role: "tab",
    "aria-selected" => "false",
    tabindex: "-1",
    "data-state" => "inactive",
    "data-value" => value,
    "data-shadcn--tabs-target" => "trigger",
    "data-action" => "click->shadcn--tabs#select keydown->shadcn--tabs#keydown"
  }.merge(defaults))
end