govuk-components 5.2.1 → 5.3.0

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: aa5e94a9160f8896885ff9a35d00d091c9fa26a70f7a818214ffea37347e4736
4
- data.tar.gz: 40fb13fe108b13896ae68a27e59da95b1861b85c2eb9bfdc9d9756229d132542
3
+ metadata.gz: b22deb7323c7532776a46557ba64d5a4aba958e1a684dc7d4a8eff188a1ed3ee
4
+ data.tar.gz: 235dbcf62c374970390c483532998f18480c74cfb3a746413e4bb6e0a277f557
5
5
  SHA512:
6
- metadata.gz: 6fee19918f8ce6482e387bac2265f1ab64906daad807296fd1094728440adebc0ce79bbdcc42752ef3ebe4e8525022fea2fd8c7bd383a4e053a24439dd9b7a24
7
- data.tar.gz: 1f3746438b6497191b42980a341a9caafc17d46651d22a4c2137c818fd8ac87b20c234f65633d826587e8ef2b37b6f3f14c9096ccf20f6550cc5a7858d17ad37
6
+ metadata.gz: 5122fe37f57d769672a1155a6f5c2cdc6ad63bf3216d35997869a2c48391d8741917cac02928532808db421c2b9a242a2948b0fc3bee835256f8a20407f615ab
7
+ data.tar.gz: 4fcdd601d78c4f03dc71d2ff33d6749d5166d8416acd1624e36a6101ec6554880ec7085ad4eefc4515046d44a01f5028225b85c6618d9e449f134ce36e4a4bbf
@@ -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,7 @@
23
23
  </li>
24
24
  <% end %>
25
25
  </ul>
26
+ <%= content_after_meta_items %>
26
27
  <% end %>
27
28
 
28
29
  <% if meta_content.present? %>
@@ -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, :copyright, :custom_container_classes
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
- @copyright = build_copyright(copyright_text, copyright_url)
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
 
@@ -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 build_copyright(text, url)
85
- link_to(text, url, class: "#{brand}-footer__link #{brand}-footer__copyright-logo")
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(role: 'banner', data: { module: "#{brand}-header" }, **html_attributes) do %>
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
- { role: "navigation", aria: { label: landmark_label }, class: "#{brand}-pagination" }
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:, id: nil, classes: [], html_attributes: {})
8
+ def initialize(title: 'Contents', id: nil, classes: [], html_attributes: {})
9
9
  @title = title
10
10
  @id = id
11
11
 
@@ -115,14 +115,16 @@ private
115
115
  Rails.logger.warn(controller_warning_message(kwargs.fetch(:controller))) if kwargs.key?(:controller)
116
116
 
117
117
  button_classes = extract_button_classes(inverse:, secondary:, warning:)
118
+ data_attributes = build_data_attributes("#{brand}-button")
118
119
 
119
- { **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)
120
121
  end
121
122
 
122
- 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)
123
124
  button_classes = extract_button_classes(inverse:, secondary:, warning:)
125
+ data_attributes = build_data_attributes("#{brand}-button", prevent_double_click:)
124
126
 
125
- { **button_classes, **button_attributes(disabled) }.deep_merge_html_attributes(kwargs)
127
+ { **button_classes, **data_attributes, **button_attributes(disabled) }.deep_merge_html_attributes(kwargs)
126
128
  end
127
129
 
128
130
  def extract_link_classes(inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false)
@@ -183,6 +185,13 @@ private
183
185
  def controller_warning_message(value)
184
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"
185
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
186
195
  end
187
196
 
188
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: "govuk-button" }
47
+ data: { module: "#{brand}-button" }
48
48
  }
49
49
 
50
50
  if extra_options && extra_options[:prevent_double_click]
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '5.2.1'.freeze
3
+ VERSION = '5.3.0'.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: 5.2.1
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-02-23 00:00:00.000000000 Z
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: '6.0'
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: '6.0'
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.11'
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.11'
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