govuk_publishing_components 12.12.1 → 12.13.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: 5b13a00475042ebd34c43e8950fa268c17eed67c18dd465d20dab324b3bc886d
4
- data.tar.gz: edb4159464208a56730f5c9a123778c6ca717be855ce8451773d06b170ce4492
3
+ metadata.gz: acaa0a2707fc4755d1cd27cb0bcff4ffaf43184142c9d830893c9a31b2009ae4
4
+ data.tar.gz: fde7f8260325a8f34892ae1172ee6aa08d9a8f80b6eca75b22fcda3e10a2ceee
5
5
  SHA512:
6
- metadata.gz: 69004560351e1073fbe2c86e808c3e3256cdd8917a2fa5d9ea417cc42d733a77a80f2d032c91b51b3bbce6477035ba2474ac64870ba7c62fc966026bf9fb146e
7
- data.tar.gz: b88f74f26fc4bb51a45d1b1c5aa5909fbed93c78c26c170f5f9d8bffe3bd146e4788ed467bf62bb0c0e0551f58614e237acc295e70705c2a7493a0809aa4caa8
6
+ metadata.gz: 4da5ff851b5f138306729313d500f1449b4e6a74d0926e12b4c65282ca01ce4212a269ce9e3252673071f17cd43b6052af77daac3796dfe295306518640bf9ef
7
+ data.tar.gz: d89afaec0bb2b5ef4083acc885869c17be60a455602570abe1ffe563aded1ed704786b33dd6a19dab52a2b1e480a9ee8187eed444376f2e7aa8286a6c1f7e5de
@@ -3,91 +3,109 @@
3
3
  items ||= []
4
4
 
5
5
  label ||= nil
6
+ heading ||= nil
7
+ is_page_heading ||= false
6
8
  hint ||= nil
7
9
  error_message ||= nil
8
10
  error_items ||= nil
11
+
9
12
  has_error = error_message || error_items&.any?
10
- hint_id = "hint-#{SecureRandom.hex(4)}"
13
+ hint_id = "hint-#{SecureRandom.hex(4)}" if hint
11
14
  error_id = "error-#{SecureRandom.hex(4)}"
12
15
 
13
16
  form_group_css_classes = %w(govuk-form-group)
14
17
  form_group_css_classes << "govuk-form-group--error" if has_error
15
18
 
19
+ aria = "#{hint_id} #{"#{error_id}" if has_error}".strip if hint or has_error
20
+
16
21
  # check if any item is set as being conditional
17
22
  has_conditional = items.any? { |item| item.is_a?(Hash) && item[:conditional] }
18
23
  %>
19
24
  <%= content_tag :div, class: form_group_css_classes do %>
25
+ <%= tag.fieldset class: "govuk-fieldset", "aria-describedby": aria do %>
20
26
 
21
- <% if hint %>
22
- <%= render "govuk_publishing_components/components/hint", {
23
- id: hint_id,
24
- text: hint
25
- } %>
26
- <% end %>
27
+ <% if heading.present? %>
28
+ <% if is_page_heading %>
29
+ <%= tag.legend class: "govuk-fieldset__legend govuk-fieldset__legend--xl gem-c-title gem-c-title--margin-bottom-5" do %>
30
+ <%= tag.h1 heading, class: "gem-c-title__text" %>
31
+ <% end %>
32
+ <% else %>
33
+ <%= tag.legend heading, class: "govuk-fieldset__legend govuk-fieldset__legend--m" %>
34
+ <% end %>
35
+ <% end %>
27
36
 
28
- <% if error_message %>
29
- <%= render "govuk_publishing_components/components/error_message", {
30
- id: error_id,
31
- text: error_message
32
- } %>
33
- <% elsif error_items %>
34
- <%= render "govuk_publishing_components/components/error_message", {
35
- id: error_id,
36
- text: raw(error_items.map { |item| item[:text] }.join("<br/>"))
37
- } %>
38
- <% end %>
37
+ <% if hint %>
38
+ <%= render "govuk_publishing_components/components/hint", {
39
+ id: hint_id,
40
+ text: hint
41
+ } %>
42
+ <% end %>
39
43
 
