Class: CCS::Components::GovUK::Header
- Defined in:
- lib/ccs/components/govuk/header.rb,
lib/ccs/components/govuk/header/link.rb,
lib/ccs/components/govuk/header/navigation.rb
Overview
GOV.UK Header
This is used to generate the header component from the GDS - Components - Header
Defined Under Namespace
Classes: Link, Navigation
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the breadcrumbs
{ class: 'govuk-header', data: { module: 'govuk-header' } }.freeze
Instance Method Summary collapse
-
#initialize(navigation: nil, menu_button: nil, service: nil, **options) ⇒ Header
constructor
A new instance of Header.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Header component.
Constructor Details
#initialize(navigation: nil, menu_button: nil, service: nil, **options) ⇒ Header
Returns a new instance of Header.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ccs/components/govuk/header.rb', line 41 def initialize(navigation: nil, menu_button: nil, service: nil, **) super(**) @options[:container_classes] ||= 'govuk-width-container' @options[:homepage_url] ||= '/' @options[:use_tudor_crown] = true if @options[:use_tudor_crown].nil? @navigation = Navigation.new(navigation: , menu_button: , context: @context) if && [:items].present? @service = service end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Header component
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ccs/components/govuk/header.rb', line 56 def render tag.header(**[:attributes]) do tag.div(class: "govuk-header__container #{[:container_classes]}") do concat(header_logo) if service || concat(tag.div(class: 'govuk-header__content') do concat(header_service_name) if service concat(.render) if end) end end end end |