govuk_publishing_components 32.1.0 → 33.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/component_guide/accessibility-test.js +0 -1
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +175 -0
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js +4 -4
  5. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +5 -13
  6. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +80 -309
  7. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +2 -2
  8. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +140 -0
  9. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +3 -0
  10. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
  11. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +12 -1
  12. data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +24 -8
  13. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +22 -1
  14. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +140 -191
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +2 -5
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -5
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +3 -5
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +10 -30
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +0 -7
  20. data/app/views/govuk_publishing_components/components/_accordion.html.erb +14 -1
  21. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +27 -26
  22. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
  23. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_share_links.html.erb +11 -13
  25. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +1 -1
  26. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +4 -1
  27. data/app/views/govuk_publishing_components/components/docs/accordion.yml +15 -3
  28. data/app/views/govuk_publishing_components/components/docs/button.yml +10 -0
  29. data/app/views/govuk_publishing_components/components/docs/share_links.yml +59 -30
  30. data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +10 -1
  31. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +34 -0
  32. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +1 -1
  34. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +3 -3
  35. data/lib/govuk_publishing_components/presenters/button_helper.rb +9 -2
  36. data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +25 -1
  37. data/lib/govuk_publishing_components/version.rb +1 -1
  38. data/node_modules/axe-core/axe.js +4559 -4673
  39. data/node_modules/axe-core/axe.min.js +2 -2
  40. data/node_modules/axe-core/package.json +2 -2
  41. data/node_modules/axe-core/sri-history.json +4 -0
  42. data/node_modules/govuk-frontend/README.md +1 -2
  43. data/node_modules/govuk-frontend/govuk/all.js +1398 -273
  44. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +70 -0
  45. data/node_modules/govuk-frontend/govuk/common/index.js +172 -0
  46. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +373 -0
  47. data/node_modules/govuk-frontend/govuk/common.js +138 -3
  48. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +753 -25
  49. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +54 -22
  50. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +36 -0
  51. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +7 -1
  52. data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +12 -12
  53. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +22 -22
  54. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +23 -5
  55. data/node_modules/govuk-frontend/govuk/components/button/button.js +365 -107
  56. data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +85 -66
  57. data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
  58. data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +9 -0
  59. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1033 -121
  60. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +112 -36
  61. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +42 -0
  62. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +27 -3
  63. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +30 -2
  64. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +96 -93
  65. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +46 -46
  66. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +50 -50
  67. data/node_modules/govuk-frontend/govuk/components/details/details.js +43 -13
  68. data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +20 -20
  69. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +20 -20
  70. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +268 -6
  71. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +44 -35
  72. data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +25 -21
  73. data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +51 -39
  74. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +26 -26
  75. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +1 -1
  76. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +46 -46
  77. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +2 -2
  78. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +93 -38
  79. data/node_modules/govuk-frontend/govuk/components/header/header.js +6 -0
  80. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +8 -2
  81. data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -2
  82. data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +12 -12
  83. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +80 -80
  84. data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +12 -12
  85. data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +34 -34
  86. data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +56 -46
  87. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +252 -2
  88. data/node_modules/govuk-frontend/govuk/components/notification-banner/template.njk +1 -1
  89. data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +10 -7
  90. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +33 -26
  91. data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +18 -18
  92. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +14 -14
  93. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +94 -91
  94. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +30 -2
  95. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +32 -32
  96. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +22 -20
  97. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +10 -4
  98. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +50 -50
  99. data/node_modules/govuk-frontend/govuk/components/table/_index.scss +1 -1
  100. data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +40 -40
  101. data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +29 -29
  102. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +28 -0
  103. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +28 -28
  104. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +34 -34
  105. data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +14 -14
  106. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +1 -1
  107. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
  108. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -6
  109. data/node_modules/govuk-frontend/govuk/i18n.js +390 -0
  110. data/node_modules/govuk-frontend/govuk/macros/i18n.njk +15 -0
  111. data/node_modules/govuk-frontend/govuk/settings/_all.scss +1 -0
  112. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +12 -0
  113. data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +26 -0
  114. data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +23 -0
  115. data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +12 -0
  116. data/node_modules/govuk-frontend/govuk/settings/_warnings.scss +53 -0
  117. data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +20 -6
  118. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +21 -0
  119. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +300 -0
  120. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +21 -0
  121. data/node_modules/govuk-frontend/govuk-esm/all.mjs +50 -27
  122. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +15 -0
  123. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +159 -0
  124. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +58 -0
  125. data/node_modules/govuk-frontend/govuk-esm/common.mjs +6 -28
  126. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +113 -43
  127. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +67 -30
  128. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +325 -123
  129. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +9 -3
  130. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +22 -8
  131. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +48 -6
  132. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +6 -0
  133. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +32 -2
  134. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +9 -3
  135. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +10 -4
  136. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +8 -2
  137. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +380 -0
  138. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +13 -0
  139. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +68 -0
  140. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +13 -0
  141. data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +7 -0
  142. data/node_modules/govuk-frontend/govuk-prototype-kit/init.scss +12 -0
  143. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +138 -7
  144. data/node_modules/govuk-frontend/package.json +1 -1
  145. metadata +22 -3
