Class: GovukComponent::Header::Item

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

Instance Attribute Summary collapse

Attributes included from Traits::CustomHtmlAttributes

#html_attributes

Instance Method Summary collapse

Methods included from Traits::CustomClasses

#classes

Constructor Details

#initialize(title:, href:, active: false, classes: [], html_attributes: {}) ⇒ Item

Returns a new instance of Item.



27
28
29
30
31
32
33
# File 'app/components/govuk_component/header.rb', line 27

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

  self.title  = title
  self.href   = href
  self.active = active
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



25
26
27
# File 'app/components/govuk_component/header.rb', line 25

def active
  @active
end

#hrefObject

Returns the value of attribute href.



25
26
27
# File 'app/components/govuk_component/header.rb', line 25

def href
  @href
end

#titleObject

Returns the value of attribute title.



25
26
27
# File 'app/components/govuk_component/header.rb', line 25

def title
  @title
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/components/govuk_component/header.rb', line 35

def active?
  active
end

#active_classObject



39
40
41
# File 'app/components/govuk_component/header.rb', line 39

def active_class
  %w(govuk-header__navigation-item--active) if active?
end