govuk_publishing_components 12.2.0 → 12.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a163b8629c527f42192e2e01c02b0b873752abb7af36601d12624d8c41f84c4e
4
- data.tar.gz: f307b43dd38217403a89f8ed51c4fe8838f2a08db74724ca1949e317df21e4c9
3
+ metadata.gz: 78d7656c28a7185b30c712e1cc5fd67ce22feb573f465bbc33854a29d31f3d93
4
+ data.tar.gz: 17e26835d2f10127ff196593640cf02baa0e09b65c96d5a61eee501d555086d8
5
5
  SHA512:
6
- metadata.gz: d6df7a8ea26d0cb6bc456b4269970581e65834644349858756f59031043e05a8fb0c0bbfc7ef15d719f64da5205dc545805f73c914740dd918c80ee16e760eca
7
- data.tar.gz: a6843135492f1ea827986ee8374f50487dc146b314f31d8112085c769f8a63c4d3699bc5b529a1d599b3d318048bea6fee283a975a922fe335c129ba3f2f8747
6
+ metadata.gz: b7f1e69e7c5a53cd73cdab140585e1189e84a43f62aafa08b51fb45d316da177078d8af82d9183b41bf260a60540ea43cac627ea96273e0e0b7ebf7d81c28f85
7
+ data.tar.gz: a5efd248664d8912343574d36b39ecb264520037709eb35f2536a4c532a59252f134bd9be72b8c4f118580614c4a52766018b85ecd6acefac23d5994d375cbda
@@ -0,0 +1,2 @@
1
+ // This component relies on JavaScript from GOV.UK Frontend
2
+ //= require govuk-frontend/components/checkboxes/checkboxes.js
@@ -1,20 +1,2 @@
1
- window.GOVUK = window.GOVUK || {}
2
- window.GOVUK.Modules = window.GOVUK.Modules || {};
3
-
4
- (function (global, GOVUK) {
5
- 'use strict'
6
-
7
- var $ = global.jQuery
8
-
9
- GOVUK.Modules.ErrorSummary = function () {
10
- this.start = function (element) {
11
- element.focus()
12
- // Focus on inputs with errors, so they're easier to discover
13
- element.on('click', '.js-error-summary__link', function (event) {
14
- event.preventDefault()
15
- var href = $(this).attr('href')
16
- $(href).focus()
17
- })
18
- }
19
- }
20
- })(window, window.GOVUK)
1
+ // This component relies on JavaScript from GOV.UK Frontend
2
+ //= require govuk-frontend/components/error-summary/error-summary.js
@@ -1,32 +1,2 @@
1
1
  // This component relies on JavaScript from GOV.UK Frontend
2
2
  //= require govuk-frontend/components/radios/radios.js
3
-
4
- window.GOVUK = window.GOVUK || {}
5
- window.GOVUK.FrontendModules = window.GOVUK.FrontendModules || {};
6
-
7
- (function (global, GOVUK) {
8
- 'use strict'
9
-
10
- /**
11
- * TODO: Ideally this would be a NodeList.prototype.forEach polyfill
12
- *
13
- * See: https://github.com/imagitama/nodelist-foreach-polyfill
14
- * but the polyfill doesn't work in IE8 and needs more investigation
15
- */
16
- function nodeListForEach (nodes, callback) {
17
- if (window.NodeList.prototype.forEach) {
18
- return nodes.forEach(callback)
19
- }
20
- for (var i = 0; i < nodes.length; i++) {
21
- callback.call(window, nodes[i], i, nodes)
22
- }
23
- }
24
-
25
- GOVUK.FrontendModules.Radios = window.GOVUKFrontend
26
-
27
- var $radios = document.querySelectorAll('[data-module="radios"]')
28
-
29
- nodeListForEach($radios, function ($radio) {
30
- new GOVUK.FrontendModules.Radios($radio).init()
31
- })
32
- })(window, window.GOVUK)
@@ -16,6 +16,7 @@
16
16
  @import "components/breadcrumbs";
17
17
  @import "components/button";
18
18
  @import "components/character-count";
19
+ @import "components/checkboxes";
19
20
  @import "components/contents-list";
20
21
  @import "components/copy-to-clipboard";
21
22
  @import "components/details";
@@ -63,3 +64,4 @@
63
64
  @import "components/textarea";
64
65
  @import "components/title";
65
66
  @import "components/translation-nav";
