govuk_publishing_components 13.3.0 → 13.4.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: ad57d157c8db11024f51b94c8748da31734480431e8ee77146729150759e381e
4
- data.tar.gz: 9b9986abd051efb7755a4ce076c97a2a86a1a59b495e7117541bd931a288ae88
3
+ metadata.gz: 6aed21bd6fa1e23add3b93c2aa01e7b030d8de8453b38b928c145c72c4d218fc
4
+ data.tar.gz: 62d586c29c3258e7c0ed912747eaa966febab77cc2dc6b06d53db760afa55a35
5
5
  SHA512:
6
- metadata.gz: d52e91705cc31ee3c1fc9c5bc7245c06ed94e62dfde2927314b8d08e409e59643529a08a32d9d76cd580d283d092bfdcccb6fc5b53b8a8bf6c80605f467a630e
7
- data.tar.gz: 3ea49edf3cc68d857147a584a18a7a1152d56b8515843c6617a4265489bcf79599490c3a896d17461b6f2ac48446484e19626e8108257e4234c93c713509a385
6
+ metadata.gz: 79ea00580b5ec71f62bb73fa73375279378041c834b8955ed9c9764e7ff779662fbf63a9bc892f7966b4a8543bcb3563c3f6f07641ec0b476c0cca51e70866ee
7
+ data.tar.gz: 89840dc3a094b510398f5cb407e68517b10bebfb6a4f02e5a41931e31c4cb7cf60f58d3e85c0bee16e571a43a4af59c34f13d78b745dd1f69577600aea9927f8
@@ -50,4 +50,8 @@
50
50
  .govuk-label:not(.govuk-label--m):not(.govuk-label--l):not(.govuk-label--xl) + .govuk-hint {
51
51
  margin-bottom: 0;
52
52
  }
53
+
54
+ .gem-c-checkboxes__legend--hidden {
55
+ @include govuk-visually-hidden();
56
+ }
53
57
  }
@@ -8,43 +8,45 @@
8
8
  <%= cb_helper.checkbox_markup(cb_helper.items[0], 0) %>
9
9
 
10
10
  <% else %>
11
- <%= tag.fieldset class: "govuk-fieldset", "aria-describedby": cb_helper.fieldset_describedby do %>
12
- <%= cb_helper.heading_markup %>
11
+ <% if cb_helper.heading_markup %>
12
+ <%= tag.fieldset class: "govuk-fieldset", "aria-describedby": cb_helper.fieldset_describedby do %>
13
+ <%= cb_helper.heading_markup %>
13
14
 
14
- <% if cb_helper.hint_text %>
15
- <%= tag.span cb_helper.hint_text, id: "#{id}-hint", class: "govuk-hint" %>
16
- <% end %>
15
+ <% if cb_helper.hint_text %>
16
+ <%= tag.span cb_helper.hint_text, id: "#{id}-hint", class: "govuk-hint" %>
17
+ <% end %>
17
18
 
18
- <% if cb_helper.error %>
19
- <%= tag.span error, id: "#{id}-error", class: "govuk-error-message" %>
20
- <% end %>
19
+ <% if cb_helper.error %>
20
+ <%= tag.span error, id: "#{id}-error", class: "govuk-error-message" %>
21
+ <% end %>
21
22
 
22
- <%= tag.ul class: "govuk-checkboxes gem-c-checkboxes__list", data: {
23
- module: ('checkboxes' if cb_helper.has_conditional),
24
- nested: ('true' if cb_helper.has_nested),
25
- } do %>
26
- <% cb_helper.items.each_with_index do |item, index| %>
27
- <%= tag.li class: "gem-c-checkboxes__list-item" do %>
28
- <%= cb_helper.checkbox_markup(item, index) %>
23
+ <%= tag.ul class: "govuk-checkboxes gem-c-checkboxes__list", data: {
24
+ module: ('checkboxes' if cb_helper.has_conditional),
25
+ nested: ('true' if cb_helper.has_nested),
26
+ } do %>
27
+ <% cb_helper.items.each_with_index do |item, index| %>
28
+ <%= tag.li class: "gem-c-checkboxes__list-item" do %>
29
+ <%= cb_helper.checkbox_markup(item, index) %>
29
30
 
30
- <% if item[:conditional] %>
31
- <%= tag.div item[:conditional], id: "#{id}-#{index}-conditional-#{index}", class: "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" %>
32
- <% end %>
31
+ <% if item[:conditional] %>
32
+ <%= tag.div item[:conditional], id: "#{id}-#{index}-conditional-#{index}", class: "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" %>
33
+ <% end %>
33
34
 
