govuk_publishing_components 35.3.0 → 35.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f87c9fa99d845d53392c5a02a8c4330f7a9557b94290a55cc18b5f169862215
4
- data.tar.gz: ee6d97596ccbc7cfc9704f95dd3b1940e6b60254fc3fe7f6c51d5d6c16d1ead4
3
+ metadata.gz: 66ace2c61b08a0641bc1234bf1e1b34e3e2e184ad07f554bde39c60280e58dd5
4
+ data.tar.gz: fb3dbf387e8e668bf81b2b13c8c73a5152d3d4c2e570f7b2743e96f424b70680
5
5
  SHA512:
6
- metadata.gz: 635eaae4b3ce872688184197dd240be9751f6d9286680f324a876cea3d00a9bfa0b6037b5817fbf58a66d319510dcbca747ff5c7bc69e5d76a7c33cb345963cb
7
- data.tar.gz: 595feac64b2542ef4ff5cb669e7e12462cea78d250cb0d44f01312de9297379d0e2c9f4d8bff0ab75a59a3b523fd6d801df93518f4c407c600b87695c17c1ea8
6
+ metadata.gz: da81d3abeeb7d15ea0c74d1f428df7a9d7856ce078a50e63c8e66da7e244dea937f6600a457592c5ebafc1615dd623a8cc81e578e2a8eae4de97e7fa8fb7b779
7
+ data.tar.gz: c2dcc61e03d0999871fca19f559833717892cb67ab16ed198eb8266fe06fe0d58a6465d65eae4e62c3aa84865732216ffeb8e224b2cb9f84fb8a2ae5ef089491
@@ -84,7 +84,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
84
84
 
85
85
  // if GA4 is enabled, set attributes on 'show all sections' for tracking using ga4-event-tracker
86
86
  if (this.$module.isGa4Enabled) {
87
- var showAllAttributesGa4 = { event_name: 'select_content', type: 'step by step', index: 0, index_total: this.$module.totalSteps }
87
+ var showAllAttributesGa4 = { event_name: 'select_content', type: 'step by step', index: 0, index_section_count: this.$module.totalSteps }
88
88
  this.$module.showOrHideAllButton.setAttribute('data-ga4-event', JSON.stringify(showAllAttributesGa4))
89
89
  }
90
90
  }
@@ -87,3 +87,12 @@
87
87
  border-color: govuk-colour("black");
88
88
  }
89
89
  }
90
+
91
+ // new colour for DSIT for use until govuk-frontend#3523 has been released
92
+
93
+ .brand--department-for-science-innovation-and-technology {
94
+ &.brand__border-color,
95
+ .brand__border-color {
96
+ border-color: #045f71;
97
+ }
98
+ }
@@ -17,7 +17,6 @@ module GovukPublishingComponents
17
17
  licence-finder
18
18
  release
19
19
  search-admin
20
- service-manual-frontend
21
20
  signon
22
21
  smart-answers
23
22
  static
@@ -42,7 +42,9 @@
42
42
  tabindex: "-1",
43
43
  "aria-hidden": true,
44
44
  data: data_attributes do %>
45
- <% if attachment.document? %>
45
+ <% if attachment.thumbnail_url %>
46
+ <% image_tag(attachment.thumbnail_url, alt: "") %>
47
+ <% elsif attachment.document? %>
46
48
  <%= render "govuk_publishing_components/components/attachment/thumbnail_document" %>
47
49
  <% elsif attachment.spreadsheet? %>
48
50
  <%= render "govuk_publishing_components/components/attachment/thumbnail_spreadsheet" %>
@@ -5,6 +5,9 @@
5
5
  request.query_parameters[:ga4_tracking] = ga4_tracking
6
6
  navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request)
7
7
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
8
+ show_ukraine_cta = navigation.show_ukraine_cta?
9
+ ga4_tracking_counts = OpenStruct.new(index_section_count: 0)
10
+ ga4_tracking_counts.index_section_count = 1 if show_ukraine_cta
8
11
  %>
