govuk_publishing_components 21.63.3 → 21.66.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/govuk_publishing_components/action-link-arrow--transparent.svg +1 -0
  3. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +25 -7
  4. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +3 -3
  5. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +3 -1
  6. data/app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js +25 -20
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +8 -2
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +9 -5
  10. data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -0
  11. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -4
  12. data/app/views/govuk_publishing_components/components/_notice.html.erb +2 -1
  13. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +2 -2
  14. data/app/views/govuk_publishing_components/components/docs/action_link.yml +8 -0
  15. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +6 -0
  16. data/app/views/govuk_publishing_components/components/docs/notice.yml +8 -0
  17. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +3 -1
  18. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +0 -1
  19. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +1 -1
  20. data/lib/govuk_publishing_components/presenters/breadcrumbs.rb +0 -4
  21. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +19 -5
  22. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +1 -1
  23. data/lib/govuk_publishing_components/version.rb +1 -1
  24. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dfe72210f443a0c8d4f94c41fc1996bffa3fe47b772ecc7851c4c223612d4c5
4
- data.tar.gz: 299ba77eba106b9d4ba23257ff645fefa8b9a6ea5e5aa010f9f564a821d0fa73
3
+ metadata.gz: 9bf9f7485f017d85bcc7a495d8589ef344ec7e942536e9b0e1e572b37e36c919
4
+ data.tar.gz: afab329a86f75e95926103ec746038e0e2ac6967b756985efc0d39f86a2c0b35
5
5
  SHA512:
6
- metadata.gz: b9a85dda00e7198025eff0c30434c57ccf72e10840d81d32f8990ad9cb08d6989735eb387cfad56d09486e56d848662d27df14c14686dd47e24f5e444da2f02e
7
- data.tar.gz: 0b95e6218d7772692270f7257545fe62a30608e9627f8f7b527e621f11a1f70d319af5b07a066c1fdbe5618fbfed1d580e4793f29f8b99a425bbe14de7a39f67
6
+ metadata.gz: 1b95b4802e4e9dbe071e1c9c24b8994cc868df9f1f949d2e6b64d78cd34ed4bc6d3db8ca742fc57c08236efd258418d91edeb85915f02c26b4658c6680e410fb
7
+ data.tar.gz: 56e3f6bcddaf5fa925016960767017683b2ea100bdac40141b2440335ca3f1d3435658c4e11024ef19cd5d4beeefa897154ab86907fd25205c44438dc11df1dc
@@ -0,0 +1 @@
1
+ <svg width="39" height="39" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.01 6.818l-2.828 2.828 7.853 7.854-22 .066L0 21.5h22.035l-7.853 7.854 2.828 2.828L29.69 19.5zM39 19.5C39 30.27 30.27 39 19.5 39 9.373 39 1.05 31.28.092 21.405A19.737 19.737 0 010 19.5C0 8.73 8.73 0 19.5 0S39 8.73 39 19.5z" fill="#fff500"/></svg>
@@ -8,19 +8,23 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
8
8
 
