govuk_publishing_components 29.9.0 → 29.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -5
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +4 -4
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-click-tracking.js +46 -24
  5. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-page-views.js +98 -0
  6. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +3 -0
  7. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +28 -1
  8. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js +2 -2
  9. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +20 -0
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +3 -8
  12. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +7 -1
  13. data/app/assets/stylesheets/govuk_publishing_components/components/print/_organisation-logo.scss +4 -0
  14. data/app/controllers/govuk_publishing_components/audit_controller.rb +3 -3
  15. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +0 -9
  16. data/app/models/govuk_publishing_components/audit_comparer.rb +91 -34
  17. data/app/views/govuk_publishing_components/audit/_applications.html.erb +20 -9
  18. data/app/views/govuk_publishing_components/component_guide/index.html.erb +1 -19
  19. data/app/views/govuk_publishing_components/components/_accordion.html.erb +7 -5
  20. data/app/views/govuk_publishing_components/components/_attachment.html.erb +1 -3
  21. data/app/views/govuk_publishing_components/components/_character_count.html.erb +1 -1
  22. data/app/views/govuk_publishing_components/components/_date_input.html.erb +0 -1
  23. data/app/views/govuk_publishing_components/components/_error_alert.html.erb +6 -3
  24. data/app/views/govuk_publishing_components/components/_input.html.erb +0 -2
  25. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +23 -5
  26. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +3 -8
  27. data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +18 -19
  28. data/app/views/govuk_publishing_components/components/docs/accordion.yml +22 -13
  29. data/app/views/govuk_publishing_components/components/docs/attachment.yml +0 -11
  30. data/app/views/govuk_publishing_components/components/docs/error_alert.yml +4 -0
  31. data/config/locales/ar.yml +1 -2
  32. data/config/locales/az.yml +1 -2
  33. data/config/locales/be.yml +1 -2
  34. data/config/locales/bg.yml +1 -2
  35. data/config/locales/bn.yml +1 -2
  36. data/config/locales/cs.yml +1 -2
  37. data/config/locales/cy.yml +1 -2
  38. data/config/locales/da.yml +1 -2
  39. data/config/locales/de.yml +1 -2
  40. data/config/locales/dr.yml +1 -2
  41. data/config/locales/el.yml +1 -2
  42. data/config/locales/en.yml +9 -2
  43. data/config/locales/es-419.yml +1 -2
  44. data/config/locales/es.yml +1 -2
  45. data/config/locales/et.yml +1 -2
  46. data/config/locales/fa.yml +1 -2
  47. data/config/locales/fi.yml +1 -2
  48. data/config/locales/fr.yml +1 -2
  49. data/config/locales/gd.yml +1 -2
  50. data/config/locales/gu.yml +1 -2
  51. data/config/locales/he.yml +1 -2
  52. data/config/locales/hi.yml +1 -2
  53. data/config/locales/hr.yml +1 -2
  54. data/config/locales/hu.yml +1 -2
  55. data/config/locales/hy.yml +1 -2
  56. data/config/locales/id.yml +1 -2
  57. data/config/locales/is.yml +1 -2
  58. data/config/locales/it.yml +1 -2
  59. data/config/locales/ja.yml +1 -2
  60. data/config/locales/ka.yml +1 -2
  61. data/config/locales/kk.yml +1 -2
  62. data/config/locales/ko.yml +1 -2
  63. data/config/locales/lt.yml +1 -2
  64. data/config/locales/lv.yml +1 -2
  65. data/config/locales/ms.yml +1 -2
  66. data/config/locales/mt.yml +1 -2
  67. data/config/locales/nl.yml +1 -2
  68. data/config/locales/no.yml +1 -2
  69. data/config/locales/pa-pk.yml +1 -2
  70. data/config/locales/pa.yml +1 -2
  71. data/config/locales/pl.yml +1 -2
  72. data/config/locales/ps.yml +1 -2
  73. data/config/locales/pt.yml +1 -2
  74. data/config/locales/ro.yml +1 -2
  75. data/config/locales/ru.yml +1 -2
  76. data/config/locales/si.yml +1 -2
  77. data/config/locales/sk.yml +1 -2
  78. data/config/locales/sl.yml +1 -2
  79. data/config/locales/so.yml +1 -2
  80. data/config/locales/sq.yml +1 -2
  81. data/config/locales/sr.yml +1 -2
  82. data/config/locales/sv.yml +1 -2
  83. data/config/locales/sw.yml +1 -2
  84. data/config/locales/ta.yml +1 -2
  85. data/config/locales/th.yml +1 -2
  86. data/config/locales/tk.yml +1 -2
  87. data/config/locales/tr.yml +1 -2
  88. data/config/locales/uk.yml +1 -2
  89. data/config/locales/ur.yml +1 -2
  90. data/config/locales/uz.yml +1 -2
  91. data/config/locales/vi.yml +1 -2
  92. data/config/locales/zh-hk.yml +1 -2
  93. data/config/locales/zh-tw.yml +1 -2
  94. data/config/locales/zh.yml +1 -2
  95. data/lib/govuk_publishing_components/presenters/attachment_helper.rb +0 -21
  96. data/lib/govuk_publishing_components/presenters/meta_tags.rb +6 -0
  97. data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +35 -16
  98. data/lib/govuk_publishing_components/version.rb +1 -1
  99. data/node_modules/govuk-frontend/govuk/all.js +120 -49
  100. data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +2 -2
  101. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +0 -2
  102. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +2 -2
  103. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +6 -16
  104. data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +2 -2
  105. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +120 -49
  106. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +33 -17
  107. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +2 -2
  108. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +1 -4
  109. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +3 -2
  110. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +22 -10
  111. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +2 -2
  112. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +23 -23
  113. data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
  114. data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +4 -4
  115. data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +2 -2
  116. data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +3 -3
  117. data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +2 -2
  118. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +12 -22
  119. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +13 -3
  120. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +2 -2
  121. data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +2 -2
  122. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +4 -13
  123. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +5 -5
  124. data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +2 -2
  125. data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +2 -2
  126. data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +1 -1
  127. data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +4 -4
  128. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +2 -2
  129. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -4
  130. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +17 -12
  131. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +2 -2
  132. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -3
  133. data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +2 -2
  134. data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +5 -5
  135. data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +4 -4
  136. data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +2 -2
  137. data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +2 -2
  138. data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +2 -2
  139. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +3 -3
  140. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +7 -5
  141. data/node_modules/govuk-frontend/govuk/helpers/_media-queries.scss +2 -2
  142. data/node_modules/govuk-frontend/govuk/helpers/_shape-arrow.scss +1 -1
  143. data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +3 -3
  144. data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +2 -2
  145. data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +10 -26
  146. data/node_modules/govuk-frontend/govuk/objects/_template.scss +1 -1
  147. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +0 -4
  148. data/node_modules/govuk-frontend/govuk/tools/_exports.scss +1 -1
  149. data/node_modules/govuk-frontend/govuk/tools/_font-url.scss +1 -1
  150. data/node_modules/govuk-frontend/govuk/tools/_image-url.scss +1 -1
  151. data/node_modules/govuk-frontend/govuk/tools/_px-to-em.scss +2 -2
  152. data/node_modules/govuk-frontend/govuk/tools/_px-to-rem.scss +1 -1
  153. data/node_modules/govuk-frontend/govuk-esm/all.mjs +88 -0
  154. data/node_modules/govuk-frontend/govuk-esm/common.mjs +28 -0
  155. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +374 -0
  156. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +64 -0
  157. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +251 -0
  158. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +164 -0
  159. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +147 -0
  160. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +168 -0
  161. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +52 -0
  162. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +55 -0
  163. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +122 -0
  164. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +94 -0
  165. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +282 -0
  166. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.js +264 -0
  167. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.js +26 -0
  168. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.js +93 -0
  169. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.js +24 -0
  170. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.js +23 -0
  171. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.js +22 -0
  172. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.js +22 -0
  173. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.js +114 -0
  174. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.js +252 -0
  175. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.js +159 -0
  176. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.js +86 -0
  177. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.js +20 -0
  178. data/node_modules/govuk-frontend/package.json +8 -1
  179. metadata +29 -3
@@ -2,26 +2,58 @@ module GovukPublishingComponents
2
2
  class AuditComparer
3
3
  attr_reader :applications_data, :gem_data
4
4
 
5
- def initialize(gem_data, results, simple)
5
+ def initialize(gem_data, results)
6
6
  if gem_data[:gem_found]
7
+ @applications_using_static = %w[
8
+ collections
9
+ email-alert-frontend
10
+ feedback
11
+ finder-frontend
12
+ frontend
13
+ government-frontend
14
+ info-frontend
15
+ licence-finder
16
+ service-manual-frontend
17
+ smart-answers
18
+ whitehall
19
+ ]
20
+
21
+ @static_data = find_static(results)
7
22
  @gem_data = gem_data
8
- @applications_data = sort_results(results, simple)
23
+ @applications_data = sort_results(results)
9
24
  @gem_data[:components_by_application] = get_components_by_application || []
10
25
  end
11
26
  end
12
27
 
13
28
  private
14
29
 
30
+ # find static to check for global includes, reduce false warnings
31
+ def find_static(results)
32
+ results.each do |result|
33
+ if result[:name] == "static" && result[:application_found] == true
34
+ return clean_static(result)
35
+ end
36
+ end
37
+
38
+ false
39
+ end
40
+
41
+ # turn static data into an object so locations can be easily referenced
42
+ # should give object of form { "templates" => [], "stylesheets" => [] }
43
+ def clean_static(data)
44
+ Hash[data[:components_found].map { |d| [d[:location], d[:components]] }]
45
+ end
46
+
15
47
  def prettify_key(key)