67
+ @import "components/warning-text";
@@ -0,0 +1,2 @@
1
+ @import "helpers/govuk-frontend-settings";
2
+ @import "govuk-frontend/components/checkboxes/checkboxes";
@@ -0,0 +1,2 @@
1
+ @import "helpers/govuk-frontend-settings";
2
+ @import "govuk-frontend/components/warning-text/warning-text";
@@ -0,0 +1,55 @@
1
+ <%
2
+ id ||= "checkboxes-#{SecureRandom.hex(4)}"
3
+ classes ||= ''
4
+ css_classes = %w( gem-c-checkboxes govuk-form-group )
5
+ css_classes << classes if classes
6
+ error ||= nil
7
+ css_classes << "govuk-form-group--error" if error
8
+ hint_text ||= "Select all that apply."
9
+ items ||= []
10
+
11
+ # check if any item is set as being conditional
12
+ has_conditional = items.any? { |item| item.is_a?(Hash) && item[:conditional] }
13
+ %>
14
+
15
+ <%= tag.div id: id, class: css_classes do %>
16
+ <%= tag.fieldset class: "govuk-fieldset", "aria-describedby": "#{id}-hint #{"#{id}-error" if error}" do %>
17
+
18
+ <%= tag.legend class: "govuk-fieldset__legend govuk-fieldset__legend--xl" do %>
19
+ <%= tag.h1 heading, class: "govuk-fieldset__heading" %>
20
+ <% end %>
21
+
22
+ <%= tag.span hint_text, id: "#{id}-hint", class: "govuk-hint" %>
23
+
24
+ <% if error.present? %>
25
+ <%= tag.span error, id: "#{id}-error", class: "govuk-error-message" %>
26
+ <% end %>
27
+
28
+ <%= tag.div class: "govuk-checkboxes", data: {
29
+ module: ('checkboxes' if has_conditional)
30
+ } do %>
31
+ <% items.each_with_index do |item, index| %>
32
+ <%= tag.div class: "govuk-checkboxes__item" do %>
33
+ <%= tag.input id: "#{id}-#{index}",
34
+ name: name,
35
+ type: "checkbox",
36
+ value: item[:value],
37
+ class: "govuk-checkboxes__input",
38
+ aria: {
39
+ describedby: item[:hint].present? ? "#{id}-#{index}-item-hint" : nil,
40
+ controls: item[:conditional].present? ? "#{id}-conditional-#{index}" : nil
41
+ } do %>
42
+ <%= tag.label item[:label], class: "govuk-label govuk-checkboxes__label", for: "#{id}-#{index}" %>
43
+ <% if item[:hint].present? %>
44
+ <%= tag.span item[:hint], id: "#{id}-#{index}-item-hint", class: "govuk-hint govuk-checkboxes__hint" %>
45
+ <% end %>
46
+ <% end %>
47
+ <% end %>
48
+ <% if item[:conditional] %>
49
+ <%= tag.div item[:conditional], id: "#{id}-conditional-#{index}", class: "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" %>
50
+ <% end %>
51
+ <% end %>
52
+ <% end %>
53
+
54
+ <% end %>
55
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <%
2
+ id ||= "warning-text-#{SecureRandom.hex(4)}"
3
+ classes ||= ''
4
+ css_classes = %w(gem-c-warning-text govuk-warning-text)
5
+ css_classes << classes if classes
6
+ text_assistive ||= 'Warning'
7
+ text_icon ||= '!'
8
+ %>
9
+
10
+ <%= tag.div id: id, class: css_classes do %>
11
+ <%= tag.span text_icon, class: "govuk-warning-text__icon", "aria-hidden": "true" %>
12
+ <%= tag.strong class: "govuk-warning-text__text" do %>
13
+ <%= tag.span text_assistive, class: "govuk-warning-text__assistive" %>
14
+ <%= text %>
15
+ <% end %>
16
+ <% end %>
@@ -0,0 +1,82 @@
1
+ name: Form checkboxes
2
+ description: Help users enter text when there is a limit on the number of characters they can type
3
+ govuk_frontend_components:
4
+ - checkboxes
5
+ accessibility_criteria: |
6
+ The component must:
7
+
8
+ - accept focus
9
+ - be focusable with a keyboard
10
+ - be usable with a keyboard
11
+ - be usable with touch
12
+ - indicate when they have focus
13
+ - be recognisable as form textarea elements
14
+ - have correctly associated labels
15
+ - inform the user about the character limit
16
+ - inform the user as the number of left characters changes
17
+
18
+ Labels use the [label component](/component-guide/label).
19
+ examples:
20
+ default:
21
+ data:
22
+ name: "favourite_colour"
23
+ heading: "What is your favourite colour?"
24
+ items:
25
+ - label: "Red"
26
+ value: "red"
27
+ - label: "Green"
28
+ value: "green"
29
+ - label: "Blue"
30
+ value: "blue"
31
+ custom_hint_text:
32
+ data:
33
+ name: "favourite_skittle"
34
+ heading: "What is your favourite skittle?"
35
+ hint_text: "Taste the rainbow"
36
+ items:
37
+ - label: "Red"
38
+ value: "red"
39
+ - label: "Green"
40
+ value: "green"
41
+ - label: "Blue"
42
+ value: "blue"
43
+ checkbox_items_with_hint:
44
+ data:
45
+ name: "nationality"
46
+ heading: "What is your nationality?"
47
+ hint_text: "If you have dual nationality, select all options that are relevant to you."
48
+ items:
49
+ - label: "British"
50
+ value: "british"
51
+ hint: "including English, Scottish, Welsh and Northern Irish"
52
+ - label: "Irish"
53
+ value: "irish"
54
+ - label: "Other"
55
+ value: "other"
56
+ checkbox_items_with_error:
57
+ data:
58
+ name: "nationality"
59
+ heading: "What is your nationality?"
60
+ error: "Select if you are British, Irish or a citizen of a different country"
61
+ hint_text: "If you have dual nationality, select all options that are relevant to you."
62
+ items:
63
+ - label: "British"
64
+ value: "british"
65
+ hint: "including English, Scottish, Welsh and Northern Irish"
66
+ - label: "Irish"
67
+ value: "irish"
68
+ - label: "Other"
69
+ value: "other"
70
+ checkbox_items_with_conditional_reveal:
71
+ data:
72
+ name: "nationality"
73
+ heading: "What is your nationality?"
74
+ hint_text: "If you have dual nationality, select all options that are relevant to you."
75
+ items:
76
+ - label: "British"
77
+ value: "british"
78
+ conditional: "including English, Scottish, Welsh and Northern Irish"
79
+ - label: "Irish"
80
+ value: "irish"
81
+ - label: "Other"
82
+ value: "other"
@@ -114,6 +114,31 @@ examples:
114
114
  base_path: /world/united-kingdom/news