40
- <%= content_tag :div, class: "govuk-radios",
41
- data: {
42
- module: ('radios' if has_conditional)
43
- } do %>
44
- <% items.each_with_index do |item, index| %>
45
- <% if item === :or %>
46
- <div class="gem-c-radios__divider govuk-radios__divider">
47
- <%= t('components.radio.or') %>
48
- </div>
49
- <% else %>
50
- <%
51
- item_next = items[index + 1] unless index === items.size - 1
52
- label_id = item[:id] ? item[:id] : "#{id_prefix}-#{index}"
53
- label_hint_id = "label-hint-#{SecureRandom.hex(4)}" if item[:hint_text].present?
54
- conditional_id = "conditional-#{SecureRandom.hex(4)}" if item[:conditional].present?
44
+ <% if error_message %>
45
+ <%= render "govuk_publishing_components/components/error_message", {
46
+ id: error_id,
47
+ text: error_message
48
+ } %>
49
+ <% elsif error_items %>
50
+ <%= render "govuk_publishing_components/components/error_message", {
51
+ id: error_id,
52
+ text: raw(error_items.map { |item| item[:text] }.join("<br/>"))
53
+ } %>
54
+ <% end %>
55
+
56
+ <%= content_tag :div, class: "govuk-radios",
57
+ data: {
58
+ module: ('radios' if has_conditional)
59
+ } do %>
60
+ <% items.each_with_index do |item, index| %>
61
+ <% if item === :or %>
62
+ <div class="gem-c-radios__divider govuk-radios__divider">
63
+ <%= t('components.radio.or') %>
64
+ </div>
65
+ <% else %>
66
+ <%
67
+ item_next = items[index + 1] unless index === items.size - 1
68
+ label_id = item[:id] ? item[:id] : "#{id_prefix}-#{index}"
69
+ label_hint_id = "label-hint-#{SecureRandom.hex(4)}" if item[:hint_text].present?
70
+ conditional_id = "conditional-#{SecureRandom.hex(4)}" if item[:conditional].present?
55
71
 
56
- data_attrs = { "aria-controls": conditional_id }
57
- data_attrs["tracking-url"] = item[:url] if item.key?(:url)
58
- %>
59
- <%= tag.div class: %w( gem-c-radio govuk-radios__item ) do %>
60
- <%= check_box_tag name,
61
- item[:value],
62
- item[:checked],
63
- {
64
- class: "govuk-radios__input",
65
- id: label_id,
66
- type: "radio",
67
- aria: {
68
- describedby: label_hint_id
69
- },
70
- data: data_attrs,
71
- }
72
+ data_attrs = { "aria-controls": conditional_id }
73
+ data_attrs["tracking-url"] = item[:url] if item.key?(:url)
72
74
  %>
73
- <%= render "govuk_publishing_components/components/label", {
74
- hint_id: label_hint_id,
75
- html_for: label_id,
76
- classes: "govuk-radios__label",
77
- hint_text_classes: "govuk-radios__hint",
78
- hint_text: item[:hint_text],
79
- text: item[:text],
80
- bold: item[:bold]
81
- } %>
82
- <% end %>
75
+ <%= tag.div class: %w( gem-c-radio govuk-radios__item ) do %>
76
+ <%= check_box_tag name,
77
+ item[:value],
78
+ item[:checked],
79
+ {
80
+ class: "govuk-radios__input",
81
+ id: label_id,
82
+ type: "radio",
83
+ aria: {
84
+ describedby: label_hint_id
85
+ },
86
+ data: data_attrs,
87
+ }
88
+ %>
89
+ <%= render "govuk_publishing_components/components/label", {
90
+ hint_id: label_hint_id,
91
+ html_for: label_id,
92
+ classes: "govuk-radios__label",
93
+ hint_text_classes: "govuk-radios__hint",
94
+ hint_text: item[:hint_text],
95
+ text: item[:text],
96
+ bold: item[:bold]
97
+ } %>
98
+ <% end %>
83
99
 
84
- <% if item[:conditional] %>
85
- <div class="govuk-radios__conditional" id="<%= conditional_id %>">
86
- <%= item[:conditional] %>
87
- </div>
88
- <% end %>
100
+ <% if item[:conditional] %>
101
+ <div class="govuk-radios__conditional" id="<%= conditional_id %>">
102
+ <%= item[:conditional] %>
103
+ </div>
104
+ <% end %>
89
105
 
