govuk_publishing_components 46.4.0 → 48.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) 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/_all_components.scss +0 -1
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak.scss +0 -1
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +6 -14
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +4 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_highlight-answer.scss +4 -4
  9. data/app/models/govuk_publishing_components/component_doc.rb +1 -1
  10. data/app/views/govuk_publishing_components/components/_heading.html.erb +24 -9
  11. data/app/views/govuk_publishing_components/components/_intervention.html.erb +10 -14
  12. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +1 -0
  13. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +10 -21
  14. data/app/views/govuk_publishing_components/components/_list.html.erb +6 -12
  15. data/app/views/govuk_publishing_components/components/_search.html.erb +17 -21
  16. data/app/views/govuk_publishing_components/components/_skip_link.html.erb +6 -1
  17. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +4 -7
  18. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +6 -5
  19. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +5 -11
  20. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +8 -12
  21. data/app/views/govuk_publishing_components/components/_summary_card.html.erb +4 -2
  22. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +6 -2
  23. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +7 -5
  24. data/app/views/govuk_publishing_components/components/_warning_text.html.erb +5 -1
  25. data/app/views/govuk_publishing_components/components/docs/devolved_nations.yml +3 -3
  26. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +0 -6
  27. data/app/views/govuk_publishing_components/components/docs/heading.yml +34 -10
  28. data/app/views/govuk_publishing_components/components/docs/intervention.yml +1 -0
  29. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +1 -1
  30. data/app/views/govuk_publishing_components/components/docs/layout_super_navigation_header.yml +1 -0
  31. data/app/views/govuk_publishing_components/components/docs/list.yml +3 -1
  32. data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +9 -0
  33. data/app/views/govuk_publishing_components/components/docs/search.yml +2 -2
  34. data/app/views/govuk_publishing_components/components/docs/skip_link.yml +1 -0
  35. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +1 -0
  36. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +1 -0
  37. data/app/views/govuk_publishing_components/components/docs/subscription_links.yml +1 -0
  38. data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -0
  39. data/app/views/govuk_publishing_components/components/docs/summary_card.yml +1 -0
  40. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +1 -0
  41. data/app/views/govuk_publishing_components/components/docs/translation_nav.yml +1 -0
  42. data/app/views/govuk_publishing_components/components/docs/warning_text.yml +1 -0
  43. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +1 -1
  44. data/config/locales/ar.yml +0 -8
  45. data/config/locales/az.yml +0 -8
  46. data/config/locales/be.yml +0 -8
  47. data/config/locales/bg.yml +0 -8
  48. data/config/locales/bn.yml +0 -8
  49. data/config/locales/cs.yml +0 -8
  50. data/config/locales/cy.yml +0 -8
  51. data/config/locales/da.yml +0 -8
  52. data/config/locales/de.yml +0 -8
  53. data/config/locales/dr.yml +0 -8
  54. data/config/locales/el.yml +0 -8
  55. data/config/locales/en.yml +0 -8
  56. data/config/locales/es-419.yml +0 -8
  57. data/config/locales/es.yml +0 -8
  58. data/config/locales/et.yml +0 -8
  59. data/config/locales/fa.yml +0 -8
  60. data/config/locales/fi.yml +0 -8
  61. data/config/locales/fr.yml +0 -8
  62. data/config/locales/gd.yml +0 -8
  63. data/config/locales/gu.yml +0 -8
  64. data/config/locales/he.yml +0 -8
  65. data/config/locales/hi.yml +0 -8
  66. data/config/locales/hr.yml +0 -8
  67. data/config/locales/hu.yml +0 -8
  68. data/config/locales/hy.yml +0 -8
  69. data/config/locales/id.yml +0 -8
  70. data/config/locales/is.yml +0 -8
  71. data/config/locales/it.yml +0 -8
  72. data/config/locales/ja.yml +0 -8
  73. data/config/locales/ka.yml +0 -8
  74. data/config/locales/kk.yml +0 -8
  75. data/config/locales/ko.yml +0 -8
  76. data/config/locales/lt.yml +0 -8
  77. data/config/locales/lv.yml +0 -8
  78. data/config/locales/ms.yml +0 -8
  79. data/config/locales/mt.yml +0 -8
  80. data/config/locales/nl.yml +0 -8
  81. data/config/locales/no.yml +0 -8
  82. data/config/locales/pa-pk.yml +0 -8
  83. data/config/locales/pa.yml +0 -8
  84. data/config/locales/pl.yml +0 -8
  85. data/config/locales/ps.yml +0 -8
  86. data/config/locales/pt.yml +0 -8
  87. data/config/locales/ro.yml +0 -8
  88. data/config/locales/ru.yml +0 -8
  89. data/config/locales/si.yml +0 -8
  90. data/config/locales/sk.yml +0 -8
  91. data/config/locales/sl.yml +0 -8
  92. data/config/locales/so.yml +0 -8
  93. data/config/locales/sq.yml +0 -8
  94. data/config/locales/sr.yml +0 -8
  95. data/config/locales/sv.yml +0 -8
  96. data/config/locales/sw.yml +0 -8
  97. data/config/locales/ta.yml +0 -8
  98. data/config/locales/th.yml +0 -8
  99. data/config/locales/tk.yml +0 -8
  100. data/config/locales/tr.yml +0 -8
  101. data/config/locales/uk.yml +0 -8
  102. data/config/locales/ur.yml +0 -8
  103. data/config/locales/uz.yml +0 -8
  104. data/config/locales/vi.yml +0 -8
  105. data/config/locales/zh-hk.yml +0 -8
  106. data/config/locales/zh-tw.yml +0 -8
  107. data/config/locales/zh.yml +0 -8
  108. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +16 -0
  109. data/lib/govuk_publishing_components/presenters/devolved_nations_helper.rb +4 -4
  110. data/lib/govuk_publishing_components/presenters/heading_helper.rb +3 -3
  111. data/lib/govuk_publishing_components/presenters/organisation_logo_helper.rb +3 -1
  112. data/lib/govuk_publishing_components/version.rb +1 -1
  113. data/lib/govuk_publishing_components.rb +0 -1
  114. metadata +4 -37
  115. data/app/assets/javascripts/govuk_publishing_components/components/chart.js +0 -1
  116. data/app/assets/stylesheets/govuk_publishing_components/components/_chart.scss +0 -57
  117. data/app/assets/stylesheets/govuk_publishing_components/components/_chat-entry.scss +0 -39
  118. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_advisory.scss +0 -36
  119. data/app/views/govuk_publishing_components/components/_chart.html.erb +0 -146
  120. data/app/views/govuk_publishing_components/components/_chat_entry.html.erb +0 -55
  121. data/app/views/govuk_publishing_components/components/docs/chart.yml +0 -576
  122. data/app/views/govuk_publishing_components/components/docs/chat_entry.yml +0 -45
  123. data/lib/govuk_publishing_components/presenters/chart_helper.rb +0 -112
  124. data/node_modules/chartkick/LICENSE.txt +0 -22
  125. data/node_modules/chartkick/README.md +0 -593
  126. data/node_modules/chartkick/chart.js/chart.esm.js +0 -5
  127. data/node_modules/chartkick/chart.js/package.json +0 -6
  128. data/node_modules/chartkick/dist/chartkick.esm.js +0 -2562
  129. data/node_modules/chartkick/dist/chartkick.js +0 -2570
  130. data/node_modules/chartkick/dist/chartkick.min.js +0 -2
  131. data/node_modules/chartkick/highcharts/highcharts.esm.js +0 -4
  132. data/node_modules/chartkick/highcharts/package.json +0 -6
  133. data/node_modules/chartkick/package.json +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7972dc1e95cf1c1175ee81653f3b298d0d2d930b62bbd8c1035ba110fbbdcb72