115
115
  - title: USA
116
116
  base_path: /world/usa/news
117
+ with_quick_links:
118
+ data:
119
+ details:
120
+ quick_links:
121
+ - title: "Money Laundering Regulations: introduction"
122
+ url: "https://www.gov.uk/money-laundering-regulations-introduction"
123
+ - title: "Money Laundering Regulations: report suspicious activities"
124
+ url: "https://www.gov.uk/money-laundering-regulations-report-suspicious-activities"
125
+ with_related_statistical_data_sets:
126
+ data:
127
+ links:
128
+ related_statistical_data_sets:
129
+ - title: International road fuel prices
130
+ base_path: /government/statistical-data-sets/comparisons-of-industrial-and-domestic-energy-prices-monthly-figures
131
+ document_type: statistical_data_set
132
+ - title: Weekly road fuel prices
133
+ base_path: /government/statistical-data-sets/oil-and-petroleum-products-weekly-statistics
134
+ document_type: statistical_data_set
135
+ with_related_contacts:
136
+ data:
137
+ links:
138
+ related:
139
+ - title: Pest Control
140
+ base_path: /pest-control
141
+ document_type: contact
117
142
  with_all_related-content:
118
143
  data:
119
144
  links:
@@ -134,6 +159,21 @@ examples:
134
159
  - title: Apprenticeships
135
160
  base_path: /topic/further-education-skills/apprenticeships
136
161
  document_type: topic
162
+ topical_events:
163
+ - title: UK-China High-Level People to People Dialogue 2017
164
+ base_path: /government/topical-events/uk-china-high-level-people-to-people-dialogue-2017
165
+ document_type: topical_event
166
+ related:
167
+ - title: Pest Control
168
+ base_path: /pest-control
169
+ document_type: contact
170
+ related_statistical_data_sets:
171
+ - title: International road fuel prices
172
+ base_path: /government/statistical-data-sets/comparisons-of-industrial-and-domestic-energy-prices-monthly-figures
173
+ document_type: statistical_data_set
174
+ - title: Weekly road fuel prices
175
+ base_path: /government/statistical-data-sets/oil-and-petroleum-products-weekly-statistics
176
+ document_type: statistical_data_set
137
177
  document_collections:
138
178
  - title: Recruit an apprentice (formerly apprenticeship vacancies)
139
179
  base_path: /government/collections/apprenticeship-vacancies
