Class: Nav::TabPanels::PanelComponent
- Inherits:
-
SparkComponents::Component
- Object
- SparkComponents::Component
- Nav::TabPanels::PanelComponent
- Defined in:
- app/components/spark/nav/tab_panels/panel_component.rb
Instance Method Summary collapse
- #active=(bool) ⇒ Object
- #after_init ⇒ Object
- #new_tab(active: false) ⇒ Object
- #render ⇒ Object
- #tab_id ⇒ Object
- #tab_wrapper_id ⇒ Object
Instance Method Details
#active=(bool) ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/components/spark/nav/tab_panels/panel_component.rb', line 11 def active=(bool) if bool add_class 'active' else root_attr(hidden: true) end end |
#after_init ⇒ Object
6 7 8 9 |
# File 'app/components/spark/nav/tab_panels/panel_component.rb', line 6 def after_init root_attr id: unique_id("panel"), role: "tabpanel" aria_attr labeledby: tab_id end |
#new_tab(active: false) ⇒ Object
27 28 29 30 31 32 |
# File 'app/components/spark/nav/tab_panels/panel_component.rb', line 27 def new_tab(active: false) tab = Nav::TabPanels::TabComponent.new(@view, text: text, href: href, icon: icon, active: active) tab.parent = self tab.before_render tab.render end |
#render ⇒ Object
34 35 36 |
# File 'app/components/spark/nav/tab_panels/panel_component.rb', line 34 def render @yield end |
#tab_id ⇒ Object
19 20 21 |
# File 'app/components/spark/nav/tab_panels/panel_component.rb', line 19 def tab_id "tab-for-#{root_attr[:id]}" end |
#tab_wrapper_id ⇒ Object
23 24 25 |
# File 'app/components/spark/nav/tab_panels/panel_component.rb', line 23 def tab_wrapper_id "wrapper-for-#{tab_id}" end |