govuk_publishing_components 47.0.0 → 48.0.0

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/rum-custom-data.js +18 -0
  3. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js +0 -37
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak.scss +0 -1
  5. data/app/views/govuk_publishing_components/components/_intervention.html.erb +10 -14
  6. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +1 -0
  7. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +10 -21
  8. data/app/views/govuk_publishing_components/components/_list.html.erb +6 -12
  9. data/app/views/govuk_publishing_components/components/_search.html.erb +17 -21
  10. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +5 -11
  11. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +8 -12
  12. data/app/views/govuk_publishing_components/components/_summary_card.html.erb +4 -2
  13. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +6 -2
  14. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +7 -5
  15. data/app/views/govuk_publishing_components/components/_warning_text.html.erb +5 -1
  16. data/app/views/govuk_publishing_components/components/docs/devolved_nations.yml +3 -3
  17. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +0 -6
  18. data/app/views/govuk_publishing_components/components/docs/intervention.yml +1 -0
  19. data/app/views/govuk_publishing_components/components/docs/layout_super_navigation_header.yml +1 -0
  20. data/app/views/govuk_publishing_components/components/docs/list.yml +3 -1
  21. data/app/views/govuk_publishing_components/components/docs/search.yml +2 -2
  22. data/app/views/govuk_publishing_components/components/docs/subscription_links.yml +1 -0
  23. data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -0
  24. data/app/views/govuk_publishing_components/components/docs/summary_card.yml +1 -0
  25. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +1 -0
  26. data/app/views/govuk_publishing_components/components/docs/translation_nav.yml +1 -0
  27. data/app/views/govuk_publishing_components/components/docs/warning_text.yml +1 -0
  28. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +1 -1
  29. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +16 -0
  30. data/lib/govuk_publishing_components/presenters/devolved_nations_helper.rb +4 -4
  31. data/lib/govuk_publishing_components/version.rb +1 -1
  32. metadata +3 -3
  33. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_advisory.scss +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd401f42bccab58df5ab5fb8d73e8faca9662f68038087b3fe103f0fd383bd21
4
- data.tar.gz: 14202a57ad52922b57252c5484bfe7540dbc0d1e2c83690881bf4aed17cc185b
3
+ metadata.gz: 36a9c949e5b0818fd9a88c6e3d391589f2856b2354b061526323ee0da268663b
4
+ data.tar.gz: 9e50cfbc67ab2a7ad2be57cc08de07d962555de601f760a1737f99100fb20608
5
5
  SHA512:
6
- metadata.gz: ef6d0b85a5a028746ca5df2d9dd301cae0401b22d3b9aac4bad2beeeba292ba128940284539b68c1ccc9d6ecd175ab9173bb4e7e49e411f2d252b3a53dda17e9
7
- data.tar.gz: 9692404de6256b99bd839ab47e7dd26b52d3641cf51c503caa7d530a7c5a98cf826e47af9deb3f26701805ff8048e9ba2bb2824d69988388cce1ae3412bb294c
6
+ metadata.gz: d43bd8d3c8c0f58404798658c83e7b5349776b123dd1f3be9f9b380a8124ee510fce6d36ffbc634f33cdd0f4c5f7a4be2002a6c1225869e5289ab9f1c9c65183
7
+ data.tar.gz: a26a44f9bc7ba5b824d9f145662675935cf329f8cb98cfd076f217b18b1e2a557aff6df08b8bc03dc3c84f1d0b90330eb26c211569a3d99d3836bb765b4e5fe2
@@ -0,0 +1,18 @@
1
+ (function () {
2
+ /* global LUX, performance */
3
+ if (typeof LUX === 'undefined') { return }
4
+
5
+ const navigationPerformance = performance.getEntriesByType('navigation')[0]
6
+ if (!navigationPerformance) { return }
7
+
8
+ // As per RFC 147[1], this adds in monitoring of the type of HTTP protocol that
9
+ // is used when a browser loads a page.
10
+ // [1]: https://github.com/alphagov/govuk-rfcs/pull/148
11
+ LUX.addData('http-protocol', navigationPerformance.nextHopProtocol)
12
+
13
+ const serverTiming = navigationPerformance.serverTiming
14
+ if (serverTiming) {
15
+ const cacheState = serverTiming.find(entry => ['cacheHit', 'cacheMiss'].includes(entry.name))
16
+ if (cacheState) { LUX.addData('cache', cacheState.name) }
17
+ }
18
+ }())
@@ -157,40 +157,3 @@ if (
157
157
  LongTaskObserver.observe({ type: ["longtask"] });
158
158
  } catch (e) {}
159
159
  }