@@ -0,0 +1,19 @@
1
+ name: Warning text
2
+ description: |
3
+ Use the warning text component when you need to warn users about something important, such as legal consequences of an action, or lack of action, that they might take.
4
+ govuk_frontend_components:
5
+ - warning-text
6
+ accessibility_criteria: |
7
+ All text must have a contrast ratio higher than 4.5:1 against the background colour to meet [WCAG AA](https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast)
8
+ examples:
9
+ default:
10
+ data:
11
+ text: "You can be fined up to £5,000 if you don’t register."
12
+ custom_assistive_text:
13
+ data:
14
+ text_assistive: "Danger"
15
+ text: "You can be fined up to £5,000 if you don’t register."
16
+ custom_icon_text:
17
+ data:
18
+ text_icon: "£"
19
+ text: "You can be fined up to £5,000 if you don’t register."
@@ -32,7 +32,7 @@ module GovukPublishingComponents
32
32
  end
33
33
 
34
34
  def image_url
35
- content_item.dig("details", "image", "url")
35
+ content_item.dig("details", "image", "high_resolution_url") || content_item.dig("details", "image", "url")
36
36
  end
37
37
 
38
38
  def image_alt_text
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '12.2.0'.freeze
2
+ VERSION = '12.3.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: 12.2.0
4
+ version: 12.3.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: 2018-10-19 00:00:00.000000000 Z
11
+ date: 2018-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -309,6 +309,7 @@ files:
309
309
  - app/assets/javascripts/component_guide/visual-regression.js
310
310
  - app/assets/javascripts/govuk_publishing_components/all_components.js
311
311
  - app/assets/javascripts/govuk_publishing_components/components/character-count.js
312
+ - app/assets/javascripts/govuk_publishing_components/components/checkboxes.js
312
313
  - app/assets/javascripts/govuk_publishing_components/components/copy-to-clipboard.js
313
314
  - app/assets/javascripts/govuk_publishing_components/components/error-summary.js
314
315
  - app/assets/javascripts/govuk_publishing_components/components/feedback.js
@@ -327,6 +328,7 @@ files:
327
328
  - app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss
328
329
  - app/assets/stylesheets/govuk_publishing_components/components/_button.scss
329
330
  - app/assets/stylesheets/govuk_publishing_components/components/_character-count.scss
331
+ - app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss
330
332
  - app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss
331
333
  - app/assets/stylesheets/govuk_publishing_components/components/_copy-to-clipboard.scss
332
334
  - app/assets/stylesheets/govuk_publishing_components/components/_details.scss
@@ -375,6 +377,7 @@ files:
375
377
  - app/assets/stylesheets/govuk_publishing_components/components/_textarea.scss
376
378
  - app/assets/stylesheets/govuk_publishing_components/components/_title.scss
377
379
  - app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss
380
+ - app/assets/stylesheets/govuk_publishing_components/components/_warning-text.scss
378
381
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_advisory.scss
379
382
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss
380
383
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss
@@ -434,6 +437,7 @@ files:
434
437
  - app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
435
438
  - app/views/govuk_publishing_components/components/_button.html.erb
436
439
  - app/views/govuk_publishing_components/components/_character_count.html.erb
440
+ - app/views/govuk_publishing_components/components/_checkboxes.html.erb
437
441
  - app/views/govuk_publishing_components/components/_contents_list.html.erb
438
442
  - app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb
439
443
  - app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb
@@ -488,11 +492,13 @@ files:
488
492
  - app/views/govuk_publishing_components/components/_textarea.html.erb
489
493
  - app/views/govuk_publishing_components/components/_title.html.erb
490
494
  - app/views/govuk_publishing_components/components/_translation-nav.html.erb
495
+ - app/views/govuk_publishing_components/components/_warning_text.html.erb
491
496
  - app/views/govuk_publishing_components/components/docs/admin_analytics.yml
492
497
  - app/views/govuk_publishing_components/components/docs/back_link.yml
493
498
  - app/views/govuk_publishing_components/components/docs/breadcrumbs.yml
494
499
  - app/views/govuk_publishing_components/components/docs/button.yml
495
500
  - app/views/govuk_publishing_components/components/docs/character_count.yml
501
+ - app/views/govuk_publishing_components/components/docs/checkboxes.yml
496
502
  - app/views/govuk_publishing_components/components/docs/contents_list.yml
497
503
  - app/views/govuk_publishing_components/components/docs/contextual_breadcrumbs.yml
498
504
  - app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml
@@ -547,6 +553,7 @@ files:
547
553
  - app/views/govuk_publishing_components/components/docs/textarea.yml
548
554
  - app/views/govuk_publishing_components/components/docs/title.yml
549
555
  - app/views/govuk_publishing_components/components/docs/translation-nav.yml
556
+ - app/views/govuk_publishing_components/components/docs/warning_text.yml
550
557
  - app/views/govuk_publishing_components/components/metadata/_sentence.html.erb
551
558
  - app/views/govuk_publishing_components/components/related_navigation/_section.html.erb
552
559
  - app/views/layouts/govuk_publishing_components/application.html.erb