govuk_publishing_components 34.12.0 → 34.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/govuk_publishing_components_manifest.js +75 -0
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-auto-tracker.js +4 -1
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +31 -0
  5. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +1 -0
  6. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +1 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/_individual_component_support.scss +10 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +1 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +2 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_attachment.scss +2 -0
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss +1 -0
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +2 -0
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +1 -0
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +1 -0
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_cards.scss +1 -0
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_character-count.scss +1 -0
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss +1 -0
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss +1 -0
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-guidance.scss +2 -0
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +2 -0
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +1 -0
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_date-input.scss +1 -0
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_details.scss +1 -0
  24. data/app/assets/stylesheets/govuk_publishing_components/components/_devolved-nations.scss +2 -0
  25. data/app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss +2 -0
  26. data/app/assets/stylesheets/govuk_publishing_components/components/_emergency-banner.scss +2 -0
  27. data/app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss +2 -0
  28. data/app/assets/stylesheets/govuk_publishing_components/components/_error-message.scss +1 -0
  29. data/app/assets/stylesheets/govuk_publishing_components/components/_error-summary.scss +1 -0
  30. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +2 -0
  31. data/app/assets/stylesheets/govuk_publishing_components/components/_fieldset.scss +1 -0
  32. data/app/assets/stylesheets/govuk_publishing_components/components/_file-upload.scss +1 -0
  33. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak-html-publication.scss +2 -0
  34. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak.scss +2 -0
  35. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +2 -0
  36. data/app/assets/stylesheets/govuk_publishing_components/components/_hint.scss +1 -0
  37. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +2 -0
  38. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +2 -0
  39. data/app/assets/stylesheets/govuk_publishing_components/components/_inset-text.scss +1 -0
  40. data/app/assets/stylesheets/govuk_publishing_components/components/_intervention.scss +2 -0
  41. data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +2 -0
  42. data/app/assets/stylesheets/govuk_publishing_components/components/_label.scss +1 -0
  43. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-footer.scss +1 -0
  44. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +2 -0
  45. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +1 -0
  46. data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +2 -0
  47. data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +2 -0
  48. data/app/assets/stylesheets/govuk_publishing_components/components/_modal-dialogue.scss +2 -0
  49. data/app/assets/stylesheets/govuk_publishing_components/components/_notice.scss +1 -0
  50. data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +2 -0
  51. data/app/assets/stylesheets/govuk_publishing_components/components/_panel.scss +1 -0
  52. data/app/assets/stylesheets/govuk_publishing_components/components/_phase-banner.scss +1 -0
  53. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +1 -0
  54. data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +2 -0
  55. data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +1 -0
  56. data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +2 -0
  57. data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +2 -0
  58. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +2 -0
  59. data/app/assets/stylesheets/govuk_publishing_components/components/_select.scss +1 -0
  60. data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +2 -0
  61. data/app/assets/stylesheets/govuk_publishing_components/components/_show-password.scss +2 -0
  62. data/app/assets/stylesheets/govuk_publishing_components/components/_signup-link.scss +2 -0
  63. data/app/assets/stylesheets/govuk_publishing_components/components/_single-page-notification-button.scss +2 -0
  64. data/app/assets/stylesheets/govuk_publishing_components/components/_skip-link.scss +1 -0
  65. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +2 -0
  66. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +2 -0
  67. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +2 -0
  68. data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +2 -0
  69. data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +1 -0
  70. data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +1 -0
  71. data/app/assets/stylesheets/govuk_publishing_components/components/_table.scss +1 -0
  72. data/app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss +1 -0
  73. data/app/assets/stylesheets/govuk_publishing_components/components/_textarea.scss +1 -0
  74. data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +2 -0
  75. data/app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss +2 -0
  76. data/app/assets/stylesheets/govuk_publishing_components/components/_warning-text.scss +1 -0
  77. data/app/views/govuk_publishing_components/components/_accordion.html.erb +2 -0
  78. data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -0
  79. data/app/views/govuk_publishing_components/components/_attachment.html.erb +2 -0
  80. data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +2 -0
  81. data/app/views/govuk_publishing_components/components/_back_link.html.erb +2 -0
  82. data/app/views/govuk_publishing_components/components/_big_number.html.erb +3 -1
  83. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +2 -0
  84. data/app/views/govuk_publishing_components/components/_button.html.erb +2 -0
  85. data/app/views/govuk_publishing_components/components/_cards.html.erb +2 -0
  86. data/app/views/govuk_publishing_components/components/_character_count.html.erb +2 -0
  87. data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +2 -0
  88. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +2 -0
  89. data/app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb +7 -4
  90. data/app/views/govuk_publishing_components/components/_contextual_guidance.html.erb +2 -0
  91. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +5 -2
  92. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +2 -0
  93. data/app/views/govuk_publishing_components/components/_date_input.html.erb +2 -0
  94. data/app/views/govuk_publishing_components/components/_details.html.erb +2 -0
  95. data/app/views/govuk_publishing_components/components/_devolved_nations.html.erb +2 -0
  96. data/app/views/govuk_publishing_components/components/_document_list.html.erb +2 -0
  97. data/app/views/govuk_publishing_components/components/_emergency_banner.html.erb +2 -0
  98. data/app/views/govuk_publishing_components/components/_error_alert.html.erb +2 -0
  99. data/app/views/govuk_publishing_components/components/_error_message.html.erb +2 -0
  100. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +2 -0
  101. data/app/views/govuk_publishing_components/components/_feedback.html.erb +2 -0
  102. data/app/views/govuk_publishing_components/components/_fieldset.html.erb +2 -0
  103. data/app/views/govuk_publishing_components/components/_file_upload.html.erb +2 -0
  104. data/app/views/govuk_publishing_components/components/_govspeak.html.erb +1 -0
  105. data/app/views/govuk_publishing_components/components/_govspeak_html_publication.html.erb +2 -0
  106. data/app/views/govuk_publishing_components/components/_heading.html.erb +2 -0
  107. data/app/views/govuk_publishing_components/components/_hint.html.erb +2 -0
  108. data/app/views/govuk_publishing_components/components/_image_card.html.erb +5 -3
  109. data/app/views/govuk_publishing_components/components/_input.html.erb +2 -0
  110. data/app/views/govuk_publishing_components/components/_inset_text.html.erb +2 -0
  111. data/app/views/govuk_publishing_components/components/_intervention.html.erb +2 -0
  112. data/app/views/govuk_publishing_components/components/_inverse_header.html.erb +2 -0
  113. data/app/views/govuk_publishing_components/components/_label.html.erb +2 -0
  114. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +2 -0
  115. data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +5 -1
  116. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +2 -0
  117. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +2 -0
  118. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -0
  119. data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +2 -0
  120. data/app/views/govuk_publishing_components/components/_metadata.html.erb +2 -0
  121. data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +2 -0
  122. data/app/views/govuk_publishing_components/components/_notice.html.erb +2 -0
  123. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +2 -0
  124. data/app/views/govuk_publishing_components/components/_panel.html.erb +2 -0
  125. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +2 -0
  126. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +6 -1
  127. data/app/views/govuk_publishing_components/components/_print_link.html.erb +2 -0
  128. data/app/views/govuk_publishing_components/components/_radio.html.erb +2 -0
  129. data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +4 -0
  130. data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +2 -0
  131. data/app/views/govuk_publishing_components/components/_search.html.erb +2 -0
  132. data/app/views/govuk_publishing_components/components/_select.html.erb +2 -0
  133. data/app/views/govuk_publishing_components/components/_share_links.html.erb +2 -0
  134. data/app/views/govuk_publishing_components/components/_show_password.html.erb +2 -0
  135. data/app/views/govuk_publishing_components/components/_signup_link.html.erb +2 -0
  136. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +2 -0
  137. data/app/views/govuk_publishing_components/components/_skip_link.html.erb +2 -0
  138. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +2 -0
  139. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +12 -2
  140. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +21 -8
  141. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +2 -0
  142. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +2 -0
  143. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +2 -0
  144. data/app/views/govuk_publishing_components/components/_table.html.erb +3 -1
  145. data/app/views/govuk_publishing_components/components/_tabs.html.erb +2 -0
  146. data/app/views/govuk_publishing_components/components/_textarea.html.erb +2 -0
  147. data/app/views/govuk_publishing_components/components/_title.html.erb +2 -0
  148. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +2 -0
  149. data/app/views/govuk_publishing_components/components/_warning_text.html.erb +2 -0
  150. data/app/views/govuk_publishing_components/components/docs/contextual_breadcrumbs.yml +13 -0
  151. data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +11 -0
  152. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +6 -0
  153. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +10 -0
  154. data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +86 -0
  155. data/lib/govuk_publishing_components/config.rb +3 -0
  156. data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +3 -2
  157. data/lib/govuk_publishing_components/presenters/breadcrumbs.rb +3 -1
  158. data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +2 -1
  159. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +1 -1
  160. data/lib/govuk_publishing_components/railtie.rb +7 -0
  161. data/lib/govuk_publishing_components/version.rb +1 -1
  162. data/lib/govuk_publishing_components.rb +3 -0
  163. metadata +5 -2
