govuk_publishing_components 21.66.4 → 21.67.0

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: 4f1d9c7682de95500ed81dea0c882a0ee4d06712de97959ba929a0a4df3be026
4
- data.tar.gz: a218c351949f15ade0339e0c75e44d92d4e36c1eda24d6814bddeda038ce94e7
3
+ metadata.gz: a7991985a7a9869043e35d91693f0248e5ba011de2eac78f1b2275b979d25264
4
+ data.tar.gz: 89c607b3f7064922a61cf2827cd5a3b6394f97ca7ad8701bf5ad174810f6e432
5
5
  SHA512:
6
- metadata.gz: c2619f5980dd8a3f2001a1ba6090df652c66e0b20db6b5c12d80bde86f07b096bc577c82e2a084a8f2db21cf1523632d3cd6083c4c0a1b468383a6b0cc86433d
7
- data.tar.gz: bf214537cd46646d40a28e3d9e7beabb6a26185584fb83f213c465eb9eeb13262d990cea26a213c1d7f5256bf285be0aa2e61a96d1718bfe042cb0f09859b592
6
+ metadata.gz: 4cc489ecf258a21462db3af8a187180240f6b2b2cfe83c2ba3e84338cb155ea262b5c34e7250c4d2026d1ff65e853f2696f9f03322bebd44bf5387da82dbad24
7
+ data.tar.gz: 18822a14a52b63504b3132a66ede1e8ef85ca4c55023dd2e9f6f7b1ba19ece9318e8d3b083ba182512ff27d7e1c3d471551307e812d41287cbcd03662ade90a7
@@ -1,52 +1,55 @@
1
- /* eslint-env jquery */
2
-
3
1
  window.GOVUK = window.GOVUK || {}
4
2
  window.GOVUK.Modules = window.GOVUK.Modules || {};
5
3
 
6
4
  (function (Modules) {
7
- 'use strict'
8
-
9
- Modules.TrackSelectChange = function () {
10
- this.start = function (element) {
11
- element.change(function (e) {
12
- var selectedOption = $(this).find(':selected')
13
- var trackable = '[data-track-category][data-track-action]'
14
-
15
- if (selectedOption.is(trackable)) {
16
- fireTrackingChange(selectedOption)
17
- }
18
- })
19
-
20
- function fireTrackingChange (element) {
21
- var options = { transport: 'beacon' }
22
- var category = element.attr('data-track-category')
23
- var action = element.attr('data-track-action')
24
- var label = element.attr('data-track-label')
25
- var value = element.attr('data-track-value')
26
- var dimension = element.attr('data-track-dimension')
27
- var dimensionIndex = element.attr('data-track-dimension-index')
28
- var extraOptions = element.attr('data-track-options')
29
-
30
- if (label) {
31
- options.label = label
32
- }
33
-
34
- if (value) {
35
- options.value = value
36
- }
37
-
38
- if (dimension && dimensionIndex) {
39
- options['dimension' + dimensionIndex] = dimension
40
- }
41
-
42
- if (extraOptions) {
43
- $.extend(options, JSON.parse(extraOptions))
44
- }
45
-
46
- if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
47
- window.GOVUK.analytics.trackEvent(category, action, options)
48
- }
49
- };
5
+ function TrackSelectChange () { }
6
+
7
+ TrackSelectChange.prototype.start = function ($module) {
8
+ this.$module = $module[0]
9
+ this.$module.trackChange = this.trackChange.bind(this)
10
+ this.$module.fireTrackingChange = this.fireTrackingChange.bind(this)
11
+ this.$module.addEventListener('change', this.trackChange)
12
+ }
13
+
14
+ TrackSelectChange.prototype.trackChange = function () {
15
+ var selectedOption = this.options[this.selectedIndex]
16
+
17
+ if (selectedOption.hasAttribute('data-track-category') && selectedOption.hasAttribute('data-track-action')) {
18
+ this.fireTrackingChange(selectedOption)
50
19
  }
51
20
  }
21
+
22
+ TrackSelectChange.prototype.fireTrackingChange = function (selectedOption) {
23
+ var options = { transport: 'beacon' }
24
+ var category = selectedOption.getAttribute('data-track-category')
25
+ var action = selectedOption.getAttribute('data-track-action')
26
+ var label = selectedOption.getAttribute('data-track-label')
27
+ var value = selectedOption.getAttribute('data-track-value')
28
+ var dimension = selectedOption.getAttribute('data-track-dimension')
29
+ var dimensionIndex = selectedOption.getAttribute('data-track-dimension-index')
30
+ var extraOptions = selectedOption.getAttribute('data-track-options')
31
+
32
+ if (label) {
33
+ options.label = label
34
+ }
35
+
36
+ if (value) {
37
+ options.value = value
38
+ }
39
+
40
+ if (dimension && dimensionIndex) {
41
+ options['dimension' + dimensionIndex] = dimension
42
+ }
43
+
44
+ if (extraOptions) {
45
+ extraOptions = JSON.parse(extraOptions)
46
+ for (var k in extraOptions) options[k] = extraOptions[k]
47
+ }
48
+
49
+ if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
50
+ window.GOVUK.analytics.trackEvent(category, action, options)
51
+ }
52
+ }
53
+
54
+ Modules.TrackSelectChange = TrackSelectChange
52
55
  })(window.GOVUK.Modules)
