govuk_publishing_components 23.10.2 → 23.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/external-link-tracker.js +0 -2
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/pii.js +29 -1
  4. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +66 -14
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +46 -6
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_show-password.scss +4 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_charts.scss +17 -6
  8. data/app/controllers/govuk_publishing_components/audit_controller.rb +3 -0
  9. data/app/models/govuk_publishing_components/audit_applications.rb +12 -5
  10. data/app/models/govuk_publishing_components/audit_comparer.rb +12 -0
  11. data/app/views/govuk_publishing_components/audit/show.html.erb +15 -0
  12. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +5 -18
  13. data/app/views/govuk_publishing_components/components/_machine_readable_metadata.html.erb +1 -1
  14. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +17 -3
  15. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_related_links.html.erb +6 -0
  16. data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +2 -2
  17. data/config/locales/cy.yml +2 -5
  18. data/config/locales/en.yml +2 -5
  19. data/lib/govuk_publishing_components.rb +0 -1
  20. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +1 -1
  21. data/lib/govuk_publishing_components/version.rb +1 -1
  22. metadata +3 -5
  23. data/app/views/govuk_publishing_components/components/_transition_countdown.html.erb +0 -35
  24. data/app/views/govuk_publishing_components/components/docs/transition_countdown.yml +0 -17
  25. data/lib/govuk_publishing_components/app_helpers/countdown_helper.rb +0 -49
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 737265f42ca1a81cb1a854d9858c053b36da1dd49096d4ab271880e40a0d265a
4
- data.tar.gz: 53e08f6b824be9665c54eb1e421463d63d8a761cc0aa8b432fdea43025fe173f
3
+ metadata.gz: ee5a24f565f5900b36058d428d5944f205d001d89d4fec819ce73696cab40f92
4
+ data.tar.gz: a3c714fac1eace552f26dabf2da1f357ac0b8a0dc79a7e328f99c748206bcec9
5
5
  SHA512:
6
- metadata.gz: d668236b7496da22426217927da594ff3dc3da9a903fafe647ca9ab47cc7877d779aef7dd841dde4b1f514571155a149a8d81bc40ff0b4e506ec8d90eeb6b80b
7
- data.tar.gz: 5ea78e25ed6a8ca39346ce90b46262b96c793ebd0fcc84a83715378099f029aa2c72bc29f758ba1b414d81fc7a73a3b21e7bd35603313d621d8c7fb112b1364f
6
+ metadata.gz: 6354ef8debf4cab296f119140d6a4018a0484b6c5ef61734a3d4e1920d9e7ea6c0b60219ca14a2275ec0b9d32ae73aae61a9a116218a5eab8651526fd09b9d72
7
+ data.tar.gz: fe69a6990d168343f224155fa7430d22e7f023fab8a9af88ae95f0d08de457bb088c0411e80c85b66e8aef75b5164f2ed5f20e1a5cbc5f350f31a87a8dcf7612
@@ -10,7 +10,6 @@
10
10
  var externalLinkUploadCustomDimension = options.externalLinkUploadCustomDimension
11
11
  var currentHost = GOVUK.analyticsPlugins.externalLinkTracker.getHostname()
12
12
  var externalLinkSelector = 'a[href^="http"]:not(a[href*="' + currentHost + '"])'
13
-
14
13
  $('body').on('click', externalLinkSelector, trackClickEvent)
15
14
 
16
15
  function trackClickEvent (evt) {
@@ -33,7 +32,6 @@
33
32
 
34
33
  GOVUK.analytics.setDimension(externalLinkUploadCustomDimension, externalLinkToJoinUploadOn)
35
34
  }
36
-
37
35
  GOVUK.analytics.trackEvent('External Link Clicked', href, options)
38
36
  }
39
37
 
@@ -5,8 +5,9 @@
5
5
 
6
6
  var GOVUK = global.GOVUK || {}
7
7
  var EMAIL_PATTERN = /[^\s=/?&]+(?:@|%40)[^\s=/?&]+/g
8
- var POSTCODE_PATTERN = /[A-PR-UWYZ][A-HJ-Z]?[0-9][0-9A-HJKMNPR-Y]?(?:[\s+]|%20)*[0-9][ABD-HJLNPQ-Z]{2}/gi
8
+ var POSTCODE_PATTERN = /[A-PR-UWYZ][A-HJ-Z]?[0-9][0-9A-HJKMNPR-Y]?(?:[\s+]|%20)*[0-9](?!refund)[ABD-HJLNPQ-Z]{2,3}/gi
9
9
  var DATE_PATTERN = /\d{4}(-?)\d{2}(-?)\d{2}/g
10
+ var ESCAPE_REGEX_PATTERN = /[|\\{}()[\]^$+*?.]/g
10
11
 
11
12
  // specific URL parameters to be redacted from accounts URLs
12
13
  var RESET_PASSWORD_TOKEN_PATTERN = /reset_password_token=[a-zA-Z0-9-]+/g
@@ -21,9 +22,24 @@
21
22
  return ($('meta[name="govuk:static-analytics:strip-postcodes"]').length > 0)
22
23
  }
23
24
 
25
+ function queryStringParametersToStrip () {
26
+ var value = $('meta[name="govuk:static-analytics:strip-query-string-parameters"]').attr('content')
27
+ var parameters = []
28
+
29
+ if (value) {
30
+ var split = value.split(',')
31
+ for (var i = 0; i < split.length; i++) {
32
+ parameters.push(split[i].trim())
33
+ }
34
+ }
35
+
36
+ return parameters
37
+ }
38
+
24
39
  var pii = function () {
25
40
  this.stripDatePII = shouldStripDates()
26
41
  this.stripPostcodePII = shouldStripPostcodes()
42
+ this.queryStringParametersToStrip = queryStringParametersToStrip()
27
43
  }
28
44
 
29
45
  pii.prototype.stripPII = function (value) {
@@ -43,6 +59,7 @@
43
59
  stripped = stripped.replace(RESET_PASSWORD_TOKEN_PATTERN, 'reset_password_token=[reset_password_token]')
44
60
  stripped = stripped.replace(UNLOCK_TOKEN_PATTERN, 'unlock_token=[unlock_token]')
45
61
  stripped = stripped.replace(STATE_PATTERN, 'state=[state]')
62
+ stripped = this.stripQueryStringParameters(stripped)
46
63
 
47
64
  if (this.stripDatePII === true) {
48
65
  stripped = stripped.replace(DATE_PATTERN, '[date]')
@@ -77,6 +94,17 @@
77
94
  return array
78
95
  }
79
96
 
97
+ pii.prototype.stripQueryStringParameters = function (string) {
98
+ for (var i = 0; i < this.queryStringParametersToStrip.length; i++) {
99
+ var parameter = this.queryStringParametersToStrip[i]
100
+ var escaped = parameter.replace(ESCAPE_REGEX_PATTERN, '\\$&')
101
+ var regexp = new RegExp('((?:\\?|&)' + escaped + '=)(?:[^&#\\s]*)', 'g')
102
+ string = string.replace(regexp, '$1[' + parameter + ']')
103
+ }
104
+
105
+ return string
106
+ }
107
+
80
108
  GOVUK.Pii = pii
81
109
 
82
110
  global.GOVUK = GOVUK
@@ -11,9 +11,12 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
11
11
  this.options = {
12
12
  outOf: 65,
13
13
  applyOnInit: true,
14
- toggleText: 'Toggle between chart and table',
15
14
  autoOutdent: false,
16
15
  outdentAll: false,
16
+ chartVisibleText: 'Change to table and accessible view',
17
+ tableVisibleText: 'Change to chart view',
18
+ chartAlertText: 'Chart visible',
19
+ tableAlertText: 'Table visible',
17
20
  toggleAfter: false, // BOOL set TRUE to append the toggle link
18
21
  returnReference: false // for testing purposes
19
22
  }
@@ -27,6 +30,10 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
27
30
  // store a reference to the table in the object
28
31
  this.$table = $module
29
32
 
33
+ // a container around the graph element so that it can be targeted by screen readers, allowing us to inform screen reader users that the graph isn't accessible
34
+ this.$graphContainer = document.createElement('div')
35
+ this.$graphContainer.className = 'mc-chart-container'
36
+
30
37
  // lets make what will become the new graph
31
38
  this.$graph = document.createElement('div')
32
39
 
@@ -39,6 +46,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
39
46
  this.$graph.setAttribute('class', this.$table.className)
40
47
  this.$graph.classList.add('mc-chart')
41
48
 
49
+ // get the id of the current chart within the page so that it can be used during the generation of the toggleLink
50
+ this.chartId = this.getChartId($module)
51
+
42
52
  // set the stacked option based on
43
53
  // giving the table a class of mc-stacked
44
54
  this.options.stacked = this.$table.classList.contains('mc-stacked')
@@ -102,7 +112,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
102
112
  this.addClassesToHeader()
103
113
  this.applyWidths()
104
114
  this.insert()
105
- this.$table.classList.add('visually-hidden')
115
+ this.$table.classList.add('mc-hidden')
106
116
  this.applyOutdent()
107
117
  }
108
118
  }
@@ -164,24 +174,42 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
164
174
  }
165
175
 
166
176
  // construct a link to allow the user to toggle between chart and table
167
- MagnaCharta.prototype.construct.toggleLink = function (toggleText) {
168
- var link = document.createElement('a')
169
- link.setAttribute('href', '#')
170
- link.classList.add('mc-toggle-link')
171
- link.innerHTML = toggleText
172
- link.setAttribute('aria-hidden', 'true')
177
+ MagnaCharta.prototype.construct.toggleLink = function (chartVisibleText) {
178
+ var link = document.createElement('button')
179
+
180
+ // These spans are for managing the content within the button
181
+ // toggleText is the public facing content whilst toggleStatus is visually hidden content that we use to let screen reader users know that the toggle link has been clicked
182
+ var toggleText = document.createElement('span')
183
+ var toggleStatus = document.createElement('span')
184
+
185
+ toggleText.classList.add('mc-toggle-text')
186
+ toggleText.innerHTML = chartVisibleText
187
+
188
+ toggleStatus.classList.add('govuk-visually-hidden', 'mc-toggle-status')
189
+ toggleStatus.setAttribute('role', 'alert')
190
+
191
+ link.classList.add('mc-toggle-button')
192
+ link.appendChild(toggleText)
193
+ link.appendChild(toggleStatus)
173
194
 
174
195
  return link
175
196
  }
176
197
 
177
198
  // toggles between showing the table and showing the chart
178
- MagnaCharta.prototype.addToggleClick = function () {
199
+ MagnaCharta.prototype.addToggleClick = function (chartVisible, tableVisible, chartAlert, tableAlert) {
179
200
  var that = this
180
201
 
181
202
  this.toggleLink.addEventListener('click', function (e) {
182
203
  e.preventDefault()
183
- that.$graph.classList.toggle('visually-hidden')
184
- that.$table.classList.toggle('visually-hidden')
204
+
205
+ var toggleText = that.toggleLink.querySelector('.mc-toggle-text')
206
+ var toggleStatus = that.toggleLink.querySelector('.mc-toggle-status')
207
+
208
+ that.$graphContainer.classList.toggle('mc-hidden')
209
+ that.$table.classList.toggle('mc-hidden')
210
+
211
+ toggleText.innerHTML = toggleText.innerHTML === tableVisible ? chartVisible : tableVisible
212
+ toggleStatus.innerHTML = toggleStatus.innerHTML === tableAlert ? chartAlert : tableAlert
185
213
  })
186
214
  }
187
215
 
@@ -191,8 +219,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
191
219
  // get at options and properties
192
220
  var thead = this.construct.thead.call(this)
193
221
  var tbody = this.construct.tbody.call(this)
194
- this.toggleLink = this.construct.toggleLink(this.options.toggleText)
195
- this.addToggleClick(this.toggleLink)
222
+ this.toggleLink = this.construct.toggleLink(this.options.chartVisibleText)
223
+ this.addToggleClick(this.options.chartVisibleText, this.options.tableVisibleText, this.options.chartAlertText, this.options.tableAlertText)
196
224
 
197
225
  if (this.options.hasCaption) {
198
226
  var caption = this.construct.caption.call(this)
@@ -379,7 +407,18 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
379
407
  }
380
408
 
381
409
  MagnaCharta.prototype.insert = function () {
382
- this.$table.insertAdjacentElement('afterend', this.$graph)
410
+ var label = document.createElement('span')
411
+ var labelId = 'mc-chart-not-accessible-' + this.chartId
412
+
413
+ label.innerHTML = 'This content is not accessible - switch to table'
414
+ label.className = 'mc-hidden'
415
+ label.id = labelId
416
+
417
+ this.$graphContainer.setAttribute('aria-labelledby', labelId)
418
+ this.$graphContainer.appendChild(this.$graph)
419
+ this.$graphContainer.appendChild(label)
420
+
421
+ this.$table.insertAdjacentElement('afterend', this.$graphContainer)
383
422
  }
384
423
 
385
424
  MagnaCharta.prototype.applyOutdent = function () {
@@ -419,5 +458,18 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
419
458
  }
420
459
  }
421
460
 
461
+ MagnaCharta.prototype.getChartId = function (module) {
462
+ var allCharts = document.querySelectorAll('table.js-barchart-table')
463
+ var id = null
464
+
465
+ allCharts.forEach(function (chart, i) {
466
+ if (chart === module) {
467
+ id = i
468
+ }
469
+ })
470
+
471
+ return id
472
+ }
473
+
422
474
  Modules.MagnaCharta = MagnaCharta
423
475
  })(window.GOVUK.Modules)
