Class: PhlexKit::TabsContent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::TabsContent
- Defined in:
- app/components/phlex_kit/tabs/tabs_content.rb
Instance Method Summary collapse
-
#initialize(value:, active: false, id: nil, **attrs) ⇒ TabsContent
constructor
id: is a named kwarg (not left in **attrs) — see TabsTrigger.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(value:, active: false, id: nil, **attrs) ⇒ TabsContent
id: is a named kwarg (not left in **attrs) — see TabsTrigger.
4 5 6 7 8 9 |
# File 'app/components/phlex_kit/tabs/tabs_content.rb', line 4 def initialize(value:, active: false, id: nil, **attrs) @value = value @active = active @id = id || "pk-tabs-panel-#{value}" @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/components/phlex_kit/tabs/tabs_content.rb', line 10 def view_template(&) # id / aria-labelledby mirror TabsTrigger's deterministic ids (re-scoped # per instance by the controller); tabindex="0" makes the panel itself # focusable, per the APG tabs pattern. `active:` (mirroring TabsTrigger's) # renders the panel visible pre-JS/no-JS; the controller's sync() # reconciles visibility from the active value after connect. div(**mix({ class: @active ? "pk-tabs-content" : "pk-tabs-content pk-hidden", role: "tabpanel", id: @id, aria_labelledby: "pk-tabs-trigger-#{@value}", tabindex: "0", data: { phlex_kit__tabs_target: "content", value: @value } }, @attrs), &) end |