@@ -11,7 +11,6 @@
11
11
  // hide without js
12
12
  // show with js, unless also has the js-hidden class
13
13
  .gem-c-feedback__js-show,
14
- .gem-c-feedback__form,
15
14
  .gem-c-feedback__prompt-success,
16
15
  .gem-c-feedback__prompt-questions,
17
16
  .gem-c-feedback__error-summary {
@@ -26,6 +25,24 @@
26
25
  }
27
26
  }
28
27
 
28
+ // maintain table display for prompt and prompt-questions
29
+ .js-enabled .gem-c-feedback__prompt {
30
+ @include govuk-media-query($from: tablet) {
31
+ display: table;
32
+ }
33
+ }
34
+
35
+ .js-enabled .gem-c-feedback__prompt-questions {
36
+ @include govuk-media-query($from: tablet) {
37
+ display: table-cell;
38
+ }
39
+ }
40
+
41
+ // show the default feedback form without js
42
+ .js-enabled .gem-c-feedback__form.js-hidden {
43
+ display: none;
44
+ }
45
+
29
46
  .gem-c-feedback__prompt-questions {
30
47
  text-align: center;
31
48
  border-bottom: 1px solid govuk-colour("white");
@@ -34,7 +51,7 @@
34
51
 
35
52
  @include govuk-media-query($from: tablet) {
36
53
  width: 50%;
37
- float: left;
54
+ display: table-cell;
38
55
  text-align: left;
39
56
  border-bottom: 0;
40
57
  }
@@ -45,6 +62,8 @@
45
62
 
46
63
  @include govuk-media-query($from: tablet) {
47
64
  text-align: right;
65
+ vertical-align: bottom;
66
+ float: none;
48
67
  }
49
68
  }
50
69
 
@@ -53,6 +72,12 @@
53
72
  background-color: govuk-colour("blue");
54
73
  color: govuk-colour("white");
55
74
  outline: 0;
75
+
76
+ @include govuk-media-query($from: tablet) {
77
+ @include govuk-font(16, $weight: bold);
78
+ display: table;
79
+ width: 100%;
80
+ }
56
81
  }
57
82
 
58
83
  .gem-c-feedback__prompt-question,
@@ -65,13 +90,9 @@
65
90
  }
66
91
 
