Class: CCS::Components::GovUK::Breadcrumbs
- Defined in:
- lib/ccs/components/govuk/breadcrumbs.rb,
lib/ccs/components/govuk/breadcrumbs/link.rb
Overview
GOV.UK Breadcrumbs
This is used to generate the breadcrumbs component from the GDS - Components - Breadcrumbs
Defined Under Namespace
Classes: Link
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the breadcrumbs
{ class: 'govuk-breadcrumbs' }.freeze
Instance Method Summary collapse
-
#initialize(breadcrumb_links:, **options) ⇒ Breadcrumbs
constructor
A new instance of Breadcrumbs.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK breadcrumbs component.
Constructor Details
#initialize(breadcrumb_links:, **options) ⇒ Breadcrumbs
Returns a new instance of Breadcrumbs.
30 31 32 33 34 35 36 |
# File 'lib/ccs/components/govuk/breadcrumbs.rb', line 30 def initialize(breadcrumb_links:, **) super(**) @options[:attributes][:class] << ' govuk-breadcrumbs--collapse-on-mobile' if @options[:collapse_on_mobile] (@options[:attributes][:aria] ||= {})[:label] ||= 'Breadcrumb' @breadcrumb_links = .map { || Link.new(context: @context, **) } end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK breadcrumbs component
42 43 44 45 46 47 48 |
# File 'lib/ccs/components/govuk/breadcrumbs.rb', line 42 def render tag.nav(**[:attributes]) do tag.ol(class: 'govuk-breadcrumbs__list') do .each { || concat(.render) } end end end |