160
-
161
- // As per RFC 147[1], this adds in monitoring of the type of HTTP protocol that
162
- // is used when a browser loads a page.
163
- //
164
- // The User Timing API (aka window.performance) is used to record the data - to
165
- // avoid the use of this from breaking the JavaScript for the small number of
166
- // browsers that don't support it, it's been wrapped in a try/catch block plus a
167
- // couple of checks to prevent "is not defined" errors.
168
- //
169
- // Because the `nextHopProtocol` isn't immediately available - it seems to need
170
- // a request to be made before it's populated - we need to wait for the
171
- // `DOMContentReady` event before we can see what the HTTP version is.
172
- //
173
- // [1]: https://github.com/alphagov/govuk-rfcs/pull/148
174
-
175
- var measureHTTPProtocol = function () {
176
- var getEntriesByType = performance.getEntriesByType('navigation')
177
-
178
- if (typeof getEntriesByType !== 'undefined' && getEntriesByType.length > 0) {
179
- var httpProtocol = getEntriesByType[0].nextHopProtocol
180
- LUX.addData("http-protocol", httpProtocol)
181
- }
182
- }
183
-
184
- try {
185
- if (typeof performance !== 'undefined' && typeof performance.getEntriesByType !== 'undefined') {
186
- if (document.readyState === 'complete') {
187
- measureHTTPProtocol()
188
- } else {
189
- window.addEventListener('load', function() {
190
- measureHTTPProtocol()
191
- })
192
- }
193
- }
194
- } catch (e) {
195
- console.error('Error in LUX reporting the HTTP protocol (%s):', window.location, e)
196
- }
@@ -1,6 +1,5 @@
1
1
  @import "govuk_publishing_components/individual_component_support";
2
2
 
3
- @import "govspeak/advisory";
4
3
  @import "govspeak/attachment";
5
4
  @import "govspeak/button";
6
5
  @import "govspeak/call-to-action";
@@ -9,15 +9,10 @@
9
9
  hide ||= false
10
10
  new_tab ||= false
11
11
 
12
- data_attributes = {}
13
12
  suggestion_data_attributes = {}
14
13
  dismiss_data_attributes = {}
15
14
  dismiss_link_data_attributes = {}
16
- data_attributes[:module] = "intervention"
17
- data_attributes["intervention-name"] = name
18
15
 
19
- aria_attributes ||= {}
20
- aria_attributes[:label] = 'Intervention'
21
16
 