4
- data.tar.gz: f55e702ced40190a656f098fc3f192738b1478cf989a0b532051a778a308126b
3
+ metadata.gz: 36a9c949e5b0818fd9a88c6e3d391589f2856b2354b061526323ee0da268663b
4
+ data.tar.gz: 9e50cfbc67ab2a7ad2be57cc08de07d962555de601f760a1737f99100fb20608
5
5
  SHA512:
6
- metadata.gz: a588ba7241dc601438da646c2fc3ca9f5ddc93750cdaebac5e913f9a006acb8b13f61d7fe28b30936b41ba5268817876de7c235e4016f50790d5732d313a3939
7
- data.tar.gz: d4f317981b263f21b71a8768600f6582c4a0592c22721f858a3e712f6756dca05c86e0cac787872043703df463456a8c7fed95b63cbc0377657dbdbbe35f960e
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
- }
@@ -19,7 +19,6 @@
19
19
  @import "components/button";
20
20
  @import "components/cards";
21
21
  @import "components/character-count";
22
- @import "components/chat-entry";
23
22
  @import "components/checkboxes";
24
23
  @import "components/contents-list";
25
24
  @import "components/contextual-guidance";
@@ -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";
@@ -1,6 +1,7 @@
1
1
  @import "govuk_publishing_components/individual_component_support";