@@ -1,12 +1,17 @@
1
1
  <%
2
+ add_gem_component_stylesheet("step-by-step-nav-related")
3
+ ga4_tracking ||= false
2
4
  links ||= []
3
5
  pretitle ||= t("components.step_by_step_nav_related.part_of")
4
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] = "gem-track-click"
11
+ data[:module] << " ga4-link-tracker" if ga4_tracking
5
12
  %>
6
13
  <% if links.any? %>
7
- <div
8
- class="gem-c-step-nav-related <%= "gem-c-step-nav-related--singular" if links.length == 1 %>"
9
- data-module="gem-track-click">
14
+ <%= tag.div(class: classes, data: data) do %>
10
15
  <h2 class="gem-c-step-nav-related__heading">
11
16
  <span class="gem-c-step-nav-related__pretitle"><%= pretitle %></span>
12
17
  <% if links.length == 1 && !always_display_as_list %>
@@ -17,14 +22,18 @@
17
22
  data-track-label="<%= links[0][:href] %>"
18
23
  data-track-dimension="<%= links[0][:text] %>"
19
24
  data-track-dimension-index="29"
20
- data-track-options='{"dimension96" : "<%= links[0][:tracking_id] %>" }'>
25
+ data-track-options='{"dimension96" : "<%= links[0][:tracking_id] %>" }'
26
+ <% if ga4_tracking %>
27
+ data-ga4-link='{"event_name":"navigation", "type":"related content", "index":{"index_link": "1"}, "index_total":"1"}'
28
+ <% end %>
29
+ >
21
30
  <%= links[0][:text] %>