@@ -1,11 +1,51 @@
1
- @import 'transition-countdown';
1
+ $transition-campaign-red: #ff003b;
2
+ $transition-campaign-dark-blue: #1e1348;
2
3
 
3
- .gem-c-contextual-sidebar__brexit-cta {
4
+ .gem-c-contextual-sidebar__brexit-related-links {
4
5
  border-top: 2px solid $govuk-brand-colour;
6
+
7
+ .gem-c-contextual-sidebar__brexit-heading {
8
+ @include govuk-font(19, $weight: bold);
9
+ padding-top: govuk-spacing(3);
10
+ margin-bottom: govuk-spacing(2);
11
+ }
12
+ }
13
+
14
+ .gem-c-contextual-sidebar__brexit-cta {
15
+ @include govuk-font(19);
16
+ margin-bottom: govuk-spacing(6);
17
+ background-color: govuk-colour('light-grey', $legacy: 'grey-4');
18
+ border-top: 4px solid $transition-campaign-red;
19
+ display: block;
20
+ padding: govuk-spacing(3);
21
+ text-decoration: none;
22
+
23
+ .gem-c-contextual-sidebar__brexit-heading {
24
+ @extend %govuk-heading-m;
25
+ color: $transition-campaign-dark-blue;
26
+ }
27
+
28
+ .gem-c-contextual-sidebar__brexit-text {
29
+ @extend %govuk-link;
30
+
31
+ margin-top: 0;
32
+ margin-bottom: 0;
33
+ text-decoration: underline;
34
+
35
+ @include govuk-media-query($from: tablet) {
36
+ margin-bottom: govuk-spacing(2);
37
+ }
38
+ }
39
+
40
+ @include govuk-compatibility(govuk_template) {
41
+ .gem-c-contextual-sidebar__brexit-title {
42
+ margin-bottom: govuk-spacing(3);
43
+ }
44
+ }
5
45
  }
6
46
 
7
- .gem-c-contextual-sidebar__brexit-heading {
8
- @include govuk-font(19, $weight: bold);
9
- padding-top: govuk-spacing(3);
10
- margin-bottom: govuk-spacing(2);
47
+ .gem-c-contextual-sidebar__brexit-cta:focus {
48
+ .gem-c-contextual-sidebar__brexit-text {
49
+ text-decoration: none;
50
+ }
11
51
  }
@@ -14,6 +14,10 @@
14
14
  &:focus {
15
15
  z-index: 1;
16
16
  }
17
+
18
+ &::-ms-reveal {
19
+ display: none;
20
+ }
17
21
  }
18
22
  }
19
23
 
@@ -270,15 +270,26 @@
270
270
  text-align: left;
271
271
  }
272
272
 