22
17
  options = {
23
18
  name: name,
@@ -35,7 +30,6 @@
35
30
  disable_ga4 ||= false
36
31
  suggestion_data_attributes[:module] = "#{suggestion_data_attributes[:module]} ga4-link-tracker".strip unless disable_ga4
37
32
  suggestion_data_attributes[:ga4_link] = { event_name: "navigation", type: "intervention", section: suggestion_text, index_link: 1, index_total: 1 }.to_json unless disable_ga4
38
- data_attributes[:ga4_intervention_banner] = "" unless disable_ga4 # Added to the parent element for the GA4 pageview object to use
39
33
 
40
34
  suggestion_tag_options = {
41
35
  class: "govuk-link gem-c-force-print-link-styles",
@@ -52,18 +46,20 @@
52
46
  suggestion_link_text = intervention_helper.accessible_text
53
47
  end
54
48
 
55
- section_options = {
56
- class: "gem-c-intervention",
57
- role: "region", aria: aria_attributes,
58
- data: data_attributes,
59
- }
60
- section_options.merge!({ hidden: true }) if hide
61
-
62
49
  dismiss_link_data_attributes[:module] = "#{dismiss_link_data_attributes[:module]} ga4-event-tracker".strip unless disable_ga4
63
50
  dismiss_link_data_attributes[:ga4_event] = { event_name: "select_content", type: "intervention", section: suggestion_text, action: 'closed' }.to_json unless disable_ga4
51
+
52
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
53
+ component_helper.add_class("gem-c-intervention")
54
+ component_helper.add_role("region")
55
+ component_helper.add_aria_attribute({ label: "Intervention"})
56
+ component_helper.add_data_attribute({ module: "intervention", intervention_name: name })
57
+ component_helper.add_data_attribute({ ga4_intervention_banner: "" }) unless disable_ga4 # Added to the parent element for the GA4 pageview object to use
58
+ component_helper.set_hidden("hidden") if hide
59
+
64
60
  %>
65
61
  <% if intervention_helper.show? %>
66
- <%= tag.section **section_options do %>
62
+ <%= tag.section(**component_helper.all_attributes) do %>
67
63
  <p class="govuk-body">
68
64
  <%= tag.span suggestion_text, class: "gem-c-intervention__textwrapper" if suggestion_text %>
69
65
  <% if suggestion_link_text && suggestion_link_url %>
@@ -65,6 +65,7 @@
65
65
  <title><%= title %></title>
66
66
 
67
67
  <%= javascript_include_tag "govuk_publishing_components/vendor/lux/lux-measurer", { async: true } %>
68
+ <%= javascript_include_tag "govuk_publishing_components/rum-custom-data", type: "module" %>
68
69
  <%= javascript_include_tag "govuk_publishing_components/rum-loader",
69
70
  {
70
71
  async: true,
@@ -35,9 +35,6 @@
35
35
  search_toggle_button_classes << "gem-c-layout-super-navigation-header__search-toggle-button--blue-background" if blue_background
36
36
  search_toggle_button_classes << "gem-c-layout-super-navigation-header__search-toggle-button--large-navbar" if large_navbar
37
37
 
38
- layout_super_navigation_header_classes = %w(gem-c-layout-super-navigation-header)
39
- layout_super_navigation_header_classes << "gem-c-layout-super-navigation-header--blue-background" if blue_background
40
-
41
38
  item_link_classes = %w(gem-c-layout-super-navigation-header__navigation-item-link)
42
39
  item_link_classes << "gem-c-layout-super-navigation-header__navigation-item-link--blue-background" if blue_background
43
40
  item_link_classes << "gem-c-layout-super-navigation-header__navigation-item-link--large-navbar" if large_navbar
@@ -64,16 +61,14 @@
64
61
  dropdown_menu_classes << "gem-c-layout-super-navigation-header__navigation-dropdown-menu--large-navbar" if large_navbar
65
62
 
66
63
  absolute_links_helper = GovukPublishingComponents::Presenters::AbsoluteLinksHelper.new()
64
+
65
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
66
+ component_helper.add_class("gem-c-layout-super-navigation-header")
67
+ component_helper.add_class("gem-c-layout-super-navigation-header--blue-background") if blue_background
68
+ component_helper.add_role("banner")
69
+ component_helper.add_data_attribute({ module: "ga4-event-tracker ga4-link-tracker", ga4_expandable: "" })
67
70
  %>
68
- <%= content_tag("header",
69
- {
70
- role: "banner",
71
- class: layout_super_navigation_header_classes,
72
- data: {
73
- module: "ga4-event-tracker ga4-link-tracker",
74
- "ga4-expandable": '',
75
- }
76
- }) do %>
71
+ <%= tag.header(**component_helper.all_attributes) do %>
77
72
  <div class="gem-c-layout-super-navigation-header__container govuk-clearfix">
78
73
  <div class="govuk-width-container">
79
74
  <%= content_tag(:div, {
@@ -317,7 +312,7 @@
317
312
  label: "Site-wide",
318
313
  }
319
314
  ) do %>
320
- <% search_options = {
315
+ <%= render "govuk_publishing_components/components/search_with_autocomplete", {
321
316
  name: "keywords",
322
317
  inline_label: false,
323
318
  label_size: "m",
@@ -326,15 +321,9 @@
326
321
  size: "large",
327
322
  margin_bottom: 0,
328
323
  disable_corrections: true,
324
+ source_url: [Plek.new.website_root, "/api/search/autocomplete.json"].join,
325
+ source_key: "suggestions",
329
326
  } %>
330
- <% if ENV["GOVUK_DISABLE_SEARCH_AUTOCOMPLETE"] %>
331
- <%= render "govuk_publishing_components/components/search", search_options %>
332
- <% else %>
333
- <%= render "govuk_publishing_components/components/search_with_autocomplete", search_options.merge({
334
- source_url: [Plek.new.website_root, "/api/search/autocomplete.json"].join,
335
- source_key: "suggestions",
336
- }) %>
337
- <% end %>
338
327
  <% end %>
339
328
  </div>
340
329
  </div>
@@ -1,20 +1,14 @@
1
1
  <%
2
- aria_label ||= nil
3
2
  extra_spacing ||= nil
4
- id ||= nil
5
3
  items ||= []
6
4
  list_type ||= "unordered"
7
5
  visible_counters ||= nil
8
6
 
9
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
10
-
11
- classes = %w[gem-c-list govuk-list]
12
- classes << "govuk-list--bullet" if visible_counters and list_type === "unordered"
13
- classes << "govuk-list--number" if visible_counters and list_type === "number"
14
- classes << "govuk-list--spaced" if extra_spacing
15
- # Setting the `margin_bottom` to 4 is the same as the default margin - so we
16
- # can omit the override class. To do this we leave out `4` from the array:
17
- classes << shared_helper.get_margin_bottom if [0,1,2,3,5,6,7,8,9].include?(local_assigns[:margin_bottom])
7
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
8
+ component_helper.add_class("gem-c-list govuk-list")
9
+ component_helper.add_class("govuk-list--bullet") if visible_counters and list_type === "unordered"
10
+ component_helper.add_class("govuk-list--number") if visible_counters and list_type === "number"
11
+ component_helper.add_class("govuk-list--spaced") if extra_spacing
18
12
 
19
13
  # Default list type is unordered list.
20
14
  list_tag = "ul"
@@ -23,7 +17,7 @@
23
17
  list_tag = "ol" if list_type === "number"
24
18
  %>
25
19
  <% if items.any? %>
26
- <%= content_tag list_tag, class: classes, id: id, "aria-label": aria_label do %>
20
+ <%= content_tag list_tag, **component_helper.all_attributes do %>
27
21
  <% items.each do |item| %>
28
22
  <li><%= raw(item) %></li>
29
23
  <% end %>
@@ -7,7 +7,7 @@
7
7
  aria_controls ||= nil
8
8
  button_text ||= t("components.search_box.search_button")
9
9
  correction_value = "off" if local_assigns[:disable_corrections]
10
- id ||= "search-main-" + SecureRandom.hex(4)
10
+ label_id ||= "search-main-" + SecureRandom.hex(4)
11
11
  wrap_label_in_a_heading ||= false
12
12
  label_margin_bottom ||= nil
13
13
  label_size ||= nil
@@ -19,21 +19,17 @@
19
19
  size ||= ""
20
20
  value ||= ""
21
21
 
22
- data_attributes ||= {}
23
-
24
- classes = %w[gem-c-search govuk-!-display-none-print]
25
- classes << shared_helper.get_margin_top
26
- classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom]
27
- classes << "gem-c-search--large" if size == "large"
28
- classes << "gem-c-search--large-on-mobile" if size == "large-mobile"
29
- classes << "gem-c-search--homepage" if homepage
30
- classes << "gem-c-search--no-border" if no_border
31
- if local_assigns[:on_govuk_blue].eql?(true)
32
- classes << "gem-c-search--on-govuk-blue"
33
- else
34
- classes << "gem-c-search--on-white"
35
- end
36
- classes << "gem-c-search--separate-label" if local_assigns.include?(:inline_label) or local_assigns.include?(:label_size)
22
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
23
+ component_helper.add_data_attribute({ module: "gem-toggle-input-class-on-focus" })
24
+ component_helper.add_class("gem-c-search govuk-!-display-none-print")
25
+ component_helper.add_class(shared_helper.get_margin_top)
26
+ component_helper.add_class("gem-c-search--large") if size == "large"
27
+ component_helper.add_class("gem-c-search--large-on-mobile") if size == "large-mobile"
28
+ component_helper.add_class("gem-c-search--homepage") if homepage
29
+ component_helper.add_class("gem-c-search--no-border") if no_border
30
+ component_helper.add_class("gem-c-search--on-govuk-blue") if local_assigns[:on_govuk_blue].eql?(true)
31
+ component_helper.add_class("gem-c-search--on-white") unless local_assigns[:on_govuk_blue].eql?(true)
32
+ component_helper.add_class("gem-c-search--separate-label") if local_assigns.include?(:inline_label) or local_assigns.include?(:label_size)
37
33
 
38
34
  label_classes = []
39
35
  if (shared_helper.valid_heading_size?(label_size))
@@ -46,12 +42,12 @@
46
42
  label_classes << label_custom_class if label_custom_class
47
43
 
48
44
  tag_label = capture do
49
- tag.label(for: id, class: label_classes) do
45
+ tag.label(for: label_id, class: label_classes) do
50
46
  label_text
51
47
  end
52
48
  end
53
49
  %>
54
- <div class="<%= classes.join(" ") %>" data-module="gem-toggle-input-class-on-focus">
50
+ <%= tag.div(**component_helper.all_attributes) do %>
55
51
  <% if wrap_label_in_a_heading %>
56
52
  <%= content_tag(shared_helper.get_heading_level, class: "govuk-!-margin-0") do %>
57
53
  <%= tag_label %>
@@ -67,7 +63,7 @@
67
63
  },
68
64
  enterkeyhint: "search",
69
65
  class: "gem-c-search__item gem-c-search__input js-class-toggle",
70
- id: id,
66
+ id: label_id,
71
67
  name: name,
72
68
  title: t("components.search_box.input_title"),
73
69
  type: "search",
@@ -77,10 +73,10 @@
77
73
  ) %>
78
74
  </div>
79
75
  <div class="gem-c-search__item gem-c-search__submit-wrapper">
80
- <%= tag.button class: "gem-c-search__submit", type: "submit", data: data_attributes, enterkeyhint: "search" do %>
76
+ <%= tag.button class: "gem-c-search__submit", type: "submit", enterkeyhint: "search" do %>
81
77
  <%= button_text %>
82
78
  <%= render "govuk_publishing_components/components/search/search_icon" %>
83
79
  <% end %>
84
80
  </div>
85
81
  </div>
86
- </div>
82
+ <% end %>
@@ -5,17 +5,11 @@
5
5
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
6
6
 
7
7
  sl_helper = GovukPublishingComponents::Presenters::SubscriptionLinksHelper.new(local_assigns)
8
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
9
8
 
10
- local_assigns[:margin_bottom] ||= 0
11
- local_assigns[:margin_bottom] = 0 if local_assigns[:margin_bottom] > 9
12
-
13
- css_classes = %w( gem-c-subscription-links govuk-!-display-none-print )
14
- css_classes << shared_helper.get_margin_bottom unless local_assigns[:margin_bottom] == 0
15
- css_classes << brand_helper.brand_class
16
- css_classes << "gem-c-subscription-links--with-feed-box" if sl_helper.feed_link_box_value
17
-
18
- data = {"module": "gem-toggle"} if sl_helper.feed_link_box_value
9
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
10
+ component_helper.add_class("gem-c-subscription-links govuk-!-display-none-print #{brand_helper.brand_class}")
11
+ component_helper.add_class("gem-c-subscription-links--with-feed-box") if sl_helper.feed_link_box_value
12
+ component_helper.add_data_attribute({ module: "gem-toggle" }) if sl_helper.feed_link_box_value
19
13
 
20
14
  hide_heading ||= false
21
15
 
@@ -23,7 +17,7 @@
23
17
  feed_link_text_locale = local_assigns[:feed_link_text_locale].presence
24
18
  %>
25
19
  <% if sl_helper.component_data_is_valid? %>
26
- <%= tag.section class: css_classes, data: data do %>
20
+ <%= tag.section(**component_helper.all_attributes) do %>
27
21
  <% unless hide_heading %>
28
22
  <h2 class="gem-c-subscription-links__hidden-header visuallyhidden"><%= t("components.subscription_links.subscriptions") %></h2>
29
23
  <% end %>
@@ -3,20 +3,16 @@
3
3
 
4
4
  description ||= nil
5
5
  title_id ||= "govuk-notification-banner-title-#{SecureRandom.hex(4)}"
6
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
7
- classes = %w(gem-c-success-alert govuk-notification-banner govuk-notification-banner--success)
8
- classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom]
6
+
7
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
8
+ component_helper.add_class("gem-c-success-alert govuk-notification-banner govuk-notification-banner--success")
9
+ component_helper.add_role("alert")
10
+ component_helper.set_tabindex(-1)
11
+ component_helper.add_aria_attribute({ labelledby: title_id })
12
+ component_helper.add_data_attribute({ module: "initial-focus" })
9
13
  %>
