Module: Adminterface::Extensions::Views::Components::Tabs

Defined in:
lib/adminterface/extensions/views/components/tabs.rb

Instance Method Summary collapse

Instance Method Details

#build_content_item(title, options, &block) ⇒ Object



19
20
21
22
23
# File 'lib/adminterface/extensions/views/components/tabs.rb', line 19

def build_content_item(title, options, &block)
  fragment = options.fetch(:id, fragmentize(title))
  options = options.reverse_merge(id: fragmentize(title))
  div(options.merge(class: tab_pane_class(fragment)), &block)
end

#build_menu_item(title, options, &_block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/adminterface/extensions/views/components/tabs.rb', line 6

def build_menu_item(title, options, &_block)
  fragment = options.fetch(:id, fragmentize(title))
  html_options = options.fetch(:html_options, {})
  li html_options.merge(class: "nav-item") do
    if @http
      params[:tab] ||= @default_tab || fragment
      link_to title, url_for(tab: fragment, anchor: id, anchor_id: id), class: toggler_class(fragment)
    else
      link_to title, "##{fragment}", class: toggler_class(fragment), data: {"bs-toggle": "tab", "bs-target": "##{fragment}"}
    end
  end
end

#content_html_optionsObject



35
36
37
38
# File 'lib/adminterface/extensions/views/components/tabs.rb', line 35

def content_html_options
  content_html[:class] = "tab-content #{content_html[:class]}".squish
  content_html
end

#default_css_classObject



25
26
27
# File 'lib/adminterface/extensions/views/components/tabs.rb', line 25

def default_css_class
  tabs_css_classes
end


29
30
31
32
33
# File 'lib/adminterface/extensions/views/components/tabs.rb', line 29

def nav_html_options
  nav_html[:class] = "nav #{default_css_class} #{nav_html[:class]}".squish
  nav_html[:role] = "tablist"
  nav_html
end