@@ -201,9 +201,7 @@ $after-button-padding-left: govuk-spacing(5);
201
201
 
202
202
  display: inline-block;
203
203
  font-size: 19px;
204
- @if $govuk-typography-use-rem {
205
- font-size: govuk-px-to-rem(19px);
206
- }
204
+ font-size: govuk-px-to-rem(19px);
207
205
  font-weight: bold;
208
206
  margin: govuk-spacing(3) 0;
209
207
 
@@ -242,14 +240,10 @@ $after-button-padding-left: govuk-spacing(5);
242
240
  }
243
241
 
244
242
  @include govuk-media-query($from: "desktop") {
243
+ // stylelint-disable max-nesting-depth
245
244
  float: left;
246
245
  font-size: 16px;
247
-
248
- // stylelint-disable max-nesting-depth
249
- @if $govuk-typography-use-rem {
250
- font-size: govuk-px-to-rem(16px);
251
- }
252
-
246
+ font-size: govuk-px-to-rem(16px);
253
247
  height: govuk-spacing(4);
254
248
  position: relative;
255
249
 
@@ -394,9 +388,7 @@ $after-button-padding-left: govuk-spacing(5);
394
388
  color: govuk-colour("white");
395
389
  float: left;
396
390
  font-size: 16px;
397
- @if $govuk-typography-use-rem {
398
- font-size: govuk-px-to-rem(16px);
399
- }
391
+ font-size: govuk-px-to-rem(16px);
400
392
  height: $black-bar-height;
401
393
  position: relative;
402
394
  text-decoration: none;
@@ -604,9 +596,7 @@ $after-button-padding-left: govuk-spacing(5);
604
596
  @include govuk-link-style-no-underline;
605
597
 
606
598
  font-size: 16px;
607
- @if $govuk-typography-use-rem {
608
- font-size: govuk-px-to-rem(16px);
609
- }
599
+ font-size: govuk-px-to-rem(16px);
610
600
  font-weight: 700;
611
601
  background: govuk-colour("black");
612
602
  border: 0;
@@ -878,9 +868,7 @@ $after-button-padding-left: govuk-spacing(5);
878
868
 
879
869
  .gem-c-layout-super-navigation-header__navigation-second-item-link {
880
870
  font-size: 16px;
881
- @if $govuk-typography-use-rem {
882
- font-size: govuk-px-to-rem(16px);
883
- }
871
+ font-size: govuk-px-to-rem(16px);
884
872
 
885
873
  &:after {
886
874
  @include make-selectable-area-bigger;
@@ -898,9 +886,7 @@ $after-button-padding-left: govuk-spacing(5);
898
886
 
899
887
  .gem-c-layout-super-navigation-header__navigation-second-item-link--with-description {
900
888
  font-size: 16px;
901
- @if $govuk-typography-use-rem {
902
- font-size: govuk-px-to-rem(16px);
903
- }
889
+ font-size: govuk-px-to-rem(16px);
904
890
  font-weight: bold;
905
891
  }
906
892
 
@@ -934,9 +920,7 @@ $after-button-padding-left: govuk-spacing(5);
934
920
  .gem-c-layout-super-navigation-header__navigation-second-footer-link {
935
921
  display: inline-block;
936
922
  font-size: 16px;
937
- @if $govuk-typography-use-rem {
938
- font-size: govuk-px-to-rem(16px);
939
- }
923
+ font-size: govuk-px-to-rem(16px);
940
924
  margin: govuk-spacing(1) 0;
941
925
 
942
926
  &:after {
@@ -956,9 +940,7 @@ $after-button-padding-left: govuk-spacing(5);
956
940
  .gem-c-layout-super-navigation-header__navigation-second-item-description {
957
941
  @include govuk-typography-common;
958
942
  font-size: 16px;
959
- @if $govuk-typography-use-rem {
960
- font-size: govuk-px-to-rem(16px);
961
- }
943
+ font-size: govuk-px-to-rem(16px);
962
944
  font-weight: normal;
963
945
  margin: govuk-spacing(1) 0 0 0;
964
946
  }
@@ -996,9 +978,7 @@ $after-button-padding-left: govuk-spacing(5);
996
978
  .gem-c-layout-super-navigation-header__popular-link {
997
979
  display: inline-block;
998
980
  font-size: 16px;
999
- @if $govuk-typography-use-rem {
1000
- font-size: govuk-px-to-rem(16px);
1001
- }
981
+ font-size: govuk-px-to-rem(16px);
1002
982
  padding: 0;
1003
983
 
1004
984
  &:after {
@@ -97,13 +97,6 @@ $large-input-size: 50px;
97
97
  }
98
98
  }
99
99
 
100
- @include govuk-compatibility(govuk_template) {
101
- // ultra specific rule overrides focus styling from govuk_template
102
- #global-header .gem-c-search__input[type="search"]:focus { // stylelint-disable selector-max-id
103
- @extend %gem-c-search-input-focus;
104
- }
105
- }
106
-
107
100
  @mixin icon-positioning($container-size) {
108
101
  $icon-dimension: 20px;
109
102
  $icon-position: ($container-size - $icon-dimension) / 2;
@@ -23,10 +23,12 @@
23
23
 
24
24
  data_attributes ||= {}
25
25
  ((data_attributes[:module] ||= "") << " " << "govuk-accordion gem-accordion").strip!
26
+ ga4_tracking ||= false
27
+ data_attributes[:module] << " ga4-event-tracker" if ga4_tracking
28
+ data_attributes[:ga4_expandable] = '' if ga4_tracking
26
29
  data_attributes[:anchor_navigation] = anchor_navigation
27
30
  data_attributes[:track_show_all_clicks] = track_show_all_clicks
28
31
  data_attributes[:track_sections] = track_sections
29
-
30
32
  data_attributes_show_all ||= nil
31
33
  data_attributes[:show_all_attributes] = data_attributes_show_all if data_attributes_show_all
32
34
 
@@ -57,6 +59,17 @@
57
59
 
58
60
  item[:data_attributes] ||= nil
59
61
 
62
+ if ga4_tracking
63
+ item[:data_attributes] ||= {}
64
+ item[:data_attributes][:ga4_event] = {
65
+ event_name: "select_content",
66
+ type: "accordion",
67
+ text: item[:heading][:text],
68
+ index: index,
69
+ index_total: items.length
70
+ }.to_json
71
+ end
72
+
60
73
  section_classes = %w(govuk-accordion__section)
61
74
  section_classes << 'govuk-accordion__section--expanded' if item[:expanded]
62
75
 
@@ -4,7 +4,6 @@
4
4
  description ||= false
5
5
  data_attributes ||= {}
6
6
  items ||= []
7
- title_id ||= "error-summary-title-#{SecureRandom.hex(4)}"
8
7
  if items.empty? && !title
9
8
  raise ArgumentError, "The error_summary component needs at least one item or a title in order to render."
10
9
  end
@@ -12,33 +11,35 @@
12
11
  <%= tag.div(
13
12
  class: "gem-c-error-summary govuk-error-summary",
14
13
  data: { module: "govuk-error-summary" }.merge(data_attributes),
15
- aria: { labelledby: title_id },
16
- role: "alert",
17
14
  id: id,
18
15
  ) do %>
19
- <% if title %>
20
- <h2 class="govuk-error-summary__title" id="<%= title_id %>">
21
- <%= title %>
22
- </h2>
23
- <% end %>
24
- <div class="govuk-error-summary__body">
25
- <% if description %>
26
- <p><%= description %></p>
16
+ <%= tag.div(
17
+ role: "alert",
18
+ ) do %>
19
+ <% if title %>
20
+ <h2 class="govuk-error-summary__title">
21
+ <%= title %>
22
+ </h2>
27
23
  <% end %>
28
- <% if items.present? %>
29
- <ul class="govuk-list govuk-error-summary__list">
30
- <% items.each_with_index do |item, index| %>
31
- <li class="gem-c-error-summary__list-item">
32
- <% if item[:href] %>
33
- <%= link_to item[:text], item[:href], target: item[:target], data: item[:data_attributes] %>
34
- <% else %>
35
- <%= tag.span data: item[:data_attributes] do %>
36
- <%= item[:text] %>
24
+ <div class="govuk-error-summary__body">
25
+ <% if description %>
26
+ <p><%= description %></p>
27
+ <% end %>
28
+ <% if items.present? %>
29
+ <ul class="govuk-list govuk-error-summary__list">
30
+ <% items.each_with_index do |item, index| %>
31
+ <li class="gem-c-error-summary__list-item">
32
+ <% if item[:href] %>
33
+ <%= link_to item[:text], item[:href], target: item[:target], data: item[:data_attributes] %>
34
+ <% else %>
35
+ <%= tag.span data: item[:data_attributes] do %>
36
+ <%= item[:text] %>
37
+ <% end %>
37
38
  <% end %>
38
- <% end %>
39
- </li>
40
- <% end %>
41
- </ul>
42
- <% end %>
43
- </div>
39
+ </li>
40
+ <% end %>
41
+ </ul>
42
+ <% end %>
43
+ </div>
44
+ <% end %>
44
45
  <% end %>
@@ -78,7 +78,7 @@
78
78
  hidden
79
79
  id="super-navigation-menu-toggle"
80
80
  type="button"
81
- data-ga4="<%= {
81
+ data-ga4-event="<%= {
82
82
  "event_name": "select_content",
83
83
  "type": "header menu bar",
84
84
  "text": "Menu",
@@ -233,7 +233,7 @@
233
233
  hidden
234
234
  id="super-search-menu-toggle"
235
235
  type="button"
236
- data-ga4="<%= {
236
+ data-ga4-event="<%= {
237
237
  "event_name": "select_content",
238
238
  "type": "header menu bar",
239
239
  "text": "Search",
@@ -8,7 +8,7 @@ unless message.present?
8
8
  if phase == "beta"
9
9
  message = raw("This part of GOV.UK is being rebuilt &ndash; <a class=\"govuk-link\" href=\"/help/beta\">find out what beta means</a>")
10
10
  elsif phase == "alpha"
11
- message = raw("This part of GOV.UK is being built &ndash; <a class=\"govuk-link\" href=\"/service-manual/phases/ideal-alphas\">find out what alpha means</a>")
11
+ message = raw("This part of GOV.UK is being built &ndash; <a class=\"govuk-link\" href=\"/service-manual/agile-delivery/how-the-alpha-phase-works\">find out what alpha means</a>")
12
12
  end
13
13
  end
14
14
 
@@ -15,7 +15,8 @@
15
15
  classes << brand_helper.brand_class
16
16
 
17
17
  data_attributes ||= {}
18
- data_attributes[:module] = 'gem-track-click'
18
+ ((data_attributes[:module] ||= "") << " " << "gem-track-click").strip!
19
+ data_attributes[:module] << " ga4-link-tracker" if track_as_sharing || track_as_follow
19
20
  %>
20
21
  <% if links.any? %>
21
22
  <%= tag.div(class: classes, data: data_attributes) do %>
@@ -54,7 +55,6 @@
54
55
  'index': index + 1,
55
56
  'index_total': links.length,
56
57
  'text': link[:icon],
57
- 'method': 'populated-via-js'
58
58
  }
59
59
  end
60
60
  if track_as_follow
@@ -62,23 +62,21 @@
62
62
  'event_name': 'navigation',
63
63
  'type': 'follow us',
64
64
  'index': index + 1,
65
- 'index_total': links.length,
66
- 'text': link[:text],
67
- 'external': 'populated-via-js',
68
- 'url': link[:href],
69
- 'method': 'populated-via-js'
65
+ 'index_total': links.length
70
66
  }
71
67
  end
72
68
  %>
69
+ <%
70
+ data_attributes = link[:data_attributes] ||= {}
71
+ data_attributes[:track_category] = 'social media'
72
+ data_attributes[:track_action] = link[:icon]
73
+ data_attributes[:track_options] = track_options
74
+ data_attributes[:ga4_link] = ga4_link_data
75
+ %>
73
76
  <%= link_to link[:href],
74
77
  target: "_blank",
75
78
  rel: "noopener noreferrer external",
76
- data: {
77
- 'track-category': 'social media',
78
- 'track-action': link[:icon],
79
- 'track-options': track_options,
80
- 'ga4-link': ga4_link_data
81
- },
79
+ data: data_attributes,
82
80
  class: "govuk-link govuk-link--no-underline gem-c-share-links__link #{brand_helper.color_class}" do %>
83
81
  <span class="gem-c-share-links__link-icon">
84
82
  <% if link[:icon] == 'facebook' %>
@@ -6,7 +6,7 @@
6
6
  wrapper_classes << shared_helper.get_margin_bottom
7
7
  %>
8
8
  <% button_text = capture do %>
9
- <svg class="gem-c-single-page-notification-button__icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 0 459.334 459.334"><path fill="currentColor" d="M177.216 404.514c-.001.12-.009.239-.009.359 0 30.078 24.383 54.461 54.461 54.461s54.461-24.383 54.461-54.461c0-.12-.008-.239-.009-.359H175.216zM403.549 336.438l-49.015-72.002v-89.83c0-60.581-43.144-111.079-100.381-122.459V24.485C254.152 10.963 243.19 0 229.667 0s-24.485 10.963-24.485 24.485v27.663c-57.237 11.381-100.381 61.879-100.381 122.459v89.83l-49.015 72.002a24.76 24.76 0 0 0 20.468 38.693H383.08a24.761 24.761 0 0 0 20.469-38.694z"/></svg><%= component_helper.button_text %>
9
+ <svg class="gem-c-single-page-notification-button__icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 0 459.334 459.334"><path fill="currentColor" d="M177.216 404.514c-.001.12-.009.239-.009.359 0 30.078 24.383 54.461 54.461 54.461s54.461-24.383 54.461-54.461c0-.12-.008-.239-.009-.359H175.216zM403.549 336.438l-49.015-72.002v-89.83c0-60.581-43.144-111.079-100.381-122.459V24.485C254.152 10.963 243.19 0 229.667 0s-24.485 10.963-24.485 24.485v27.663c-57.237 11.381-100.381 61.879-100.381 122.459v89.83l-49.015 72.002a24.76 24.76 0 0 0 20.468 38.693H383.08a24.761 24.761 0 0 0 20.469-38.694z"/></svg><span class="gem-c-single-page-notication-button__text"><%= component_helper.button_text %></span>
10
10
  <% end %>
11
11
  <%= tag.div class: wrapper_classes, data: { module: "gem-track-click"} do %>
12
12
  <%= tag.form class: component_helper.classes, action: "/email/subscriptions/single-page/new", method: "POST", data: component_helper.data do %>
@@ -15,10 +15,13 @@
15
15
  step_number = 0
16
16
 
17
17
  step_nav_helper = GovukPublishingComponents::Presenters::StepByStepNavHelper.new
18
+
19
+ ga4_tracking ||= false
18
20
  %>
19
21
  <% if steps %>
20
22
  <div
21
- data-module="gemstepnav"
23
+ data-module="gemstepnav<% if ga4_tracking %> ga4-event-tracker<% end %>"
24
+ <%= "data-ga4-expandable" if ga4_tracking %>
22
25
  class="gem-c-step-nav js-hidden <% if small %>govuk-!-display-none-print<% end %> <% unless small %>gem-c-step-nav--large<% end %>"
23
26
  <%= "data-remember" if remember_last_step %>
24
27
  <%= "data-id=#{tracking_id}" if tracking_id %>
@@ -181,21 +181,33 @@ examples:
181
181
  <a class="govuk-link" href="#">Retiring your service</a>
182
182
  </li>
183
183
  </ul>'
184
+ with_ga4_tracking:
185
+ description: |
186
+ Allows you to add GA4 tracking to an accordion. This will add a data module and data-attributes with JSONs to the accordion. See the [ga4-event-tracker documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-event-tracker.md) for more information.
187
+ data:
188
+ ga4_tracking: true
189
+ items:
190
+ - heading:
191
+ text: Writing well for the web
192
+ content:
193
+ html: <p class="govuk-body">This is the content for Writing well for the web.</p>
194
+ - heading:
195
+ text: Writing well for specialists
196
+ content:
197
+ html: <p class="govuk-body">This is the content for Writing well for specialists.</p>
184
198
  with_data_attributes:
185
199
  description: |
186
200
  Adds custom data attributes to each section of the accordion. Accepts a hash, so multiple attributes can be added.
187
201
 
188
202
  The `data_attributes` option applies attributes to the outermost element in the accordion. Each item can also have a `data_attributes` hash, which are placed on the `button` that triggers the opening and closing - useful for differentiating between each section of the accordion.
189
203
 
190
- Data attributes can 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). More details on how this can be used with the GA4 event tracking can be found in the 'Advanced' section of the [event tracking documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-event-tracker.md).
204
+ Data attributes can 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). Currently, this is only used for tracking with Universal Analytics.
191
205
 
192
206
  If `track_options` within `data_attributes_show_all` is set, then it is possible to pass a custom dimension when 'Show/Hide all' is clicked.
193
207
  data:
194
208
  data_attributes:
195
209
  custom_data_attr: custom-data-attr-accordion
196
210
  data_attributes_show_all:
197
- custom_data_attr-event-name: example
198
- custom_data_attr-attributes: "{ 'ui': { 'type': 'type value', 'section': 'section value' } }"
199
211
  tracking-options: "{ 'dimension114': 1 }"
200
212
  items:
201
213
  - heading:
@@ -129,3 +129,13 @@ examples:
129
129
  data:
130
130
  text: Button
131
131
  aria_label: Button with custom label
132
+ with_aria_controls:
133
+ description: Used to identify what element(s) the button controls, this can be useful for users with visual impairment. In the example shown, the button controls the page wrapper with ID `wrapper` but it could be another identifying attribute.
134
+ data:
135
+ text: Button
136
+ aria_controls: wrapper
137
+ with_aria_describedby:
138
+ description: Can be used to give context to a button, this will be read after aria-label by a screenreader
139
+ data:
140
+ text: Button
141
+ aria_describedby: with_aria_describedby
@@ -3,6 +3,8 @@ description: Social media links for linking to or sharing the current page on so
3
3
  body: |
4
4
  The component will not process a URL into a share link itself. Pass complete share URLs to the component.
5
5
 
6
+ Note that the component automatically appends visually hidden text to the link (default: `Share on <your text> (opens in a new tab)`). Consider this when setting the link text.
7
+
6
8
  Real world examples:
7
9
 
8
10
  - [News article](https://www.gov.uk/government/news/fast-tracking-uk-innovation-apply-for-business-funding)
@@ -44,36 +46,27 @@ examples:
44
46
  ]
45
47
  context:
46
48
  right_to_left: true
47
- track_as_sharing_links:
48
- description: Where the component is used to allow users to share content on social media, tracking can be added that uses [Social Interactions](https://developers.google.com/analytics/devguides/collection/analyticsjs/social-interactions) in UA. If this option is not included, it is assumed the component is simply linking to social media pages and the extra options are omitted from the tracking call in UA. In GA4, when this is set to true, a JSON is added to a data-attribute called data-ga4-link, which is detected by ga4-link-tracker.js and pushed to the dataLayer.
49
- data:
50
- track_as_sharing: true
51
- links: [
52
- {
53
- href: 'share',
54
- text: 'Share on Facebook',
55
- icon: 'facebook'
56
- },
57
- {
58
- href: 'share',
59
- text: 'Share on Twitter',
60
- icon: 'twitter'
61
- },
62
- ]
63
- track_as_follow_links:
64
- description: Where the component is used to allow users to follow us on social media, tracking can be added. When this is set to true, a JSON is added to a data-attribute called data-ga4-link, which is detected by ga4-link-tracker.js and pushed to the dataLayer.
49
+ with_data_attributes:
50
+ description: Data attributes can be added to both the parent element and the individual share links, as shown. Note that the component defaults to having a `data-module` of `gem-track-click`, but this is preserved even if another value for module is passed.
65
51
  data:
66
- track_as_follow: true
52
+ data_attributes:
53
+ module: 'example-passed-module'
67
54
  links: [
68
55
  {
69
- href: 'follow',
70
- text: 'Follow us on Facebook',
71
- icon: 'facebook'
56
+ href: '/facebook-share-link',
57
+ text: 'Facebook',
58
+ icon: 'facebook',
59
+ data_attributes: {
60
+ meeting: 'hello'
61
+ },
72
62
  },
73
63
  {
74
- href: 'follow',
75
- text: 'Follow us on Twitter',
76
- icon: 'twitter'
64
+ href: '/twitter-share-link',
65
+ text: 'Twitter',
66
+ icon: 'twitter',
67
+ data_attributes: {
68
+ departing: 'goodbye'
69
+ },
77
70
  },
78
71
  ]
79
72
  with_title:
@@ -83,9 +76,22 @@ examples:
83
76
  {
84
77
  href: 'share',
85
78
  text: 'Share on Facebook',
79
+ hidden_text: '',
86
80
  icon: 'facebook'
87
81
  }
88
82
  ]
83
+ with_branding:
84
+ description: Organisation [colour branding](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/component_branding.md) can be added to the component as shown.
85
+ data:
86
+ brand: 'attorney-generals-office'
87
+ links: [
88
+ {
89
+ href: 'share',
90
+ text: 'Follow the Attorney General on Twitter',
91
+ hidden_text: '',
92
+ icon: 'twitter'
93
+ }
94
+ ]
89
95
  with_custom_visually_hidden_text:
90
96
  description: |
91
97
  Use this option to specify a visually hidden text for screenreaders to prepend to the link text.
@@ -100,16 +106,39 @@ examples:
100
106
  icon: 'facebook'
101
107
  }