10
14
 
11
- <%= tag.div class: classes,
12
- role: "alert",
13
- tabindex: "-1",
14
- aria: {
15
- labelledby: title_id,
16
- },
17
- data: {
18
- module: "initial-focus",
19
- } do %>
15
+ <%= tag.div(**component_helper.all_attributes) do %>
20
16
  <div class="govuk-notification-banner__header">
21
17
  <%= tag.h2 t("components.success_alert.success"), class: "govuk-notification-banner__title", id: title_id %>
22
18
  </div>
@@ -3,12 +3,14 @@
3
3
 
4
4
  id ||= nil
5
5
  title ||= nil
6
- data_attributes ||= {}
7
6
  summary_card_actions ||= []
8
7
  rows ||=[]
8
+
9
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
10
+ component_helper.add_class("gem-c-summary-card")
9
11
  %>
10
12
  <% if title || rows.any? %>
11
- <%= tag.div class: "gem-c-summary-card", id: id, data: data_attributes do %>
13
+ <%= tag.div(**component_helper.all_attributes) do %>
12
14
  <%= tag.div class: "govuk-summary-card" do %>
13
15
  <%= tag.div class: "govuk-summary-card__title-wrapper" do %>
14
16
  <%= tag.h2 class: "govuk-summary-card__title" do %>