9
12
 
10
13
  <div class="gem-c-contextual-sidebar">
@@ -18,7 +21,7 @@
18
21
  <%= render 'govuk_publishing_components/components/step_by_step_nav', navigation.step_nav_helper.sidebar %>
19
22
  <% else %>
20
23
  <%# Rendering related navigation sidebar because no step by step list %>
21
- <%= render 'govuk_publishing_components/components/related_navigation', content_item: content_item, context: :sidebar, ga4_tracking: ga4_tracking %>
24
+ <%= render 'govuk_publishing_components/components/related_navigation', content_item: content_item, context: :sidebar, ga4_tracking: ga4_tracking, ga4_tracking_counts: ga4_tracking_counts %>
22
25
  <% end %>
23
26
 
24
27
  <% if navigation.content_tagged_to_other_step_by_steps? %>
@@ -31,7 +34,7 @@
31
34
  } %>
32
35
  <% end %>
33
36
 
34
- <% if navigation.show_ukraine_cta? %>
35
- <%= render 'govuk_publishing_components/components/contextual_sidebar/ukraine_cta', content_item: content_item, ga4_tracking: ga4_tracking %>
37
+ <% if show_ukraine_cta %>
38
+ <%= render 'govuk_publishing_components/components/contextual_sidebar/ukraine_cta', content_item: content_item, ga4_tracking: ga4_tracking, ga4_tracking_counts: ga4_tracking_counts %>
36
39
  <% end %>
37
40
  </div>
@@ -35,6 +35,7 @@
35
35
  <div class="<%= width_class %> govuk-!-display-none-print">
36
36
  <h2 class="govuk-footer__heading govuk-heading-m"><%= section[:title] %></h2>
37
37
  <ul class="<%= list_classes.join(' ') %>">
38
+ <% index_total = section[:items].length %>
38
39
  <% section[:items].each_with_index do |item, index| %>
39
40
  <% if item[:href] && item[:text] %>
40
41
  <li class="govuk-footer__list-item">
@@ -48,7 +49,7 @@
48
49
  attributes[:rel] = "noopener" if attributes[:target] == "_blank" && !attributes[:rel]
49
50
 
50
51
  unless attributes[:data][:ga4_link]
51
- attributes[:data][:ga4_link] = layout_footer_helper.generate_ga4_link_attribute(index, ga4_section_index, section[:title])
52
+ attributes[:data][:ga4_link] = layout_footer_helper.generate_ga4_link_attribute(index, ga4_section_index, section[:title], index_total)
52
53
  end
53
54
  %>
54
55
  <%= link_to item[:text], item[:href], attributes %>
@@ -68,6 +69,7 @@
68
69
  <% if meta.any? %>
69
70
  <h2 class="govuk-visually-hidden"><%= t("components.layout_footer.support_links") %></h2>
70
71
  <ul class="govuk-footer__inline-list govuk-!-display-none-print" data-module="gem-track-click" data-track-links-only>
72
+ <% index_total = meta[:items].length %>
71
73
  <% meta[:items].each_with_index do |item, index| %>
72
74
  <li class="govuk-footer__inline-list-item">
73
75
  <%
@@ -78,7 +80,7 @@
78
80
  attributes[:rel] = "noopener" if attributes[:target] == "_blank" && !attributes[:rel]
79
81
 
80
82
  unless attributes[:data][:ga4_link]
81
- attributes[:data][:ga4_link] = layout_footer_helper.generate_ga4_link_attribute(index, navigation.length, "Support links")
83
+ attributes[:data][:ga4_link] = layout_footer_helper.generate_ga4_link_attribute(index, navigation.length, "Support links", index_total)
82
84
  end
83
85
  %>
84
86
  <%= link_to item[:text], item[:href], attributes %>
@@ -111,7 +113,7 @@
111
113
  "index_section_count": layout_footer_helper.ga4_index_section_count.to_s,
112
114
  },
113
115
  "text": "Open Government Licence v3.0",
