govuk-components 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fa9844129aad4b89c9845af6db1fbd942d0bde94823f891f65164163b935295
4
- data.tar.gz: 962375a05bc998a2b5caf5e3eeccb2a7f12a8dd120e8054857e79128287d3b8f
3
+ metadata.gz: c829ddc2492475939db14c1ad3af5ead810f8fbff0cf43ed79c747f01b7866cf
4
+ data.tar.gz: 777a37175936a10048a020be1bd5612607fb6d1db954b5031af8fe5147b3272b
5
5
  SHA512:
6
- metadata.gz: '048424bb98e6ed1ba126dfa971310ffa8b61629aea7394c1da291eeaa0c9bf31b1d1d547d190bcf8e31ce17f13b8b9d501bb8e9ccd01e2ba5c3a2f9444b6693d'
7
- data.tar.gz: 4c30a89b2f53b0cdcc869ae766182249f7d0c34b2c81c507c8ae6835344cc2b734b065ada162643a1ad15cb701d5af2445abec5173a400470c5cf458f28146ba
6
+ metadata.gz: ea38981feda270c38323611dcf24440162e0c868de8193501b8b461dc38c8e6533bb17884c60cea42fb75e5b2a855f4ce99dfcf211a9648675d6bd673bd64fdc
7
+ data.tar.gz: 211d2ce55a3a39dea50606a0a076c02a73e2f05904f0cdaf5ad8540ad0e498aa05d62fa58cc185d17ec4cbfe137e18067e593926b758e6eb76c97c9f63722153
@@ -11,16 +11,16 @@
11
11
  <%= @logo %>
12
12
  </span>
13
13
  </span>
14
- </a>
15
- <% if @product_name.present? %>
16
- <span class="govuk-header__product-name">
17
- <%= @product_name %>
18
- </span>
19
- <% end %>
14
+ <% if @product_name.present? %>
15
+ <span class="govuk-header__product-name">
16
+ <%= @product_name %>
17
+ </span>
18
+ <% end %>
20
19
 
21
- <% if product_description.present? %>
22
- <%= product_description.content %>
23
- <% end %>
20
+ <% if product_description.present? %>
21
+ <%= product_description.content %>
22
+ <% end %>
23
+ </a>
24
24
  </div>
25
25
  <div class="govuk-header__content">
26
26
  <% if @service_name.present? %>
@@ -30,16 +30,21 @@
30
30
  <% end %>
31
31
 
32
32
  <% if items.any? %>
33
+ <button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide navigation menu">
34
+ <%= menu_button_label %>
35
+ </button>
33
36
  <nav>
34
- <ul class="govuk-header__navigation " aria-label="Top Level Navigation">
37
+ <%= tag.ul(class: navigation_classes, aria: { label: "Top Level Navigation" }) do %>
35
38
  <% items.each do |item| %>
36
39
  <%= tag.li(class: item.classes.append(item.active_class), **item.html_attributes) do %>
37
- <a class="govuk-header__link" href="<%= item.href %>">
40
+ <% if item.link? %>
41
+ <%= link_to(item.title, item.href, class: "govuk-header__link") %>
42
+ <% else %>
38
43
  <%= item.title %>
39
- </a>
44
+ <% end %>
40
45
  <% end %>
41
46
  <% end %>
42
- </ul>
47
+ <% end %>
43
48
  </nav>
44
49
  <% end %>
45
50
  </div>
@@ -1,7 +1,7 @@
1
1
  class GovukComponent::Header < GovukComponent::Base
2
2
  include ViewComponent::Slotable
3
3
 
4
- attr_accessor :logo, :logo_href, :service_name, :service_name_href, :product_name
4
+ attr_accessor :logo, :logo_href, :service_name, :service_name_href, :product_name, :menu_button_label
5
5
 
6
6
  with_slot :item, collection: true, class_name: 'Item'
7
7
  wrap_slot :item
@@ -9,14 +9,16 @@ class GovukComponent::Header < GovukComponent::Base
9
9
  with_slot :product_description
10
10
  wrap_slot :product_description
11
11
 
12
- def initialize(logo: 'GOV.UK', logo_href: '/', service_name: nil, service_name_href: '/', product_name: nil, classes: [], html_attributes: {})
12
+ def initialize(logo: 'GOV.UK', logo_href: '/', service_name: nil, service_name_href: '/', product_name: nil, menu_button_label: 'Menu', classes: [], navigation_classes: [], html_attributes: {})
13
13
  super(classes: classes, html_attributes: html_attributes)
14
14
 
15
- @logo = logo
16
- @logo_href = logo_href
17
- @service_name = service_name
18
- @service_name_href = service_name_href
19
- @product_name = product_name
15
+ @logo = logo
16
+ @logo_href = logo_href
17
+ @service_name = service_name
18
+ @service_name_href = service_name_href
19
+ @product_name = product_name
20
+ @menu_button_label = menu_button_label
21
+ @navigation_classes = navigation_classes
20
22
  end
21
23
 
22
24
  private
@@ -25,10 +27,16 @@ private
25
27
  %w(govuk-header)
26
28
  end
27
29
 
30
+ def navigation_classes
31
+ %w(govuk-header__navigation).tap { |nc|
32
+ nc.concat(@navigation_classes.is_a?(String) ? @navigation_classes.split : @navigation_classes)
33
+ }.uniq
34
+ end
35
+
28
36
  class Item < GovukComponent::Slot
29
37
  attr_accessor :title, :href, :active
30
38
 
31
- def initialize(title:, href:, active: false, classes: [], html_attributes: {})
39
+ def initialize(title:, href: nil, active: false, classes: [], html_attributes: {})
32
40
  super(classes: classes, html_attributes: html_attributes)
33
41
 
34
42
  self.title = title
@@ -44,6 +52,10 @@ private
44
52
  %w(govuk-header__navigation-item--active) if active?
45
53
  end
46
54
 
55
+ def link?
56
+ href.present?
57
+ end
58
+
47
59
  private
48
60
 
49
61
  def default_classes
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '1.1.7'.freeze
3
+ VERSION = '1.1.8'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - DfE developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-12 00:00:00.000000000 Z
11
+ date: 2021-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties