Class: CCS::Components::GovUK::ServiceNavigation::Link
- Defined in:
- lib/ccs/components/govuk/service_navigation/link.rb
Overview
GOV.UK Service navigation link
The individual service navigation link item
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(text:, href: nil, **options) ⇒ Link
constructor
A new instance of Link.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Service navigation link.
Constructor Details
#initialize(text:, href: nil, **options) ⇒ Link
Returns a new instance of Link.
30 31 32 33 34 35 36 37 |
# File 'lib/ccs/components/govuk/service_navigation/link.rb', line 30 def initialize(text:, href: nil, **) super(**) @options[:attributes][:aria] = { current: [:current] ? 'page' : 'true' } if [:active] || [:current] @text = text @href = href end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Service navigation link
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ccs/components/govuk/service_navigation/link.rb', line 43 def render tag.li(class: "govuk-service-navigation__item #{'govuk-service-navigation__item--active' if [:active] || [:current]}".rstrip) do if href [:attributes][:class] = 'govuk-service-navigation__link' link_to(inner_content, href, **[:attributes]) else [:attributes][:class] = 'govuk-service-navigation__text' tag.span(inner_content, **[:attributes]) end end end |