106
+ <% end %>
90
107
  <% end %>
91
108
  <% end %>
109
+
92
110
  <% end %>
93
111
  <% end %>
@@ -57,7 +57,61 @@ examples:
57
57
  text: "Use GOV.UK Verify"
58
58
  hint_text: "You'll have an account if you've already proved your identity with a certified company, such as the Post Office."
59
59
  bold: true
60
- with_hint_text:
60
+ with_hint_on_form_group:
61
+ data:
62
+ name: "radio-group-error"
63
+ id_prefix: "hint"
64
+ hint: "You’ll need to prove your identity using one of the following methods"
65
+ items:
66
+ - value: "government-gateway"
67
+ text: "Use Government Gateway"
68
+ - value: "govuk-verify"
69
+ text: "Use GOV.UK Verify"
70
+ with_heading:
71
+ description: This adds a legend element containing the text supplied.
72
+ data:
73
+ name: "radio-group-heading"
74
+ heading: "Are you hungry?"
75
+ items:
76
+ - value: "yes"
77
+ text: "Yes"
78
+ - value: "no"
79
+ text: "No"
80
+ with_heading_and_hint:
81
+ data:
82
+ name: "radio-group-heading"
83
+ heading: "What is your favourite colour?"
84
+ hint: "If your favourite is not below, pick the colour closest to it."
85
+ items:
86
+ - value: "red"
87
+ text: "Red"
88
+ - value: "green"
89
+ text: "Green"
90
+ - value: "blue"
91
+ text: "Blue"
92
+ with_page_heading:
93
+ description: This adds a H1 element containing the text supplied.
94
+ data:
95
+ name: "radio-group-heading"
96
+ heading: "Is it raining?"
97
+ is_page_heading: true
98
+ items:
99
+ - value: "yes"
100
+ text: "Yes"
101
+ - value: "no"
102
+ text: "No"
103
+ with_page_heading_and_hint:
104
+ data:
105
+ name: "radio-group-heading"
106
+ heading: "Is it snowing?"
107
+ is_page_heading: true
108
+ hint: "Sleet or hail doesn’t count."
109
+ items:
110
+ - value: "yes"
111
+ text: "Yes"
112
+ - value: "no"
113
+ text: "No"
114
+ with_hint_text_on_radios:
61
115
  data:
62
116
  name: "radio-group-hint-text"
63
117
  items:
@@ -120,21 +174,23 @@ examples:
120
174
  hint_text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus sapien justo, lobortis elementum tortor in, luctus interdum turpis. Nam sit amet nulla nec arcu condimentum dapibus quis varius metus. Suspendisse cursus tristique diam et vestibulum. Proin nec lacinia tortor. Morbi at nisi id lorem aliquam ullamcorper. Pellentesque laoreet sit amet leo sodales ultricies. Suspendisse maximus efficitur odio in tristique."
121
175
  text: "Quisque tincidunt venenatis bibendum. Morbi volutpat magna euismod ipsum consequat cursus. Etiam bibendum interdum ultricies."
122
176
  bold: true
123
- with_hint_on_form_group:
177
+ with_error_on_form_group:
124
178
  data:
125
179
  name: "radio-group-error"
126
- id_prefix: "hint"
127
- hint: "You’ll need to prove your identity using one of the following methods"
180
+ id_prefix: "error"
181
+ error_message: "Please select one option"
128
182
  items:
129
183
  - value: "government-gateway"
130
184
  text: "Use Government Gateway"
131
185
  - value: "govuk-verify"
132
186
  text: "Use GOV.UK Verify"
133
- with_error_on_form_group:
187
+ with_error_and_hint_on_form_group:
188
+ description: ""
134
189
  data:
135
190
  name: "radio-group-error"
136
191
  id_prefix: "error"
137
192
  error_message: "Please select one option"
193
+ hint: "Choose the option that suits"
138
194
  items:
139
195
  - value: "government-gateway"
140
196
  text: "Use Government Gateway"
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '12.12.1'.freeze
2
+ VERSION = '12.13.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.12.1
4
+ version: 12.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev