govuk_publishing_components 21.45.0 → 21.46.0

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/components/checkboxes.js +15 -0
  3. data/app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss +9 -0
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -1
  5. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_footnotes.scss +4 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_tables.scss +2 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +4 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss +0 -13
  9. data/app/models/govuk_publishing_components/component_example.rb +4 -4
  10. data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +16 -11
  11. data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +23 -0
  12. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +22 -3
  13. data/config/locales/en.yml +2 -0
  14. data/lib/govuk_publishing_components/presenters/attachment.rb +3 -3
  15. data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +4 -1
  16. data/lib/govuk_publishing_components/presenters/contents_list_helper.rb +1 -1
  17. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +1 -1
  18. data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +1 -1
  19. data/lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb +1 -1
  20. data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +1 -1
  21. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +3 -3
  22. data/lib/govuk_publishing_components/presenters/select.rb +2 -2
  23. data/lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb +2 -2
  24. data/lib/govuk_publishing_components/version.rb +1 -1
  25. metadata +16 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6b9b3ccb50fed59ef6f76d01f29904a100f1b3e3f5585e4884dd59c2ebe61a2
4
- data.tar.gz: 11681141b7eb3b7904c8ee16f950370599ec2c4f4f9121ba34b6d04a57c4b522
3
+ metadata.gz: 8d54671ad8f273c7964008613ed64cb631808376ac9a1dbb9b810649dbb13909
4
+ data.tar.gz: a5497f0e68627da627a50ea02d4fad88af8e6f58f79d7482b1c5f12d45d3fbb7
5
5
  SHA512:
6
- metadata.gz: 8be5fd215ab57c63d064a6b98f41ff4a6ecf92aafeea63e63a27a823075d72e12881b54c0d76995fc8037089b37696b64e9353940814ade22692439db3999ab8
7
- data.tar.gz: bb193cd02f9916cdd204132eeccf7a3c155bf74503c8be662ac947a5d867bcdbd3d455e3fbede4950129c79dd7c6561ce459ff916b3198c9d80c47c1989658b7
6
+ metadata.gz: c4a9b2848c97f714246a21736f7bd0aa2febec61777da0b8319cf77d354db2048e1b4dd552698e30d61edc7d613cd6db8582b014936da86ce339e45cde8a61bb
7
+ data.tar.gz: 9ce6d6e08b93012137c37b489f16d45ffd784739df06ab7e65d50979417499a7dee7f7ea1af551bb8418e28e371cb27f17de8504085a12a173c60d5b14239359
@@ -48,6 +48,21 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
48
48
  }
49
49
  }
50
50
  })
51
+
52
+ $(scope).on('change', '[data-exclusive=true] input[type=checkbox]', function (e) {
53
+ var currentCheckbox = e.target
54
+ var checkboxes = currentCheckbox.closest('.govuk-checkboxes')
55
+ var exclusiveOption = $(checkboxes).find('input[type=checkbox][data-exclusive]')
56
+ var nonExclusiveOptions = $(checkboxes).find('input[type=checkbox]:not([data-exclusive])')
57
+
58
+ if (currentCheckbox.dataset.exclusive === 'true' && currentCheckbox.checked === true) {
59
+ nonExclusiveOptions.each(function () {
60
+ $(this).prop('checked', false)
61
+ })
62
+ } else if (currentCheckbox.dataset.exclusive !== 'true' && currentCheckbox.checked === true) {
63
+ exclusiveOption.prop('checked', false)
64
+ }
65
+ })
51
66
  }
52
67
 
53
68
  this.toggleNestedCheckboxes = function (scope, checkbox) {
@@ -25,6 +25,15 @@
25
25
  margin: 0;
26
26
  }
27
27
 
28
+ .gem-c-checkboxes__divider {
29
+ @include govuk-font($size: 19);
30
+ @include govuk-text-colour;
31
+ list-style-type: none;
32
+ margin-bottom: govuk-spacing(2);
33
+ text-align: center;
34
+ width: 40px;
35
+ }
36
+
28
37
  .gem-c-checkboxes {
29
38
  // this is complex but needed to override the govuk-frontend styles in
30
39
  // https://github.com/alphagov/govuk-frontend/blob/b8058640b9602ecb6e1f66f887553190cbae7b46/src/components/hint/_hint.scss#L16
@@ -34,7 +34,7 @@
34
34
  .gem-c-input__suffix {
35
35
  @include govuk-font($size: 19);
36
36
 
37
- background-color: govuk-colour("light-grey");
37
+ background-color: govuk-colour("light-grey", $legacy: "grey-3");
38
38
  border: $govuk-border-width-form-element solid $govuk-input-border-colour;
39
39
  border-left: 0;
40
40
  box-sizing: border-box;
@@ -15,6 +15,10 @@
15
15
  margin-top: govuk-spacing(6);
16
16
  padding-top: govuk-spacing(2);
17
17
 
18
+ a {
19
+ overflow-wrap: break-word;
20
+ }
21
+
18
22
  ol {
19
23
  margin-top: 0;
20
24
  padding-top: 0;
@@ -9,7 +9,9 @@
9
9
  table {
10
10
  border-collapse: collapse;
11
11
  border-spacing: 0;
12
+ display: block;
12
13
  margin: govuk-spacing(6) 0;
14
+ overflow-x: auto;
13
15
  width: 100%;
14
16
  @include govuk-font($size: 14);
15
17
 
@@ -17,6 +17,10 @@
17
17
  margin-left: 0;
18
18
  margin-right: govuk-spacing(4);
19
19
 
20
+ a {
21
+ overflow-wrap: break-word;
22
+ }
23
+
20
24
  ul,
21
25
  ol {
22
26
  margin-top: 0;
@@ -90,16 +90,3 @@
90
90
  border-color: govuk-colour("black");
91
91
  }
92
92
  }
93
-
94
- // new brand colour to match Public Health England
95
- // used on the coronavirus page
96
- // note that PHE already has a different brand colour, the brand
97
- // department-for-health is used on the PHE org page
98
- $gem-c-covid-yellow: #ffe114;
99
-
100
- .brand--public-health-england {
101
- &.brand__border-color,
102
- .brand__border-color {
103
- border-color: $gem-c-covid-yellow;
104
- }
105
- }
@@ -71,11 +71,11 @@ module GovukPublishingComponents
71
71
  end
72
72
 
73
73
  def right_to_left?
74
- !!context["right_to_left"]
74
+ context["right_to_left"].present?
75
75
  end
76
76
 
77
77
  def dark_background?
78
- !!context["dark_background"]
78
+ context["dark_background"].present?
79
79
  end
80
80
 
81
81
  def html_description
@@ -83,11 +83,11 @@ module GovukPublishingComponents
83
83
  end
84
84
 
85
85
  def has_block?
86
- !!block
86
+ block.present?
87
87
  end
88
88
 
89
89
  def has_embed?
90
- !!embed
90
+ embed.present?
91
91
  end
92
92
 
93
93
  private
@@ -25,20 +25,25 @@
25
25
  <%= tag.ul class: cb_helper.list_classes, data: {
26
26
  module: ('checkboxes' if cb_helper.has_conditional),
27
27
  nested: ('true' if cb_helper.has_nested),
28
+ exclusive: ('true' if cb_helper.has_exclusive)
28
29
  } do %>
29
30
  <% cb_helper.items.each_with_index do |item, index| %>
30
- <%= tag.li class: "govuk-checkboxes__item" do %>
31
- <%= cb_helper.checkbox_markup(item, index) %>
32
-
33
- <% if item[:conditional] %>
34
- <%= tag.div item[:conditional], id: "#{id}-#{index}-conditional-#{index}", class: "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" %>
35
- <% end %>
31
+ <% if item === :or %>
32
+ <%= tag.li t('components.checkboxes.or'), class: "gem-c-checkboxes__divider" %>
33
+ <% else %>
34
+ <%= tag.li class: "govuk-checkboxes__item" do %>
35
+ <%= cb_helper.checkbox_markup(item, index) %>
36
+
37
+ <% if item[:conditional] %>
38
+ <%= tag.div item[:conditional], id: "#{id}-#{index}-conditional-#{index}", class: "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" %>
39
+ <% end %>
36
40
 
37
- <% if item[:items].present? %>
38
- <%= tag.ul id: "#{id}-nested-#{index}", class: "govuk-checkboxes govuk-checkboxes--nested", data: { parent: "#{id}-#{index}" } do %>
39
- <% item[:items].each_with_index do |nested_item, nested_index| %>
40
- <%= tag.li class: "govuk-checkboxes__item" do %>
41
- <%= cb_helper.checkbox_markup(nested_item, "#{index}-#{nested_index}") %>
41
+ <% if item[:items].present? %>
42
+ <%= tag.ul id: "#{id}-nested-#{index}", class: "govuk-checkboxes govuk-checkboxes--nested", data: { parent: "#{id}-#{index}" } do %>
43
+ <% item[:items].each_with_index do |nested_item, nested_index| %>
44
+ <%= tag.li class: "govuk-checkboxes__item" do %>
45
+ <%= cb_helper.checkbox_markup(nested_item, "#{index}-#{nested_index}") %>
46
+ <% end %>
42
47
  <% end %>
43
48
  <% end %>
44
49
  <% end %>
@@ -268,6 +268,29 @@ examples:
268
268
  value: "irish"
269
269
  - label: "Other"
270
270
  value: "other"
271
+ checkbox_with_exclusive_item:
272
+ description: |
273
+ Allows an option to become exclusive, as follows:
274
+
275
+ - when the exclusive item is checked, all non-exclusive items are unchecked
276
+ - when a non-exclusive item is checked, the exclusive item is unchecked
277
+
278
+ This behaviour should be doubled by similar checks on the backend.
279
+ data:
280
+ name: "nationality-exclusive"
281
+ heading: "What kind of expertise can you offer?"
282
+ hint_text: "Select the types of support you can offer."
283
+ items:
284
+ - label: "Medical"
285
+ value: "medical"
286
+ - label: "Engineering"
287
+ value: "engineering"
288
+ - label: "Other"
289
+ value: "other"
290
+ - :or
291
+ - label: "I cannot offer expertise"
292
+ value: "no-expertise"
293
+ exclusive: true
271
294
  checkbox_items_with_conditional_reveal:
272
295
  description: |
273
296
  Checkboxes can be configured to show additional elements when checked. This could include further components, such as text inputs as shown.
@@ -149,15 +149,30 @@ examples:
149
149
  <caption>A table with data</caption>
150
150
  <thead>
151
151
  <tr>
152
- <th>Heading 1</th><th>Heading 2</th>
152
+ <th>Group</th>
153
+ <th>Explanation</th>
154
+ <th>Current and continuing guidance</th>
155
+ <th>Government support</th>
153
156
  </tr>
154
157
  </thead>
155
158
  <tbody>
156
159
  <tr>
157
- <td>cell 1</td><td>cell 2</td>
160
+ <th>Clinically extremely vulnerable people (all people in this cohort will have received communication from the NHS)</th>
161
+ <td>People defined on medical grounds a clinically extremely vulnerable, meaning they are at the greatest risk of severe illness. This group includes solid organ transplant recipients, people receiving chemotherapy, renal dialysis patients and others.</td>
162
+ <td>Follow shielding guidance by staying at home at all times and avoiding all non-essential face-to-face contact. This guidance is in place until end June.</td>
163
+ <td>Support available from the National Shielding Programme, which includes food supplies (through food boxes and priority supermarket deliveries), pharmacy deliveries and care. Support is available via the NHS Volunteer Responders app.</td>
158
164
  </tr>
159
165
  <tr>
160
- <td>cell 3</td><td>cell 4</td>
166
+ <th>Clinically vulnerable people</th>
167
+ <td>People considered to be at higher risk of severe illness from COVID-19. Clinically vulnerable people include the following: people aged 70 or older, people with liver disease, people with diabetes, pregnant women and others.</td>
168
+ <td>Stay at home as much as possible. If you do go out, take particular care to minimise contact with others outside your household.</td>
169
+ <td>Range of support available while measures in place, including by local authorities and through voluntary and community groups. Support is available via the NHS Volunteer Responders app.</td>
170
+ </tr>
171
+ <tr>
172
+ <th>Vulnerable people (non-clinical)</th>
173
+ <td>There are a range of people who can be classified as ‘vulnerable’ due to non-clinical factors, such as children at risk of violence or with special education needs, victims of domestic abuse, rough sleepers and others.</td>
174
+ <td>People in this group will need to follow general guidance except where they are also clinically vulnerable or clinically extremely vulnerable, where they should follow guidance as set out above.</td>
175
+ <td>For those who need it, a range of support and guidance across public services and the benefits system, including by central and local government and the voluntary and community sector.</td>
161
176
  </tr>
162
177
  </tbody>
163
178
  </table>
@@ -257,6 +272,10 @@ examples:
257
272
  <li id="fn:1a">
258
273
  <p>And here is the definition. <a href="#fnref:1a" class="reversefootnote">&#8617;</a></p>
259
274
  </li>
275
+ <li id="fn:2">
276
+ <a href="https://www.ons.gov.uk/peoplepopulationandcommunity/birthsdeathsandmarriages/deaths/datasets/weeklyprovisionalfiguresondeathsregisteredinenglandandwales" class="govuk-link">https://www.ons.gov.uk/peoplepopulationandcommunity/birthsdeathsandmarriages/deaths/datasets/weeklyprovisionalfiguresondeathsregisteredinenglandandwales</a>
277
+ <a href="#fnref:2" class="govuk-link">↩</a>
278
+ </li>
260
279
  </ol>
261
280
  </div>
262
281
  rtl_block:
@@ -32,6 +32,8 @@ en:
32
32
  scoped_search_description: "Search within %{title}"
33
33
  back_link:
34
34
  back: 'Back'
35
+ checkboxes:
36
+ or: 'or'
35
37
  contents_list:
36
38
  contents: Contents
37
39
  organisation_schema:
@@ -131,15 +131,15 @@ module GovukPublishingComponents
131
131
  end
132
132
 
133
133
  def opendocument?
134
- !!content_type_data[:opendocument]
134
+ content_type_data[:opendocument].present?
135
135
  end
136
136
 
137
137
  def document?
138
- !!content_type_data[:document]
138
+ content_type_data[:document].present?
139
139
  end
140
140
 
141
141
  def spreadsheet?
142
- !!content_type_data[:spreadsheet]
142
+ content_type_data[:spreadsheet].present?
143
143
  end
144
144
  end
145
145
 
@@ -5,7 +5,8 @@ module GovukPublishingComponents
5
5
  include ActionView::Context
6
6
 
7
7
  attr_reader :items, :name, :css_classes, :list_classes, :error, :has_conditional,
8
- :has_nested, :id, :hint_text, :description, :heading_size, :heading_caption
8
+ :has_nested, :id, :hint_text, :description, :heading_size, :heading_caption,
9
+ :has_exclusive
9
10
 
10
11
  def initialize(options)
11
12
  @items = options[:items] || []
@@ -19,6 +20,7 @@ module GovukPublishingComponents
19
20
 
20
21
  # check if any item is set as being conditional
21
22
  @has_conditional = options[:items].any? { |item| item.is_a?(Hash) && item[:conditional] }
23
+ @has_exclusive = options[:items].any? { |item| item.is_a?(Hash) && item[:exclusive] }
22
24
  @has_nested = options[:items].any? { |item| item.is_a?(Hash) && item[:items] }
23
25
 
24
26
  @id = options[:id] || "checkboxes-#{SecureRandom.hex(4)}"
@@ -77,6 +79,7 @@ module GovukPublishingComponents
77
79
  data = checkbox[:data_attributes] || {}
78
80
  data[:controls] = controls
79
81
  data["aria-controls"] = aria_controls
82
+ data[:exclusive] = checkbox[:exclusive]
80
83
 
81
84
  capture do
82
85
  concat check_box_tag checkbox_name, checkbox[:value], checked, class: "govuk-checkboxes__input", id: checkbox_id, data: data
@@ -9,7 +9,7 @@ module GovukPublishingComponents
9
9
 
10
10
  def initialize(options)
11
11
  @contents = options[:contents] || []
12
- @nested = !!@contents.find { |c| c[:items] && c[:items].any? }
12
+ @nested = @contents.any? { |c| c[:items] && c[:items].any? }
13
13
  @format_numbers = options[:format_numbers]
14
14
 
15
15
  @classes = %w[gem-c-contents-list]
@@ -13,7 +13,7 @@ module GovukPublishingComponents
13
13
  end
14
14
 
15
15
  def simple_smart_answer?
16
- content_item["document_type"] === "simple_smart_answer"
16
+ content_item["document_type"] == "simple_smart_answer"
17
17
  end
18
18
 
19
19
  def taxon_breadcrumbs
@@ -100,7 +100,7 @@ module GovukPublishingComponents
100
100
  end
101
101
 
102
102
  def answer_is_unset?(q_and_as, question)
103
- !q_and_as[question].has_key?(:answer)
103
+ !q_and_as[question].key?(:answer)
104
104
  end
105
105
 
106
106
  # we use H2 tags as the "question" and the html between them as the "answer"
@@ -47,7 +47,7 @@ module GovukPublishingComponents
47
47
  ministers.each_with_object({}) do |minister, grouped|
48
48
  person_schema = person_schema_for_minister(minister)
49
49
 
50
- if grouped.has_key? person_schema
50
+ if grouped.key? person_schema
51
51
  grouped[person_schema] << role_for_minister(minister)
52
52
  else
53
53
  grouped[person_schema] = [role_for_minister(minister)]
@@ -115,7 +115,7 @@ module GovukPublishingComponents
115
115
  end
116
116
 
117
117
  def show_secondary_step_by_step?
118
- !primary_step_by_steps? && secondary_step_by_step? && secondary_step_by_steps.count === 1
118
+ !primary_step_by_steps? && secondary_step_by_step? && secondary_step_by_steps.count == 1
119
119
  end
120
120
 
121
121
  def show_related_links_for_secondary_step_by_steps?
@@ -54,7 +54,7 @@ module GovukPublishingComponents
54
54
  end
55
55
 
56
56
  def construct_section_heading(section_title)
57
- unless section_title === "related_items"
57
+ unless section_title == "related_items"
58
58
  I18n.t("components.related_#{@context}_navigation." + section_title,
59
59
  default: [
60
60
  I18n.t("components.related_navigation." + section_title),
@@ -232,13 +232,13 @@ module GovukPublishingComponents
232
232
  links = links.find_all { |link| link["document_type"] == only }
233
233
  end
234
234
 
235
- links.map { |link|
235
+ links.map do |link|
236
236
  {
237
237
  path: link["base_path"],
238
238
  text: link["title"],
239
239
  locale: link["locale"],
240
240
  }
241
- }
241
+ end
242
242
  end
243
243
  end
244
244
  end
@@ -17,14 +17,14 @@ module GovukPublishingComponents
17
17
  def get_options
18
18
  return if options.nil?
19
19
 
20
- options.map { |option|
20
+ options.map do |option|
21
21
  @selected_option = option[:value] if option[:selected]
22
22
  [
23
23
  option[:text],
24
24
  option[:value],
25
25
  options_data_attribute(option[:data_attributes]),
26
26
  ]
27
- }
27
+ end
28
28
  end
29
29
 
30
30
  def options_data_attribute(attributes)
@@ -40,7 +40,7 @@ module GovukPublishingComponents
40
40
  length: element[:contents].length,
41
41
  },
42
42
  ) do
43
- element[:contents].collect { |contents|
43
+ element[:contents].collect do |contents|
44
44
  concat(
45
45
  content_tag(
46
46
  :li,
@@ -49,7 +49,7 @@ module GovukPublishingComponents
49
49
  create_list_item_content(contents)
50
50
  end,
51
51
  )
52
- }
52
+ end
53
53
  end
54
54
  end
55
55
 
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.45.0".freeze
2
+ VERSION = "21.46.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.45.0
4
+ version: 21.46.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-05-06 00:00:00.000000000 Z
11
+ date: 2020-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters
@@ -108,34 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: sass
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '='
116
- - !ruby/object:Gem::Version
117
- version: 3.7.4
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '='
123
- - !ruby/object:Gem::Version
124
- version: 3.7.4
125
- - !ruby/object:Gem::Dependency
126
- name: sassc-rails
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: 2.0.1
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: 2.0.1
139
111
  - !ruby/object:Gem::Dependency
140
112
  name: sprockets
141
113
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +248,20 @@ dependencies:
276
248
  - - "~>"
277
249
  - !ruby/object:Gem::Version
278
250
  version: '3'
251
+ - !ruby/object:Gem::Dependency
252
+ name: sassc-rails
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '2'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '2'
279
265
  - !ruby/object:Gem::Dependency
280
266
  name: selenium-webdriver
281
267
  requirement: !ruby/object:Gem::Requirement