Class: ShadcnPhlexcomponents::TabsTrigger

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/tabs.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child

Constructor Details

#initialize(value: nil, aria_id: nil, **attributes) ⇒ TabsTrigger

Returns a new instance of TabsTrigger.



91
92
93
94
95
# File 'lib/shadcn_phlexcomponents/components/tabs.rb', line 91

def initialize(value: nil, aria_id: nil, **attributes)
  @value = value
  @aria_id = aria_id
  super(**attributes)
end

Instance Method Details

#default_attributes ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/shadcn_phlexcomponents/components/tabs.rb', line 101

def default_attributes
  {
    id: "#{@aria_id}-trigger-#{@value}",
    role: "tab",
    tabindex: "-1",
    aria: {
      controls: "#{@aria_id}-content-#{@value}",
      selected: false,
    },
    data: {
      tabs_target: "trigger",
      value: @value,
      state: "inactive",
      action: "        click->tabs#setActiveTab\n        keydown.left->tabs#setActiveTab:prevent\n        keydown.right->tabs#setActiveTab:prevent\n      HEREDOC\n    },\n  }\nend\n",

#view_template ⇒ Object



97
98
99
# File 'lib/shadcn_phlexcomponents/components/tabs.rb', line 97

def view_template(&)
  button(**@attributes, &)
end