Class: DsfrComponent::TabsComponent::TabComponent
- Defined in:
- app/components/dsfr_component/tabs_component/tab_component.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(title:, active: false, path: nil, icon: nil, classes: [], html_attributes: {}) ⇒ TabComponent
constructor
A new instance of TabComponent.
- #nav_id ⇒ Object
- #nav_item ⇒ Object
- #panel_id ⇒ Object
Constructor Details
#initialize(title:, active: false, path: nil, icon: nil, classes: [], html_attributes: {}) ⇒ TabComponent
Returns a new instance of TabComponent.
6 7 8 9 10 11 12 13 |
# File 'app/components/dsfr_component/tabs_component/tab_component.rb', line 6 def initialize(title:, active: false, path: nil, icon: nil, classes: [], html_attributes: {}) @title = title @active = active @path = path @icon = icon super(classes: classes, html_attributes: html_attributes) end |
Instance Method Details
#call ⇒ Object
27 28 29 |
# File 'app/components/dsfr_component/tabs_component/tab_component.rb', line 27 def call tag.div(**html_attributes) { content } end |
#nav_id ⇒ Object
15 16 17 |
# File 'app/components/dsfr_component/tabs_component/tab_component.rb', line 15 def nav_id @nav_id ||= "tab-#{title_slug}-nav" end |
#nav_item ⇒ Object
23 24 25 |
# File 'app/components/dsfr_component/tabs_component/tab_component.rb', line 23 def nav_item path ? nav_link : end |
#panel_id ⇒ Object
19 20 21 |
# File 'app/components/dsfr_component/tabs_component/tab_component.rb', line 19 def panel_id @panel_id ||= "tab-#{title_slug}-panel" end |