Class: CodengageViewComponents::TabItemComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/codengage_view_components/tab_item_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(url:, tab:, icon: "", text: "", classes: "") ⇒ TabItemComponent

Returns a new instance of TabItemComponent.



5
6
7
8
9
10
11
# File 'app/components/codengage_view_components/tab_item_component.rb', line 5

def initialize(url:, tab:, icon: "", text: "", classes: "")
  @url = url
  @tab = tab
  @icon = icon
  @text = text
  @classes = classes
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/components/codengage_view_components/tab_item_component.rb', line 13

def active?
  params[:tab] == @tab
end

#tab_item_classObject



17
18
19
# File 'app/components/codengage_view_components/tab_item_component.rb', line 17

def tab_item_class
  active? ? "tab__selected #{@classes}" : "tab__not-selected #{@classes}"
end