67
92
  .gem-c-feedback__prompt-question {
93
+ vertical-align: text-top;
68
94
  display: inline-block;
69
-
70
- // There's a global h3 rule in some layouts that interferes with this component
71
- margin: 0;
72
-
73
- margin-left: govuk-spacing(4);
74
- margin-right: govuk-spacing(4);
95
+ margin: govuk-spacing(2) govuk-spacing(4);
75
96
 
76
97
  &:focus {
77
98
  outline: 0;
@@ -79,13 +100,26 @@
79
100
 
80
101
  @include govuk-media-query($from: tablet) {
81
102
  margin-left: 0;
103
+ margin-top: 0;
104
+ display: block;
105
+ }
106
+
107
+ // This custom media-query is to account for some awkward positioning where the yes and no buttons are too big to sit inline with the prompt question
108
+ @include govuk-media-query($from: 950px) {
109
+ display: inline-block;
110
+ margin-top: govuk-spacing(2);
82
111
  }
83
112
  }
84
113
 
85
114
  .gem-c-feedback__prompt-link {
86
- @include govuk-link-common;
87
115
  @include govuk-font(19);
88
- display: inline-block;
116
+ box-shadow: 0 2px 0 govuk-colour("black");
117
+ min-width: 100%;
118
+
119
+ @include govuk-media-query($from: mobile) {
120
+ min-width: 100px;
121
+ margin-bottom: 0;
122
+ }
89
123
 
90
124
  @include govuk-media-query($from: tablet) {
91
125
  @include govuk-font(16);
@@ -116,24 +150,31 @@
116
150
  }
117
151
 
118
152
  .gem-c-feedback__option-list {
119
- display: inline-block;
120
153
  list-style-type: none;
121
154
  margin: 0;
122
155
  padding: 0;
123
- margin-right: govuk-spacing(2);
124
156
  margin-top: govuk-spacing(2);
125
157
 
158
+ @include govuk-media-query($from: mobile) {
159
+ display: inline-block;
160
+ margin-right: govuk-spacing(2);
161
+ }
162
+
126
163
  @include govuk-media-query($from: tablet) {
127
164
  margin-top: 0;
128
165
  }
129
166
  }
130
167
 
131
168
  .gem-c-feedback__option-list-item {
132
- display: inline-block;
169
+ @include govuk-media-query($from: mobile) {
170
+ display: inline-block;
171
+ }
133
172
  }
134
173
 
135
174
  .gem-c-feedback__option-list-item:first-child {
136
- margin-right: govuk-spacing(7);
175
+ @include govuk-media-query($from: mobile) {
176
+ margin-right: govuk-spacing(4);
177
+ }
137
178
  }
138
179
 
139
180
  // Feedback form styles
@@ -206,15 +247,8 @@
206
247
  }
207
248
 
208
249
  .gem-c-feedback__close {
209
- @include govuk-link-common;
210
- @include govuk-link-style-default;
211
- @include govuk-font(19);
212
250
  float: right;
213
251
  margin: 0 govuk-spacing(1) govuk-spacing(2) 0;
214
-
215
- @include govuk-media-query($from: tablet) {
216
- padding-top: 0;
217
- }
218
252
  }
219
253
 
220
254
  .gem-c-feedback__email-link {
@@ -2,8 +2,9 @@
2
2
  cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new(local_assigns)
3
3
  aria_label ||= "Contents"
4
4
  format_numbers ||= false
5
+ title_lang ||= false
6
+ title = local_assigns[:title].presence || t("components.contents_list.contents")
5
7
  hide_title ||= false
6
-
7
8
  brand ||= false
8
9
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
9
10
 
@@ -21,7 +22,13 @@
21
22
  }
22
23
  ) do %>
23
24
  <% unless hide_title %>
24
- <h2 class="gem-c-contents-list__title"><%= t("components.contents_list.contents") %></h2>
25
+ <%= content_tag(
26
+ :h2,
27
+ class: "gem-c-contents-list__title",
28
+ lang: title_lang.presence
29
+ ) do %>
30
+ <%= title %>
31
+ <% end %>
25
32
  <% end %>
26
33
 
27
34
  <ol class="gem-c-contents-list__list">
@@ -56,13 +56,15 @@
56
56
  <% if sl_helper.feed_link_box_value %>
57
57
  <div class="gem-c-subscription-links__feed-box js-hidden" id="<%= sl_helper.feed_box_id %>">
58
58
  <p class="gem-c-subscription-links__feed-hidden-description visuallyhidden"><%= sl_helper.feed_link_text %></p>
59
- <%= render "govuk_publishing_components/components/input", {
60
- label: {
61
- text: "Copy and paste this URL into your feed reader"
62
- },
63
- name: "feed-reader-box",
64
- value: feed_link_box_value
65
- } %>
59
+ <div lang="en">
60
+ <%= render "govuk_publishing_components/components/input", {
61
+ label: {
62
+ text: "Copy and paste this URL into your feed reader"
63
+ },
64
+ name: "feed-reader-box",
65
+ value: feed_link_box_value
66
+ } %>
67
+ </div>
66
68
  </div>
