Class: Bs5::Tabs::LinkComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bs5::Tabs::LinkComponent
- Defined in:
- app/components/bs5/tabs/link_component.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
- #active_class ⇒ Object
- #component_class ⇒ Object
-
#initialize(item) ⇒ LinkComponent
constructor
A new instance of LinkComponent.
Constructor Details
#initialize(item) ⇒ LinkComponent
Returns a new instance of LinkComponent.
8 9 10 |
# File 'app/components/bs5/tabs/link_component.rb', line 8 def initialize(item) @item = item end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
6 7 8 |
# File 'app/components/bs5/tabs/link_component.rb', line 6 def item @item end |
Instance Method Details
#active_class ⇒ Object
20 21 22 23 24 |
# File 'app/components/bs5/tabs/link_component.rb', line 20 def active_class return unless item.active? %w[active] end |
#component_class ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/components/bs5/tabs/link_component.rb', line 12 def component_class class_names = ['nav-link'] class_names << active_class class_names.compact.join(' ') end |