16
48
  key.to_s.gsub("_", " ").capitalize
17
49
  end
18
50
 
19
- def sort_results(results, simple)
20
- @simple = simple
51
+ def sort_results(results)
21
52
  data = []
22
53
 
23
54
  results.each do |result|
24
55
  if result[:application_found]
56
+ application_uses_static = @applications_using_static.include?(result[:name])
25
57
  templates = result[:components_found].find { |c| c[:location] == "templates" }
26
58
  stylesheets = result[:components_found].find { |c| c[:location] == "stylesheets" }
27
59
  print_stylesheets = result[:components_found].find { |c| c[:location] == "print_stylesheets" }
@@ -39,37 +71,36 @@ module GovukPublishingComponents
39
71
  warnings << warn_about_missing_assets(result[:components_found])
40
72
  warnings << warn_about_style_overrides(result[:gem_style_references])
41
73
  warnings << warn_about_jquery_references(result[:jquery_references])
74
+ warnings << check_for_assets_already_in_static(result[:components_found]) if @static_data && application_uses_static
42
75
  warnings = warnings.flatten
43
76
 
44
- summary = []
45
- unless @simple
46
- summary = [
47
- {
48
- name: "Components in templates",
49
- value: templates[:components].flatten.uniq.sort.join(", "),
50
- },
51
- {
52
- name: "Components in stylesheets",
53
- value: stylesheets[:components].join(", "),
54
- },
55
- {
56
- name: "Components in print stylesheets",
57
- value: print_stylesheets[:components].join(", "),
58
- },
59
- {
60
- name: "Components in javascripts",
61
- value: javascripts[:components].join(", "),
62
- },
63
- {
64
- name: "Components in ruby",
65
- value: ruby[:components].join(", "),
66
- },
67
- ]
68
- end
77
+ summary = [
78
+ {
79
+ name: "Components in templates",
80
+ value: templates[:components].flatten.uniq.sort.join(", "),
81
+ },
82
+ {
83
+ name: "Components in stylesheets",
84
+ value: stylesheets[:components].join(", "),
85
+ },
86
+ {
87
+ name: "Components in print stylesheets",
88
+ value: print_stylesheets[:components].join(", "),
89
+ },
90
+ {
91
+ name: "Components in javascripts",
92
+ value: javascripts[:components].join(", "),
93
+ },
94
+ {
95
+ name: "Components in ruby",
96
+ value: ruby[:components].join(", "),
97
+ },
98
+ ]
69
99
 
70
100
  data << {
71
101
  name: result[:name],
72
102
  application_found: result[:application_found],
103
+ uses_static: application_uses_static,
73
104
  summary: summary,
74
105
  warnings: warnings,
75
106
  warning_count: warnings.length,
@@ -102,6 +133,7 @@ module GovukPublishingComponents
102
133
  }
103
134
  end
104
135
 
136
+ # given two groups of components, check the difference
105
137
  def find_missing_items(first_group, second_group)
106
138
  warnings = []
107
139
 
@@ -111,14 +143,20 @@ module GovukPublishingComponents
111
143
  second_group.each do |second|
112
144
  second_location = second[:location]
113
145
  second_location = "code" if %w[templates ruby].include?(second_location)
146
+ # subtract one group from the other, leaving only those not in both
114
147
  in_current = find_missing(second[:components].clone, first[:components].clone)
115
148
 
116
149
  next if second[:components].include?("all")
117
150
 
151
+ # now we have a list of 'missing' component assets, check the gem to see if that asset exists
118
152
  in_current.each do |component|
119
- if @gem_data.include?("component_#{second_location}".to_sym) && @gem_data["component_#{second_location}".to_sym].include?(component)
120
- warnings << create_warning(component, "Included in #{first_location} but not #{second_location}")
121
- end
153
+ asset_in_gem = @gem_data.include?("component_#{second_location}".to_sym) && @gem_data["component_#{second_location}".to_sym].include?(component)
154
+ check_static = @static_data && second_location != "code"
155
+ asset_in_static = asset_already_in_static(second_location, component) if check_static
156
+ raise_warning = asset_in_gem && !asset_in_static
157
+
158
+ # this raises a warning if the asset exists and isn't included either in the application or static
159
+ warnings << create_warning(component, "Included in #{first_location} but not #{second_location}") if raise_warning
122
160
  end
123
161
  end
124
162
  end
@@ -126,6 +164,27 @@ module GovukPublishingComponents
126
164
  warnings
127
165
  end
128
166
 