22
31
  </a>
23
32
  </h2>
24
33
  <% else %>
25
34
  </h2>
26
35
  <ul class="gem-c-step-nav-related__links">
27
- <% links.each do |link| %>
36
+ <% links.each_with_index do |link, index| %>
28
37
  <li class="gem-c-step-nav-related__link-item">
29
38
  <a href="<%= link[:href] %>"
30
39
  class="govuk-link"
@@ -33,12 +42,16 @@
33
42
  data-track-label="<%= link[:href] %>"
34
43
  data-track-dimension="<%= link[:text] %>"
35
44
  data-track-dimension-index="29"
36
- data-track-options='{"dimension96" : "<%= link[:tracking_id] %>" }'>
45
+ data-track-options='{"dimension96" : "<%= link[:tracking_id] %>" }'
46
+ <% if ga4_tracking %>
47
+ data-ga4-link='{"event_name":"navigation", "type":"related content", "index":{"index_link": "<%= index + 1 %>"}, "index_total": "<%= links.length %>"}'
48
+ <% end %>
49
+ >
37
50
  <%= link[:text] %>
38
51
  </a>
39
52
  </li>
40
53
  <% end %>
41
54
  </ul>
42
55
  <% end %>
43
- </div>
44
- <% end %>
56
+ <% end %>
57
+ <% end %>
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("subscription-links")
3
+
2
4
  brand ||= false
3
5
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
4
6
 
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("success-alert")
3
+
2
4
  description ||= nil
3
5
  title_id ||= "govuk-notification-banner-title-#{SecureRandom.hex(4)}"
4
6
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("summary-list")
3
+
2
4
  local_assigns[:heading_level] ||= 3
3
5
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
4
6
  heading_size = "m" unless shared_helper.valid_heading_size?(heading_size)
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("table")
3
+
2
4
  caption ||= nil
3
5
  head ||= []
4
6
  rows ||= []
@@ -16,7 +18,7 @@
16
18
  <%= GovukPublishingComponents::AppHelpers::TableHelper.helper(self, caption, {
17
19
  sortable: sortable,
18
20
  filterable: filterable,
19
- caption_classes: caption_classes,
21
+ caption_classes: caption_classes,
20
22
  table_id: table_id
21
23
  }) do |t| %>
22
24
 
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("tabs")
3
+
2
4
  tabs ||= []
3
5
  panel_border ||= true unless panel_border == false
4
6
  panel_css_classes = %w(govuk-tabs__panel)
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("textarea")
3
+
2
4
  id ||= "textarea-#{SecureRandom.hex(4)}"
3
5
  value ||= nil
4
6
  rows ||= 5
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("title")
3
+
2
4
  average_title_length ||= false
3
5
 
4
6
  context ||= false
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("translation-nav")
3
+
2
4
  brand ||= false
3
5
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
4
6
  translation_helper = GovukPublishingComponents::Presenters::TranslationNavHelper.new(local_assigns)
@@ -1,4 +1,6 @@
1
1
  <%
2
+ add_gem_component_stylesheet("warning-text")
3
+
2
4
  id ||= "warning-text-#{SecureRandom.hex(4)}"
3
5
  text_assistive ||= 'Warning'
4
6
  text_icon ||= '!'
@@ -32,3 +32,16 @@ examples:
32
32
  inverse: true
33
33
  context:
34
34
  dark_background: true
35
+ with_ga4_tracking:
36
+ description: |
37
+ Adds GA4 tracking to the step by step nav header component when it is rendered as a breadcrumb. See the
38
+ [ga4-link-tracker documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-link-tracker.md) for more information.
39
+ Note: tracking on regular breadcrumbs is enabled by default and does not require activating.
40
+ data:
41
+ ga4_tracking: true
42
+ content_item:
43
+ title: "A content item"
44
+ links:
45
+ part_of_step_navs:
46
+ - title: "Learn to drive a car: step by step"
47
+ base_path: "/micropigs-vs-micropugs"
@@ -157,3 +157,14 @@ examples:
157
157
  - text: Arrange the funeral
158
158
  href: "/after-a-death/arrange-the-funeral"
159
159
  optional: false
160
+ with_ga4_tracking_on_part_of_step_by_step_heading(s):
161
+ description: Adds Google Analytics 4 tracking to the "Part of" step by step heading(s) in the sidebar. Currently only the Related Navigation component, Step by Step navigation component and Ukraine CTA accept this option.
162
+ data:
163
+ ga4_tracking: true
164
+ content_item:
165
+ links:
166
+ part_of_step_navs:
167
+ - title: "Choosing a micropig or micropug: step by step"
168
+ base_path: "/micropigs-vs-micropugs"
169
+ - title: "Walk your micropig: step by step"
170
+ base_path: "/porgs-step-by-step"
@@ -51,3 +51,9 @@ examples:
51
51
  tracking_action: "customTrackingAction"
52
52
  tracking_label: "customTrackingLabel"
53
53
  tracking_dimension_enabled: false
54
+ with_ga4_tracking:
55
+ description: The ga4_tracking boolean allows you to add Google Analytics 4 (GA4) tracking to your component. Setting this to true will add the `ga4-link-tracker` module to your component. The JavaScript will then add a `data-ga4-link` attribute which contains a JSON object with data relevant to our tracking. See the [ga4-link-tracker docs](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-link-tracker.md) for more information.
56
+ data:
57
+ ga4_tracking: true
58
+ title: 'Learn to drive a motorbike: step by step'
59
+ path: /learn-to-drive-a-motorbike
@@ -76,3 +76,13 @@ examples:
76
76
  text: 'Learn to drive a motorbike: step by step'
77
77
  }
78
78
  ]
79
+ with_ga4_tracking:
80
+ description: The ga4_tracking boolean allows you to add Google Analytics 4 (GA4) tracking to your component. Setting this to true will add the `ga4-link-tracker` module to your component. The JavaScript will then add a `data-ga4-link` attribute which contains a JSON object with data relevant to our tracking. See the [ga4-link-tracker docs](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-link-tracker.md) for more information.
81
+ data:
82
+ ga4_tracking: true
83
+ links: [
84
+ {
85
+ href: '#',
86
+ text: 'With ga4 tracking'
87
+ }
88
+ ]
@@ -0,0 +1,86 @@
1
+ module GovukPublishingComponents
2
+ module AppHelpers
3
+ module AssetHelper
4
+ # This is a list of all the components that have stylesheets - so a new
5
+ # component needs to be added to this list rather than being laboriously
6
+ # added and removed from every single rendering application.
7
+ COMPONENT_CSS_PATHS = Dir.glob("#{GovukPublishingComponents::Config.gem_directory}/app/assets/stylesheets/govuk_publishing_components/components/_*.scss").map { |path|
8
+ filename = path.split("/").last
9
+ component_name = filename.sub("_", "").sub(".scss", "")
10
+ "govuk_publishing_components/components/_#{component_name}.css"
11
+ }.freeze
12
+
13
+ # This list includes components already included in Static; taken from
14
+ # https://github.com/alphagov/static/blob/198a598682df40ce4a2c3c286c06244297c18cf0/app/assets/stylesheets/application.scss
15
+
16
+ # This is used to dedupe stylesheets.
17
+ STATIC_STYLESHEET_LIST = %w[
18
+ govuk_publishing_components/components/_breadcrumbs.css
19
+ govuk_publishing_components/components/_button.css
20
+ govuk_publishing_components/components/_error-message.css
21
+ govuk_publishing_components/components/_heading.css
22
+ govuk_publishing_components/components/_hint.css
23
+ govuk_publishing_components/components/_input.css
24
+ govuk_publishing_components/components/_label.css
25
+ govuk_publishing_components/components/_search.css
26
+ govuk_publishing_components/components/_skip-link.css
27
+ govuk_publishing_components/components/_textarea.css
28
+ govuk_publishing_components/components/_title.css
29
+
30
+ govuk_publishing_components/components/_cookie-banner.css
31
+ govuk_publishing_components/components/_feedback.css
32
+ govuk_publishing_components/components/_layout-footer.css
33
+ govuk_publishing_components/components/_layout-for-public.css
34
+ govuk_publishing_components/components/_layout-header.css
35
+ govuk_publishing_components/components/_layout-super-navigation-header.css
36
+ ].freeze
37
+
38
+ def add_stylesheet_path(component_path)
39
+ unless is_already_used?(component_path)
40
+ all_component_stylesheets_being_used << component_path
41
+ end
42
+ end
43
+
44
+ # Used to add a component that exists in the gem to the list
45
+ def add_gem_component_stylesheet(gem_component)
46
+ add_stylesheet_path("govuk_publishing_components/components/_#{gem_component}.css")
47
+ end
48
+
49
+ # Used to add a component that exists in the application to the list
50
+ def add_app_component_stylesheet(app_component)
51
+ add_stylesheet_path("components/_#{app_component}.css")
52
+ end
53
+
54
+ # Some applications have view-specific stylesheets - use this method
55
+ # to add them to the list
56
+ def add_view_stylesheet(view_component)
57
+ add_stylesheet_path("views/_#{view_component}.css")
58
+ end
59
+
60
+ def all_component_stylesheets_being_used
61
+ @all_component_stylesheets_being_used ||= []
62
+ end
63
+
64
+ def render_component_stylesheets
65
+ list_of_stylesheets = all_component_stylesheets_being_used.map do |component|
66
+ stylesheet_link_tag(component, integrity: false)
67
+ end
68
+ raw(list_of_stylesheets.join(""))
69
+ end
70
+
71
+ def get_component_css_paths
72
+ COMPONENT_CSS_PATHS
73
+ end
74
+
75
+ private
76
+
77
+ def is_already_used?(component)
78
+ if GovukPublishingComponents::Config.exclude_css_from_static
79
+ all_component_stylesheets_being_used.include?(component) || STATIC_STYLESHEET_LIST.include?(component)
80
+ else
81
+ all_component_stylesheets_being_used.include?(component)
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -15,6 +15,9 @@ module GovukPublishingComponents
15
15
  mattr_accessor :application_javascript
16
16
  self.application_javascript = "application"
17
17
 
18
+ mattr_accessor :exclude_css_from_static
19
+ self.exclude_css_from_static = true
20
+
18
21
  def self.component_directory_name
19
22
  APP_COMPONENT_DIRECTORY
20
23
  end
@@ -3,10 +3,11 @@ module GovukPublishingComponents
3
3
  class BreadcrumbSelector
4
4
  attr_reader :content_item, :request, :prioritise_taxon_breadcrumbs
5
5
 
6
- def initialize(content_item, request, prioritise_taxon_breadcrumbs)
6
+ def initialize(content_item, request, prioritise_taxon_breadcrumbs, ga4_tracking)
7
7
  @content_item = content_item
8
8
  @request = request
9
9
  @prioritise_taxon_breadcrumbs = prioritise_taxon_breadcrumbs
10
+ @ga4_tracking = ga4_tracking
10
11
  end
11
12
 
12
13
  def breadcrumbs
@@ -37,7 +38,7 @@ module GovukPublishingComponents
37
38
  elsif navigation.content_tagged_to_current_step_by_step?
