11require_relative '../base'
22require_relative 'logo'
3- require_relative 'header/service_authentication'
4- require_relative 'header/navigation'
53
64module CCS
75 module Components
@@ -13,72 +11,42 @@ module CCS
1311 #
1412 # @!attribute [r] logo
1513 # @return [Logo] The initialised Logo component
16- # @!attribute [r] service_authentication
17- # @return [ServiceAuthentication] The initialised service authentication section
18- # @!attribute [r] navigation
19- # @return [Navigation] The initialised navigation section
20- # @!attribute [r] service
21- # @return [Hash] The options for the service section
2214
2315 class Header < Base
2416 private
2517
26- attr_reader :logo , :service_authentication , :navigation , :service
18+ attr_reader :logo
2719
2820 public
2921
30- # @param service_authentication_items [Array<Hash>] An array of links for the service authentication section of the header.
31- # See {Components::CCS::Header::ServiceAuthentication#initialize ServiceAuthentication#initialize} for details of the items in the array.
32- # @param navigation [Hash] options for the navigation section of the header.
33- # See {Components::CCS::Header::Navigation#initialize Navigation#initialize} for details of the options.
34- # @param menu_button [Hash] options for the menu button in the header.
35- # See {Components::CCS::Header::Navigation#initialize Navigation#initialize} for details of the options.
36- # @param service [Hash] options for the service name
3722 # @param options [Hash] options that will be used in customising the HTML
3823 #
39- # @option service [String] :name the name of the service, included in the header
40- # @option service [String] :href URL for the service name anchor
41- #
4224 # @option options [String] :classes additional CSS classes for the header HTML
4325 # @option options [String] :container_classes classes for the container
4426 # @option options [String] :homepage_url URL of the homepage. Defaults to +/https://www.crowncommercial.gov.uk+
4527 # @option options [Hash] :attributes additional attributes that will added as part of the header HTML
4628
47- def initialize ( service_authentication_items : nil , navigation : nil , menu_button : nil , service : nil , **)
48- super ( ** )
29+ def initialize ( **)
30+ super
4931
5032 @options [ :container_classes ] ||= 'govuk-width-container'
5133 @options [ :homepage_url ] ||= 'https://www.crowncommercial.gov.uk'
5234
5335 @logo = Logo . new ( context : @context )
54- @service_authentication = ServiceAuthentication . new ( service_authentication_items : service_authentication_items , container_classes : @options [ :container_classes ] , context : @context ) if service_authentication_items
55- @navigation = Navigation . new ( navigation : navigation , serivce_name_present : service , menu_button : menu_button , context : @context ) if navigation && ( navigation [ :primary_items ] || navigation [ :secondary_items ] )
56- @service = service
5736 end
5837
59- # rubocop:disable Metrics/AbcSize
60-
6138 # Generates the HTML for the CCS Header component
6239 #
6340 # @return [ActiveSupport::SafeBuffer]
6441
6542 def render
6643 tag . header ( **options [ :attributes ] ) do
67- concat ( service_authentication . render ) if service_authentication
6844 concat ( tag . div ( class : "ccs-header__container #{ options [ :container_classes ] } " . rstrip ) do
6945 concat ( header_logo )
70- if service || navigation
71- concat ( tag . div ( class : 'ccs-header__content' ) do
72- concat ( header_service_name ) if service
73- concat ( navigation . render ) if navigation
74- end )
75- end
7646 end )
7747 end
7848 end
7949
80- # rubocop:enable Metrics/AbcSize
81-
8250 # The default attributes for the breadcrumbs
8351
8452 DEFAULT_ATTRIBUTES = { class : 'ccs-header' , data : { module : 'ccs-header' } } . freeze
@@ -94,18 +62,6 @@ def header_logo
9462 link_to ( logo . render , options [ :homepage_url ] , class : 'ccs-header__link ccs-header__link--homepage' , aria : { label : 'Crown Commercial Service' } )
9563 end
9664 end
97-
98- # Generates the service name section
99- #
100- # @return [ActiveSupport::SafeBuffer]
101-
102- def header_service_name
103- if service [ :href ]
104- link_to ( service [ :name ] , service [ :href ] , class : 'ccs-header__link ccs-header__link--service-name' )
105- else
106- tag . span ( service [ :name ] , class : 'ccs-header__link--service-name' )
107- end
108- end
10965 end
11066 end
11167 end
0 commit comments