Class: BulmaPhlex::TabComponents::Content

Inherits:
Base
  • Object
show all
Defined in:
lib/bulma_phlex/tab_components/content.rb

Overview

Renders a single content panel within a BulmaPhlex::Tabs component.

Manages visibility (shown/hidden) based on the active state, and accepts a **data attributes proc** for Stimulus integration.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, active:, data_attributes_proc: nil) ⇒ Content

Returns a new instance of Content.



20
21
22
23
24
25
# File 'lib/bulma_phlex/tab_components/content.rb', line 20

def initialize(id:, active:, data_attributes_proc: nil)
  @id = id
  @active = active
  @data_attributes = data_attributes_proc ||
                     BulmaPhlex::Tabs::StimulusDataAttributes.new("bulma-phlex--tabs").method(:for_content)
end

Class Method Details

.new(id:, active:, data_attributes_proc: nil) ⇒ Object

Parameters

  • ‘id` — Unique identifier for the content panel

  • ‘active` — If `true`, the content panel is visible; otherwise it is hidden

  • ‘data_attributes_proc` — A proc that generates data attributes for the content panel



16
17
18
# File 'lib/bulma_phlex/tab_components/content.rb', line 16

def self.new(id:, active:, data_attributes_proc: nil)
  super
end

Instance Method Details

#view_templateObject



27
28
29
30
31
# File 'lib/bulma_phlex/tab_components/content.rb', line 27

def view_template(&)
  div(id: @id,
      class: @active ? "" : "is-hidden",
      data: @data_attributes.call(@id), &)
end