38
39
  {
39
40
  step_by_step: true,
40
- breadcrumbs: navigation.step_nav_helper.header,
41
+ breadcrumbs: navigation.step_nav_helper.header(@ga4_tracking),
41
42
  }
42
43
  elsif navigation.content_is_tagged_to_a_live_taxon? && prioritise_taxon_breadcrumbs
43
44
  {
@@ -61,7 +61,9 @@ module GovukPublishingComponents
61
61
  ga4_link: {
62
62
  event_name: "navigation",
63
63
  type: "breadcrumbs",
64
- index: index.to_s,
64
+ index: {
65
+ index_link: index.to_s,
66
+ },
65
67
  index_total: breadcrumbs_length.to_s,
66
68
  },
67
69
  }
@@ -82,12 +82,13 @@ module GovukPublishingComponents
82
82
  end
83
83
  end
84
84
 
85
- def header
85
+ def header(ga4_tracking)
86
86
  if show_header?
87
87
  {
88
88
  title: current_step_nav.title,
89
89
  path: current_step_nav.base_path,
90
90
  tracking_id: current_step_nav.content_id,
91
+ ga4_tracking: ga4_tracking,
91
92
  }
92
93
  else
93
94
  {}
@@ -69,7 +69,7 @@ module GovukPublishingComponents
69
69
  # Force English so we can still understand what is being tracked if translated.
70
70
  underscores_to_spaces = true
71
71
  underscores_to_spaces = false if section == "related_content"
72
- I18n.with_locale("en") do
72
+ I18n.with_locale(:en) do
73
73
  construct_section_text(section, underscores_to_spaces)
74
74
  end
75
75
  end
@@ -0,0 +1,7 @@
1
+ module GovukPublishingComponents
2
+ class Railtie < Rails::Railtie
3
+ initializer "govuk_publishing_components.view_helpers" do
4
+ ActiveSupport.on_load(:action_view) { include GovukPublishingComponents::AppHelpers::AssetHelper }
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "34.12.0".freeze
2
+ VERSION = "34.14.0".freeze
3
3
  end
@@ -40,6 +40,9 @@ require "govuk_publishing_components/app_helpers/taxon_breadcrumbs"
40
40
  require "govuk_publishing_components/app_helpers/table_helper"
41
41
  require "govuk_publishing_components/app_helpers/brand_helper"
42
42
  require "govuk_publishing_components/app_helpers/environment"
43
+ require "govuk_publishing_components/app_helpers/asset_helper"
44
+
45
+ require "govuk_publishing_components/railtie" if defined?(Rails::Railtie)
43
46
 
44
47
  # Add i18n paths and views for usage outside of a Rails app
45
48
  I18n.load_path.unshift(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 34.12.0
4
+ version: 34.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-23 00:00:00.000000000 Z
11
+ date: 2023-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -525,6 +525,7 @@ files:
525
525
  - app/assets/javascripts/govuk_publishing_components/vendor/polyfills/indexOf.js
526
526
  - app/assets/stylesheets/component_guide/application.scss
527
527
  - app/assets/stylesheets/govuk_publishing_components/_all_components.scss
528
+ - app/assets/stylesheets/govuk_publishing_components/_individual_component_support.scss
528
529
  - app/assets/stylesheets/govuk_publishing_components/component_support.scss
529
530
  - app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss
530
531
  - app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss
@@ -905,6 +906,7 @@ files:
905
906
  - lib/generators/govuk_publishing_components/templates/_component.scss
906
907
  - lib/generators/govuk_publishing_components/templates/component.yml.erb
907
908
  - lib/govuk_publishing_components.rb
909
+ - lib/govuk_publishing_components/app_helpers/asset_helper.rb
908
910
  - lib/govuk_publishing_components/app_helpers/brand_helper.rb
909
911
  - lib/govuk_publishing_components/app_helpers/environment.rb
910
912
  - lib/govuk_publishing_components/app_helpers/table_helper.rb
@@ -957,6 +959,7 @@ files:
957
959
  - lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb
958
960
  - lib/govuk_publishing_components/presenters/subscription_links_helper.rb
959
961
  - lib/govuk_publishing_components/presenters/translation_nav_helper.rb
962
+ - lib/govuk_publishing_components/railtie.rb
960
963
  - lib/govuk_publishing_components/version.rb
961
964
  - node_modules/axe-core/LICENSE
962
965
  - node_modules/axe-core/README.md