102
108
  ]
103
- with_branding:
104
- description: Organisation [colour branding](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/component_branding.md) can be added to the component as shown.
109
+ track_as_sharing_links:
110
+ description: Where the component is used to allow users to share content on social media, tracking can be added that uses [Social Interactions](https://developers.google.com/analytics/devguides/collection/analyticsjs/social-interactions) in UA. If this option is not included, it is assumed the component is simply linking to social media pages and the extra options are omitted from the tracking call in UA. In GA4, when this is set to true, a JSON is added to a data-attribute called data-ga4-link, which is detected by ga4-link-tracker.js and pushed to the dataLayer.
105
111
  data:
106
- brand: 'attorney-generals-office'
112
+ track_as_sharing: true
107
113
  links: [
108
114
  {
109
115
  href: 'share',
110
- text: 'Follow the Attorney General on Twitter',
116
+ text: 'Share on Facebook',
117
+ icon: 'facebook'
118
+ },
119
+ {
120
+ href: 'share',
121
+ text: 'Share on Twitter',
111
122
  icon: 'twitter'
112
- }
123
+ },
124
+ ]
125
+ track_as_follow_links:
126
+ description: Where the component is used to allow users to follow us on social media, tracking can be added. When this is set to true, a JSON is added to a data-attribute called data-ga4-link, which is detected by ga4-link-tracker.js and pushed to the dataLayer.
127
+ data:
128
+ track_as_follow: true
129
+ links: [
130
+ {
131
+ href: 'follow',
132
+ text: 'Follow us on Facebook',
133
+ hidden_text: '',
134
+ icon: 'facebook'
135
+ },
136
+ {
137
+ href: 'follow',
138
+ text: 'Follow us on Twitter',
139
+ hidden_text: '',
140
+ icon: 'twitter'
141
+ },
113
142
  ]
114
143
  stack_vertically:
115
144
  data:
@@ -33,7 +33,8 @@ examples:
33
33
  margin_bottom: 5
34
34
  with_js_enhancement:
35
35
  description: |
36
- If the `js-enhancement` flag is present, the component uses JavaScript to check if the user has already subscribed to email notifications on the current page. If yes, the state of the component updates accordingly.
36
+ If the `js-enhancement` flag is present, the component uses JavaScript to check if the user has already subscribed to email notifications on the current page and accordingly updates its tracking attribute and (optionally) button text.
37
+
37
38
  data:
38
39
  base_path: '/current-page-path'
39
40
  js_enhancement: true
@@ -48,3 +49,11 @@ examples:
48
49
  base_path: '/current-page-path'
49
50
  js_enhancement: true
50
51
  button_location: 'top'
52
+ with_custom_button_text:
53
+ description: The component accepts custom button text, provided that both subscribe and unsubscribe text is provided.
54
+ data:
55
+ base_path: '/current-page-path'
56
+ js_enhancement: true
57
+ button_text:
58
+ subscribe: 'Subscribe to this page of things'
59
+ unsubscribe: 'Unsubscribe to this page of things'
@@ -72,6 +72,40 @@ examples:
72
72
  ]
73
73
  }
74
74
  ]
75
+ with_google_analytics_4_tracking:
76
+ description: |
77
+ The ga4_tracking boolean allows you to add Google Analytics 4 (GA4) tracking to your component.
78
+ Setting this to true will add the `ga4-event-tracker` module to your component. The JavaScript will then add a `data-ga4-event` attribute and `data-ga4-expandable` attribute to the "Show all steps" button, and each clickable Step heading.
79
+ GA4 will then track these elements when they are expanded or collapsed.
80
+ `data-ga4-event` contains a JSON with event data relevant to our tracking. `data-ga4-expandable` enables the value of `aria-expanded` to be captured.
81
+ See the [ga4-event-tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-event-tracker.md) docs for more information.
82
+ data:
83
+ ga4_tracking: true
84
+ steps: [
85
+ {
86
+ title: "Do something",
87
+ contents: [
88
+ {
89
+ type: 'paragraph',
90
+ text: 'This is a paragraph of text.'
91
+ },
92
+ {
93
+ type: 'paragraph',
94
+ text: 'This is also a paragraph of text that intentionally contains lots of words in order to fill the width of the page successfully to check layout and so forth.'
95
+ }
96
+ ],
97
+ },
98
+ {
99
+ title: "Do something thing else",
100
+ logic: "and",
101
+ contents: [
102
+ {
103
+ type: 'paragraph',
104
+ text: 'Some more text.'
105
+ },
106
+ ]
107
+ },
108
+ ]
75
109
  with_unique_tracking:
76
110
  description: |
77
111
  In order to identify the step by step navigation the component is part of, we need to track a unique ID of the navigation in Google Analytics. This ID should be the same across all pages that are linked from and are part of that navigation. Its value is included in any tracking events, specifically in dimension96. It refers to the ID of the step nav page.
@@ -41,7 +41,7 @@
41
41
  <%= render "govuk_publishing_components/components/button", {
42
42
  text: t("components.feedback.send"),
43
43
  data_attributes: {
44
- ga4: {
44
+ ga4_event: {
45
45
  event_name: "form_submit",
46
46
  type: "feedback",
47
47
  text: "Send",
@@ -28,7 +28,7 @@
28
28
  <%= render "govuk_publishing_components/components/button", {
29
29
  text: t("components.feedback.send_me_survey"),
30
30
  data_attributes: {
31
- ga4: {
31
+ ga4_event: {
32
32
  event_name: "form_submit",
33
33
  type: "feedback",
34
34
  text: "Send me the survey",
@@ -21,12 +21,12 @@
21
21
  <% end %>
22
22
  </li>
23
23
  <li class="gem-c-feedback__option-list-item">
24
- <button class="govuk-button gem-c-feedback__prompt-link js-page-is-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffYesClick" data-ga4='{"event_name":"form_submit","type":"feedback","text":"Yes", "section": "Is this page useful?"}'>
24
+ <button class="govuk-button gem-c-feedback__prompt-link js-page-is-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffYesClick" data-ga4-event='{"event_name":"form_submit","type":"feedback","text":"Yes", "section": "Is this page useful?"}'>
25
25
  <%= t("components.feedback.yes") %> <span class="govuk-visually-hidden"><%= t("components.feedback.is_useful") %></span>
26
26
  </button>
27
27
  </li>
28
28
  <li class="gem-c-feedback__option-list-item">
29
- <button class="govuk-button gem-c-feedback__prompt-link js-toggle-form js-page-is-not-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffNoClick" aria-controls="page-is-not-useful" aria-expanded="false" data-ga4='{"event_name":"form_submit","type":"feedback","text":"No", "section": "Is this page useful?"}'>
29
+ <button class="govuk-button gem-c-feedback__prompt-link js-toggle-form js-page-is-not-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffNoClick" aria-controls="page-is-not-useful" aria-expanded="false" data-ga4-event='{"event_name":"form_submit","type":"feedback","text":"No", "section": "Is this page useful?"}'>
30
30
  <%= t("components.feedback.no") %> <span class="govuk-visually-hidden"><%= t("components.feedback.is_not_useful") %></span>
31
31
  </button>
32
32
  </li>
@@ -39,7 +39,7 @@
39
39
  </div>
40
40
 
41
41
  <div class="gem-c-feedback__prompt-questions gem-c-feedback__prompt-questions--something-is-wrong js-prompt-questions" hidden>
42
- <button class="govuk-button gem-c-feedback__prompt-link js-toggle-form js-something-is-wrong" data-track-category="Onsite Feedback" data-track-action="GOV-UK Open Form" aria-controls="something-is-wrong" aria-expanded="false" data-ga4='{"event_name":"form_submit","type":"feedback","text":"Report a problem with this page", "section": "Is this page useful?"}'>
42
+ <button class="govuk-button gem-c-feedback__prompt-link js-toggle-form js-something-is-wrong" data-track-category="Onsite Feedback" data-track-action="GOV-UK Open Form" aria-controls="something-is-wrong" aria-expanded="false" data-ga4-event='{"event_name":"form_submit","type":"feedback","text":"Report a problem with this page", "section": "Is this page useful?"}'>
43
43
  <%= t("components.feedback.something_wrong") %>
44
44
  </button>
45
45
  </div>