2
2
 
3
- .gem-c-heading {
3
+ .gem-c-heading,
4
+ .gem-c-heading__text {
4
5
  margin: 0;
5
6
  }
6
7
 
@@ -9,18 +10,6 @@
9
10
  @include govuk-font(27, $weight: bold);
10
11
  }
11
12
 
12
- // special case for publications and consultations pages
13
- // separated to allow normalisation of the component for wider use
14
- .gem-c-heading--mobile-top-margin {
15
- margin-top: govuk-spacing(6);
16
- margin-bottom: govuk-spacing(3);
17
-
18
- @include govuk-media-query($from: tablet) {
19
- margin-top: 0;
20
- margin-bottom: govuk-spacing(6);
21
- }
22
- }
23
-
24
13
  .gem-c-heading--padding {
25
14
  padding: govuk-spacing(3) 0;
26
15
  }
@@ -43,7 +32,10 @@
43
32
  }
44
33
 
45
34
  .gem-c-heading--inverse {
46
- color: govuk-colour("white");
35
+ .gem-c-heading__context,
36
+ .gem-c-heading__text {
37
+ color: govuk-colour("white");
38
+ }
47
39
  }
48
40
 
49
41
  // stylelint-disable declaration-no-important
@@ -82,6 +82,10 @@
82
82
  }
83
83
  }
84
84
 