167
+ def asset_already_in_static(location, component)
168
+ return true if @static_data[location].include?(component)
169
+
170
+ false
171
+ end
172
+
173
+ def check_for_assets_already_in_static(locations)
174
+ warnings = []
175
+
176
+ locations.each do |location|
177
+ next if location[:location] == "templates" || location[:location] == "ruby"
178
+
179
+ location[:components].each do |component|
180
+ raise_warning = asset_already_in_static(location[:location], component)
181
+ warnings << create_warning(component, "Included in #{location[:location]} but already included in static") if raise_warning
182
+ end
183
+ end
184
+
185
+ warnings
186
+ end
187
+
129
188
  def warn_about_missing_assets(components)
130
189
  warnings = []
131
190
 
@@ -186,8 +245,6 @@ module GovukPublishingComponents
186
245
  end
187
246
 
188
247
  def get_components_by_application
189
- return [] if @simple
190
-
191
248
  results = []
192
249
  found_something = false
193
250
 
@@ -22,22 +22,33 @@
22
22
  %>
23
23
  <% application_items = @applications.map do |application| %>
24
24
  <%
25
- summary = '<strong class="govuk-tag govuk-tag--red">Application not found</strong>'
25
+ if @other_applications
26
+ summary = '<strong class="govuk-tag govuk-tag--red">Application not found</strong>'
26
27
 
27
- if application[:application_found]
28
- summary = "Warnings: 0"
29
- summary = "Warnings: <strong class=\"govuk-tag govuk-tag--red\">#{application[:warning_count]}</strong>" if application[:warning_count] > 0
28
+ if application[:application_found]
29
+ summary = "Warnings: 0"
30
+ summary = "Warnings: <strong class=\"govuk-tag govuk-tag--red\">#{application[:warning_count]}</strong>" if application[:warning_count] > 0
31
+ end
30
32
  end
31
33
  %>
32
34
 
33
35
  <% accordion_content = capture do %>
34
36
  <% if application[:application_found] %>
35
37
  <% github_link = 'https://github.com/alphagov/' + application[:name] + '/blob/main/' %>
36
- <% application[:warnings].each do |warning| %>
37
- <p class="govuk-body">
38
- <strong class="govuk-tag">Warn</strong>
39
- <strong><%= warning[:component] %></strong> - <%= warning[:message] %>
40
- </p>
38
+
39
+ <% if @other_applications %>
40
+ <% if application[:uses_static] %>
41
+ <p class="govuk-body">This application uses <a href="https://github.com/alphagov/static" class="govuk-link">static</a>, which can contain assets for components used in more than one application. Warnings for missing component assets in this application that are already included in static have been suppressed.</p>
42
+ <% end %>
43
+
44
+ <% application[:warnings].each do |warning| %>
45
+ <p class="govuk-body">
46
+ <strong class="govuk-tag">Warn</strong>
47
+ <strong><%= warning[:component] %></strong> - <%= warning[:message] %>
48
+ </p>
49
+ <% end %>
50
+ <% else %>
51
+ <p class="govuk-body">More information about this application is available by viewing the component guide from a locally running instance of govuk_publishing_components.</p>
41
52
  <% end %>
42
53
 
