govuk_publishing_components 21.51.0 → 21.52.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 +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +13 -4
- data/app/views/govuk_publishing_components/components/_input.html.erb +12 -1
- data/app/views/govuk_publishing_components/components/docs/input.yml +9 -0
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +12 -8
- data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +5 -29
- 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: 234a3be5422d6b92280ef595c69afdaada4ee4864ba5fd41322af61240a96bca
|
4
|
+
data.tar.gz: b0441c7783a3ee2301e778ee718ad6dcfd071210d13e0cf9af9eee9cfc87f49f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29de3cc3fb22c684b8cebede771cd5ff480619def581003a358054d19def4f4f6418bde6f1f4a07d697cbae5a0401981cded033aecea5f370a9175c6a48b7d4d
|
7
|
+
data.tar.gz: 45c2944476356e650e9f5197280af55466bdc3eb80c893572497263b6bb4b7073254e3dfa9716c93b98e0046252dabe26a649c3c935bb1718b0b4131662ac081
|
@@ -31,22 +31,31 @@
|
|
31
31
|
}
|
32
32
|
}
|
33
33
|
|
34
|
+
.gem-c-input__prefix,
|
34
35
|
.gem-c-input__suffix {
|
35
36
|
@include govuk-font($size: 19);
|
36
37
|
|
37
38
|
background-color: govuk-colour("light-grey", $legacy: "grey-3");
|
38
39
|
border: $govuk-border-width-form-element solid $govuk-input-border-colour;
|
39
|
-
border-left: 0;
|
40
40
|
box-sizing: border-box;
|
41
41
|
cursor: default; // emphasise non-editable status of prefixes and suffixes
|
42
42
|
display: inline-block;
|
43
|
-
flex: 0 0 0;
|
44
|
-
padding: govuk-spacing(1);
|
45
43
|
white-space: nowrap;
|
46
44
|
width: auto;
|
45
|
+
text-align: center;
|
47
46
|
height: 40px;
|
47
|
+
padding: govuk-spacing(1);
|
48
|
+
min-width: 40px;
|
48
49
|
@if $govuk-typography-use-rem {
|
49
|
-
|
50
|
+
min-width: govuk-px-to-rem(40px);
|
50
51
|
}
|
51
52
|
margin-top: 0;
|
52
53
|
}
|
54
|
+
|
55
|
+
.gem-c-input__prefix {
|
56
|
+
border-right: 0;
|
57
|
+
}
|
58
|
+
|
59
|
+
.gem-c-input__suffix {
|
60
|
+
border-left: 0;
|
61
|
+
}
|
@@ -22,6 +22,7 @@
|
|
22
22
|
error_id = "error-#{SecureRandom.hex(4)}"
|
23
23
|
search_icon ||= nil
|
24
24
|
heading_size = false unless ['s', 'm', 'l', 'xl'].include?(heading_size)
|
25
|
+
prefix ||= nil
|
25
26
|
suffix ||= nil
|
26
27
|
|
27
28
|
css_classes = %w(gem-c-input govuk-input)
|
@@ -92,7 +93,17 @@
|
|
92
93
|
}
|
93
94
|
%>
|
94
95
|
|
95
|
-
<% if suffix %>
|
96
|
+
<% if prefix && suffix %>
|
97
|
+
<%= tag.div class: "gem-c-input__wrapper" do %>
|
98
|
+
<%= tag.span prefix, class: "gem-c-input__prefix", aria: { hidden: true } %>
|
99
|
+
<%= input_tag %>
|
100
|
+
<%= tag.span suffix, class: "gem-c-input__suffix", aria: { hidden: true } %>
|
101
|
+
<% end %>
|
102
|
+
<% elsif prefix %>
|
103
|
+
<%= tag.div class: "gem-c-input__wrapper" do %>
|
104
|
+
<%= tag.span prefix, class: "gem-c-input__prefix", aria: { hidden: true } %><%= input_tag %>
|
105
|
+
<% end %>
|
106
|
+
<% elsif suffix %>
|
96
107
|
<%= tag.div class: "gem-c-input__wrapper" do %>
|
97
108
|
<%= input_tag %><%= tag.span suffix, class: "gem-c-input__suffix", aria: { hidden: true } %>
|
98
109
|
<% end %>
|
@@ -140,6 +140,15 @@ examples:
|
|
140
140
|
name: "lead-times"
|
141
141
|
width: 10
|
142
142
|
suffix: "days"
|
143
|
+
with_prefix_and_suffix:
|
144
|
+
description: To help users understand how the input should look like. Often used for units of measurement.
|
145
|
+
data:
|
146
|
+
label:
|
147
|
+
text: "Cost per item, in pounds"
|
148
|
+
name: "Cost-per-item"
|
149
|
+
width: 10
|
150
|
+
prefix: "£"
|
151
|
+
suffix: "per item"
|
143
152
|
with_suffix_and_error:
|
144
153
|
description: To help users understand how the input should look like. Often used for units of measurement.
|
145
154
|
data:
|
@@ -27,16 +27,20 @@ module GovukPublishingComponents
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def priority_taxons
|
30
|
-
taxons = content_item.dig("links", "taxons")
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
taxons = content_item.dig("links", "taxons")
|
31
|
+
taxon_tree(taxons).select do |taxon|
|
32
|
+
priority_taxon?(taxon)
|
34
33
|
end
|
35
|
-
|
34
|
+
end
|
35
|
+
|
36
|
+
def taxon_tree(taxons)
|
37
|
+
return [] if taxons.blank?
|
38
|
+
|
39
|
+
taxons + taxons.flat_map { |taxon| taxon_tree(taxon.dig("links", "parent_taxons")) }
|
40
|
+
end
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
taxons
|
42
|
+
def priority_taxon?(taxon)
|
43
|
+
PRIORITY_TAXONS.values.include?(taxon["content_id"])
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
@@ -58,29 +58,10 @@ module GovukPublishingComponents
|
|
58
58
|
question = page.title
|
59
59
|
|
60
60
|
doc.xpath("html/body").children.each_with_object({}) do |element, q_and_as|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
def recursive_question_and_answers(element, question, q_and_as)
|
66
|
-
if is_a_question?(element)
|
67
|
-
question = element.text
|
68
|
-
q_and_as[question] = { anchor: element["id"] }
|
69
|
-
else
|
70
|
-
q_and_as = add_answer_to_question(q_and_as, element, question)
|
71
|
-
element.children.each do |child_element|
|
72
|
-
if child_element.element?
|
73
|
-
q_and_as, question = recursive_question_and_answers(child_element, question, q_and_as)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
[q_and_as, question]
|
79
|
-
end
|
80
|
-
|
81
|
-
def add_answer_to_question(q_and_as, element, question)
|
82
|
-
if no_questions_in_subtree?(element)
|
83
|
-
if question_hash_is_unset?(q_and_as, question)
|
61
|
+
if question_element?(element)
|
62
|
+
question = element.text
|
63
|
+
q_and_as[question] = { anchor: element["id"] }
|
64
|
+
elsif question_hash_is_unset?(q_and_as, question)
|
84
65
|
q_and_as[question] = { answer: element.to_s }
|
85
66
|
elsif answer_is_unset?(q_and_as, question)
|
86
67
|
q_and_as[question][:answer] = element.to_s
|
@@ -88,11 +69,6 @@ module GovukPublishingComponents
|
|
88
69
|
q_and_as[question][:answer] << element.to_s
|
89
70
|
end
|
90
71
|
end
|
91
|
-
q_and_as
|
92
|
-
end
|
93
|
-
|
94
|
-
def no_questions_in_subtree?(element)
|
95
|
-
element.search(QUESTION_TAG).none?
|
96
72
|
end
|
97
73
|
|
98
74
|
def question_hash_is_unset?(q_and_as, question)
|
@@ -106,7 +82,7 @@ module GovukPublishingComponents
|
|
106
82
|
# we use H2 tags as the "question" and the html between them as the "answer"
|
107
83
|
QUESTION_TAG = "h2".freeze
|
108
84
|
|
109
|
-
def
|
85
|
+
def question_element?(element)
|
110
86
|
element.name == QUESTION_TAG
|
111
87
|
end
|
112
88
|
|
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.
|
4
|
+
version: 21.52.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-
|
11
|
+
date: 2020-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gds-api-adapters
|