govuk_publishing_components 21.65.0 → 21.66.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (21) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +25 -7
  3. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +3 -3
  4. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +8 -1
  5. data/app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js +25 -20
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +9 -5
  8. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -4
  9. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +1 -1
  10. data/app/views/govuk_publishing_components/components/_document_list.html.erb +2 -2
  11. data/app/views/govuk_publishing_components/components/_notice.html.erb +2 -1
  12. data/app/views/govuk_publishing_components/components/docs/contents_list.yml +3 -5
  13. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +6 -0
  14. data/app/views/govuk_publishing_components/components/docs/notice.yml +8 -0
  15. data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +9 -0
  16. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +0 -1
  17. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +1 -1
  18. data/lib/govuk_publishing_components/presenters/breadcrumbs.rb +0 -4
  19. data/lib/govuk_publishing_components/presenters/organisation_logo_helper.rb +2 -1
  20. data/lib/govuk_publishing_components/version.rb +1 -1
  21. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c223c076bcecd87fb23721eba8271d89a681ad4a67a11103d14330a3fefd17ac
4
- data.tar.gz: 69114b477b5b22856acf4378b875bcdb69ba05b4d127eb4c9b5d0dc465f00993
3
+ metadata.gz: 7dde9e7cc89ab9b102414add462ef9e8a85a1dddfb1b172fbc01e077a613312f
4
+ data.tar.gz: e1402ae8bcb0dade6fad52b5e3f33689319ee32f4cb86229947760bc3021e48e
5
5
  SHA512:
6
- metadata.gz: 616fd5f93cdc4229bc187915bd2021a0ab9b6637aaed0532c0880b7ef12a76ad9f0264e274ca69635c07f84ec121497a3e32157373836f595a8b9159f57087af
7
- data.tar.gz: 6ee53e65daf9887db6f6acc92bc0d53d6394fd8a9fa6994e51baf0581700679ed7897d32a68d151176b0a0ccedc7f64d37826448cacf69240d92cfe6894884a8
6
+ metadata.gz: 9739fca8bdb77b7f4a67ee620c08a575782ce0e479fd7cf03f0520eb41d7e524398723bb5ea30a7ff583c2c86c826dd7e6c375c5d51c8d4480dcbe504182516f
7
+ data.tar.gz: 51c29f5094ef43a28fa8804990926b1bc3ac156f983e09d25b999e215e695c2c7d056ed07b41ba021ff52611e5a30ef046d6cf37d45d2dd76446cc1b38d061af
@@ -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,9 +10,10 @@
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
+ var isSearchToggle = sourceClass.match('search-toggle')
16
17
 
17
18
  if (targetClass.indexOf('js-visible') !== -1) {
18
19
  target.setAttribute('class', targetClass.replace(/(^|\s)js-visible(\s|$)/, ''))
@@ -21,8 +22,14 @@
21
22
  }
22
23
  if (sourceClass.indexOf('js-visible') !== -1) {
23
24
  this.setAttribute('class', sourceClass.replace(/(^|\s)js-visible(\s|$)/, ''))
25
+ if (isSearchToggle) {
26
+ this.innerText = 'Show search'
27
+ }
24
28
  } else {
25
29
  this.setAttribute('class', sourceClass + ' js-visible')
30
+ if (isSearchToggle) {
31
+ this.innerText = 'Hide search'
32
+ }
26
33
  }
27
34
  this.setAttribute('aria-expanded', this.getAttribute('aria-expanded') !== 'true')
28
35
  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)
@@ -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
  }
@@ -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] %>
@@ -1,6 +1,6 @@
1
1
  <%-
2
2
  cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new(local_assigns)
3
- aria_label ||= nil
3
+ aria_label ||= "Contents"
4
4
  format_numbers ||= false
5
5
  hide_title ||= false
6
6
 
@@ -15,7 +15,7 @@
15
15
  %>
16
16
  <% if items.any? %>
17
17
  <% unless within_multitype_list %>
18
- <ol class="<%= classes %>">
18
+ <ul class="<%= classes %>">
19
19
  <% end %>
20
20
  <% items.each do |item| %>
21
21
  <% highlight_class = " gem-c-document-list__item--highlight" if item[:highlight] %>
@@ -112,6 +112,6 @@
112
112
  </li>
113
113
  <% end %>
114
114
  <% unless within_multitype_list %>
115
- </ol>
115
+ </ul>
116
116
  <% end %>
117
117
  <% end %>
@@ -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" %>
@@ -17,9 +17,7 @@ accessibility_criteria: |
17
17
  - inform the user how many items are in the list
18
18
  - convey the content structure
19
19
  - indicate the current page when contents span different pages, and not link to itself
20
-
21
- The contents list may:
22
- - include an aria-label to contextualise the list if helpful
20
+ - include an aria-label to contextualise the list
23
21
 
24
22
  Links with formatted numbers must separate the number and text with a space for correct screen reader pronunciation. This changes pronunciation from "1 dot Item" to "1 Item".
25
23
  shared_accessibility_criteria:
@@ -67,8 +65,8 @@ examples:
67
65
  active: true
68
66
  - href: "#third-thing"
69
67
  text: Third thing
70
- aria_label:
71
- description: 'An aria-label string can be used to contextualise the navigation for assistive technology.'
68
+ with_custom_aria_label:
69
+ description: 'An aria-label string should be used to contextualise the navigation for assistive technology. Defaults to "Contents" if aria-label is not passed.'
72
70
  data:
73
71
  aria_label: "Pages in this guide"
74
72
  contents:
@@ -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'
@@ -191,3 +191,12 @@ examples:
191
191
  brand: cabinet-office
192
192
  crest: 'single-identity'
193
193
  inline: true
194
+ with-explicit-language:
195
+ description: The language attribute on the name of the organisation can be set if required. If this option is not passed, no lang attribute is set.
196
+ data:
197
+ organisation:
198
+ name: Tŷ'r Cwmnïau
199
+ url: '/government/organisations/companies-house.cy'
200
+ brand: department-for-business-innovation-skills
201
+ crest: 'single-identity'
202
+ lang: "cy"
@@ -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",
@@ -11,6 +11,7 @@ module GovukPublishingComponents
11
11
  @url = local_assigns[:organisation][:url]
12
12
  @crest = local_assigns[:organisation][:crest]
13
13
  @image = local_assigns[:organisation][:image] || false
14
+ @lang = local_assigns[:lang] || nil
14
15
  if @image
15
16
  @logo_image_src = local_assigns[:organisation][:image][:url] || false
16
17
  @logo_image_alt = local_assigns[:organisation][:image][:alt_text] || false
@@ -21,7 +22,7 @@ module GovukPublishingComponents
21
22
  if image
22
23
  image_tag(logo_image_src, alt: logo_image_alt, class: "gem-c-organisation-logo__image")
23
24
  else
24
- content_tag("span", name, class: "gem-c-organisation-logo__name")
25
+ content_tag("span", name, class: "gem-c-organisation-logo__name", lang: @lang)
25
26
  end
26
27
  end
27
28
 
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.65.0".freeze
2
+ VERSION = "21.66.3".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.65.0
4
+ version: 21.66.3
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-08 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config