34
- <% if item[:items].present? %>
35
- <%= tag.ul id: "#{id}-nested-#{index}", class: "govuk-checkboxes govuk-checkboxes--nested", data: { parent: "#{id}-#{index}" } do %>
36
- <% item[:items].each_with_index do |nested_item, nested_index| %>
37
- <%= tag.li class: "gem-c-checkboxes__list-item" do %>
38
- <%= cb_helper.checkbox_markup(nested_item, "#{index}-#{nested_index}") %>
35
+ <% if item[:items].present? %>
36
+ <%= tag.ul id: "#{id}-nested-#{index}", class: "govuk-checkboxes govuk-checkboxes--nested", data: { parent: "#{id}-#{index}" } do %>
37
+ <% item[:items].each_with_index do |nested_item, nested_index| %>
38
+ <%= tag.li class: "gem-c-checkboxes__list-item" do %>
39
+ <%= cb_helper.checkbox_markup(nested_item, "#{index}-#{nested_index}") %>
40
+ <% end %>
39
41
  <% end %>
40
42
  <% end %>
41
43
  <% end %>
42
- <% end %>
43
44
 
45
+ <% end %>
44
46
  <% end %>
45
47
  <% end %>
46
- <% end %>
47
48
 
49
+ <% end %>
48
50
  <% end %>
49
51
  <% end %>
50
52
  <% end %>
@@ -35,6 +35,19 @@ examples:
35
35
  value: "green"
36
36
  - label: "Blue"
37
37
  value: "blue"
38
+ with_a_hidden_heading:
39
+ description: If the heading/legend on the checkboxes is not required, it can be visually hidden using this option. It will still be visible to screen readers.
40
+ data:
41
+ name: "favourite_colour"
42
+ heading: "What is your favourite colour?"
43
+ visually_hide_heading: true
44
+ items:
45
+ - label: "Red"
46
+ value: "red"
47
+ - label: "Green"
48
+ value: "green"
49
+ - label: "Blue"
50
+ value: "blue"
38
51
  with_a_custom_id_attribute:
39
52
  description: Note that if an id is not given one is generated automatically. In either case, the id is applied to the parent element of the checkboxes, and each checkbox is given the same id with an incremented number at the end, e.g. the checkboxes below have ids of potatoes-0 and potatoes-1.
40
53
  data:
@@ -59,7 +72,7 @@ examples:
59
72
  - label: "Purple"
60
73
  value: "purple"
61
74
  with_custom_hint_text:
62
- description: Note that a hint (and a heading) is only displayed if there is more than one checkbox.
75
+ description: Hint text defaults to 'Select all that apply' but can be overridden with this option. Note that a hint (and a heading) is only displayed if there is more than one checkbox.
63
76
  data:
64
77
  name: "favourite_skittle"
65
78
  heading: "What is your favourite skittle?"
@@ -71,6 +84,18 @@ examples:
71
84
  value: "green"
72
85
  - label: "Blue"
73
86
  value: "blue"
87
+ without_hint_text:
88
+ description: Hint text can be removed entirely with this option. Note that this option can be combined with the visually_hide_heading option, as shown.
89
+ data:
90
+ name: "favourite_skittle"
91
+ heading: "What is your favourite skittle?"
92
+ visually_hide_heading: true
93
+ no_hint_text: true
94
+ items:
95
+ - label: "Mauve"
96
+ value: "mauve"
97
+ - label: "Sunset orange"
98
+ value: "sunsetorange"
74
99
  with_legend_as_page_heading:
75
100
  description: Since the legend/heading is required, if the checkboxes are alone on a page it makes sense to use this element as the H1 on the page rather than duplicate text.
76
101
  data:
@@ -20,14 +20,18 @@ module GovukPublishingComponents
20
20
  @id = options[:id] || "checkboxes-#{SecureRandom.hex(4)}"
21
21
  @heading = options[:heading]
22
22
  @is_page_heading = options[:is_page_heading]
23
- @hint_text = options[:hint_text] || "Select all that apply."
23
+ @no_hint_text = options[:no_hint_text]
24
+ @hint_text = options[:hint_text] || "Select all that apply." unless @no_hint_text
25
+ @visually_hide_heading = options[:visually_hide_heading]
24
26
  end
25
27
 
26
28
  def fieldset_describedby
27
- text = %w()
28
- text << "#{id}-hint" if @hint_text
29
- text << "#{id}-error" if @error
30
- text
29
+ unless @no_hint_text
30
+ text = %w()
31
+ text << "#{id}-hint" if @hint_text
32
+ text << "#{id}-error" if @error
33
+ text
34
+ end
31
35
  end
32
36
 
33
37
  def heading_markup
@@ -41,7 +45,10 @@ module GovukPublishingComponents
41
45
  content_tag(:h1, @heading, class: "gem-c-title__text")
42
46
  end
43
47
  else
44
- content_tag(:legend, @heading, class: "govuk-fieldset__legend govuk-fieldset__legend--m")
48
+ classes = %w(govuk-fieldset__legend govuk-fieldset__legend--m)
49
+ classes << "gem-c-checkboxes__legend--hidden" if @visually_hide_heading
50
+
51
+ content_tag(:legend, @heading, class: classes)
45
52
  end
46
53
  end
47
54
 
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '13.3.0'.freeze
2
+ VERSION = '13.4.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: 13.3.0
4
+ version: 13.4.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-12-19 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govspeak