43
54
  <%= render "govuk_publishing_components/components/heading", {
@@ -1,29 +1,11 @@
1
1
  <%= render 'govuk_publishing_components/components/title', title: GovukPublishingComponents::Config.component_guide_title, margin_top: 0 %>
2
2
 
3
- <% unless ENV["MAIN_COMPONENT_GUIDE"] %>
4
- <p class="govuk-body">
5
- <% if @index_audit_summary[:application_found] %>
6
- Warnings:
7
- <% if @index_audit_summary[:warning_count] > 0 %>
8
- <strong class="govuk-tag govuk-tag--red"><%= @index_audit_summary[:warning_count] %></strong>
9
- <% else %>
10
- <%= @index_audit_summary[:warning_count] %>
11
- <% end %>
12
- <a href="/component-guide/audit" class="govuk-link">Warning details</a>
13
- <% else %>
14
- <strong class="govuk-tag govuk-tag--red">Application not found</strong>
15
- <% end %>
16
- </p>
17
- <% end %>
18
-
19
3
  <div class="component-markdown">
20
4
  <p>Components are packages of template, style, behaviour and documentation that live in your application.</p>
21
5
  <p>See the <a href="https://github.com/alphagov/govuk_publishing_components">govuk_publishing_components gem</a> for further details, or <a href="https://docs.publishing.service.gov.uk/manual/components.html#component-guides">a list of all component guides</a>.</p>
22
6
  <ul>
23
7
  <li>Read about how to <a href="https://github.com/alphagov/govuk_publishing_components/blob/main/docs/publishing-to-rubygems.md">release a new version of the gem</a></li>
24
- <% if ENV["MAIN_COMPONENT_GUIDE"] %>
25
- <li><a href="/component-guide/audit">View component audits</a></li>
26
- <% end %>
8
+ <li><a href="/component-guide/audit">View component audits</a></li>
27
9
  </ul>
28
10
  </div>
29
11
 
@@ -27,6 +27,9 @@
27
27
  data_attributes[:track_show_all_clicks] = track_show_all_clicks
28
28
  data_attributes[:track_sections] = track_sections
29
29
 
30
+ data_attributes_show_all ||= nil
31
+ data_attributes[:show_all_attributes] = data_attributes_show_all if data_attributes_show_all
32
+
30
33
  translations.each do |key, translation|
31
34
  locales[key] = shared_helper.t_locale(translation)
32
35
  data_attributes[key] = t(translation)
@@ -47,8 +50,8 @@
47
50
  <%= tag.div(class: accordion_classes, id: id, data: data_attributes) do %>
48
51
  <% items.each_with_index do |item, i| %>
49
52
  <%
50
- # The GOVUK Frontend JavaScript for this component
51
- # uses a loop starting at 1 for accessing heading ID values,
53
+ # The GOVUK Frontend JavaScript for this component
54
+ # uses a loop starting at 1 for accessing heading ID values,
52
55
  # hence the increment below
53
56
  index = i + 1
54
57
 
@@ -65,11 +68,10 @@
65
68
  content_tag(
66
69
  shared_helper.get_heading_level,
67
70
  content_tag(
68
- 'span',
69
- item[:heading][:text],
71
+ 'span',
72
+ item[:heading][:text],
70
73
  class: "govuk-accordion__section-button",
71
74
  id: "#{id}-heading-#{index}"
72
-
73
75
  ),
74
76
  class: "govuk-accordion__section-heading",
75
77
  id: item[:heading][:id],
@@ -83,9 +83,7 @@
83
83
  <% end %>
84
84
  <% end %>
85
85
 
86
- <% if attachment.display_accessible_format_request_form_link? %>
87
- <%= link_to "Request an accessible format of this document", "/contact/govuk/request-accessible-format?content_id=#{attachment.owning_document_content_id}&attachment_id=#{attachment.attachment_id}", class: "govuk-link" %>
88
- <% elsif attachment.alternative_format_contact_email %>
86
+ <% if attachment.alternative_format_contact_email %>
89
87
  <%= tag.p t("components.attachment.request_format_text"), class: "gem-c-attachment__metadata" %>
90
88
  <%= render "govuk_publishing_components/components/details", {
91
89
  title: t("components.attachment.request_format_cta")
@@ -17,7 +17,7 @@
17
17
 
18
18
  <%= render "govuk_publishing_components/components/textarea", { id: id, character_count: true }.merge(textarea.symbolize_keys) %>
19
19
 
20
- <div id="<%= id %>-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
20
+ <div id="<%= id %>-info" class="govuk-hint govuk-character-count__message">
21
21
  <%= t("components.character_count.body", number: maxlength || maxwords, type: maxwords ? t("components.character_count.type.words") : t("components.character_count.type.characters")) %>
22
22
  </div>
23
23
  <% end %>
@@ -29,7 +29,6 @@
29
29
  aria_described_by << describedby if describedby
30
30
  aria_described_by = aria_described_by.join(" ")
31
31
  end
32
-
33
32
  %>
34
33
 
35
34
  <%= content_tag :div, class: form_group_css_classes do %>
@@ -1,7 +1,10 @@
1
- <% description ||= nil %>
2
- <% data_attributes ||= {} %>
1
+ <%
2
+ id ||= nil
3
+ description ||= nil
4
+ data_attributes ||= {}
5
+ %>
3
6
 
4
- <%= tag.div class: "gem-c-error-alert", data: { module: "initial-focus" }.merge(data_attributes), role: "alert", tabindex: "-1" do %>
7
+ <%= tag.div id: id, class: "gem-c-error-alert", data: { module: "initial-focus" }.merge(data_attributes), role: "alert", tabindex: "-1" do %>
5
8
  <% if description.present? %>
6
9
  <%= tag.h2 message, class: "gem-c-error-summary__title" %>
7
10
  <%= tag.div description, class: "gem-c-error-summary__body" %>
@@ -62,9 +62,7 @@
62
62
  if type == "number"
63
63
  type = "text"
64
64
  inputmode = "numeric"
65
- pattern = "[0-9]*"
66
65
  end
67
-
68
66
  %>
69
67
 
70
68
  <%= content_tag :div, class: form_group_css_classes do %>
@@ -6,9 +6,9 @@
6
6
  classes << "gem-c-layout-footer--border" if with_border
7
7
  %>
8
8
  <%= tag.footer class: classes, role: "contentinfo" do %>
9
- <div class="govuk-width-container" data-module="gem-track-click">
9
+ <div class="govuk-width-container">
10
10
  <% if navigation.any? %>
11
- <div class="govuk-footer__navigation">
11
+ <div class="govuk-footer__navigation" data-module="gem-track-click" data-track-links-only>
12
12
  <% navigation.each do |item| %>
13
13
  <% if item[:items] %>
14
14
  <%
@@ -60,7 +60,7 @@
60
60
  <div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
61
61
  <% if meta.any? %>
62
62
  <h2 class="govuk-visually-hidden"><%= t("components.layout_footer.support_links") %></h2>
63
- <ul class="govuk-footer__inline-list govuk-!-display-none-print">
63
+ <ul class="govuk-footer__inline-list govuk-!-display-none-print" data-module="gem-track-click" data-track-links-only>
64
64
  <% meta[:items].each do |item| %>
65
65
  <li class="govuk-footer__inline-list-item">
66
66
  <%
@@ -78,11 +78,29 @@
78
78
  d="M421.5 142.8V.1l-50.7 32.3v161.1h112.4v-50.7zm-122.3-9.6A47.12 47.12 0 0 1 221 97.8c0-26 21.1-47.1 47.1-47.1 16.7 0 31.4 8.7 39.7 21.8l42.7-27.2A97.63 97.63 0 0 0 268.1 0c-36.5 0-68.3 20.1-85.1 49.7A98 98 0 0 0 97.8 0C43.9 0 0 43.9 0 97.8s43.9 97.8 97.8 97.8c36.5 0 68.3-20.1 85.1-49.7a97.76 97.76 0 0 0 149.6 25.4l19.4 22.2h3v-87.8h-80l24.3 27.5zM97.8 145c-26 0-47.1-21.1-47.1-47.1s21.1-47.1 47.1-47.1 47.2 21 47.2 47S123.8 145 97.8 145"
79
79
  />
80
80
  </svg>
81
- <span class="govuk-footer__licence-description">
81
+ <% # this is to avoid having hardcoded data attributes in locale files %>
82
+ <span
83
+ class="govuk-footer__licence-description"
84
+ data-module="gem-track-click"
85
+ data-track-action="copyrightLink"
86
+ data-track-category="footerClicked"
87
+ data-track-label="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/"
88
+ data-track-options='{"dimension29": "Open Government Licence v3.0"}'
89
+ data-track-links-only
90
+ >
82
91
  <%= t("components.layout_footer.licence_html") %>
83
92
  </span>
84
93
  </div>
85
- <div class="govuk-footer__meta-item">
94
+ <% # this is to avoid having hardcoded data attributes in locale files %>
95
+ <div
96
+ class="govuk-footer__meta-item"
97
+ data-module="gem-track-click"
98
+ data-track-action="copyrightLink"
99
+ data-track-category="footerClicked"
100
+ data-track-label="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/"
101
+ data-track-options='{"dimension29": "© Crown copyright"}'
102
+ data-track-links-only
103
+ >
86
104
  <%= t("components.layout_footer.copyright_html") %>
87
105
  </div>
88
106
  </div>
@@ -15,12 +15,11 @@
15
15
  hide_navigation_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.hide", :label => "navigation")
16
16
  show_navigation_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.show", :label => "navigation")
17
17
  %>
18
- <header role="banner" class="gem-c-layout-super-navigation-header">
18
+ <header role="banner" class="gem-c-layout-super-navigation-header" data-module="gem-track-click" data-track-links-only>
19
19
  <div class="gem-c-layout-super-navigation-header__container govuk-width-container govuk-clearfix">
20
20
  <div class="gem-c-layout-super-navigation-header__header-logo">
21
21
  <a
22
22
  class="govuk-header__link govuk-header__link--homepage"
23
- data-module="gem-track-click"
24
23
  data-track-action="logoLink"
25
24
  data-track-category="headerClicked"
26
25
  data-track-label="<%= logo_link %>"
@@ -100,7 +99,6 @@
100
99
  <%= link_to link[:label], link[:href], {
101
100
  class: "gem-c-layout-super-navigation-header__navigation-item-link",
102
101
  data: {
103
- module: "gem-track-click",
104
102
  track_action: "#{tracking_label}Link",
105
103
  track_category: "headerClicked",
106
104
  track_label: link[:href],
@@ -141,9 +139,9 @@
141
139
  <div class="govuk-grid-row">
142
140
  <div class="govuk-grid-column-one-third-from-desktop">
143
141
  <% if link[:description].present? %>
144
- <p class="govuk-body-l gem-c-layout-super-navigation-header__menu-description">
142
+ <h3 class="govuk-body-l gem-c-layout-super-navigation-header__menu-description">
145
143
  <%= link[:description] %>
146
- </p>
144
+ </h3>
147
145
  <% end %>
148
146
  </div>
149
147
  <div class="govuk-grid-column-two-thirds-from-desktop">
@@ -159,7 +157,6 @@
159
157
  <%= link_to item[:label], item[:href], {
160
158
  class: link_classes,
161
159
  data: {
162
- module: "gem-track-click",
163
160
  track_action: "#{tracking_label}Link",
164
161
  track_category: "headerClicked",
165
162
  track_label: item[:href],
@@ -183,7 +180,6 @@
183
180
  "gem-c-layout-super-navigation-header__navigation-second-footer-link",
184
181
  ],
185
182
  data: {
186
- module: "gem-track-click",
187
183
  track_action: "#{tracking_label}Link",
188
184
  track_category: "headerClicked",
189
185
  track_label: item[:href],
@@ -312,7 +308,6 @@
312
308
  "gem-c-layout-super-navigation-header__popular-link",
313
309
  ],
314
310
  data: {
315
- module: "gem-track-click",
316
311
  track_action: "popularLink",
317
312
  track_category: "headerClicked",
318
313
  track_label: popular_link[:href],
@@ -1,27 +1,26 @@
1
1
  <% shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) %>
2
2
  <%
3
3
  title = t("components.related_navigation.ukraine.title")
4
- link_text = t("components.related_navigation.ukraine.link_text")
5
- link_path = t("components.related_navigation.ukraine.link_path")
6
4
  lang = shared_helper.t_locale("components.related_navigation.ukraine.title")
7
5
  %>
8
6
 
9
- <% data_attributes = {
10
- "module": "gem-track-click",
11
- "track-category": "relatedLinkClicked",
12
- "track-action": "1.0 Invasion of Ukraine",
13
- "track-label": link_path,
14
- "track-dimension": link_text,
15
- "track-dimension-index": "29",
16
- } %>
17
-
18
- <%= tag.div class: "gem-c-contextual-sidebar__cta" do %>
7
+ <%= tag.div class: "gem-c-contextual-sidebar__cta gem-c-contextual-sidebar__cta--ukraine", data: { module: "gem-track-click" } do %>
19
8
  <%= tag.h2 title, class: "gem-c-contextual-sidebar__heading govuk-heading-s" %>
20
- <%= tag.p class: "gem-c-contextual-sidebar__text govuk-body" do %>
21
- <%= link_to link_text,
22
- link_path,
23
- class: "govuk-link",
24
- data: data_attributes,
25
- lang: lang %>
26
- <% end %>
9
+ <%= tag.ul class: "gem-c-contextual-sidebar__list" do %>
10
+ <% t("components.related_navigation.ukraine.links").each do |link| %>
11
+ <%= tag.li class: "gem-c-contextual-sidebar__text govuk-body" do %>
12
+ <%= link_to link[:label],
13
+ link[:href],
14
+ class: "govuk-link",
15
+ data: {
16
+ "track-category": "relatedLinkClicked",
17
+ "track-action": "1.0 Invasion of Ukraine",
18
+ "track-label": link[:href],
19
+ "track-dimension": link[:label],
20
+ "track-dimension-index": "29",
21
+ },
22
+ lang: lang %>
23
+ <% end %>
24
+ <% end %>
25
+ <% end %>
27
26
  <% end %>
@@ -189,10 +189,14 @@ examples:
189
189
 
190
190
  Each item can also have a `data_attributes` hash. These `data_attributes` are placed on the `button` that triggers the opening and closing - useful for differentiating between each section of the accordion.
191
191
 
192
+ Data attributes can also be added to the 'Show/hide all' link using the `data_attributes_show_all` option, primarily where custom tracking is required. These attributes are read from the accordion markup and then added to the link by JavaScript (which is how the link is created).
192
193
  data:
193
194
  data_attributes:
194
195
  gtm: gtm-accordion
195
196
  ga: ga-accordion
197
+ data_attributes_show_all:
198
+ gtm-event-name: example
199
+ gtm-attributes: "{ 'ui': { 'type': 'type value', 'section': 'section value' } }"
196
200
  items:
197
201
  - heading:
198
202
  text: Writing well for the web
@@ -277,13 +281,13 @@ examples:
277
281
  html: <p class="govuk-body">This is the content for How people read.</p>
278
282
  with_the_anchor_link_navigation:
279
283
  description: |
280
- Some apps require custom `id`s per accordion section heading. Custom `id`s allow you to link section headings, sometimes across multiple pages.
281
-
284
+ Some apps require custom `id`s per accordion section heading. Custom `id`s allow you to link section headings, sometimes across multiple pages.
285
+
282
286
  For example on [guidance pages for Content Designers, referred to as "manuals",](https://www.gov.uk/guidance/how-to-publish-on-gov-uk/creating-and-updating-pages#associations) each manual includes multiple sets of accordions and will reference between specific sections to easily access content.
283
287
 
284
- Using the same rules, custom `id`s automatically open accordions when users click within another accordion that links to either
288
+ Using the same rules, custom `id`s automatically open accordions when users click within another accordion that links to either
285
289
 
286
- * the `id` of an accordion section heading
290
+ * the `id` of an accordion section heading
287
291
  * an `id` within the content of an accordion (this will also automatically navigate to and open accordions on page load)
288
292
 
289
293
  This feature will only be used if the `anchor_navigation` flag is passed as `true`. This mitigates performance risk from event listeners on a large number of links.
@@ -294,13 +298,13 @@ examples:
294
298
  items:
295
299
  - heading:
296
300
  text: Writing well for the web
297
- id: writing-well-for-the-web
301
+ id: writing-well-for-the-web-1
298
302
  content:
299
- html: <p class="govuk-body">This is content for accordion 1 of 2</p><p class="govuk-body">This content contains a <a href="#anchor-nav-test" class="govuk-link">link</a></p>
303
+ html: <p class="govuk-body">This is content for accordion 1 of 2</p><p class="govuk-body">This content contains a <a href="#anchor-nav-test-1" class="govuk-link">link</a></p>
300
304
  - heading:
301
305
  text: Writing well for specialists
302
306
  content:
303
- html: <p class="govuk-body" id="anchor-nav-test">This is content for accordion 2 of 2</p>
307
+ html: <p class="govuk-body" id="anchor-nav-test-1">This is content for accordion 2 of 2</p>
304
308
  - heading:
305
309
  text: Know your audience
306
310
  content:
@@ -312,33 +316,38 @@ examples:
312
316
  with_track_show_all_clicks:
313
317
  description: |
314
318
  To switch on Google Analytics for the "Show all sections" button on click, pass `track_show_all_clicks: true` the values passed on open will be
315
- `Event Action: accordionOpened` `Event Category: pageElementInteraction` `Event Label: Show all sections`
319
+ `Event Action: accordionOpened` `Event Category: pageElementInteraction` `Event Label: Show all sections`
316
320
  data:
317
321
  track_show_all_clicks: true
318
322
  items:
319
323
  - heading:
320
324
  text: Writing well for the web
321
- id: writing-well-for-the-web
325
+ id: writing-well-for-the-web-2
322
326
  content:
323
- html: <p class="govuk-body">This is content for accordion 1 of 2</p><p class="govuk-body">This content contains a <a href="#anchor-nav-test" class="govuk-link">link</a></p>
327
+ html: <p class="govuk-body">This is content for accordion 1 of 2</p>
324
328
  - heading:
325
329
  text: Writing well for specialists
326
330
  content:
327
- html: <p class="govuk-body" id="anchor-nav-test">This is content for accordion 2 of 2</p>
331
+ html: <p class="govuk-body">This is content for accordion 2 of 2</p>
328
332
  with_track_sections:
329
333
  description: |
330
334
  To switch on Google Analytics for each section, on click, pass `track_sections: true` the values passed on open will be
331
335
  `Event Action: accordionOpened` / `accordionClosed` `Event Category: pageElementInteraction` and the `Event Label` being the heading text.
332
-
336
+
337
+ If `track_options` in an item is set, then it is possible to pass a custom dimension when the section is clicked.
338
+
333
339
  (`track_show_all_clicks: true` can be added to track the "Show all sections" button as well, if required)
334
340
  data:
335
341
  track_sections: true
336
342
  items:
337
343
  - heading:
338
344
  text: Writing well for the web
339
- id: writing-well-for-the-web
345
+ id: writing-well-for-the-web-3
340
346
  content:
341
347
  html: <p class="govuk-body">This is content for accordion 1 of 2</p><p class="govuk-body">This content contains a <a href="#anchor-nav-test" class="govuk-link">link</a></p>
348
+ data_attributes:
349
+ track_options:
350
+ dimension114: 1
342
351
  - heading:
343
352
  text: Writing well for specialists
344
353
  content:
@@ -76,17 +76,6 @@ examples:
76
76
  content_type: application/pdf
77
77
  file_size: 20000
78
78
  alternative_format_contact_email: defra.helpline@defra.gsi.gov.uk
79
- with_link_to_request_accessible_format_form:
80
- data:
81
- attachment:
82
- title: "Department for Transport information asset register"
83
- url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/747661/department-for-transport-information-asset-register.csv
84
- filename: department-for-transport-information-asset-register.csv
85
- content_type: application/pdf
86
- file_size: 20000
87
- owning_document_content_id: 456_abc
88
- attachment_id: 123
89
- alternative_format_contact_email: govuk_publishing_components@example.com
90
79
  with_data_attributes:
91
80
  data:
92
81
  attachment:
@@ -27,3 +27,7 @@ examples:
27
27
  description: A further description
28
28
  data_attributes:
29
29
  tracking: GTM-123AB
30
+ with_specified_id_attribute:
31
+ data:
32
+ id: test-id
33
+ message: Message to alert the user to a unsuccessful action goes here