Class: DsfrComponent::TabsComponent::TabComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- DsfrComponent::TabsComponent::TabComponent
show all
- Defined in:
- app/components/dsfr_component/tabs_component/tab_component.rb
Constant Summary
Constants inherited
from Base
Base::HEADING_LEVELS, Base::SIZES
Instance Attribute Summary
Attributes inherited from Base
#html_attributes
Instance Method Summary
collapse
Constructor Details
#initialize(title:, active: false, path: nil, icon: nil, 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, html_attributes: {})
@title = title
@active = active
@path = path
@icon = icon
super(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 : nav_button
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
|