govuk_publishing_components 21.49.0 → 21.52.1
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/javascripts/govuk_publishing_components/all_components.js +1 -3
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +3 -0
- data/app/assets/javascripts/govuk_publishing_components/components/button.js +5 -0
- data/app/assets/javascripts/govuk_publishing_components/components/character-count.js +3 -0
- data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +2 -1
- data/app/assets/javascripts/govuk_publishing_components/components/error-summary.js +3 -0
- data/app/assets/javascripts/govuk_publishing_components/components/header.js +5 -0
- data/app/assets/javascripts/govuk_publishing_components/components/radio.js +3 -0
- data/app/assets/javascripts/govuk_publishing_components/components/tabs.js +5 -0
- data/app/assets/javascripts/govuk_publishing_components/lib.js +1 -0
- data/app/assets/javascripts/govuk_publishing_components/modules.js +15 -3
- data/app/assets/stylesheets/component_guide/application.scss +0 -7
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +4 -13
- data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +7 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +13 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_steps.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss +0 -3
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +24 -0
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +8 -1
- data/app/views/govuk_publishing_components/components/_action_link.html.erb +16 -8
- data/app/views/govuk_publishing_components/components/_input.html.erb +12 -1
- data/app/views/govuk_publishing_components/components/_select.html.erb +6 -1
- data/app/views/govuk_publishing_components/components/docs/input.yml +9 -0
- data/app/views/govuk_publishing_components/components/docs/select.yml +12 -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 +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 65eb0fccf1664b1adcf30dd55e74c36e06f066c820af124c0552d44ebbe78d31
|
|
4
|
+
data.tar.gz: e9b31f220f80191550b6e4674b29971dea1a1caf707ef586733cb13b42137642
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a28ae072f25f52aa4c900228f8e12f0939de188df0d47aa74d594fc43eb57d4bf180413a7e902a82a9aacec8d5747dc2c4f124a762a39edd44684693ecad0b3a
|
|
7
|
+
data.tar.gz: b8501ea511d02c48db9b3fa4ffa27c7db8178caf5c427dcc6b74adedfaba54a006695df9cf13153fec95507ef10bf2be557cca4a2e089fdfbc4ae5c5c35bad75
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
// This component relies on JavaScript from GOV.UK Frontend
|
|
2
2
|
// = require govuk/components/character-count/character-count.js
|
|
3
|
+
window.GOVUK = window.GOVUK || {}
|
|
4
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {}
|
|
5
|
+
window.GOVUK.Modules.CharacterCount = window.GOVUKFrontend
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-env jquery */
|
|
2
2
|
// = require govuk/components/checkboxes/checkboxes.js
|
|
3
3
|
window.GOVUK = window.GOVUK || {}
|
|
4
|
-
window.GOVUK.Modules = window.GOVUK.Modules || {}
|
|
4
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {}
|
|
5
|
+
window.GOVUK.Modules.Checkboxes = window.GOVUKFrontend;
|
|
5
6
|
|
|
6
7
|
(function (Modules) {
|
|
7
8
|
'use strict'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// = require_tree ./lib
|
|
@@ -28,13 +28,25 @@
|
|
|
28
28
|
for (var i = 0, l = modules.length; i < l; i++) {
|
|
29
29
|
var module
|
|
30
30
|
var element = $(modules[i])
|
|
31
|
-
var
|
|
31
|
+
var moduleName = camelCaseAndCapitalise(element.data('module'))
|
|
32
32
|
var started = element.data('module-started')
|
|
33
|
+
var frontendModuleName = moduleName.replace('Govuk', '')
|
|
33
34
|
|
|
34
|
-
if (
|
|
35
|
-
|
|
35
|
+
if ( // GOV.UK Publishing & Legacy Modules
|
|
36
|
+
typeof GOVUK.Modules[moduleName] === 'function' &&
|
|
37
|
+
!GOVUK.Modules[moduleName].prototype.init &&
|
|
38
|
+
!started
|
|
39
|
+
) {
|
|
40
|
+
module = new GOVUK.Modules[moduleName]()
|
|
36
41
|
module.start(element)
|
|
37
42
|
element.data('module-started', true)
|
|
43
|
+
} else if ( // GOV.UK Frontend Modules
|
|
44
|
+
typeof GOVUK.Modules[frontendModuleName] === 'function' &&
|
|
45
|
+
GOVUK.Modules[frontendModuleName].prototype.init &&
|
|
46
|
+
!started
|
|
47
|
+
) {
|
|
48
|
+
module = new GOVUK.Modules[frontendModuleName](element[0]).init()
|
|
49
|
+
element.data('module-started', true)
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
52
|
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
// This file contains the styles for the Component Guide.
|
|
2
2
|
|
|
3
|
-
@import "govuk_publishing_components/components/helpers/govuk-frontend-settings";
|
|
4
|
-
@import "govuk_publishing_components/components/helpers/markdown-typography";
|
|
5
|
-
@import "govuk/settings/all";
|
|
6
|
-
@import "govuk/tools/all";
|
|
7
|
-
@import "govuk/helpers/all";
|
|
8
|
-
@import "govuk/core/all";
|
|
9
|
-
|
|
10
3
|
@import "govuk_publishing_components/all_components";
|
|
11
4
|
|
|
12
5
|
$gem-guide-border-width: 1px;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
// This is the file that the application needs to include in order to use
|
|
2
2
|
// the components.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
@import "govuk_publishing_components/govuk_frontend_support";
|
|
5
|
+
@import "govuk_publishing_components/component_support";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// Include common imports used by many components
|
|
9
|
-
@import "govuk/all";
|
|
10
|
-
|
|
11
|
-
@import "components/helpers/variables";
|
|
12
|
-
@import "components/helpers/brand-colours";
|
|
13
|
-
@import "components/mixins/govuk-template-link-focus-override";
|
|
14
|
-
@import "components/mixins/media-down";
|
|
15
|
-
@import "components/mixins/margins";
|
|
16
|
-
@import "components/mixins/clearfix";
|
|
17
|
-
@import "components/mixins/css3";
|
|
7
|
+
// Include all govuk frontend components
|
|
8
|
+
@import "govuk/components/all";
|
|
18
9
|
|
|
19
10
|
// components
|
|
20
11
|
@import "components/accordion";
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
.gem-c-action-link__contents-wrapper {
|
|
24
|
+
display: table-cell;
|
|
25
|
+
vertical-align: middle;
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
.gem-c-action-link__link-wrapper {
|
|
24
29
|
@include govuk-font(19, $weight: bold, $line-height: 1.3);
|
|
25
30
|
display: table-cell;
|
|
@@ -89,7 +94,7 @@
|
|
|
89
94
|
background-image: image-url("govuk_publishing_components/action-link-arrow--simple.svg");
|
|
90
95
|
// sass-lint:enable no-duplicate-properties
|
|
91
96
|
background-size: 25px auto;
|
|
92
|
-
background-position: 0
|
|
97
|
+
background-position: 0 2px;
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
.gem-c-action-link__link {
|
|
@@ -112,7 +117,7 @@
|
|
|
112
117
|
background-image: image-url("govuk_publishing_components/action-link-arrow--dark.svg");
|
|
113
118
|
// sass-lint:enable no-duplicate-properties
|
|
114
119
|
background-size: 25px auto;
|
|
115
|
-
background-position: 0
|
|
120
|
+
background-position: 0 2px;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
.gem-c-action-link__link {
|
|
@@ -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
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
margin-left: 0;
|
|
11
11
|
padding: .75em 0 .75em 2.5em;
|
|
12
12
|
|
|
13
|
-
@for $i from 1 through
|
|
13
|
+
@for $i from 1 through 30 {
|
|
14
14
|
&:nth-child(#{$i}) {
|
|
15
15
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Ccircle cx='125' cy='125' r='100' fill='black' /%3E%3Ctext x='50%25' y='50%25' text-anchor='middle' alignment-baseline='middle' font-family='sans-serif' font-size='100px' fill='white'%3E#{$i}%3C/text%3E%3C/svg%3E");
|
|
16
16
|
background-repeat: no-repeat;
|
|
@@ -10,6 +10,7 @@ module GovukPublishingComponents
|
|
|
10
10
|
@components_in_use_docs = components_in_use_docs.used_in_this_app
|
|
11
11
|
@components_in_use_sass = components_in_use_sass(false)
|
|
12
12
|
@components_in_use_print_sass = components_in_use_sass(true)
|
|
13
|
+
@components_in_use_js = components_in_use_js
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def show
|
|
@@ -62,6 +63,25 @@ module GovukPublishingComponents
|
|
|
62
63
|
}.compact.uniq.sort.join("\n").squeeze("\n").prepend(additional_files)
|
|
63
64
|
end
|
|
64
65
|
|
|
66
|
+
def components_in_use_js
|
|
67
|
+
additional_files = "//= require govuk_publishing_components/lib\n"
|
|
68
|
+
|
|
69
|
+
components = components_in_use
|
|
70
|
+
extra_components = []
|
|
71
|
+
|
|
72
|
+
components.each do |component|
|
|
73
|
+
components_in_component = components_within_component(component)
|
|
74
|
+
extra_components << components_in_component
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
components << extra_components.compact
|
|
78
|
+
components = components.flatten.uniq.sort
|
|
79
|
+
|
|
80
|
+
components.map { |component|
|
|
81
|
+
"//= require govuk_publishing_components/components/#{component.gsub('_', '-')}" if component_has_js_file(component.gsub("_", "-"))
|
|
82
|
+
}.compact.uniq.sort.join("\n").squeeze("\n").prepend(additional_files)
|
|
83
|
+
end
|
|
84
|
+
|
|
65
85
|
private
|
|
66
86
|
|
|
67
87
|
def component_docs
|
|
@@ -95,6 +115,10 @@ module GovukPublishingComponents
|
|
|
95
115
|
Pathname.new(@component_gem_path + "/app/assets/stylesheets/govuk_publishing_components/components/#{print_path}_#{component}.scss").exist?
|
|
96
116
|
end
|
|
97
117
|
|
|
118
|
+
def component_has_js_file(component)
|
|
119
|
+
Pathname.new(@component_gem_path + "/app/assets/javascripts/govuk_publishing_components/components/#{component}.js").exist?
|
|
120
|
+
end
|
|
121
|
+
|
|
98
122
|
def components_within_component(component)
|
|
99
123
|
data = File.read(@component_gem_path + "/app/views/govuk_publishing_components/components/_#{component}.html.erb")
|
|
100
124
|
match = data.scan(/(govuk_publishing_components\/components\/[a-z_-]+)/)
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<h2 class="component-doc-h2">Gem components used by this app (<%= @components_in_use_docs.length %>)</h2>
|
|
21
21
|
|
|
22
22
|
<%= render "govuk_publishing_components/components/details", {
|
|
23
|
-
title: "Suggested
|
|
23
|
+
title: "Suggested imports for this application"
|
|
24
24
|
} do %>
|
|
25
25
|
<%= render "govuk_publishing_components/components/textarea", {
|
|
26
26
|
label: {
|
|
@@ -36,6 +36,13 @@
|
|
|
36
36
|
name: "print-sass",
|
|
37
37
|
value: @components_in_use_print_sass
|
|
38
38
|
} %>
|
|
39
|
+
<%= render "govuk_publishing_components/components/textarea", {
|
|
40
|
+
label: {
|
|
41
|
+
text: "Add this to your application's main js file, before your other local imports."
|
|
42
|
+
},
|
|
43
|
+
name: "main-js",
|
|
44
|
+
value: @components_in_use_js
|
|
45
|
+
} %>
|
|
39
46
|
<% end %>
|
|
40
47
|
<pre>
|
|
41
48
|
|
|
@@ -24,16 +24,24 @@
|
|
|
24
24
|
%>
|
|
25
25
|
<% if href.present? && text.present? %>
|
|
26
26
|
<div class="<%= css_classes.join(' ') %>">
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<%=
|
|
30
|
-
|
|
27
|
+
<% contents = capture do %>
|
|
28
|
+
<span class="gem-c-action-link__link-wrapper">
|
|
29
|
+
<%= link_to href, :class => link_classes, :data => data do %>
|
|
30
|
+
<%= text %>
|
|
31
|
+
<%= content_tag(:span, nowrap_text, class: "gem-c-action-link__nowrap-text") if nowrap_text %>
|
|
32
|
+
<% end %>
|
|
33
|
+
</span>
|
|
34
|
+
<% if subtext %>
|
|
35
|
+
<span class="gem-c-action-link__subtext-wrapper">
|
|
36
|
+
<%= content_tag(:span, subtext, class: "gem-c-action-link__subtext") %>
|
|
37
|
+
</span>
|
|
31
38
|
<% end %>
|
|
32
|
-
|
|
39
|
+
<% end %>
|
|
40
|
+
|
|
33
41
|
<% if subtext %>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
<%= content_tag(:span, contents, class: "gem-c-action-link__contents-wrapper") %>
|
|
43
|
+
<% else %>
|
|
44
|
+
<%= contents %>
|
|
37
45
|
<% end %>
|
|
38
46
|
</div>
|
|
39
47
|
<% end %>
|
|
@@ -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 %>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
label ||= false
|
|
5
5
|
full_width ||= false
|
|
6
6
|
name ||= id
|
|
7
|
+
is_page_heading ||= false
|
|
7
8
|
heading_size = false unless ['s', 'm', 'l', 'xl'].include?(heading_size)
|
|
8
9
|
error_message ||= nil
|
|
9
10
|
error_id ||= nil
|
|
@@ -28,7 +29,11 @@
|
|
|
28
29
|
%>
|
|
29
30
|
<% if options.any? && id && label %>
|
|
30
31
|
<%= content_tag :div, class: css_classes do %>
|
|
31
|
-
|
|
32
|
+
<% if is_page_heading %>
|
|
33
|
+
<%= tag.h1 label_tag(id, label, class: label_classes), class: "gem-c-title__text" %>
|
|
34
|
+
<% else %>
|
|
35
|
+
<%= label_tag(id, label, class: label_classes) %>
|
|
36
|
+
<% end %>
|
|
32
37
|
|
|
33
38
|
<% if error_message %>
|
|
34
39
|
<%= render "govuk_publishing_components/components/error_message", {
|
|
@@ -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:
|
|
@@ -143,3 +143,15 @@ examples:
|
|
|
143
143
|
value: 'option2'
|
|
144
144
|
- text: 'Option three'
|
|
145
145
|
value: 'option3'
|
|
146
|
+
with_page_heading:
|
|
147
|
+
description: This adds a H1 element with a label element inside containing the text supplied.
|
|
148
|
+
data:
|
|
149
|
+
id: 'select-with-heading'
|
|
150
|
+
label: 'This is a page heading'
|
|
151
|
+
heading_size: 'xl'
|
|
152
|
+
is_page_heading: true
|
|
153
|
+
options:
|
|
154
|
+
- text: 'Option one'
|
|
155
|
+
value: 'option1'
|
|
156
|
+
- text: 'Option two'
|
|
157
|
+
value: 'option2'
|
|
@@ -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.1
|
|
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-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gds-api-adapters
|
|
@@ -408,6 +408,7 @@ files:
|
|
|
408
408
|
- app/assets/javascripts/component_guide/visual-regression.js
|
|
409
409
|
- app/assets/javascripts/govuk_publishing_components/all_components.js
|
|
410
410
|
- app/assets/javascripts/govuk_publishing_components/components/accordion.js
|
|
411
|
+
- app/assets/javascripts/govuk_publishing_components/components/button.js
|
|
411
412
|
- app/assets/javascripts/govuk_publishing_components/components/character-count.js
|
|
412
413
|
- app/assets/javascripts/govuk_publishing_components/components/checkboxes.js
|
|
413
414
|
- app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
|
|
@@ -417,11 +418,14 @@ files:
|
|
|
417
418
|
- app/assets/javascripts/govuk_publishing_components/components/error-summary.js
|
|
418
419
|
- app/assets/javascripts/govuk_publishing_components/components/feedback.js
|
|
419
420
|
- app/assets/javascripts/govuk_publishing_components/components/govspeak.js
|
|
421
|
+
- app/assets/javascripts/govuk_publishing_components/components/header.js
|
|
420
422
|
- app/assets/javascripts/govuk_publishing_components/components/initial-focus.js
|
|
421
423
|
- app/assets/javascripts/govuk_publishing_components/components/modal-dialogue.js
|
|
422
424
|
- app/assets/javascripts/govuk_publishing_components/components/radio.js
|
|
423
425
|
- app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js
|
|
426
|
+
- app/assets/javascripts/govuk_publishing_components/components/tabs.js
|
|
424
427
|
- app/assets/javascripts/govuk_publishing_components/dependencies.js
|
|
428
|
+
- app/assets/javascripts/govuk_publishing_components/lib.js
|
|
425
429
|
- app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js
|
|
426
430
|
- app/assets/javascripts/govuk_publishing_components/lib/current-location.js
|
|
427
431
|
- app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
|