Module: Components::TabsHelper

Defined in:
app/helpers/components/tabs_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_tabs(&block) ⇒ Object



2
3
4
5
6
# File 'app/helpers/components/tabs_helper.rb', line 2

def render_tabs(&block)
  @_tabs = []
  capture(&block)
  render "components/ui/tabs"
end

#tab(title, **options) ⇒ Object



12
13
14
15
16
17
18
# File 'app/helpers/components/tabs_helper.rb', line 12

def tab(title, **options)
  options[:id] ||= "tab_#{title.parameterize}"
  options[:state] = options[:active] ? "active" : "inactive"

  @_tabs << {title: title, id: options[:id]}
  render("components/ui/tabs/tab", title:, options:)
end

#tab_list(&block) ⇒ Object



8
9
10
# File 'app/helpers/components/tabs_helper.rb', line 8

def tab_list(&block)
  content_for :tab_list, capture(&block), flush: true
end

#tab_panel(**options, &block) ⇒ Object



24
25
26
27
28
# File 'app/helpers/components/tabs_helper.rb', line 24

def tab_panel(**options, &block)
  options[:state] = options[:active] ? "active" : "inactive"
  content_for :panel, capture(&block), flush: true
  render("components/ui/tabs/panel", options:)
end

#tab_panels(&block) ⇒ Object



20
21
22
# File 'app/helpers/components/tabs_helper.rb', line 20

def tab_panels(&block)
  content_for :tab_panels, capture(&block), flush: true
end