Class: PhlexKit::Tabs
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Tabs
- Defined in:
- app/components/phlex_kit/tabs/tabs.rb
Overview
Tabbed panels. Ported from ruby_ui's RubyUI::Tabs. Compose Tabs(default:) > (TabsList > TabsTrigger(value:)) + TabsContent(value:). phlex-kit--tabs.
Constant Summary collapse
- ORIENTATIONS =
{ horizontal: nil, vertical: "vertical" }.freeze
Instance Method Summary collapse
-
#initialize(default: nil, orientation: :horizontal, **attrs) ⇒ Tabs
constructor
A new instance of Tabs.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(default: nil, orientation: :horizontal, **attrs) ⇒ Tabs
Returns a new instance of Tabs.
7 8 9 10 11 |
# File 'app/components/phlex_kit/tabs/tabs.rb', line 7 def initialize(default: nil, orientation: :horizontal, **attrs) @default = default @orientation = orientation.to_sym @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
13 14 15 16 |
# File 'app/components/phlex_kit/tabs/tabs.rb', line 13 def view_template(&) classes = [ "pk-tabs", fetch_option(ORIENTATIONS, @orientation, :orientation) ].compact.join(" ") div(**mix({ class: classes, data: { controller: "phlex-kit--tabs", phlex_kit__tabs_active_value: @default } }, @attrs), &) end |