@@ -5,7 +5,6 @@
5
5
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
6
6
  heading_size = "m" unless shared_helper.valid_heading_size?(heading_size)
7
7
 
8
- id ||= nil
9
8
  title ||= nil
10
9
  borderless ||= false
11
10
  edit ||= {}
@@ -13,9 +12,14 @@
13
12
  items ||= []
14
13
  block ||= yield
15
14
  wide_title ||= false
15
+
16
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
17
+ component_helper.add_class("gem-c-summary-list")
18
+ component_helper.add_class("govuk-summary-list--no-border") if borderless
19
+ component_helper.add_class("gem-c-summary-list--wide-title") if wide_title
16
20
  %>
17
21
  <% if title || items.any? %>
18
- <%= tag.div class: "gem-c-summary-list #{"govuk-summary-list--no-border" if borderless} #{"gem-c-summary-list--wide-title" if wide_title}", id: id do %>
22
+ <%= tag.div(**component_helper.all_attributes) do %>
19
23
  <% if title %>
20
24
  <%= content_tag(shared_helper.get_heading_level, title, class: "govuk-heading-#{heading_size} gem-c-summary-list__group-title") %>
21
25
 
@@ -4,12 +4,14 @@
4
4
  brand ||= false
5
5
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
6
6
  translation_helper = GovukPublishingComponents::Presenters::TranslationNavHelper.new(local_assigns)
