Class: ShadcnPhlexcomponents::TabsContent

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) ⇒ TabsContent

Returns a new instance of TabsContent.



134
135
136
137
138
# File 'lib/shadcn_phlexcomponents/components/tabs.rb', line 134

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

Instance Method Details

#default_attributes ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/shadcn_phlexcomponents/components/tabs.rb', line 144

def default_attributes
  {
    id: "#{@aria_id}-content-#{@value}",
    role: "tabpanel",
    tabindex: "0",
    aria: {
      labelledby: "#{@aria_id}-trigger-#{@value}",
    },
    data: {
      value: @value,
      tabs_target: "content",
    },
  }
end

#view_template ⇒ Object



140
141
142
# File 'lib/shadcn_phlexcomponents/components/tabs.rb', line 140

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