114
- "index_total": layout_footer_helper.ga4_index_total.to_s,
116
+ "index_total": "1",
115
117
  "type": "footer",
116
118
  }.to_json %>"
117
119
  >
@@ -136,7 +138,7 @@
136
138
  "index_section_count": layout_footer_helper.ga4_index_section_count.to_s,
137
139
  },
138
140
  "text": "© Crown copyright",
139
- "index_total": layout_footer_helper.ga4_index_total.to_s,
141
+ "index_total": "1",
140
142
  "type": "footer",
141
143
  }.to_json %>"
142
144
  >
@@ -16,12 +16,6 @@
16
16
  show_search_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.show", :label => "search")
17
17
  hide_navigation_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.hide", :label => "navigation")
18
18
  show_navigation_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.show", :label => "navigation")
19
-
20
- navigation_links_length = 1 # GOVUK Logo makes this start from 1
21
- navigation_links_columns.each do | column |
22
- navigation_links_length = navigation_links_length + column[:menu_contents].length
23
- end
24
- navigation_links_length = navigation_links_length + popular_links.length
25
19
  %>
26
20
  <header role="banner" class="gem-c-layout-super-navigation-header" data-module="gem-track-click ga4-event-tracker ga4-link-tracker" data-track-links-only data-ga4-expandable>
27
21
  <div class="gem-c-layout-super-navigation-header__container govuk-clearfix">
@@ -46,7 +40,7 @@
46
40
  "index": {
47
41
  "index_section": 0,
48
42
  },
49
- "index_total": navigation_links_length
43
+ "index_total": 1
50
44
  }.to_json %>"
51
45
  >
52
46
  <span class="govuk-header__logotype">
@@ -225,6 +219,7 @@
225
219
  <%= column[:label] %>
226
220
  </h3>
227
221
  <ul class="gem-c-layout-super-navigation-header__navigation-second-items gem-c-layout-super-navigation-header__navigation-second-items--<%= column[:label].downcase.sub(" ", "-") %>">
222
+ <% index_total = column[:menu_contents].length %>
228
223
  <% column[:menu_contents].each_with_index do | item, index | %>
229
224
  <%
230
225
  has_description = item[:description].present?
@@ -249,7 +244,7 @@
249
244
  "index_link": index + 1,
250
245
  "index_section_count": 4,
251
246
  },
252
- "index_total": navigation_links_length,
247
+ "index_total": index_total,
253
248
  "section": column[:label],
254
249
  }
255
250
  }
@@ -302,6 +297,7 @@
302
297
  <div class="govuk-grid-column-full">
303
298
  <h3 class="govuk-heading-m"><%= popular_links_heading %></h3>
304
299
  <ul class="govuk-list">
300
+ <% index_total = popular_links.length %>
305
301
  <% popular_links.each_with_index do | popular_link, index | %>
306
302
  <li class="gem-c-layout-super-navigation-header__popular-item">
307
303
  <%= link_to popular_link[:label], popular_link[:href], {
@@ -323,7 +319,7 @@
323
319
  "index_link": index + 1,
324
320
  "index_section_count": 4,
325
321
  },
326
- "index_total": navigation_links_length,
322
+ "index_total": index_total,
327
323
  "section": popular_links_heading,
328
324
  }
329
325
  }
@@ -5,12 +5,11 @@
5
5
  data = {}
6
6
  data[:module] = "gem-track-click"
7
7
  data[:module] << " ga4-link-tracker" if ga4_tracking
8
- %>
8
+ ga4_tracking_counts ||= OpenStruct.new(index_section_count: 0)
9
+ ga4_tracking_counts.index_section_count += related_nav_helper.index_section_count
9
10
 
10
- <%
11
11
  add_gem_component_stylesheet("related-navigation")
12
12
  %>
13
-
14
13
  <% if related_nav_helper.related_navigation? %>
15
14
  <% random = SecureRandom.hex(4) %>
16
15
  <%= tag.div(class: "gem-c-related-navigation", data: data) do %>
