Class: Bs5::Tabs::LinkComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/bs5/tabs/link_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#itemObject (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_classObject



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_classObject



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