Class: GovukComponent::Tabs::Tab

Inherits:
Slot
  • Object
show all
Defined in:
app/components/govuk_component/tabs.rb

Instance Attribute Summary collapse

Attributes included from GovukComponent::Traits::CustomHtmlAttributes

#html_attributes

Instance Method Summary collapse

Methods included from GovukComponent::Traits::CustomClasses

#classes

Constructor Details

#initialize(title:, classes: [], html_attributes: {}) ⇒ Tab

Returns a new instance of Tab.



24
25
26
27
28
# File 'app/components/govuk_component/tabs.rb', line 24

def initialize(title:, classes: [], html_attributes: {})
  super(classes: classes, html_attributes: html_attributes)

  self.title = title
end

Instance Attribute Details

#titleObject

Returns the value of attribute title.



22
23
24
# File 'app/components/govuk_component/tabs.rb', line 22

def title
  @title
end

Instance Method Details

#default_classesObject



34
35
36
# File 'app/components/govuk_component/tabs.rb', line 34

def default_classes
  %w(govuk-tabs__panel)
end

#hidden_class(i = nil) ⇒ Object



38
39
40
# File 'app/components/govuk_component/tabs.rb', line 38

def hidden_class(i = nil)
  %(govuk-tabs__panel--hidden) unless i&.zero?
end

#id(prefix: nil) ⇒ Object



30
31
32
# File 'app/components/govuk_component/tabs.rb', line 30

def id(prefix: nil)
  [prefix, title.parameterize].join
end