7
+
8
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
9
+ component_helper.add_role("navigation")
10
+ component_helper.add_class("gem-c-translation-nav govuk-!-display-none-print #{translation_helper.classes} #{brand_helper.brand_class}")
11
+ component_helper.add_aria_attribute({ label: t("common.translations") })
7
12
  %>
8
13
  <% if translation_helper.has_translations? %>
9
- <nav role="navigation"
10
- class="gem-c-translation-nav govuk-!-display-none-print <%= translation_helper.classes %> <%= brand_helper.brand_class %>"
11
- aria-label="<%= t("common.translations") %>"
12
- >
14
+ <%= tag.nav(**component_helper.all_attributes) do %>
13
15
  <ul class="gem-c-translation-nav__list">
14
16
  <% translation_helper.translations.each.with_index do |translation, i| %>
15
17
  <li class="gem-c-translation-nav__list-item">
@@ -27,5 +29,5 @@
27
29
  </li>
28
30
  <% end %>
29
31
  </ul>
30
- </nav>
32
+ <% end %>
31
33
  <% end %>
@@ -14,9 +14,13 @@
14
14
  text_classes << "gem-c-warning-text__text--no-indent" if text_icon.empty?
15
15
  text_classes << "gem-c-warning-text__text--large" if large_font
16
16
  text_classes << "gem-c-warning-text__text--highlight" if highlight_text
17
+
18
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
19
+ component_helper.set_id(id)
20
+ component_helper.add_class("gem-c-warning-text govuk-warning-text")
17
21
  %>
18
22
 
19
- <%= tag.div id: id, class: "gem-c-warning-text govuk-warning-text" do %>
23
+ <%= tag.div(**component_helper.all_attributes) do %>
20
24
  <% unless text_icon.empty? %>
21
25
  <%= tag.span text_icon, class: "govuk-warning-text__icon", "aria-hidden": "true" %>
22
26
  <% end %>
@@ -72,7 +72,7 @@ examples:
72
72
  northern_ireland:
73
73
  applicable: false
74
74
  alternative_url: /
75
- type: consultation
75
+ content_type: consultation
76
76
  applies_to_one_nation_individual_guidance_available:
77
77
  description: Specify alternative type for the content e.g. Guidance
78
78
  data:
@@ -82,7 +82,7 @@ examples:
82
82
  northern_ireland:
83
83
  applicable: false
84
84
  alternative_url: /
85
- type: detailed_guide
85
+ content_type: detailed_guide
86
86
  specific_heading level:
87
87
  description: Use a different heading level for the main link title. Defaults to `h2` if not passed.
88
88
  data:
@@ -104,5 +104,5 @@ examples:
104
104
  northern_ireland:
105
105
  applicable: false
106
106
  alternative_url: /
107
- type: detailed_guide
107
+ content_type: detailed_guide
108
108
  disable_ga4: true
@@ -842,12 +842,6 @@ examples:
842
842
  The water in the mouth of a blue whale weighs more than its body.
843
843
  </p>
844
844
  </div>
845
- advisory:
846
- data:
847
- block: |
848
- <h3 role="note" aria-label="Important" class="advisory">
849
- <span>This is a very important message or warning</span>
850
- </h3>
851
845
  form_download:
852
846
  data:
853
847
  block: |
@@ -21,6 +21,7 @@ shared_accessibility_criteria:
21
21
  - link
22
22
  accessibility_excluded_rules:
23
23
  - landmark-unique # aria-label attributes will be duplicated in component examples list
24
+ uses_component_wrapper_helper: true
24
25
  examples:
25
26
  default:
26
27
  data:
@@ -26,6 +26,7 @@ accessibility_excluded_rules:
26
26
  - duplicate-id-aria
27
27
  - landmark-no-duplicate-banner
28
28
  - landmark-unique
29
+ uses_component_wrapper_helper: true
29
30
  examples:
30
31
  default:
31
32
  with_custom_logo_link:
@@ -5,6 +5,7 @@ body: |
5
5
 
6
6
  The `items` parameter can include HTML to display - such as links or another
