module Adminterface::Extensions::Views::Components::Tabs

Public Instance Methods

build_content_item(title, options, &block) click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 15
def build_content_item(title, options, &block)
  fragment = options.fetch(:id, fragmentize(title))
  options = options.reverse_merge(id: fragment, "aria-labelledby": "#{fragment}-tab")
  div(options.merge(tab_pane_options(fragment)), &block)
end
build_menu_item(title, options, &_block) click to toggle source
# 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", role: "presentation") do
    @http ? link_to_http(title, fragment) : link_to_js(title, fragment)
  end
end
content_html_options() click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 31
def content_html_options
  content_html[:class] = "tab-content #{content_html[:class]}".squish
  content_html
end
default_css_class() click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 21
def default_css_class
  tabs_css_classes
end
nav_html_options() click to toggle source

Private Instance Methods

current_tab?(fragment) click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 75
def current_tab?(fragment)
  fragment.eql?(params[:tab]) || (!@http && @tabs_content&.children.blank?)
end
resource_scope() click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 52
def resource_scope
  session.fetch(:resource_scope, {}).with_indifferent_access
end
tab_pane_options(fragment) click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 68
def tab_pane_options(fragment)
  {
    class: "tab-pane #{current_tab?(fragment) ? "active" : nil}".squish,
    role: "tabpanel"
  }
end
toggler_options(fragment) click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 56
def toggler_options(fragment)
  defaults = {id: "#{fragment}-tab", "aria-controls": fragment}
  options =
    if current_tab?(fragment)
      {class: "nav-link active", "aria-selected": "true"}
    else
      {class: "nav-link", "aria-selected": "false"}
    end

  defaults.merge(options)
end