Class: PhlexKit::TabsList
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::TabsList
- Defined in:
- app/components/phlex_kit/tabs/tabs_list.rb
Constant Summary collapse
- VARIANTS =
{ default: nil, line: "line" }.freeze
Instance Method Summary collapse
-
#initialize(variant: :default, orientation: :horizontal, **attrs) ⇒ TabsList
constructor
A new instance of TabsList.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(variant: :default, orientation: :horizontal, **attrs) ⇒ TabsList
Returns a new instance of TabsList.
5 6 7 8 9 |
# File 'app/components/phlex_kit/tabs/tabs_list.rb', line 5 def initialize(variant: :default, orientation: :horizontal, **attrs) @variant = variant.to_sym @orientation = orientation.to_sym @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/components/phlex_kit/tabs/tabs_list.rb', line 11 def view_template(&) classes = [ "pk-tabs-list", fetch_option(VARIANTS, @variant, :variant) ].compact.join(" ") base = { class: classes, role: "tablist", data: { phlex_kit__tabs_target: "list", action: "keydown->phlex-kit--tabs#keydown" } } # Server-rendered so AT hears the right axis pre-JS / with JS off; the # controller re-stamps it on connect from the root's vertical class. base[:aria] = { orientation: "vertical" } if @orientation == :vertical div(**mix(base, @attrs), &) end |