9
9
  Modules.Feedback = function () {
10
10
  this.start = function ($element) {
11
+ this.element = $element[0]
12
+ this.somethingIsWrongForm = this.element.querySelector('#something-is-wrong')
13
+ this.surveyForm = this.element.querySelector('#page-is-not-useful')
11
14
  this.$prompt = $element.find('.js-prompt')
12
15
  this.$fields = $element.find('.gem-c-feedback__form-field')
13
16
  this.$forms = $element.find('.js-feedback-form')
14
17
  this.$toggleForms = $element.find('.js-toggle-form')
15
18
  this.$closeForms = $element.find('.js-close-form')
19
+ this.activeForm = false
16
20
  this.$activeForm = false
17
21
  this.$pageIsUsefulButton = $element.find('.js-page-is-useful')
18
22
  this.$pageIsNotUsefulButton = $element.find('.js-page-is-not-useful')
19
23
  this.$somethingIsWrongButton = $element.find('.js-something-is-wrong')
20
24
  this.$promptQuestions = $element.find('.js-prompt-questions')
21
25
  this.$promptSuccessMessage = $element.find('.js-prompt-success')
22
- this.$somethingIsWrongForm = $element.find('#something-is-wrong')
23
- this.$surveyForm = $element.find('#page-is-not-useful')
26
+ this.$somethingIsWrongForm = $(this.somethingIsWrongForm)
27
+ this.$surveyForm = $(this.surveyForm)
24
28
  this.$surveyWrapper = $element.find('#survey-wrapper')
25
29
 
26
30
  var that = this
@@ -103,12 +107,23 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
103
107
  function setHiddenValues () {
104
108
  that.$somethingIsWrongForm.append('<input type="hidden" name="javascript_enabled" value="true"/>')
105
109
  that.$somethingIsWrongForm.append($('<input type="hidden" name="referrer">').val(document.referrer || 'unknown'))
110
+ that.somethingIsWrongForm.invalidInfoError = [
111
+ '<h2>',
112
+ ' Sorry, we’re unable to send your message as you haven’t given us any information.',
113
+ '</h2>',
114
+ '<p>Please tell us what you were doing or what went wrong</p>'
115
+ ].join('')
106
116
  }
107
117
 
108
118
  function setHiddenValuesNotUsefulForm (gaClientId) {
109
119
  var currentPathName = window.location.pathname.replace(/[^\s=?&]+(?:@|%40)[^\s=?&]+/, '[email]')
110
120
  var finalPathName = encodeURI(currentPathName)
111
-
121
+ that.surveyForm.invalidInfoError = [
122
+ '<h2>',
123
+ ' Sorry, we’re unable to send your message as you haven’t given us a valid email address. ',
124
+ '</h2>',
125
+ '<p>Enter an email address in the correct format, like name@example.com</p>'
126
+ ].join('')
112
127
  if (document.querySelectorAll('[name="email_survey_signup[ga_client_id]"]').length === 0) {
113
128
  that.$surveyForm.append($('<input name="email_survey_signup[ga_client_id]" type="hidden">').val(gaClientId || '0'))
114
129
  }
@@ -124,7 +139,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
124
139
  }
125
140
 
126
141
  function toggleForm (formId) {
127
- that.$activeForm = $element.find('#' + formId)
142
+ that.activeForm = that.element.querySelector('#' + formId)
143
+ that.$activeForm = $(that.activeForm)
128
144
  that.$activeForm.toggleClass(jshiddenClass)
129
145
  that.$prompt.toggleClass(jshiddenClass)
130
146
 
@@ -158,18 +174,20 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
158
174
  '<p>If the problem persists, we have other ways for you to provide',
159
175
  ' feedback on the <a href="/contact/govuk">contact page</a>.</p>'
160
176
  ].join('')
161
-
162
177
  // if the response is not a 404 or 500, show the error message if it exists
163
178
  // otherwise show the generic message
164
- // this covers the 422 status the feedback application return for empty fields
165
- // for all other, show generic error
166
179
  if (typeof (error.responseJSON) !== 'undefined') {
167
180
  error = typeof (error.responseJSON.message) === 'undefined' ? genericError : error.responseJSON.message
168
181
 
169
182
  if (error === 'email survey sign up failure') {
170
183
  error = genericError
171
184
  }
185
+ } else if (error.status === 422) {
186
+ // there's clobbering by nginx on all 422 requests, which is why the response returns a rendered html page instead of the expected JSON
187
+ // this is a temporary workaround to ensure that are are displaying relevant error messages to the users
188
+ error = that.activeForm.invalidInfoError || genericError
172
189
  } else {
190
+ // for all other, show generic error
173
191
  error = genericError
174
192
  }
175
193
  var $errors = that.$activeForm.find('.js-errors')
@@ -396,14 +396,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
396
396
  var $cell = cells[i]
397
397
  var cellVal = parseFloat(this.utils.stripValue($cell.innerText), 10)
398
398
  var $cellSpan = $cell.querySelector('span')
399
- var spanWidth = parseFloat(window.getComputedStyle($cellSpan, null).width.replace('px', '')) + 10 // +10 just for extra padding
400
- var cellWidth = parseFloat(window.getComputedStyle($cell, null).width.replace('px', ''))
399
+ var spanWidth = $cell.querySelector('span').offsetWidth + 5 // +5 just for extra padding
400
+ var cellWidth = $cell.offsetWidth
401
401
 
402
402
  if (!this.options.stacked) {
403
403
  // if it's 0, it is effectively outdented
404
404
  if (cellVal === 0) { $cell.classList.add('mc-bar-outdented') }
405
405
 
406
- if ((this.options.autoOutdent && spanWidth > cellWidth) || this.options.outdentAll) {
406
+ if ((this.options.autoOutdent && spanWidth >= cellWidth) || this.options.outdentAll) {
407
407
  $cell.classList.add('mc-bar-outdented')
408
408
  $cellSpan.style.marginLeft = '100%'
409
409
  $cellSpan.style.display = 'inline-block'
@@ -10,7 +10,7 @@
10
10
  for (i = 0, _i = els.length; i < _i; i++) {
11
11
  els[i].addEventListener('click', function (e) {
12
12
  e.preventDefault()
13
- var target = document.getElementById(this.getAttribute('href').substr(1))
13
+ var target = this.getAttribute('href') ? document.getElementById(this.getAttribute('href').substr(1)) : document.getElementById(this.getAttribute('data-search-toggle-for'))
14
14
  var targetClass = target.getAttribute('class') || ''
15
15
  var sourceClass = this.getAttribute('class') || ''
16
16
 
@@ -21,8 +21,10 @@
21
21
  }
22
22
  if (sourceClass.indexOf('js-visible') !== -1) {
23
23
  this.setAttribute('class', sourceClass.replace(/(^|\s)js-visible(\s|$)/, ''))
24
+ this.innerText = 'Show search'
24
25
  } else {
25
26
  this.setAttribute('class', sourceClass + ' js-visible')
27
+ this.innerText = 'Hide search'
26
28
  }
27
29
  this.setAttribute('aria-expanded', this.getAttribute('aria-expanded') !== 'true')
28
30
  target.setAttribute('aria-hidden', target.getAttribute('aria-hidden') === 'false')
@@ -1,36 +1,41 @@
1
+ //= require govuk/vendor/polyfills/Element/prototype/classList.js
1
2
  /*
2
3
  Toggle the class 'focus' on input boxes on element focus/blur
3
4
  Used by the search component but generic enough for reuse
4
5
  */
6
+ window.GOVUK = window.GOVUK || {}
5
7
  window.GOVUK.Modules = window.GOVUK.Modules || {};
6
8
 
7
9
  (function (Modules) {
8
- 'use strict'
10
+ function GemToggleInputClassOnFocus () { }
9
11
 
10
- Modules.GemToggleInputClassOnFocus = function () {
11
- this.start = function ($el) {
12
- var $toggleTarget = $el.find('.js-class-toggle')
12
+ GemToggleInputClassOnFocus.prototype.start = function ($module) {
13
+ this.$module = $module[0]
14
+ this.toggleTarget = this.$module.querySelector('.js-class-toggle')
15
+ this.$module.addFocusClass = this.addFocusClass.bind(this)
16
+ this.$module.removeFocusClassFromEmptyInput = this.removeFocusClassFromEmptyInput.bind(this)
13
17
 
14
- if (!inputIsEmpty()) {
15
- addFocusClass()
16
- }
18
+ if (!this.inputIsEmpty()) {
19
+ this.addFocusClass()
20
+ }
17
21
 
18
- $toggleTarget.on('focus', addFocusClass)
19
- $toggleTarget.on('blur', removeFocusClassFromEmptyInput)
22
+ this.toggleTarget.addEventListener('focus', this.$module.addFocusClass)
23
+ this.toggleTarget.addEventListener('blur', this.$module.removeFocusClassFromEmptyInput)
24
+ }
20
25
 
21
- function inputIsEmpty () {
22
- return $toggleTarget.val() === ''
23
- }
26
+ GemToggleInputClassOnFocus.prototype.inputIsEmpty = function () {
27
+ return this.toggleTarget.value === ''
28
+ }
24
29
 
25
- function addFocusClass () {
26
- $toggleTarget.addClass('focus')
27
- }
30
+ GemToggleInputClassOnFocus.prototype.addFocusClass = function () {
31
+ this.toggleTarget.classList.add('focus')
32
+ }
28
33
 
29
- function removeFocusClassFromEmptyInput () {
30
- if (inputIsEmpty()) {
31
- $toggleTarget.removeClass('focus')
32
- }
33
- }
34
+ GemToggleInputClassOnFocus.prototype.removeFocusClassFromEmptyInput = function () {
35
+ if (this.inputIsEmpty()) {
36
+ this.toggleTarget.classList.remove('focus')
34
37
  }
35
38
  }
39
+
40
+ Modules.GemToggleInputClassOnFocus = GemToggleInputClassOnFocus
36
41
  })(window.GOVUK.Modules)
@@ -4,13 +4,13 @@
4
4
  &:before {
5
5
  content: "";
6
6
  display: table-cell;
7
- width: 50px;
7
+ width: 60px;
8
8
  height: 45px;
9
9
  background: image-url("govuk_publishing_components/action-link-arrow.png");
10
10
  background: image-url("govuk_publishing_components/action-link-arrow.svg"), linear-gradient(transparent, transparent);
11
11
  background-repeat: no-repeat;
12
12
  background-position: 0 50%;
13
- background-size: 37px auto;
13
+ background-size: 45px auto;
14
14
  }
15
15
 
16
16
  @include govuk-media-query($until: tablet) {
@@ -141,6 +141,12 @@
141
141
  }
142
142
  }
143
143
 
144
+ .gem-c-action-link--transparent-icon {
145
+ &:before {
146
+ background-image: image-url("govuk_publishing_components/action-link-arrow--transparent.svg");
147
+ }
148
+ }
149
+
144
150
  .gem-c-action-link--nhs {
145
151
  &:before {
146
152
  width: 80px;
@@ -12,6 +12,7 @@
12
12
  margin: 0;
13
13
  min-width: 0;
14
14
  padding: govuk-spacing(1);
15
+ box-sizing: border-box;
15
16
 
16
17
  &.gem-c-input--search-icon {
17
18
  padding-left: govuk-spacing(6);
@@ -10,6 +10,7 @@ $large-input-size: 50px;
10
10
  @include govuk-font($size: 19, $line-height: $input-size);
11
11
  display: block;
12
12
  background: govuk-colour("white");
13
+ color: $govuk-text-colour;
13
14
 
14
15
  h1 {
15
16
  @include govuk-font($size: 19, $line-height: $input-size);
@@ -129,10 +130,6 @@ $large-input-size: 50px;
129
130
  }
130
131
 
131
132
  .gem-c-search--on-govuk-blue {
132
- .gem-c-search__label {
133
- color: govuk-colour("white");
134
- }
135
-
136
133
  .gem-c-search__input {
137
134
  border-width: 0;
138
135
 
@@ -216,11 +213,11 @@ $large-input-size: 50px;
216
213
  }
217
214
 
218
215
  .search-toggle {
216
+ display: none;
219
217
  background-color: govuk-colour("blue");
220
218
  background-image: image-url("govuk_publishing_components/search-button.png");
221
219
  background-position: 0 50%;
222
220
  background-repeat: no-repeat;
223
- display: block;
224
221
  float: right;
225
222
  height: 30px;
226
223
  margin: -46px 0;
@@ -228,6 +225,7 @@ $large-input-size: 50px;
228
225
  padding: 0;
229
226
  text-indent: -5000px;
230
227
  width: 36px;
228
+ border: 0;
231
229
 
232
230
  &:focus {
233
231
  border-width: 0;
@@ -253,4 +251,10 @@ $large-input-size: 50px;
253
251
  @include govuk-media-query($from: tablet) {
254
252
  display: none;
255
253
  }
254
+
255
+ @include govuk-media-query($until: tablet) {
256
+ .js-enabled & {
257
+ display: block;
258
+ }
259
+ }
256
260
  }
@@ -13,6 +13,7 @@
13
13
  dark_icon ||= false
14
14
  small_icon ||= false
15
15
  nhs_icon ||= false
16
+ transparent_icon ||= false
16
17
  data ||= nil
17
18
  classes ||= nil
18
19
 
@@ -20,6 +21,7 @@
20
21
  css_classes << "gem-c-action-link--light-text" if light_text
21
22
  css_classes << "gem-c-action-link--dark-icon" if dark_icon
22
23
  css_classes << "gem-c-action-link--small-icon" if small_icon
24
+ css_classes << "gem-c-action-link--transparent-icon" if transparent_icon
23
25
  css_classes << "gem-c-action-link--nhs" if nhs_icon
24
26
  css_classes << "gem-c-action-link--simple" if simple
25
27
  css_classes << "gem-c-action-link--with-subtext" if subtext
@@ -17,16 +17,13 @@
17
17
  <ol class="govuk-breadcrumbs__list">
18
18
  <% breadcrumbs.each_with_index do |crumb, index| %>
19
19
  <% breadcrumb = GovukPublishingComponents::Presenters::Breadcrumb.new(crumb, index) %>
20
- <li class="govuk-breadcrumbs__list-item" aria-current="<%= breadcrumb.aria_current %>">
20
+ <li class="govuk-breadcrumbs__list-item">
21
21
  <% if breadcrumb.is_link? %>
22
22
  <%= link_to(
23
23
  breadcrumb[:title],
24
24
  breadcrumb.path,
25
25
  data: breadcrumb.tracking_data(breadcrumbs.length),
26
26
  class: "govuk-breadcrumbs__link",
27
- aria: {
28
- current: breadcrumb.aria_current,
29
- }
30
27
  ) %>
31
28
  <% else %>
32
29
  <%= breadcrumb[:title] %>
@@ -4,6 +4,7 @@
4
4
  description_govspeak ||= false
5
5
  description ||= yield || false
6
6
  aria_live ||= false
7
+ lang = local_assigns[:lang].presence
7
8
  local_assigns[:margin_bottom] ||= 8
8
9
  local_assigns[:margin_bottom] = 8 if local_assigns[:margin_bottom] > 9
9
10
 
@@ -17,7 +18,7 @@
17
18
  description_present = description.present? || description_text.present? || description_govspeak.present?
18
19
  %>
19
20
  <% if title || description_present %>
20
- <%= tag.section class: css_classes, aria: aria_attributes, role: "region" do %>
21
+ <%= tag.section class: css_classes, aria: aria_attributes, lang: lang, role: "region" do %>
21
22
  <% if title %>
22
23
  <% if description_present %>
23
24
  <%= tag.h2 title, class: "gem-c-notice__title" %>
@@ -28,7 +28,7 @@
28
28
  <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
29
29
  </script>
30
30
 
31
- <div class="<%= classes %>" data-module="track-click">
31
+ <h2 class="<%= classes %>" data-module="track-click">
32
32
  <span class="gem-c-step-nav-header__part-of">Part of</span>
33
33
  <% if path %>
34
34
  <a href="<%= path %>"
@@ -51,5 +51,5 @@
51
51
  <%= title %>
52
52
  </span>
53
53
  <% end %>
54
- </div>
54
+ </h2>
55
55
  <% end %>
@@ -36,6 +36,14 @@ examples:
36
36
  light_text: true
37
37
  context:
38
38
  dark_background: true
39
+ with_transparent_svg:
40
+ data:
41
+ text: Find out what you need to do
42
+ href: "/page"
43
+ light_text: true
44
+ transparent_icon: true
45
+ context:
46
+ dark_background: true
39
47
  with_subtext:
40
48
  data:
41
49
  text: Emergency something
@@ -188,6 +188,12 @@ examples:
188
188
  <tr>
189
189
  <td>row 2</td><td>15</td>
190
190
  </tr>
191
+ <tr>
192
+ <td>row 3</td><td>2</td>
193
+ </tr>
194
+ <tr>
195
+ <td>row 4</td><td>48</td>
196
+ </tr>
191
197
  </tbody>
192
198
  </table>
193
199
  chart_with_colours:
@@ -42,3 +42,11 @@ examples:
42
42
  title: 'Your settings have been saved'
43
43
  description_govspeak: <p>This is a confirmation message to tell you your settings have been saved</p>
44
44
  aria_live: true
45
+ with_locale:
46
+ description: |
47
+ Passing a lang value allows the content of the notice to be labelled as being a different language from surrounding content.
48
+ The lang attribute must be set to a [valid BCP47 string](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang#Language_tag_syntax). A valid code can be the two or three letter language code - for example, English is en or eng, Korean is ko or kor - but if in doubt please check.
49
+ data:
50
+ title: 'This publication was withdrawn on 30 September 2015'
51
+ description_govspeak: <p>This document is no longer current. We published a new version on 30 September 2015.</p>
52
+ lang: 'en'
@@ -3,7 +3,9 @@ description: Shows that a content page is part of a step by step navigation
3
3
  body: |
4
4
  The component indicates to the user that the current page is part of a [step by step navigation](/component-guide/step_by_step_nav), and can provide a link to it.
5
5
  accessibility_criteria: |
6
- The component is designed to go into the top of an existing content page and should not interfere with the heading structure of the page, so therefore should not contain a heading tag.
6
+ The component is designed to go into the top of an existing content page. This component looks like a heading so uses a heading level 2 element.
7
+
8
+ An earlier version of the component did not use a heading element &ndash; this failed WCAG 2.1 Success Criterion 1.3.1 ("Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text.")
7
9
 
8
10
  An early version of the component contained a hidden skip link for keyboard and screen reader users, that jumped to the step by step navigation component in the sidebar (similiar to the 'skip to content' link at the top of all GOV.UK pages). User testing suggested that rather than helping users it confused them, so this has been removed.
9
11
  shared_accessibility_criteria:
@@ -26,7 +26,6 @@
26
26
  'track-category' => 'yesNoFeedbackForm',
27
27
  'track-action' => 'ffYesClick'
28
28
  },
29
- 'aria-expanded': false,
30
29
  role: 'button',
31
30
  } do %>
32
31
  <%= t("components.feedback.yes", default: "Yes") %> <span class="govuk-visually-hidden"><%= t("components.feedback.is_useful", default: "this page is useful") %></span>
@@ -1,4 +1,4 @@
1
- <a href="#search" class="search-toggle js-header-toggle">Search</a>
1
+ <button class="search-toggle js-header-toggle" data-search-toggle-for="search">Show search</button>
2
2
  <form id="search" class="gem-c-layout-header__search-form govuk-clearfix" action="/search" method="get" role="search">
3
3
  <%= render "govuk_publishing_components/components/search", {
4
4
  id: "site-search-text",
@@ -49,10 +49,6 @@ module GovukPublishingComponents
49
49
  crumb[:url]
50
50
  end
51
51
 
52
- def aria_current
53
- "false"
54
- end
55
-
56
52
  def tracking_data(breadcrumbs_length)
57
53
  data = {
58
54
  track_category: "breadcrumbClicked",
@@ -12,18 +12,22 @@ module GovukPublishingComponents
12
12
  }.freeze
13
13
 
14
14
  # Returns the highest priority taxon that has a content_id matching those in PRIORITY_TAXONS
15
- def self.call(content_item)
16
- new(content_item).breadcrumbs
15
+ def self.call(content_item, query_parameters = nil)
16
+ new(content_item, query_parameters).breadcrumbs
17
17
  end
18
18
 
19
- attr_reader :content_item
19
+ attr_reader :content_item, :query_parameters
20
20
 
21
- def initialize(content_item)
21
+ def initialize(content_item, query_parameters = nil)
22
22
  @content_item = content_item
23
+ @query_parameters = query_parameters
23
24
  end
24
25
 
25
26
  def taxon
26
- @taxon ||= priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
27
+ @taxon ||= begin
28
+ default_taxon = priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
29
+ preferred_taxon || default_taxon
30
+ end
27
31
  end
28
32
 
29
33
  def breadcrumbs
@@ -39,6 +43,12 @@ module GovukPublishingComponents
39
43
 
40
44
  private
41
45
 
46
+ def preferred_taxon
47
+ if preferred_priority_taxon
48
+ priority_taxons.find { |t| t["content_id"] == preferred_priority_taxon }
49
+ end
50
+ end
51
+
42
52
  def priority_taxons
43
53
  return [] unless content_item["links"].is_a?(Hash)
44
54
 
@@ -57,6 +67,10 @@ module GovukPublishingComponents
57
67
  def priority_taxon?(taxon)
58
68
  PRIORITY_TAXONS.values.include?(taxon["content_id"])
59
69
  end
70
+
71
+ def preferred_priority_taxon
72
+ query_parameters["priority-taxon"] if query_parameters
73
+ end
60
74
  end
61
75
  end
62
76
  end
@@ -30,7 +30,7 @@ module GovukPublishingComponents
30
30
  end
31
31
 
32
32
  def priority_breadcrumbs
33
- @priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item)
33
+ @priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item, query_parameters)
34
34
  end
35
35
 
36
36
  def topic_breadcrumbs
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.63.3".freeze
2
+ VERSION = "21.66.1".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: 21.63.3
4
+ version: 21.66.1
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-09-03 00:00:00.000000000 Z
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -320,6 +320,7 @@ files:
320
320
  - app/assets/images/govuk_publishing_components/action-link-arrow--dark.svg
321
321
  - app/assets/images/govuk_publishing_components/action-link-arrow--simple.png
322
322
  - app/assets/images/govuk_publishing_components/action-link-arrow--simple.svg
323
+ - app/assets/images/govuk_publishing_components/action-link-arrow--transparent.svg
323
324
  - app/assets/images/govuk_publishing_components/action-link-arrow.png
324
325
  - app/assets/images/govuk_publishing_components/action-link-arrow.svg
325
326
  - app/assets/images/govuk_publishing_components/chevron-banner/chevron-banner-small-focus.svg