govuk-components 5.2.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/govuk_component/footer_component.html.erb +9 -8
- data/app/components/govuk_component/footer_component.rb +9 -6
- data/app/components/govuk_component/header_component.html.erb +1 -1
- data/app/components/govuk_component/pagination_component.rb +1 -1
- data/app/components/govuk_component/tab_component.html.erb +1 -1
- data/app/components/govuk_component/tab_component.rb +1 -1
- data/app/helpers/govuk_link_helper.rb +18 -3
- data/app/helpers/govuk_list_helper.rb +29 -0
- data/app/helpers/govuk_rails_compatible_link_helper.rb +1 -1
- data/lib/govuk/components/version.rb +1 -1
- metadata +15 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b22deb7323c7532776a46557ba64d5a4aba958e1a684dc7d4a8eff188a1ed3ee
|
4
|
+
data.tar.gz: 235dbcf62c374970390c483532998f18480c74cfb3a746413e4bb6e0a277f557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5122fe37f57d769672a1155a6f5c2cdc6ad63bf3216d35997869a2c48391d8741917cac02928532808db421c2b9a242a2948b0fc3bee835256f8a20407f615ab
|
7
|
+
data.tar.gz: 4fcdd601d78c4f03dc71d2ff33d6749d5166d8416acd1624e36a6101ec6554880ec7085ad4eefc4515046d44a01f5028225b85c6618d9e449f134ce36e4a4bbf
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<%= navigation %>
|
6
6
|
</div>
|
7
7
|
|
8
|
-
|
8
|
+
<%= tag.hr(class: "#{brand}-footer__section-break") %>
|
9
9
|
<% end %>
|
10
10
|
|
11
11
|
<%= tag.div(class: meta_classes, **meta_html_attributes) do %>
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<div class="<%= brand %>-footer__meta-item <%= brand %>-footer__meta-item--grow">
|
16
16
|
<% if meta_items.any? %>
|
17
17
|
<h2 class="<%= brand %>-visually-hidden"><%= meta_items_title %></h2>
|
18
|
-
|
18
|
+
<%= content_before_meta_items %>
|
19
19
|
<ul class="<%= brand %>-footer__inline-list">
|
20
20
|
<% @meta_items.each do |hyperlink| %>
|
21
21
|
<li class="<%= brand %>-footer__inline-list-item">
|
@@ -23,6 +23,13 @@
|
|
23
23
|
</li>
|
24
24
|
<% end %>
|
25
25
|
</ul>
|
26
|
+
<%= content_after_meta_items %>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% if meta_content.present? %>
|
30
|
+
<div class="<%= brand %>-footer__meta-custom">
|
31
|
+
<%= meta_content %>
|
32
|
+
</div>
|
26
33
|
<% end %>
|
27
34
|
|
28
35
|
<% if meta_licence.nil? %>
|
@@ -34,12 +41,6 @@
|
|
34
41
|
<% elsif meta_licence.present? %>
|
35
42
|
<%= tag.span(meta_licence, class: "#{brand}-footer__licence-description") %>
|
36
43
|
<% end %>
|
37
|
-
|
38
|
-
<% if meta_content.present? %>
|
39
|
-
<div class="<%= brand %>-footer__meta-custom">
|
40
|
-
<%= meta_content %>
|
41
|
-
</div>
|
42
|
-
<% end %>
|
43
44
|
</div>
|
44
45
|
|
45
46
|
<%= tag.div(copyright, class: "#{brand}-footer__meta-item") %>
|
@@ -4,8 +4,10 @@ class GovukComponent::FooterComponent < GovukComponent::Base
|
|
4
4
|
renders_one :meta_html
|
5
5
|
renders_one :meta
|
6
6
|
renders_one :navigation
|
7
|
+
renders_one :content_before_meta_items
|
8
|
+
renders_one :content_after_meta_items
|
7
9
|
|
8
|
-
attr_reader :meta_items, :meta_text, :meta_items_title, :meta_licence, :
|
10
|
+
attr_reader :meta_items, :meta_text, :meta_items_title, :meta_licence, :copyright_text, :copyright_url, :custom_container_classes
|
9
11
|
|
10
12
|
def initialize(
|
11
13
|
classes: [],
|
@@ -27,7 +29,8 @@ class GovukComponent::FooterComponent < GovukComponent::Base
|
|
27
29
|
@meta_licence = meta_licence
|
28
30
|
@custom_meta_classes = meta_classes
|
29
31
|
@custom_meta_html_attributes = meta_html_attributes
|
30
|
-
@
|
32
|
+
@copyright_text = copyright_text
|
33
|
+
@copyright_url = copyright_url
|
31
34
|
@custom_container_classes = container_classes
|
32
35
|
@custom_container_html_attributes = container_html_attributes
|
33
36
|
|
@@ -67,9 +70,9 @@ private
|
|
67
70
|
|
68
71
|
case links
|
69
72
|
when Array
|
70
|
-
links.map { |link|
|
73
|
+
links.map { |link| govuk_footer_link_to(link[:text], link[:href], **link.fetch(:attr, {})) }
|
71
74
|
when Hash
|
72
|
-
links.map { |text, href|
|
75
|
+
links.map { |text, href| govuk_footer_link_to(text, href) }
|
73
76
|
else
|
74
77
|
fail(ArgumentError, 'meta links must be a hash or array of hashes') unless links.is_a?(Hash)
|
75
78
|
end
|
@@ -81,7 +84,7 @@ private
|
|
81
84
|
raw(%(All content is available under the #{link}, except where otherwise stated))
|
82
85
|
end
|
83
86
|
|
84
|
-
def
|
85
|
-
link_to(
|
87
|
+
def copyright
|
88
|
+
link_to(copyright_text, copyright_url, class: "#{brand}-footer__link #{brand}-footer__copyright-logo")
|
86
89
|
end
|
87
90
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= tag.header(
|
1
|
+
<%= tag.header(data: { module: "#{brand}-header" }, **html_attributes) do %>
|
2
2
|
<%= tag.div(**container_html_attributes) do %>
|
3
3
|
<div class="<%= brand %>-header__logo">
|
4
4
|
<%= link_to(homepage_url, class: ["#{brand}-header__link", "#{brand}-header__link--homepage"]) do %>
|
@@ -85,7 +85,7 @@ class GovukComponent::PaginationComponent < GovukComponent::Base
|
|
85
85
|
private
|
86
86
|
|
87
87
|
def default_attributes
|
88
|
-
{
|
88
|
+
{ aria: { label: landmark_label }, class: "#{brand}-pagination" }
|
89
89
|
end
|
90
90
|
|
91
91
|
def build_previous
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= tag.div(**html_attributes) do %>
|
2
|
-
<%= tag.h2(title, class: "#{brand}-tabs__title") %>
|
2
|
+
<%= tag.h2(title, class: "#{brand}-tabs__title") if title %>
|
3
3
|
<ul class="<%= brand %>-tabs__list">
|
4
4
|
<% tabs.each.with_index do |tab, i| %>
|
5
5
|
<%= tag.li(tab.li_link, class: tab.li_classes(i)) %>
|
@@ -5,7 +5,7 @@ class GovukComponent::TabComponent < GovukComponent::Base
|
|
5
5
|
|
6
6
|
attr_reader :title, :id
|
7
7
|
|
8
|
-
def initialize(title
|
8
|
+
def initialize(title: 'Contents', id: nil, classes: [], html_attributes: {})
|
9
9
|
@title = title
|
10
10
|
@id = id
|
11
11
|
|
@@ -57,6 +57,12 @@ module GovukLinkHelper
|
|
57
57
|
link_to(name, href, **link_args, &block)
|
58
58
|
end
|
59
59
|
|
60
|
+
def govuk_footer_link_to(name, href = nil, **kwargs, &block)
|
61
|
+
link_args = { class: "#{brand}-footer__link" }.deep_merge_html_attributes(kwargs)
|
62
|
+
|
63
|
+
link_to(name, href, **link_args, &block)
|
64
|
+
end
|
65
|
+
|
60
66
|
def govuk_link_classes(inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false)
|
61
67
|
if [text_colour, inverse, muted].count(true) > 1
|
62
68
|
fail("links can be only be one of text_colour, inverse or muted")
|
@@ -109,14 +115,16 @@ private
|
|
109
115
|
Rails.logger.warn(controller_warning_message(kwargs.fetch(:controller))) if kwargs.key?(:controller)
|
110
116
|
|
111
117
|
button_classes = extract_button_classes(inverse:, secondary:, warning:)
|
118
|
+
data_attributes = build_data_attributes("#{brand}-button")
|
112
119
|
|
113
|
-
{ **button_classes, **button_attributes(disabled), **new_tab_args(new_tab) }.deep_merge_html_attributes(kwargs)
|
120
|
+
{ **button_classes, **data_attributes, **button_attributes(disabled), **new_tab_args(new_tab) }.deep_merge_html_attributes(kwargs)
|
114
121
|
end
|
115
122
|
|
116
|
-
def extract_button_args(disabled: false, inverse: false, secondary: false, warning: false, **kwargs)
|
123
|
+
def extract_button_args(disabled: false, inverse: false, secondary: false, warning: false, prevent_double_click: nil, **kwargs)
|
117
124
|
button_classes = extract_button_classes(inverse:, secondary:, warning:)
|
125
|
+
data_attributes = build_data_attributes("#{brand}-button", prevent_double_click:)
|
118
126
|
|
119
|
-
{ **button_classes, **button_attributes(disabled) }.deep_merge_html_attributes(kwargs)
|
127
|
+
{ **button_classes, **data_attributes, **button_attributes(disabled) }.deep_merge_html_attributes(kwargs)
|
120
128
|
end
|
121
129
|
|
122
130
|
def extract_link_classes(inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false)
|
@@ -177,6 +185,13 @@ private
|
|
177
185
|
def controller_warning_message(value)
|
178
186
|
"controller: '#{value}' parameter detected. Support for old style controller/action links has been removed. See https://github.com/x-govuk/govuk-components/releases/tag/v5.0.0"
|
179
187
|
end
|
188
|
+
|
189
|
+
def build_data_attributes(data_module, prevent_double_click: nil)
|
190
|
+
{
|
191
|
+
"data-module": data_module,
|
192
|
+
"data-prevent-double-click": prevent_double_click
|
193
|
+
}.compact
|
194
|
+
end
|
180
195
|
end
|
181
196
|
|
182
197
|
ActiveSupport.on_load(:action_view) { include GovukLinkHelper }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module GovukListHelper
|
2
|
+
def govuk_list(array = nil, type: nil, spaced: nil, classes: nil, html_attributes: {}, &block)
|
3
|
+
type = type.to_s
|
4
|
+
|
5
|
+
fail "Unrecognised type for govuk_list - should be :bullet or :number or nil" unless type.in?(["bullet", "number", ""])
|
6
|
+
|
7
|
+
tag_type = (type == "number") ? "ol" : "ul"
|
8
|
+
|
9
|
+
html_classes = class_names(
|
10
|
+
"#{brand}-list",
|
11
|
+
*classes,
|
12
|
+
"#{brand}-list--bullet" => (type == "bullet"),
|
13
|
+
"#{brand}-list--number" => (type == "number"),
|
14
|
+
"#{brand}-list--spaced" => spaced
|
15
|
+
)
|
16
|
+
|
17
|
+
if block_given?
|
18
|
+
content_tag(tag_type, class: html_classes, **html_attributes, &block)
|
19
|
+
else
|
20
|
+
content_tag(tag_type, class: html_classes, **html_attributes) do
|
21
|
+
array.each do |item|
|
22
|
+
concat tag.li(item)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
ActiveSupport.on_load(:action_view) { include GovukListHelper }
|
@@ -44,7 +44,7 @@ module GovukRailsCompatibleLinkHelper
|
|
44
44
|
def govuk_button_to(name = nil, options = nil, extra_options = {}, &block)
|
45
45
|
extra_options = options if block_given?
|
46
46
|
html_options = {
|
47
|
-
data: { module: "
|
47
|
+
data: { module: "#{brand}-button" }
|
48
48
|
}
|
49
49
|
|
50
50
|
if extra_options && extra_options[:prevent_double_click]
|
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: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DfE developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-attributes-utils
|
@@ -34,16 +34,22 @@ dependencies:
|
|
34
34
|
name: pagy
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '6'
|
40
|
+
- - "<"
|
38
41
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
42
|
+
version: '8'
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- - "
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '6'
|
50
|
+
- - "<"
|
45
51
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
52
|
+
version: '8'
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: view_component
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +59,7 @@ dependencies:
|
|
53
59
|
version: '3.9'
|
54
60
|
- - "<"
|
55
61
|
- !ruby/object:Gem::Version
|
56
|
-
version: '3.
|
62
|
+
version: '3.12'
|
57
63
|
type: :runtime
|
58
64
|
prerelease: false
|
59
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -63,7 +69,7 @@ dependencies:
|
|
63
69
|
version: '3.9'
|
64
70
|
- - "<"
|
65
71
|
- !ruby/object:Gem::Version
|
66
|
-
version: '3.
|
72
|
+
version: '3.12'
|
67
73
|
- !ruby/object:Gem::Dependency
|
68
74
|
name: deep_merge
|
69
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -384,6 +390,7 @@ files:
|
|
384
390
|
- app/helpers/govuk_components_helper.rb
|
385
391
|
- app/helpers/govuk_exit_this_page_link_helper.rb
|
386
392
|
- app/helpers/govuk_link_helper.rb
|
393
|
+
- app/helpers/govuk_list_helper.rb
|
387
394
|
- app/helpers/govuk_rails_compatible_link_helper.rb
|
388
395
|
- app/helpers/govuk_skip_link_helper.rb
|
389
396
|
- app/helpers/govuk_visually_hidden_helper.rb
|