273
- .mc-toggle-link {
274
- display: block;
275
- margin-top: 30px;
273
+ .mc-toggle-button {
274
+ @extend %govuk-body-s;
275
+ border: 1px solid $govuk-border-colour;
276
+ color: $govuk-link-colour;
277
+ cursor: pointer;
278
+ margin: govuk-spacing(0);
279
+ padding: govuk-spacing(2);
280
+ background-color: govuk-colour("white");
281
+
282
+ &:focus {
283
+ @include govuk-focused-text;
284
+ background-color: $govuk-focus-colour;
285
+ border-color: transparent;
286
+ }
276
287
  }
277
288
 
278
289
  // Hides the original table
279
- .visually-hidden,
280
- .visually-hidden caption {
281
- @include govuk-visually-hidden;
290
+ .mc-hidden,
291
+ .mc-hidden caption {
292
+ display: none;
282
293
 
283
294
  // It's reapplied to captions because Firefox can't hide
284
295
  // table captions unless it's applied directly to it. Go figure.
@@ -21,12 +21,15 @@ module GovukPublishingComponents
21
21
  collections-publisher
22
22
  content-data-admin
23
23
  content-publisher
24
+ datagovuk_find
24
25
  email-alert-frontend
25
26
  feedback
26
27
  finder-frontend
27
28
  frontend
28
29
  government-frontend
29
30
  govspeak-preview
31
+ govuk-account-manager-prototype
32
+ govuk-coronavirus-vulnerable-people-form
30
33
  info-frontend
31
34
  licence-finder
32
35
  manuals-frontend
@@ -7,6 +7,7 @@ module GovukPublishingComponents
7
7
  application_found = application_exists(path)
8
8
  components_found = []
9
9
  @gem_style_references = []
10
+ @jquery_references = []
10
11
 
11
12
  if application_found
12
13
  templates = Dir["#{path}/app/views/**/*.erb"]
@@ -65,6 +66,7 @@ module GovukPublishingComponents
65
66
  application_found: application_found,
66
67
  components_found: components_found,
67
68
  gem_style_references: @gem_style_references.flatten.uniq.sort,
69
+ jquery_references: @jquery_references.flatten.uniq.sort,
68
70
  }
69
71
  end
70
72
 
@@ -76,8 +78,14 @@ module GovukPublishingComponents
76
78
  files.each do |file|
77
79
  src = File.read(file)
78
80
  components_found << find_match(find, src, type)
79
- gem_references = find_gem_references(file, src)
80
- @gem_style_references << gem_references if gem_references
81
+
82
+ if type == "javascripts"
83
+ jquery_references = find_code_references(file, src, /\$\(/)
84
+ @jquery_references << jquery_references if jquery_references
85
+ else
86
+ gem_style_references = find_code_references(file, src, /gem-c-[-_a-zA-Z]+/)
87
+ @gem_style_references << gem_style_references if gem_style_references
88
+ end
81
89
  rescue StandardError
82
90
  puts "File #{file} not found"
83
91
  end
@@ -99,11 +107,10 @@ module GovukPublishingComponents
99
107
  all_matches
100
108
  end
101
109
 
102
- def find_gem_references(file, src)
103
- find_gem_classes = /gem-c-[-_a-zA-Z]+/
110
+ def find_code_references(file, src, regex)
104
111
  clean_file_path = /(?<=#{Regexp.escape(@path)}\/)[\/a-zA-Z_-]+.[a-zA-Z.]+/
105
112
 
106
- return file[clean_file_path] if find_gem_classes.match?(src)
113
+ return file[clean_file_path] if regex.match?(src)
107
114
  end
108
115
 
109
116
  def clean_file_name(name)
@@ -37,6 +37,7 @@ module GovukPublishingComponents
37
37
  warnings << warn_about_missing_components(result[:components_found])
38
38
  warnings << warn_about_missing_assets(result[:components_found])
39
39
  warnings << warn_about_style_overrides(result[:gem_style_references])
40
+ warnings << warn_about_jquery_references(result[:jquery_references])
40
41
  warnings = warnings.flatten
41
42
 
42
43
  data << {
@@ -67,6 +68,7 @@ module GovukPublishingComponents
67
68
  warnings: warnings,
68
69
  warning_count: warnings.length,
69
70
  gem_style_references: result[:gem_style_references],
71
+ jquery_references: result[:jquery_references],
70
72
  }
71
73
  else
72
74
  data << {
@@ -163,6 +165,16 @@ module GovukPublishingComponents
163
165
  warnings
164
166
  end
165
167
 
168
+ def warn_about_jquery_references(results)
169
+ warnings = []
170
+
171
+ results.each do |result|
172
+ warnings << create_warning("Possible jQuery", result)
173
+ end
174
+
175
+ warnings
176
+ end
177
+
166
178
  def find_missing(needle, haystack)
167
179
  (haystack - needle).flatten.sort
168
180
  end
@@ -109,6 +109,21 @@
109
109
  <% end %>
110
110
  </ul>
111
111
  <% end %>
112
+
113
+ <% if application[:jquery_references].any? %>
114
+ <%= render "govuk_publishing_components/components/heading", {
115
+ text: "jQuery references",
116
+ font_size: "m",
117
+ margin_bottom: 4,
118
+ heading_level: 3,
119
+ } %>
120
+ <p class="govuk-body">This shows JavaScript files that might contain jQuery, which we are trying to remove our dependency on.</p>
121
+ <ul class="govuk-list govuk-list--bullet">
122
+ <% application[:jquery_references].each do |ref| %>
123
+ <li><%= ref %></li>
124
+ <% end %>
125
+ </ul>
126
+ <% end %>
112
127
  <% else %>
113
128
  <p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
114
129
  <% end %>
@@ -2,23 +2,10 @@
2
2
  <% shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) %>
3
3
 
4
4
  <div class="gem-c-contextual-sidebar">
5
- <% if navigation.show_brexit_cta? && navigation.step_by_step_count.zero? %>
6
- <%= render 'govuk_publishing_components/components/contextual_sidebar/brexit_cta' %>
5
+ <% if navigation.show_brexit_related_links? && navigation.step_by_step_count.zero? %>
6
+ <%= render 'govuk_publishing_components/components/contextual_sidebar/brexit_related_links' %>
7
7
  <% elsif navigation.step_by_step_count.zero? && !navigation.transition_countdown_exception? %>
8
- <%= render 'govuk_publishing_components/components/transition_countdown', {
9
- title: t("components.related_navigation.transition.title"),
10
- url: t("components.related_navigation.transition.link_path"),
11
- text: t("components.related_navigation.transition.link_text"),
12
- data_attributes: {
13
- "module": "track-click",
14
- "track-category": "relatedLinkClicked",
15
- "track-action": "1.0 Transition",
16
- "track-label": t("components.related_navigation.transition.link_path"),
17
- "track-dimension": t("components.related_navigation.transition.link_text"),
18
- "track-dimension-index": "29",
19
- },
20
- lang: shared_helper.t_locale("components.related_navigation.transition.title"),
21
- } %>
8
+ <%= render 'govuk_publishing_components/components/contextual_sidebar/brexit_cta' %>
22
9
  <% end %>
23
10
 
24
11
  <% if navigation.content_tagged_to_a_reasonable_number_of_step_by_steps? %>
@@ -43,7 +30,7 @@
43
30
  } %>
44
31
  <% end %>
45
32
 
46
- <% if navigation.show_brexit_cta? && navigation.step_by_step_count > 0 %>
47
- <%= render 'govuk_publishing_components/components/contextual_sidebar/brexit_cta' %>
33
+ <% if navigation.show_brexit_related_links? && navigation.step_by_step_count > 0 %>
34
+ <%= render 'govuk_publishing_components/components/contextual_sidebar/brexit_related_links' %>
48
35
  <% end %>
49
36
  </div>
@@ -9,7 +9,7 @@
9
9
  <% structured_data = GovukPublishingComponents::Presenters::SchemaOrg.new(page).structured_data %>
10
10
 
11
11
  <script type="application/ld+json">
12
- <%= raw JSON.pretty_generate(structured_data) %>
12
+ <%= raw(json_escape(JSON.pretty_generate(structured_data))) %>
13
13
  </script>
14
14
 
15
15
  <link rel="canonical" href="<%= page.canonical_url %>" />
@@ -1,6 +1,20 @@
1
+ <% shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) %>
1
2
  <% link_text = t("components.related_navigation.transition.link_text") %>
2
3
  <% link_path = t("components.related_navigation.transition.link_path") %>
3
- <div class="gem-c-contextual-sidebar__brexit-cta govuk-!-margin-bottom-6" data-module="track-click" lang="en">
4
+
5
+ <% data_attributes = {
6
+ "module": "track-click",
7
+ "track-category": "relatedLinkClicked",
8
+ "track-action": "1.0 Transition",
9
+ "track-label": link_path,
10
+ "track-dimension": link_text,
11
+ "track-dimension-index": "29",
12
+ } %>
13
+
14
+ <%= link_to link_path,
15
+ class: "govuk-link gem-c-contextual-sidebar__brexit-cta",
16
+ data: data_attributes,
17
+ lang: shared_helper.t_locale("components.related_navigation.transition.title") do %>
4
18
  <h2 class="gem-c-contextual-sidebar__brexit-heading"><%= t("components.related_navigation.transition.title") %></h2>
5
- <a href="<%= link_path %>" class="govuk-link" data-track-category="relatedLinkClicked" data-track-action="1.0 Transition" data-track-label="<%= link_path %>" data-track-options='{"dimension29":"<%= link_text %>"}'><%= link_text %></a>
6
- </div>
19
+ <p class="gem-c-contextual-sidebar__brexit-text"><%= link_text %></p>
20
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% link_text = t("components.related_navigation.transition.link_text") %>
2
+ <% link_path = t("components.related_navigation.transition.link_path") %>
3
+ <div class="gem-c-contextual-sidebar__brexit-related-links govuk-!-margin-bottom-6" data-module="track-click" lang="en">
4
+ <h2 class="gem-c-contextual-sidebar__brexit-heading"><%= t("components.related_navigation.transition.title") %></h2>
5
+ <a href="<%= link_path %>" class="govuk-link" data-track-category="relatedLinkClicked" data-track-action="1.0 Transition" data-track-label="<%= link_path %>" data-track-options='{"dimension29":"<%= link_text %>"}'><%= link_text %></a>
6
+ </div>
@@ -81,7 +81,7 @@ examples:
81
81
  - text: The Highway Code
82
82
  href: "/guidance/the-highway-code"
83
83
  optional: false
84
- with_brexit_cta_and_related_links:
84
+ with_brexit_and_other_related_links:
85
85
  data:
86
86
  content_item:
87
87
  title: "A content item"
@@ -108,7 +108,7 @@ examples:
108
108
  - title: The future of jobs and skills
109
109
  base_path: /government/collections/the-future-of-jobs-and-skills
110
110
  document_type: document_collection
111
- with_brexit_cta_and_step_by_steps:
111
+ with_brexit_related_links_and_step_by_steps:
112
112
  data:
113
113
  content_item:
114
114
  title: "A content item"
@@ -10,9 +10,6 @@ cy:
10
10
  contents: Cynnwys
11
11
  related_navigation:
12
12
  transition:
13
- title: "Pontio Brexit"
13
+ title: "Brexit"
14
14
  link_path: "/transition.cy"
15
- link_text: "Gwiriwch eich bod chi'n barod ar gyfer 2021"
16
- transition_countdown:
17
- day_to_go: "diwrnod i fynd"
18
- days_to_go: "diwrnod i fynd"
15
+ link_text: "Darganfyddwch sut mae’r rheolau Brexit newydd yn effeithio arnoch chi"
@@ -77,9 +77,9 @@ en:
77
77
  topical_events: "Topical event"
78
78
  world_locations: "World locations"
79
79
  transition:
80
- title: "Brexit transition"
80
+ title: "Brexit"
81
81
  link_path: "/transition"
82
- link_text: "Check you’re ready for 2021"
82
+ link_text: "Check how the new Brexit rules affect you"
83
83
  related_footer_navigation:
84
84
  collections: "Collections"
85
85
  policies: "Policies"
@@ -103,6 +103,3 @@ en:
103
103
  summary_list:
104
104
  edit: "Change"
105
105
  delete: "Delete"
106
- transition_countdown:
107
- day_to_go: "day to go"
108
- days_to_go: "days to go"
@@ -34,7 +34,6 @@ require "govuk_publishing_components/presenters/taxonomy_list_helper"
34
34
  require "govuk_publishing_components/app_helpers/taxon_breadcrumbs"
35
35
  require "govuk_publishing_components/app_helpers/table_helper"
36
36
  require "govuk_publishing_components/app_helpers/brand_helper"
37
- require "govuk_publishing_components/app_helpers/countdown_helper"
38
37
  require "govuk_publishing_components/app_helpers/environment"
39
38
 
40
39
  # Add i18n paths and views for usage outside of a Rails app
@@ -104,7 +104,7 @@ module GovukPublishingComponents
104
104
  false
105
105
  end
106
106
 
107
- def show_brexit_cta?
107
+ def show_brexit_related_links?
108
108
  # If tagged directly to /brexit or /world/brexit
109
109
  # Or if tagged to a taxon which has /brexit as a parent
110
110
  # And is not the brexit checker start page
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "23.10.2".freeze
2
+ VERSION = "23.12.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: 23.10.2
4
+ version: 23.12.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: 2020-12-23 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -678,13 +678,13 @@ files:
678
678
  - app/views/govuk_publishing_components/components/_taxonomy_list.html.erb
679
679
  - app/views/govuk_publishing_components/components/_textarea.html.erb
680
680
  - app/views/govuk_publishing_components/components/_title.html.erb
681
- - app/views/govuk_publishing_components/components/_transition_countdown.html.erb
682
681
  - app/views/govuk_publishing_components/components/_translation-nav.html.erb
683
682
  - app/views/govuk_publishing_components/components/_warning_text.html.erb
684
683
  - app/views/govuk_publishing_components/components/attachment/_thumbnail_document.svg
685
684
  - app/views/govuk_publishing_components/components/attachment/_thumbnail_generic.svg
686
685
  - app/views/govuk_publishing_components/components/attachment/_thumbnail_spreadsheet.svg
687
686
  - app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb
687
+ - app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_related_links.html.erb
688
688
  - app/views/govuk_publishing_components/components/docs/accordion.yml
689
689
  - app/views/govuk_publishing_components/components/docs/action_link.yml
690
690
  - app/views/govuk_publishing_components/components/docs/admin_analytics.yml
@@ -758,7 +758,6 @@ files:
758
758
  - app/views/govuk_publishing_components/components/docs/taxonomy_list.yml
759
759
  - app/views/govuk_publishing_components/components/docs/textarea.yml
760
760
  - app/views/govuk_publishing_components/components/docs/title.yml
761
- - app/views/govuk_publishing_components/components/docs/transition_countdown.yml
762
761
  - app/views/govuk_publishing_components/components/docs/translation-nav.yml
763
762
  - app/views/govuk_publishing_components/components/docs/warning_text.yml
764
763
  - app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb
@@ -783,7 +782,6 @@ files:
783
782
  - lib/generators/govuk_publishing_components/templates/component.yml.erb
784
783
  - lib/govuk_publishing_components.rb
785
784
  - lib/govuk_publishing_components/app_helpers/brand_helper.rb
786
- - lib/govuk_publishing_components/app_helpers/countdown_helper.rb
787
785
  - lib/govuk_publishing_components/app_helpers/environment.rb
788
786
  - lib/govuk_publishing_components/app_helpers/table_helper.rb
789
787
  - lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb
@@ -1,35 +0,0 @@
1
- <%
2
- countdown_clock = GovukPublishingComponents::AppHelpers::CountdownHelper.new
3
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
4
-
5
- heading_level ||= 2
6
- title ||= nil
7
- text ||= nil
8
- url ||= nil
9
- data_attributes ||= {}
10
- lang ||= "en"
11
- direction ||= "ltr"
12
- css_classes = %w(gem-c-transition-countdown)
13
- css_classes << "gem-c-transition-countdown--cta" if url
14
- css_classes << "govuk-link" if url
15
- %>
16
-
17
- <% countdown = capture do %>
18
- <%= content_tag(shared_helper.get_heading_level, title, class: "gem-c-transition-countdown__title") if title %>
19
- <% if countdown_clock.show? %>
20
- <%= tag.p class: "gem-c-transition-countdown__countdown" do %>
21
- <%= tag.span countdown_clock.days_left.first, class: "gem-c-transition-countdown__countdown-number" %><%= tag.span countdown_clock.days_left.last, class: "gem-c-transition-countdown__countdown-number" %> <%= tag.span countdown_clock.days_text, class: "gem-c-transition-countdown__countdown-text" %>
22
- <% end %>
23
- <% end %>
24
- <%= tag.p text, class: "gem-c-transition-countdown__text" if text %>
25
- <% end %>
26
-
27
- <% if url %>
28
- <%= link_to url, class: css_classes, data: data_attributes, lang: lang, dir: direction do %>
29
- <%= countdown %>
30
- <% end %>
31
- <% else %>
32
- <%= tag.div class: css_classes, lang: lang, dir: direction do %>
33
- <%= countdown %>
34
- <% end %>
35
- <% end %>
@@ -1,17 +0,0 @@
1
- name: Transition countdown
2
- description: A countdown to 01 January 2021 used in the Brexit transition campaign
3
- body: When a URL is set it acts as a link to actions users need to take to prepare for brexit during the transition period
4
- shared_accessibility_criteria:
5
- - link
6
- examples:
7
- default:
8
- data:
9
- call_to_action:
10
- data:
11
- title: Brexit transition
12
- text: Check you’re ready for 2021
13
- url: "https://www.gov.uk/transition"
14
- data_attributes:
15
- "track-category": "Transition"
16
- "track-action": "Brexit transition"
17
- "track-label": "Check you’re ready for 2021"
@@ -1,49 +0,0 @@
1
- module GovukPublishingComponents
2
- module AppHelpers
3
- class CountdownHelper
4
- DEADLINE = Time.new(2020, 12, 31, 23, 59)
5
-
6
- def days_left
7
- sprintf "%02d", days_left_until_deadline
8
- end
9
-
10
- def show?
11
- minutes_left_until_deadline >= 30
12
- end
13
-
14
- def days_text
15
- if days_left_until_deadline == 1
16
- I18n.t!("components.transition_countdown.day_to_go")
17
- else
18
- I18n.t!("components.transition_countdown.days_to_go")
19
- end
20
- end
21
-
22
- private
23
-
24
- def days_left_until_deadline
25
- (minutes_left_until_deadline / 60 / 24).ceil
26
- end
27
-
28
- def minutes_left_until_deadline
29
- (seconds_left_until_deadline / 60)
30
- end
31
-
32
- def seconds_left_until_deadline
33
- end_of_transition_period - now_in_london
34
- end
35
-
36
- def end_of_transition_period
37
- london_time_zone(DEADLINE)
38
- end
39
-
40
- def now_in_london
41
- london_time_zone(Time.now)
42
- end
43
-
44
- def london_time_zone(time)
45
- time.in_time_zone("Europe/London")
46
- end
47
- end
48
- end
49
- end