@@ -30,7 +29,6 @@
30
29
  <% end %>
31
30
 
32
31
  <% section_index = 0 %>
33
-
34
32
  <% related_nav_helper.related_navigation.each do |section_title, links| %>
35
33
  <% next unless links.any? %>
36
34
 
@@ -42,6 +40,7 @@
42
40
  section_title: section_title,
43
41
  links: links,
44
42
  section_index: section_index,
43
+ section_count: ga4_tracking_counts.index_section_count,
45
44
  random: random,
46
45
  ga4_tracking: ga4_tracking %>
47
46
  <% end %>
@@ -8,13 +8,19 @@
8
8
  <%= tag.div class: "gem-c-contextual-sidebar__cta gem-c-contextual-sidebar__cta--ukraine", data: { module: data_module } do %>
9
9
  <%= tag.h2 title, class: "gem-c-contextual-sidebar__heading govuk-heading-s" %>
10
10
  <%= tag.ul class: "gem-c-contextual-sidebar__list" do %>
11
+ <% index_total = t("components.related_navigation.ukraine.links").length %>
11
12
  <% t("components.related_navigation.ukraine.links").each_with_index do |link, index| %>
12
13
  <%= tag.li class: "gem-c-contextual-sidebar__text govuk-body" do %>
13
14
  <%
14
15
  ga4_attributes = {
15
16
  event_name: "navigation",
16
17
  type: "related content",
17
- index: "1.#{index + 1}",
18
+ index: {
19
+ index_section: "#{ga4_tracking_counts.index_section_count}",
20
+ index_link: "#{index + 1}",
21
+ index_section_count: "#{ga4_tracking_counts.index_section_count}",
22
+ },
23
+ index_total: "#{index_total}",
18
24
  section: title,
19
25
  } if ga4_tracking
20
26
  %>
@@ -168,3 +168,12 @@ examples:
168
168
  filename: department-for-transport-information-asset-register.csv
169
169
  content_type: text/csv
170
170
  file_size: 20000
171
+ with_custom_thumbnail:
172
+ data:
173
+ attachment:
174
+ title: "Department for Transport, temporary snow ploughs: guidance note"
175
+ url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
176
+ filename: temporary-snow-ploughs.pdf
177
+ content_type: application/pdf
178
+ file_size: 20000
179
+ thumbnail_url: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/791567/thumbnail_the_government_financial_reporting_review_web.pdf.png"
@@ -24,17 +24,23 @@
24
24
  <% end %>
25
25
 
26
26
  <ul class="gem-c-related-navigation__link-list">
27
- <% constructed_link_array = [] %>
28
-
29
- <% section_link_limit = related_nav_helper.calculate_section_link_limit(links) %>
30
-
27
+ <%
28
+ constructed_link_array = []
29
+ section_link_limit = related_nav_helper.calculate_section_link_limit(links)
30
+ index_total = links.length
31
+ %>
31
32
  <% links.each.with_index(1) do |link, index| %>
32
33
  <%
33
34
  link_class = "govuk-link #{related_nav_helper.section_css_class("govuk-link gem-c-related-navigation__section-link", section_title, link: link, link_is_inline: (index >= section_link_limit))}"
34
35
  ga4_attributes = {
35
36
  event_name: "navigation",
36
37
  type: "related content",
37
- index: "#{section_index}.#{index}",
38
+ index: {
39
+ index_section: "#{section_index}",
40
+ index_link: "#{index}",
41
+ index_section_count: "#{section_count}",
42
+ },
43
+ index_total: "#{index_total}",
38
44
  section: ga4_heading_text,
39
45
  } if ga4_tracking