67
69
  <% end %>
68
70
  <% end %>
@@ -215,3 +215,28 @@ examples:
215
215
  text: Guidance and regulation
216
216
  - href: "#third-thing"
217
217
  text: Consultations
218
+ with_a_custom_title:
219
+ description: Override the default title of "Contents" with a custom title
220
+ data:
221
+ title: "On this page"
222
+ contents:
223
+ - href: "#first-thing"
224
+ text: First thing
225
+ - href: "#second-thing"
226
+ text: Second thing
227
+ - href: "#third-thing"
228
+ text: Third thing
229
+ with_a_custom_title_locale:
230
+ description: |
231
+ This component is often used on translated pages that don’t have a translation for the title of the contents list. This means that it could display the fallback English string if the translate method can’t find an appropriate translation. This makes sure that the lang can be set to ensure that browsers understand which parts of the page are in each language.
232
+
233
+ 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.
234
+ data:
235
+ title_lang: "cy"
236
+ contents:
237
+ - href: "#first-thing"
238
+ text: First thing
239
+ - href: "#second-thing"
240
+ text: Second thing
241
+ - href: "#third-thing"
242
+ text: Third thing
@@ -191,12 +191,3 @@ 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"
@@ -4,13 +4,14 @@
4
4
  data-track-category="Onsite Feedback"
5
5
  data-track-action="GOV.UK Send Form"
6
6
  method="post">
7
- <a href="#"
8
- class="gem-c-feedback__close gem-c-feedback__js-show js-close-form"
7
+ <button
8
+ class="govuk-button govuk-button--secondary gem-c-feedback__close gem-c-feedback__js-show js-close-form"
9
9
  data-track-category="Onsite Feedback"
10
10
  data-track-action="GOV.UK Close Form"
11
11
  aria-controls="something-is-wrong"
12
- aria-expanded="true"
13
- role="button"><%= t("components.feedback.close", default: "Close") %></a>
12
+ aria-expanded="true">
13
+ <%= t("components.feedback.close", default: "Close") %>
14
+ </button>
14
15
 
15
16
  <div class="govuk-grid-row">
16
17
  <div class="govuk-grid-column-two-thirds">
@@ -4,13 +4,14 @@
4
4
  data-track-category="yesNoFeedbackForm"
5
5
  data-track-action="Send Form"
6
6
  method="post">
7
- <a href="#"
8
- class="gem-c-feedback__close js-close-form"
7
+ <button
8
+ class="govuk-button govuk-button--secondary gem-c-feedback__close js-close-form"
9
9
  data-track-category="yesNoFeedbackForm"
10
10
  data-track-action="ffFormClose"
11
11
  aria-controls="page-is-not-useful"
12
- aria-expanded="true"
13
- role="button"><%= t("components.feedback.close", default: "Close") %></a>
12
+ aria-expanded="true">
13
+ <%= t("components.feedback.close", default: "Close") %>
14
+ </button>
14
15
 
15
16
  <div class="govuk-grid-row">
16
17
  <div class="govuk-grid-column-two-thirds" id="survey-wrapper">
@@ -6,44 +6,20 @@
6
6
  <div class="gem-c-feedback__prompt-questions js-prompt-questions">
7
7
  <h2 class="gem-c-feedback__prompt-question"><%= t("components.feedback.is_this_page_useful", default: "Is this page useful?") %></h2>
8
8
  <!-- Maybe button exists only to try and capture clicks by bots -->
9
- <%= link_to t("components.feedback.maybe", default: "Maybe"), contact_govuk_path, {
10
- class: 'gem-c-feedback__prompt-link',
11
- data: {
12
- 'track-category' => 'yesNoFeedbackForm',
13
- 'track-action' => 'ffMaybeClick'
14
- },
15
- 'aria-expanded': false,
16
- role: 'button',
17
- style: 'display: none;',
18
- hidden: 'hidden',
19
- 'aria-hidden': 'true',
20
- } %>
9
+ <button class="govuk-button govuk-button--secondary gem-c-feedback__prompt-link" data-track-category="yesNoFeedbackForm" data-track-action="ffMaybeClick" aria-expanded="false" style="display: none" hidden="hidden" aria-hidden="true">
10
+ <%= t("components.feedback.maybe", default: "Maybe") %>
11
+ </button>
12
+
21
13
  <ul class="gem-c-feedback__option-list">
22
14
  <li class="gem-c-feedback__option-list-item">
23
- <%= link_to contact_govuk_path, {
24
- class: 'gem-c-feedback__prompt-link js-page-is-useful',
25
- data: {
26
- 'track-category' => 'yesNoFeedbackForm',
27
- 'track-action' => 'ffYesClick'
28
- },
29
- role: 'button',
30
- } do %>
15
+ <button class="govuk-button govuk-button--secondary gem-c-feedback__prompt-link js-page-is-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffYesClick">
31
16
  <%= t("components.feedback.yes", default: "Yes") %> <span class="govuk-visually-hidden"><%= t("components.feedback.is_useful", default: "this page is useful") %></span>
32
- <% end %>
17
+ </button>
33
18
  </li>
34
19
  <li class="gem-c-feedback__option-list-item">
35
- <%= link_to contact_govuk_path, {
36
- class: 'gem-c-feedback__prompt-link js-toggle-form js-page-is-not-useful',
37
- data: {
38
- 'track-category' => 'yesNoFeedbackForm',
39
- 'track-action' => 'ffNoClick'
40
- },
41
- 'aria-controls': 'page-is-not-useful',
42
- 'aria-expanded': false,
43
- role: 'button',
44
- } do %>
20
+ <button class="govuk-button govuk-button--secondary gem-c-feedback__prompt-link js-toggle-form js-page-is-not-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffNoClick" aria-controls="page-is-not-useful" aria-expanded="false">
45
21
  <%= t("components.feedback.no", default: "No") %> <span class="govuk-visually-hidden"><%= t("components.feedback.is_not_useful", default: "this page is not useful") %></span>
46
- <% end %>
22
+ </button>
47
23
  </li>
48
24
  </ul>
49
25
  </div>
@@ -51,17 +27,8 @@
51
27
  <%= t("components.feedback.thank_you_for_feedback", default: "Thank you for your feedback") %>
52
28
  </div>
53
29
  <div class="gem-c-feedback__prompt-questions gem-c-feedback__prompt-questions--something-is-wrong js-prompt-questions">
54
- <%= link_to contact_govuk_path, {
55
- class: 'gem-c-feedback__prompt-link js-toggle-form js-something-is-wrong',
56
- data: {
57
- 'track-category' => 'Onsite Feedback',
58
- 'track-action' => 'GOV.UK Open Form'
59
- },
60
- 'aria-controls': 'something-is-wrong',
61
- 'aria-expanded': false,
62
- role: 'button',
63
- } do %>
30
+ <button class="govuk-button govuk-button--secondary gem-c-feedback__prompt-link js-toggle-form js-something-is-wrong" data-track-category="Onsite Feedback" data-track-action="GOV-UK Open Form" aria-controls="something-is-wrong" aria-expanded="false">
64
31
  <%= t("components.feedback.anything_wrong", default: "Is there anything wrong with this page?") %>
65
- <% end %>
32
+ </button>
66
33
  </div>
67
34
  </div>
@@ -11,7 +11,6 @@ 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
15
14
  if @image
16
15
  @logo_image_src = local_assigns[:organisation][:image][:url] || false
17
16
  @logo_image_alt = local_assigns[:organisation][:image][:alt_text] || false
@@ -22,7 +21,7 @@ module GovukPublishingComponents
22
21
  if image
23
22
  image_tag(logo_image_src, alt: logo_image_alt, class: "gem-c-organisation-logo__image")
24
23
  else
25
- content_tag("span", name, class: "gem-c-organisation-logo__name", lang: @lang)
24
+ content_tag("span", name, class: "gem-c-organisation-logo__name")
26
25
  end
27
26
  end
28
27
 
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.66.4".freeze
2
+ VERSION = "21.67.0".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.66.4
4
+ version: 21.67.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2020-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config