Class: ActiveAdmin::Views::Tabs
- Defined in:
- lib/active_admin/views/components/tabs.rb
Instance Method Summary collapse
- #build(attributes = {}, &block) ⇒ Object
- #build_content_item(title, options, &block) ⇒ Object
- #build_menu_item(title, options, &block) ⇒ Object
- #tab(title, options = {}, &block) ⇒ Object
Instance Method Details
#build(attributes = {}, &block) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/active_admin/views/components/tabs.rb', line 13 def build(attributes = {}, &block) super(attributes) add_class "tabs" @menu = nav(class: "tabs-nav", role: "tablist", "data-tabs-toggle": "#tabs-container-#{object_id}") @tabs_content = div(class: "tabs-content", id: "tabs-container-#{object_id}") end |
#build_content_item(title, options, &block) ⇒ Object
28 29 30 31 |
# File 'lib/active_admin/views/components/tabs.rb', line 28 def build_content_item(title, , &block) = .reverse_merge(id: fragmentize(title), class: "hidden", role: "tabpanel", "aria-labelledby": "#{title}-tab") div(, &block) end |
#build_menu_item(title, options, &block) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/active_admin/views/components/tabs.rb', line 20 def (title, , &block) fragment = .fetch(:id, fragmentize(title)) = .fetch(:html_options, {}).merge("data-tabs-target": "##{fragment}", role: "tab", "aria-controls": fragment, href: "#") a do title end end |
#tab(title, options = {}, &block) ⇒ Object
7 8 9 10 11 |
# File 'lib/active_admin/views/components/tabs.rb', line 7 def tab(title, = {}, &block) title = title.to_s.titleize if title.is_a? Symbol @menu << (title, , &block) @tabs_content << build_content_item(title, , &block) end |