85
+ .gem-c-organisation-logo__link-hide-underline:link:not(:hover) {
86
+ text-decoration: none;
87
+ }
88
+
85
89
  .gem-c-organisation-logo--inverse {
86
90
  .gem-c-organisation-logo__container {
87
91
  border-color: govuk-colour("white");
@@ -9,8 +9,8 @@ $highlight-answer-color: govuk-colour("white");
9
9
  background-color: $highlight-answer-bg-color;
10
10
  color: $highlight-answer-color;
11
11
  text-align: center;
12
- padding: 1.75em .75em 1.25em;
13
- margin: 0 0 1em;
12
+ padding: govuk-spacing(5) govuk-spacing(2) govuk-spacing(4);
13
+ margin: 0 0 govuk-spacing(2);
14
14
 
15
15
  p {
16
16
  color: $highlight-answer-color;
@@ -18,7 +18,7 @@ $highlight-answer-color: govuk-colour("white");
18
18
 
19
19
  em {
20
20
  display: block;
21
- padding-top: .1em;
21
+ padding-top: govuk-spacing(2);
22
22
  color: $highlight-answer-color;
23
23
  @include govuk-font($size: 80, $weight: bold);
24
24
  }
@@ -29,7 +29,7 @@ $highlight-answer-color: govuk-colour("white");
29
29
  }
30
30
 
31
31
  @include govuk-media-query($until: tablet) {
32
- margin: 0 0 1em;
32
+ margin: 0 0 govuk-spacing(2);
33
33
  @include govuk-font($size: 48);
34
34
 
35
35
  p {
@@ -83,7 +83,7 @@ module GovukPublishingComponents
83
83
  end
84
84
 
85
85
  def github_search_url
86
- params = { q: "org:alphagov components/components/#{id}", type: "Code" }
86
+ params = { q: "org:alphagov #{partial_path}", type: "Code" }
87
87
  "https://github.com/search?#{params.to_query}"
88
88
  end
89
89
 
@@ -3,21 +3,36 @@
3
3
 
4
4
  brand ||= false
5
5
  lang = local_assigns[:lang].presence
6
+ context ||= false
7
+ context_locale ||= false
8
+ context_inside ||= false
6
9
 
7
10
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
8
11
  heading_helper = GovukPublishingComponents::Presenters::HeadingHelper.new(local_assigns)
9
12
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
10
13
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
11
14
 
12
- classes = %w(gem-c-heading)
13
- classes << heading_helper.classes
14
- classes << brand_helper.brand_class
15
- classes << brand_helper.border_color_class
16
-
17
- component_helper.add_class(classes.join(" "))
15
+ component_helper.add_class("gem-c-heading")
16
+ component_helper.add_class(heading_helper.classes)
17
+ component_helper.add_class(brand_helper.brand_class)
18
+ component_helper.add_class(brand_helper.border_color_class)
18
19
  component_helper.set_id(heading_helper.id)
19
- element = shared_helper.get_heading_level
20
20
  %>
21
- <%= content_tag(element, component_helper.all_attributes) do %>
22
- <%= text %>
21
+ <% context_block = capture do %>
22
+ <span class="govuk-caption-xl gem-c-heading__context" <%= "lang=#{context_locale}" if context_locale.present? %>>
23
+ <%= context %>
24
+ </span>
25
+ <% end %>
26
+
27
+ <%= tag.div(**component_helper.all_attributes) do %>
28
+ <% if context && !context_inside %>
29
+ <%= context_block %>
30
+ <% end %>
31
+
32
+ <%= content_tag(shared_helper.get_heading_level, class: heading_helper.heading_classes) do %>
33
+ <% if context && context_inside %>
34
+ <%= context_block %>
35
+ <% end %>
36
+ <%= text %>
37
+ <% end %>
23
38
  <% end %>
@@ -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 %>
@@ -3,5 +3,10 @@
3
3
 
4
4
  href ||= '#main-content'
5
5
  text ||= t('components.skip_link.text')
6
+
7
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
8
+ component_helper.add_class("gem-c-skip-link govuk-skip-link govuk-!-display-none-print")
9
+ component_helper.add_data_attribute({ module: "govuk-skip-link" })
10
+
6
11
  %>
7
- <%= link_to(text, href, class: "gem-c-skip-link govuk-skip-link govuk-!-display-none-print", data: { module: "govuk-skip-link" }) %>
12
+ <%= link_to(text, href, **component_helper.all_attributes) %>
@@ -10,10 +10,11 @@
10
10
  ]
11
11
  breadcrumb_presenter = GovukPublishingComponents::Presenters::Breadcrumbs.new(breadcrumbs)
12
12
 
13
- data = {}
14
- data[:module] = "ga4-link-tracker" unless disable_ga4
13
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
14
+ component_helper.add_class("gem-c-step-nav-header")
15
15
 
16
16
  unless disable_ga4
17
+ component_helper.add_data_attribute({ module: "ga4-link-tracker" })
17
18
  ga4_data = {
18
19
  event_name: "navigation",
19
20
  type: "super breadcrumb",
@@ -21,17 +22,13 @@
21
22
  index_total: "1",
22
23
  }.to_json
23
24
  end
24
-
25
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
26
- classes = %w[gem-c-step-nav-header]
27
- classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom]
28
25
  %>
29
26
  <% if title %>
30
27
  <script type="application/ld+json">
31
28
  <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
32
29
  </script>
33
30
 
34
- <%= tag.div(class: classes, data: data) do %>
31
+ <%= tag.div(**component_helper.all_attributes) do %>
35
32
  <strong class="gem-c-step-nav-header__part-of">Part of</strong>
36
33
  <% if path %>
37
34
  <a href="<%= path %>"
@@ -4,13 +4,14 @@
4
4
  links ||= []
5
5
  pretitle ||= t("components.step_by_step_nav_related.part_of")
6
6
  always_display_as_list ||= false
7
- classes = %w(gem-c-step-nav-related)
8
- classes << "gem-c-step-nav-related--singular" if links.length == 1
9
- data = {}
10
- data[:module] = "ga4-link-tracker" unless disable_ga4
7
+
8
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
9
+ component_helper.add_class("gem-c-step-nav-related")
10
+ component_helper.add_class("gem-c-step-nav-related--singular") if links.length == 1
11
+ component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4
11
12
  %>
12
13
  <% if links.any? %>
13
- <%= tag.div(class: classes, data: data) do %>
14
+ <%= tag.div(**component_helper.all_attributes) do %>
14
15
  <h2 class="gem-c-step-nav-related__heading">
15
16
  <span class="gem-c-step-nav-related__pretitle"><%= pretitle %></span>
16
17
  <% if links.length == 1 && !always_display_as_list %>
@@ -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