govuk-components 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c829ddc2492475939db14c1ad3af5ead810f8fbff0cf43ed79c747f01b7866cf
|
4
|
+
data.tar.gz: 777a37175936a10048a020be1bd5612607fb6d1db954b5031af8fe5147b3272b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea38981feda270c38323611dcf24440162e0c868de8193501b8b461dc38c8e6533bb17884c60cea42fb75e5b2a855f4ce99dfcf211a9648675d6bd673bd64fdc
|
7
|
+
data.tar.gz: 211d2ce55a3a39dea50606a0a076c02a73e2f05904f0cdaf5ad8540ad0e498aa05d62fa58cc185d17ec4cbfe137e18067e593926b758e6eb76c97c9f63722153
|
@@ -11,16 +11,16 @@
|
|
11
11
|
<%= @logo %>
|
12
12
|
</span>
|
13
13
|
</span>
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
<% end %>
|
14
|
+
<% if @product_name.present? %>
|
15
|
+
<span class="govuk-header__product-name">
|
16
|
+
<%= @product_name %>
|
17
|
+
</span>
|
18
|
+
<% end %>
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
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
|
-
|
40
|
+
<% if item.link? %>
|
41
|
+
<%= link_to(item.title, item.href, class: "govuk-header__link") %>
|
42
|
+
<% else %>
|
38
43
|
<%= item.title %>
|
39
|
-
|
44
|
+
<% end %>
|
40
45
|
<% end %>
|
41
46
|
<% end %>
|
42
|
-
|
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
|
16
|
-
@logo_href
|
17
|
-
@service_name
|
18
|
-
@service_name_href
|
19
|
-
@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
|
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
|
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.
|
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-
|
11
|
+
date: 2021-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|