govuk_publishing_components 45.1.0 → 45.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +1 -0
- data/app/views/govuk_publishing_components/components/_error_message.html.erb +6 -4
- data/app/views/govuk_publishing_components/components/_feedback.html.erb +7 -4
- data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/_radio.html.erb +6 -4
- data/app/views/govuk_publishing_components/components/docs/error_message.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/feedback.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +12 -1
- data/app/views/govuk_publishing_components/components/docs/radio.yml +1 -0
- data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +16 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f938838d6305407995b5a36bad862a8fe5d802bbbef0ac614a79d85c9588b48e
|
4
|
+
data.tar.gz: 3e1b2395dade924fd5a57441818beeb2b809bfa6c260c694c1e5611c5c0eaaf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dd6560730fd2aaf23ad8bad8d2fa6b16576a9d1f2d4cfaf2182cee0b53531171796d494e25b1f7c614558ffc003bbd4c1de5882203ebda1526c5d763c2e1cb0
|
7
|
+
data.tar.gz: b0d5aab888e3ac4e3de918e3685fbe092e7adb5c77e7f220b8457e9f289109fdbee67bce72502d3411b2fe00b588f4b4972ac2ff63a29bb6d3d9f759f4ade86c
|
@@ -13,6 +13,7 @@ This component uses the component wrapper helper. It accepts the following optio
|
|
13
13
|
- `open` - accepts an open attribute value (true or false)
|
14
14
|
- `hidden` - accepts an empty string, 'hidden', or 'until-found'
|
15
15
|
- `tabindex` - accepts an integer. The integer can also be passed as a string.
|
16
|
+
- `dir` - accepts 'rtl', 'ltr', or 'auto'.
|
16
17
|
"
|
17
18
|
end
|
18
19
|
end
|
@@ -2,9 +2,6 @@
|
|
2
2
|
add_gem_component_stylesheet("error-message")
|
3
3
|
|
4
4
|
id ||= "error-message-#{SecureRandom.hex(4)}"
|
5
|
-
classes ||= ''
|
6
|
-
css_classes = %w( gem-c-error-message govuk-error-message )
|
7
|
-
css_classes << classes if classes
|
8
5
|
items ||= []
|
9
6
|
right_to_left ||= false
|
10
7
|
|
@@ -12,7 +9,12 @@
|
|
12
9
|
errors = items.map { |item| capture { item[:text] } }
|
13
10
|
text = raw(errors.join("<br />"))
|
14
11
|
end
|
12
|
+
|
13
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
14
|
+
component_helper.set_id(id)
|
15
|
+
component_helper.add_class("gem-c-error-message govuk-error-message")
|
16
|
+
component_helper.set_dir("rtl") if right_to_left
|
15
17
|
%>
|
16
|
-
<%= tag.p
|
18
|
+
<%= tag.p(**component_helper.all_attributes) do %>
|
17
19
|
<span class="govuk-visually-hidden">Error:</span> <%= text %>
|
18
20
|
<% end %>
|
@@ -11,12 +11,15 @@
|
|
11
11
|
path_without_pii = utf_encode(request.fullpath.gsub(email_regex, '[email]'))
|
12
12
|
|
13
13
|
disable_ga4 ||= false
|
14
|
-
|
15
|
-
|
14
|
+
|
15
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
16
|
+
component_helper.add_class("gem-c-feedback govuk-!-display-none-print")
|
17
|
+
component_helper.add_data_attribute({ module: "feedback" })
|
18
|
+
component_helper.add_data_attribute({ module: "ga4-event-tracker" }) unless disable_ga4
|
16
19
|
%>
|
17
20
|
|
18
|
-
|
21
|
+
<%= tag.div(**component_helper.all_attributes) do %>
|
19
22
|
<%= render "govuk_publishing_components/components/feedback/yes_no_banner", disable_ga4: %>
|
20
23
|
<%= render "govuk_publishing_components/components/feedback/problem_form", url_without_pii: url_without_pii, disable_ga4: %>
|
21
24
|
<%= render "govuk_publishing_components/components/feedback/survey_signup_form", path_without_pii: path_without_pii, disable_ga4: %>
|
22
|
-
|
25
|
+
<% end %>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%
|
2
2
|
add_gem_component_stylesheet("layout-for-public")
|
3
3
|
|
4
|
+
for_static ||= false
|
4
5
|
emergency_banner ||= nil
|
5
6
|
full_width ||= false
|
6
7
|
blue_bar ||= local_assigns.include?(:blue_bar) ? local_assigns[:blue_bar] : !full_width
|
@@ -160,13 +161,15 @@
|
|
160
161
|
<% end %>
|
161
162
|
<% elsif custom_layout %>
|
162
163
|
<%= yield %>
|
163
|
-
<%
|
164
|
+
<% elsif for_static %>
|
164
165
|
<div id="wrapper" class="<%= "govuk-width-container" unless full_width %>">
|
165
166
|
<%= yield :before_content %>
|
166
167
|
<main class="govuk-main-wrapper" id="content">
|
167
168
|
<%= yield %>
|
168
169
|
</main>
|
169
170
|
</div>
|
171
|
+
<% else %>
|
172
|
+
<%= yield %>
|
170
173
|
<% end %>
|
171
174
|
|
172
175
|
<% unless omit_feedback_form %>
|
@@ -37,9 +37,11 @@
|
|
37
37
|
hint_id = "hint-#{SecureRandom.hex(4)}" if hint
|
38
38
|
error_id = "error-#{SecureRandom.hex(4)}"
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
41
|
+
component_helper.add_class("govuk-form-group")
|
42
|
+
component_helper.add_class("govuk-form-group--error") if has_error
|
43
|
+
component_helper.add_class(shared_helper.get_margin_bottom)
|
44
|
+
component_helper.set_id(id)
|
43
45
|
|
44
46
|
radio_classes = %w(govuk-radios)
|
45
47
|
radio_classes << "govuk-radios--small" if small
|
@@ -54,7 +56,7 @@
|
|
54
56
|
# check if any item is set as being conditional
|
55
57
|
has_conditional = items.any? { |item| item.is_a?(Hash) && item[:conditional] }
|
56
58
|
%>
|
57
|
-
<%= tag.div
|
59
|
+
<%= tag.div(**component_helper.all_attributes) do %>
|
58
60
|
<%= tag.fieldset class: "govuk-fieldset", "aria-describedby": aria do %>
|
59
61
|
<% if heading.present? %>
|
60
62
|
<%= tag.legend class: legend_classes do %>
|
@@ -10,6 +10,7 @@ accessibility_criteria: |
|
|
10
10
|
- be associated with an input. The `error_message_id` must match the `aria-describedby` property on the input your label is associated with. Note that if `id` is not passed to the component an id will be generated automatically.
|
11
11
|
|
12
12
|
If error message is within a label it will be announced in its entirety by screen readers. By associating error messages with inputs using `aria-describedby`, then screen readers will read the label, describe the type of input (eg radio) and then read additional text. It means users of screen readers can scan and skip options as easy as people making choices with sight.
|
13
|
+
uses_component_wrapper_helper: true
|
13
14
|
examples:
|
14
15
|
default:
|
15
16
|
data:
|
@@ -4,6 +4,7 @@ body: |
|
|
4
4
|
This component is designed to sit at the bottom of pages on GOV.UK to allow users to submit feedback on that page.
|
5
5
|
|
6
6
|
This component uses JavaScript for expanding and collapsing and also for submitting form responses. This code is not compatible with Internet Explorer, so IE11 and down do not use JavaScript to submit the forms, instead falling back to a normal form submission.
|
7
|
+
uses_component_wrapper_helper: true
|
7
8
|
accessibility_criteria: |
|
8
9
|
The form must:
|
9
10
|
|
@@ -17,9 +17,19 @@ examples:
|
|
17
17
|
title: 'Example layout'
|
18
18
|
block: |
|
19
19
|
<h1>Page content goes here</h1>
|
20
|
+
with_static_wrapper:
|
21
|
+
description: |
|
22
|
+
By default, the layout does not include the `div#wrapper` element, nor the `main` element within that.
|
23
|
+
This behaviour is peculiar to the one app that currently uses this layout - static. Static now sets the `for_static: true` flag,
|
24
|
+
which causes the wrapper to be included. Other apps in the future will not set that flag, but provide their own wrapper and main elements.
|
25
|
+
data:
|
26
|
+
for_static: true
|
27
|
+
block: |
|
28
|
+
<h1>Page content goes here</h1>
|
20
29
|
full_width:
|
21
|
-
description: By default, the layout applies the `govuk-width-container` class to the main element. We can remove this class by setting `full_width` to `true
|
30
|
+
description: By default, the layout applies the `govuk-width-container` class to the main element. We can remove this class by setting `full_width` to `true`. Note this also requires the for_static flag, since that is needed for the main element.
|
22
31
|
data:
|
32
|
+
for_static: true
|
23
33
|
full_width: true
|
24
34
|
block: |
|
25
35
|
<h1>Page content goes here</h1>
|
@@ -30,6 +40,7 @@ examples:
|
|
30
40
|
blue_bar_background:
|
31
41
|
description: For use when a page has a heading component with a background colour.
|
32
42
|
data:
|
43
|
+
for_static: true
|
33
44
|
full_width: true
|
34
45
|
blue_bar: true
|
35
46
|
blue_bar_background_colour: "no"
|
@@ -4,6 +4,7 @@ body: |
|
|
4
4
|
You can also use 'or' as an item to break up radios.
|
5
5
|
|
6
6
|
If JavaScript is disabled a conditionally revealed content expands fully. All of the functionality (including aria attributes) are added using JavaScript.
|
7
|
+
uses_component_wrapper_helper: true
|
7
8
|
accessibility_criteria: |
|
8
9
|
Radio buttons should
|
9
10
|
|
@@ -13,6 +13,7 @@ module GovukPublishingComponents
|
|
13
13
|
check_open_is_valid(@options[:open]) if @options.include?(:open)
|
14
14
|
check_hidden_is_valid(@options[:hidden]) if @options.include?(:hidden)
|
15
15
|
check_tabindex_is_valid(@options[:tabindex]) if @options.include?(:tabindex)
|
16
|
+
check_dir_is_valid(@options[:dir]) if @options.include?(:dir)
|
16
17
|
end
|
17
18
|
|
18
19
|
def all_attributes
|
@@ -27,6 +28,7 @@ module GovukPublishingComponents
|
|
27
28
|
attributes[:open] = @options[:open] unless @options[:open].blank?
|
28
29
|
attributes[:hidden] = @options[:hidden] unless @options[:hidden].nil?
|
29
30
|
attributes[:tabindex] = @options[:tabindex] unless @options[:tabindex].blank?
|
31
|
+
attributes[:dir] = @options[:dir] unless @options[:dir].blank?
|
30
32
|
|
31
33
|
attributes
|
32
34
|
end
|
@@ -76,6 +78,11 @@ module GovukPublishingComponents
|
|
76
78
|
@options[:tabindex] = tabindex_attribute
|
77
79
|
end
|
78
80
|
|
81
|
+
def set_dir(dir_attribute)
|
82
|
+
check_dir_is_valid(dir_attribute)
|
83
|
+
@options[:dir] = dir_attribute
|
84
|
+
end
|
85
|
+
|
79
86
|
private
|
80
87
|
|
81
88
|
def check_id_is_valid(id)
|
@@ -163,6 +170,15 @@ module GovukPublishingComponents
|
|
163
170
|
end
|
164
171
|
end
|
165
172
|
|
173
|
+
def check_dir_is_valid(dir_attribute)
|
174
|
+
return if dir_attribute.nil?
|
175
|
+
|
176
|
+
options = %w[ltr rtl auto]
|
177
|
+
unless options.include? dir_attribute
|
178
|
+
raise(ArgumentError, "dir attribute (#{dir_attribute}) is not recognised")
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
166
182
|
def extend_string(option, string)
|
167
183
|
((@options[option] ||= "") << " #{string}").strip!
|
168
184
|
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: 45.
|
4
|
+
version: 45.2.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: 2024-11-
|
11
|
+
date: 2024-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|