Class: SdrViewComponents::Elements::Navigation::NavItemComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Elements::Navigation::NavItemComponent
- Defined in:
- app/components/sdr_view_components/elements/navigation/nav_item_component.rb
Overview
Component for navigation item link.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text:, path: nil, data: {}) ⇒ NavItemComponent
constructor
A new instance of NavItemComponent.
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(text:, path: nil, data: {}) ⇒ NavItemComponent
Returns a new instance of NavItemComponent.
8 9 10 11 12 13 |
# File 'app/components/sdr_view_components/elements/navigation/nav_item_component.rb', line 8 def initialize(text:, path: nil, data: {}) @text = text @path = path @data = data super() end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
15 16 17 |
# File 'app/components/sdr_view_components/elements/navigation/nav_item_component.rb', line 15 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
15 16 17 |
# File 'app/components/sdr_view_components/elements/navigation/nav_item_component.rb', line 15 def path @path end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
15 16 17 |
# File 'app/components/sdr_view_components/elements/navigation/nav_item_component.rb', line 15 def text @text end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/components/sdr_view_components/elements/navigation/nav_item_component.rb', line 17 def call tag.li class: 'nav-item' do if path.present? link_to text, path, class: 'nav-link', data: else tag.span text, class: 'nav-link' end end end |