7
7
  list. This HTML can either be directly coded or come from another component.
8
+ uses_component_wrapper_helper: true
8
9
  accessibility_criteria: |
9
10
  The list must:
10
11
 
@@ -31,7 +32,8 @@ examples:
31
32
  unordered_list_with_aria-label:
32
33
  description: "A list with an aria-label"
33
34
  data:
34
- aria_label: "A list of delicious chocolate bars."
35
+ aria:
36
+ label: "A list of delicious chocolate bars."
35
37
  <<: *default-example-data
36
38
  unordered_list_with_bullet_points:
37
39
  description: "An unordered list with visible bullet points."
@@ -12,7 +12,7 @@ accessibility_criteria: |
12
12
 
13
13
  - be used inside a form with the role of 'search', to indicate it as a [search landmark](https://www.w3.org/TR/wai-aria-practices-1.1/#aria_lh_search)
14
14
  - have a clear label to identify the search functionality, which is visible to all users
15
-
15
+ uses_component_wrapper_helper: true
16
16
  examples:
17
17
  default:
18
18
  data: {}
@@ -49,7 +49,7 @@ examples:
49
49
  label_text: "Search"
50
50
  set_id_for_search_input:
51
51
  data:
52
- id: "my_unique_id"
52
+ label_id: "my_unique_id"
53
53
  large_version:
54
54
  data:
55
55
  size: "large"
@@ -14,6 +14,7 @@ accessibility_criteria: |
14
14
  - show hidden elements by default when JavaScript is disabled
15
15
  shared_accessibility_criteria:
16
16
  - link
17
+ uses_component_wrapper_helper: true
17
18
  examples:
18
19
  default:
19
20
  data:
@@ -7,6 +7,7 @@ accessibility_criteria: |
7
7
  assistive tech
8
8
  - Should have a role of ‘alert’ to communicate that is a important and
9
9
  time sensitive message
10
+ uses_component_wrapper_helper: true
10
11
  examples:
11
12
  default:
12
13
  data:
@@ -5,6 +5,7 @@ accessibility_criteria: |
5
5
  - be focusable with a keyboard
6
6
  - be usable with a keyboard
7
7
  - indicate when it has focus
8
+ uses_component_wrapper_helper: true
8
9
  examples:
9
10
  default:
10
11
  data:
@@ -9,6 +9,7 @@ shared_accessibility_criteria:
9
9
  - link
10
10
  govuk_frontend_components:
11
11
  - summary-list
12
+ uses_component_wrapper_helper: true
12
13
  examples:
13
14
  default:
14
15
  data: &default-example-data
@@ -16,6 +16,7 @@ shared_accessibility_criteria:
16
16
  - link
17
17
  accessibility_excluded_rules:
18
18
  - landmark-unique # aria-label attributes will be duplicated in component examples list
19
+ uses_component_wrapper_helper: true
19
20
  examples:
20
21
  default:
21
22
  data:
@@ -5,6 +5,7 @@ govuk_frontend_components:
5
5
  - warning-text
6
6
  accessibility_criteria: |
7
7
  All text must have a contrast ratio higher than 4.5:1 against the background colour to meet [WCAG AA](https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast)
8
+ uses_component_wrapper_helper: true
8
9
  examples:
9
10
  default:
10
11
  data:
@@ -21,7 +21,7 @@
21
21
  >
22
22
  <%= render "govuk_publishing_components/components/search", {
23
23
  button_text: t("components.layout_header.search_button"),
24
- id: "site-search-text",
24
+ label_id: "site-search-text",
25
25
  margin_bottom: 0,
26
26
  no_border: true,
27
27
  disable_corrections: true,
@@ -14,6 +14,7 @@ module GovukPublishingComponents
14
14
  check_hidden_is_valid(@options[:hidden]) if @options.include?(:hidden)
15
15
  check_tabindex_is_valid(@options[:tabindex]) if @options.include?(:tabindex)
16
16
  check_dir_is_valid(@options[:dir]) if @options.include?(:dir)
17
+ check_type_is_valid(@options[:type]) if @options.include?(:type)
17
18
  check_margin_bottom_is_valid(@options[:margin_bottom]) if @options.include?(:margin_bottom)
18
19
  end
19
20
 
@@ -33,6 +34,7 @@ module GovukPublishingComponents
33
34
  attributes[:hidden] = @options[:hidden] unless @options[:hidden].nil?
34
35
  attributes[:tabindex] = @options[:tabindex] unless @options[:tabindex].blank?
35
36
  attributes[:dir] = @options[:dir] unless @options[:dir].blank?
37
+ attributes[:type] = @options[:type] unless @options[:type].blank?
36
38
 
37
39
  attributes
38
40
  end
@@ -87,6 +89,11 @@ module GovukPublishingComponents
87
89
  @options[:dir] = dir_attribute
88
90
  end
89
91
 
92
+ def set_type(type_attribute)
93
+ check_type_is_valid(type_attribute)
94
+ @options[:type] = type_attribute
95
+ end
96
+
90
97
  def set_margin_bottom(margin_bottom)
91
98
  check_margin_bottom_is_valid(margin_bottom)
92
99
  @options[:margin_bottom] = margin_bottom
@@ -192,6 +199,15 @@ module GovukPublishingComponents
192
199
  end
193
200
  end
194
201
 
202
+ def check_type_is_valid(type_attribute)
203
+ return if type_attribute.nil?
204
+
205
+ options = %w[button checkbox color date datetime-local email file hidden image month number password radio range reset search submit tel text time url week]
206
+ unless options.include? type_attribute
207
+ raise(ArgumentError, "type attribute (#{type_attribute}) is not recognised")
208
+ end
209
+ end
210
+
195
211
  def extend_string(option, string)
196
212
  ((@options[option] ||= "") << " #{string}").strip!
197
213
  end
@@ -1,11 +1,11 @@
1
1
  module GovukPublishingComponents
2
2
  module Presenters
3
3
  class DevolvedNationsHelper
4
- attr_reader :national_applicability, :type
4
+ attr_reader :national_applicability, :content_type
5
5
 
6
6
  def initialize(local_assigns)
7
7
  @national_applicability = local_assigns[:national_applicability]
8
- @type = local_assigns[:type] || "publication"
8
+ @content_type = local_assigns[:content_type] || "publication"
9
9
  end
10
10
 
11
11
  def applicable_nations_title_text(use_english_translation = nil)
@@ -42,8 +42,8 @@ module GovukPublishingComponents
42
42
  def alternative_content_text(name)
43
43
  nation = I18n.t("components.devolved_nations.#{name}")
44
44
 
45
- if I18n.exists?("components.devolved_nations.type.#{@type}")
46
- I18n.t("components.devolved_nations.type.#{@type}", nation:)
45
+ if I18n.exists?("components.devolved_nations.type.#{@content_type}")
46
+ I18n.t("components.devolved_nations.type.#{@content_type}", nation:)
47
47
  else
48
48
  I18n.t("components.devolved_nations.type.publication", nation:)
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "47.0.0".freeze
2
+ VERSION = "48.0.0".freeze
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 47.0.0
4
+ version: 48.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-07 00:00:00.000000000 Z
10
+ date: 2025-01-13 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: govuk_app_config
@@ -505,6 +505,7 @@ files:
505
505
  - app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
506
506
  - app/assets/javascripts/govuk_publishing_components/load-analytics.js
507
507
  - app/assets/javascripts/govuk_publishing_components/modules.js
508
+ - app/assets/javascripts/govuk_publishing_components/rum-custom-data.js
508
509
  - app/assets/javascripts/govuk_publishing_components/rum-loader.js
509
510
  - app/assets/javascripts/govuk_publishing_components/single-consent-functions.js
510
511
  - app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js
@@ -593,7 +594,6 @@ files:
593
594
  - app/assets/stylesheets/govuk_publishing_components/components/_title.scss
594
595
  - app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss
595
596
  - app/assets/stylesheets/govuk_publishing_components/components/_warning-text.scss
596
- - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_advisory.scss
597
597
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss
598
598
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss
599
599
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_call-to-action.scss
@@ -1,36 +0,0 @@
1
- $info-background: #d5e8f3;
2
- $high-alert-border: #cc0000;
3
-
4
- .govspeak, // Legacy class name that's still used in some content items - needs to be kept until `.govspeak` is removed from the content items.
5
- .gem-c-govspeak {
6
- .advisory {
7
- background-image: url("govuk_publishing_components/icon-important.svg");
8
- background-repeat: no-repeat;
9
- background-size: 30px 30px;
10
- background-position: 98% center;
11
- background-color: $info-background;
12
- line-height: 1.3em;
13
- margin: 0 0 1em;
14
- padding: govuk-spacing(3) govuk-spacing(8) govuk-spacing(3) govuk-spacing(3);
15
- text-align: left;
16
-
17
- p {
18
- margin: 0 .75em 0 0;
19
- min-height: 1.75em;
20
- padding-right: 3em;
21
- }
22
-
23
- strong {
24
- font-weight: 400;
25
- }
26
-
27
- &.high-alert {
28
- background-color: govuk-colour("light-grey");
29
- border: 1px solid $high-alert-border;
30
- }
31
-
32
- @include govuk-media-query($until: tablet) {
33
- margin: 0 0 1em;
34
- }
35
- }
36
- }