40
46
  link_element = link_to(
@@ -12,6 +12,10 @@ module GovukPublishingComponents
12
12
  @attachment_data = attachment_data.with_indifferent_access
13
13
  end
14
14
 
15
+ def thumbnail_url
16
+ @attachment_data[:thumbnail_url]
17
+ end
18
+
15
19
  def title
16
20
  attachment_data.fetch(:title)
17
21
  end
@@ -1,35 +1,25 @@
1
1
  module GovukPublishingComponents
2
2
  module Presenters
3
3
  class LayoutFooterHelper
4
- attr_reader :ga4_index_total, :ga4_index_section_count, :ga4_ogl_link_index_section, :ga4_copyright_link_index_section
4
+ attr_reader :ga4_index_section_count, :ga4_ogl_link_index_section, :ga4_copyright_link_index_section
5
5
 
6
6
  def initialize(footer_navigation_section, footer_meta_section)
7
- @ga4_index_total = 0
8
- @ga4_index_section_count = 0
7
+ @ga4_index_section_count = footer_navigation_section.length
9
8
  @amount_of_meta_sections = 0
10
9
 
11
- footer_navigation_section.each do |section|
12
- @ga4_index_section_count += 1
13
- if section[:items]
14
- @ga4_index_total += section[:items].length
15
- end
16
- end
17
-
18
10
  if footer_meta_section.any?
19
11
  @amount_of_meta_sections = 1
20
12
  @ga4_index_section_count += 1
21
- @ga4_index_total += footer_meta_section[:items].length
22
13
  end
23
14
 
24
- # For our GOVUK footer links, we need to add 2 to the index_total and index_section_count. This is due to the "Open Government License" and "Crown Copyright" links being defined separately to the rest of our footer links.
25
- @ga4_index_total += 2
15
+ # For our GOVUK footer links, we need to add 2 to the index_section_count. This is due to the "Open Government License" and "Crown Copyright" links being defined separately to the rest of our footer links.
26
16
  @ga4_index_section_count += 2
27
17
 
28
18
  @ga4_ogl_link_index_section = footer_navigation_section.length + @amount_of_meta_sections + 1
29
- @ga4_copyright_link_index_section = footer_navigation_section.length + @amount_of_meta_sections + 2
19
+ @ga4_copyright_link_index_section = @ga4_ogl_link_index_section + 1
30
20
  end
31
21
 
32
- def generate_ga4_link_attribute(index_link, index_section, section)
22
+ def generate_ga4_link_attribute(index_link, index_section, section, index_total)
33
23
  {
34
24
  "event_name": "navigation",
35
25
  "type": "footer",
@@ -38,7 +28,7 @@ module GovukPublishingComponents
38
28
  "index_section": (index_section + 1).to_s,
39
29
  "index_section_count": @ga4_index_section_count.to_s,
40
30
  },
41
- "index-total": @ga4_index_total.to_s,
31
+ "index_total": index_total.to_s,
42
32
  "section": section,
43
33
  }
44
34
  end
@@ -16,12 +16,16 @@ module GovukPublishingComponents
16
16
  "UK Mission to the European Union" => "uk-mission-to-the-eu",
17
17
  }.freeze
18
18
 
19
+ attr_reader :related_navigation, :index_section_count
20
+
19
21
  def initialize(options = {})
20
22
  @content_item = options.fetch(:content_item) { raise ArgumentError, "missing argument: content_item" }
21
23
  @context = options.fetch(:context, nil)
24
+ @related_navigation = related_navigation_contents
25
+ @index_section_count = section_count
22
26
  end
23
27
 
24
- def related_navigation
28
+ def related_navigation_contents
25
29
  case @context.try(:to_sym)
26
30
  when :sidebar
27
31
  {
@@ -53,6 +57,10 @@ module GovukPublishingComponents
53
57
  end
54
58
  end
55
59
 
60
+ def section_count
61
+ @related_navigation.select { |_, links| links.any? }.length
62
+ end
63
+
56
64
  def construct_section_text(section, underscores_to_spaces)
57
65
  unless section == "related_items"
58
66
  defaults = [I18n.t("components.related_navigation.#{section}")]
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "35.3.0".freeze
2
+ VERSION = "35.3.2".freeze
3
3
  end
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: 35.3.0
4
+ version: 35.3.2
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-04-17 00:00:00.000000000 Z
11
+ date: 2023-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config