govuk_publishing_components 21.50.1 → 21.54.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/_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/_contextual_breadcrumbs.html.erb +5 -36
- data/app/views/govuk_publishing_components/components/_input.html.erb +12 -1
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +28 -8
- data/app/views/govuk_publishing_components/components/docs/input.yml +9 -0
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +23 -0
- data/lib/govuk_publishing_components.rb +1 -0
- data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +107 -0
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +26 -9
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb +1 -3
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +40 -19
- data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +5 -29
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/CHANGELOG.md +6 -0
- data/node_modules/axe-core/axe.js +19 -3
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/bower.json +1 -1
- data/node_modules/axe-core/lib/commons/dom/get-element-stack.js +27 -1
- data/node_modules/axe-core/package.json +21 -21
- data/node_modules/axe-core/sri-history.json +4 -0
- metadata +7 -2
@@ -6,6 +6,7 @@ require "govuk_publishing_components/engine"
|
|
6
6
|
require "govuk_publishing_components/presenters/shared_helper"
|
7
7
|
require "govuk_publishing_components/presenters/attachment"
|
8
8
|
require "govuk_publishing_components/presenters/breadcrumbs"
|
9
|
+
require "govuk_publishing_components/presenters/breadcrumb_selector"
|
9
10
|
require "govuk_publishing_components/presenters/button_helper"
|
10
11
|
require "govuk_publishing_components/presenters/contextual_navigation"
|
11
12
|
require "govuk_publishing_components/presenters/related_navigation_helper"
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module Presenters
|
3
|
+
class BreadcrumbSelector
|
4
|
+
def self.call(*args)
|
5
|
+
new(*args).output
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :content_item, :request, :prioritise_taxon_breadcrumbs
|
9
|
+
|
10
|
+
def initialize(content_item, request, prioritise_taxon_breadcrumbs)
|
11
|
+
@content_item = content_item
|
12
|
+
@request = request
|
13
|
+
@prioritise_taxon_breadcrumbs = prioritise_taxon_breadcrumbs
|
14
|
+
end
|
15
|
+
|
16
|
+
def content_item_navigation
|
17
|
+
@content_item_navigation ||= ContextualNavigation.new(content_item, request)
|
18
|
+
end
|
19
|
+
|
20
|
+
def parent_item_navigation
|
21
|
+
@parent_item_navigation ||= ContextualNavigation.new(parent_item, request)
|
22
|
+
end
|
23
|
+
|
24
|
+
def parent_item
|
25
|
+
@parent_item ||= Services.content_store.content_item(content_item_navigation.parent_api_path)
|
26
|
+
rescue GdsApi::ContentStore::ItemNotFound
|
27
|
+
# Do nothing
|
28
|
+
end
|
29
|
+
|
30
|
+
def parent_item_options
|
31
|
+
@parent_item_options ||= options(parent_item_navigation)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_item_options
|
35
|
+
@content_item_options ||= options(content_item_navigation)
|
36
|
+
end
|
37
|
+
|
38
|
+
def parent_breadcrumbs
|
39
|
+
breadcrumbs = [parent_item_options[:breadcrumbs]].flatten # to ensure breadcrumbs always an array
|
40
|
+
breadcrumbs.last[:is_page_parent] = false
|
41
|
+
breadcrumbs << {
|
42
|
+
title: parent_item["title"],
|
43
|
+
url: parent_item["base_path"],
|
44
|
+
is_page_parent: true,
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def output
|
49
|
+
return content_item_options unless content_item_navigation.html_document_with_parent?
|
50
|
+
return parent_item_options if parent_item_navigation.priority_breadcrumbs
|
51
|
+
|
52
|
+
step_by_step_header = parent_item_options[:step_by_step]
|
53
|
+
|
54
|
+
{
|
55
|
+
step_by_step: step_by_step_header,
|
56
|
+
breadcrumbs: step_by_step_header ? parent_breadcrumbs.first : parent_breadcrumbs,
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def options(navigation)
|
61
|
+
if navigation.priority_breadcrumbs
|
62
|
+
{
|
63
|
+
step_by_step: true,
|
64
|
+
breadcrumbs: navigation.priority_breadcrumbs,
|
65
|
+
}
|
66
|
+
elsif navigation.content_tagged_to_current_step_by_step?
|
67
|
+
{
|
68
|
+
step_by_step: true,
|
69
|
+
breadcrumbs: navigation.step_nav_helper.header,
|
70
|
+
}
|
71
|
+
elsif navigation.content_tagged_to_a_finder?
|
72
|
+
{
|
73
|
+
step_by_step: false,
|
74
|
+
breadcrumbs: navigation.breadcrumbs,
|
75
|
+
}
|
76
|
+
elsif navigation.content_is_tagged_to_a_live_taxon? && prioritise_taxon_breadcrumbs
|
77
|
+
{
|
78
|
+
step_by_step: false,
|
79
|
+
breadcrumbs: navigation.taxon_breadcrumbs,
|
80
|
+
}
|
81
|
+
elsif navigation.content_tagged_to_mainstream_browse_pages?
|
82
|
+
{
|
83
|
+
step_by_step: false,
|
84
|
+
breadcrumbs: navigation.breadcrumbs,
|
85
|
+
}
|
86
|
+
elsif navigation.content_has_curated_related_items?
|
87
|
+
{
|
88
|
+
step_by_step: false,
|
89
|
+
breadcrumbs: navigation.breadcrumbs,
|
90
|
+
}
|
91
|
+
elsif navigation.use_taxon_breadcrumbs?
|
92
|
+
{
|
93
|
+
step_by_step: false,
|
94
|
+
breadcrumbs: navigation.taxon_breadcrumbs,
|
95
|
+
}
|
96
|
+
elsif navigation.breadcrumbs.any?
|
97
|
+
{
|
98
|
+
step_by_step: false,
|
99
|
+
breadcrumbs: navigation.breadcrumbs,
|
100
|
+
}
|
101
|
+
else
|
102
|
+
{}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -11,7 +11,7 @@ module GovukPublishingComponents
|
|
11
11
|
|
12
12
|
# Returns the highest priority taxon that has a content_id matching those in PRIORITY_TAXONS
|
13
13
|
def self.call(content_item)
|
14
|
-
new(content_item).
|
14
|
+
new(content_item).breadcrumbs
|
15
15
|
end
|
16
16
|
|
17
17
|
attr_reader :content_item
|
@@ -24,19 +24,36 @@ module GovukPublishingComponents
|
|
24
24
|
@taxon ||= priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
|
25
25
|
end
|
26
26
|
|
27
|
+
def breadcrumbs
|
28
|
+
taxon && {
|
29
|
+
title: taxon["title"],
|
30
|
+
path: taxon["base_path"],
|
31
|
+
tracking_category: "breadcrumbClicked",
|
32
|
+
tracking_action: "superBreadcrumb",
|
33
|
+
tracking_label: content_item["base_path"],
|
34
|
+
tracking_dimension_enabled: false,
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
27
38
|
private
|
28
39
|
|
29
40
|
def priority_taxons
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
return [] unless content_item["links"].is_a?(Hash)
|
42
|
+
|
43
|
+
taxons = content_item.dig("links", "taxons")
|
44
|
+
taxon_tree(taxons).select do |taxon|
|
45
|
+
priority_taxon?(taxon)
|
34
46
|
end
|
35
|
-
|
47
|
+
end
|
48
|
+
|
49
|
+
def taxon_tree(taxons)
|
50
|
+
return [] if taxons.blank?
|
51
|
+
|
52
|
+
taxons + taxons.flat_map { |taxon| taxon_tree(taxon.dig("links", "parent_taxons")) }
|
53
|
+
end
|
36
54
|
|
37
|
-
|
38
|
-
|
39
|
-
taxons
|
55
|
+
def priority_taxon?(taxon)
|
56
|
+
PRIORITY_TAXONS.values.include?(taxon["content_id"])
|
40
57
|
end
|
41
58
|
end
|
42
59
|
end
|
@@ -16,32 +16,41 @@ module GovukPublishingComponents
|
|
16
16
|
content_item["document_type"] == "simple_smart_answer"
|
17
17
|
end
|
18
18
|
|
19
|
+
def html_document_with_parent?
|
20
|
+
(content_item["document_type"] == "html_publication") && parent_api_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def parent_api_path
|
24
|
+
parent = content_item.dig("links", "parent")&.first
|
25
|
+
parent["base_path"] if parent
|
26
|
+
end
|
27
|
+
|
19
28
|
def taxon_breadcrumbs
|
20
29
|
@taxon_breadcrumbs ||= ContentBreadcrumbsBasedOnTaxons.new(content_item).breadcrumbs
|
21
30
|
end
|
22
31
|
|
23
|
-
def
|
24
|
-
@
|
32
|
+
def priority_breadcrumbs
|
33
|
+
@priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item)
|
25
34
|
end
|
26
35
|
|
27
36
|
def breadcrumbs
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
return breadcrumbs_based_on_parent unless content_tagged_to_a_finder?
|
38
|
+
return [] unless parent_finder
|
39
|
+
|
40
|
+
[
|
41
|
+
{
|
42
|
+
title: "Home",
|
43
|
+
url: "/",
|
44
|
+
},
|
45
|
+
{
|
46
|
+
title: parent_finder["title"],
|
47
|
+
url: parent_finder["base_path"],
|
48
|
+
},
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
52
|
+
def use_taxon_breadcrumbs?
|
53
|
+
content_is_tagged_to_a_live_taxon? && !content_is_a_specialist_document?
|
45
54
|
end
|
46
55
|
|
47
56
|
def content_tagged_to_a_finder?
|
@@ -64,6 +73,10 @@ module GovukPublishingComponents
|
|
64
73
|
content_item["schema_name"] == "specialist_document"
|
65
74
|
end
|
66
75
|
|
76
|
+
def content_is_a_html_publication?
|
77
|
+
content_item["document_type"] == "html_publication"
|
78
|
+
end
|
79
|
+
|
67
80
|
def tagged_to_brexit?
|
68
81
|
taxons = content_item.dig("links", "taxons").to_a
|
69
82
|
brexit_taxon = "d6c2de5d-ef90-45d1-82d4-5f2438369eea"
|
@@ -106,9 +119,17 @@ module GovukPublishingComponents
|
|
106
119
|
step_nav_helper.show_also_part_of_step_nav?
|
107
120
|
end
|
108
121
|
|
122
|
+
def breadcrumbs_based_on_parent
|
123
|
+
ContentBreadcrumbsBasedOnParent.new(content_item).breadcrumbs[:breadcrumbs]
|
124
|
+
end
|
125
|
+
|
109
126
|
def step_nav_helper
|
110
127
|
@step_nav_helper ||= PageWithStepByStepNavigation.new(content_item, request_path, query_parameters)
|
111
128
|
end
|
129
|
+
|
130
|
+
def parent_finder
|
131
|
+
@parent_finder ||= content_item.dig("links", "finder", 0)
|
132
|
+
end
|
112
133
|
end
|
113
134
|
end
|
114
135
|
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
|
|
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
4
4
|
|
5
|
+
### [3.5.4](https://github.com/dequelabs/axe-core/compare/v3.5.3...v3.5.4) (2020-05-22)
|
6
|
+
|
7
|
+
### Bug Fixes
|
8
|
+
|
9
|
+
- **get-element-stack:** properly calculate position of children of floated elements ([28a8c58](https://github.com/dequelabs/axe-core/commit/28a8c58b409461600da07eac164e5b0ca4744502))
|
10
|
+
|
5
11
|
### [3.5.3](https://github.com/dequelabs/axe-core/compare/v3.5.2...v3.5.3) (2020-03-31)
|
6
12
|
|
7
13
|
### Bug Fixes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! axe v3.5.
|
1
|
+
/*! axe v3.5.4
|
2
2
|
* Copyright (c) 2020 Deque Systems, Inc.
|
3
3
|
*
|
4
4
|
* Your use of this Source Code Form is subject to the terms of the Mozilla Public
|
@@ -27,7 +27,7 @@
|
|
27
27
|
return _typeof(obj);
|
28
28
|
}
|
29
29
|
var axe = axe || {};
|
30
|
-
axe.version = '3.5.
|
30
|
+
axe.version = '3.5.4';
|
31
31
|
if (typeof define === 'function' && define.amd) {
|
32
32
|
define('axe-core', [], function() {
|
33
33
|
'use strict';
|
@@ -21533,12 +21533,28 @@
|
|
21533
21533
|
}
|
21534
21534
|
return false;
|
21535
21535
|
}
|
21536
|
+
function isFloated(vNode) {
|
21537
|
+
if (!vNode) {
|
21538
|
+
return false;
|
21539
|
+
}
|
21540
|
+
if (vNode._isFloated !== undefined) {
|
21541
|
+
return vNode._isFloated;
|
21542
|
+
}
|
21543
|
+
var floatStyle = vNode.getComputedStylePropertyValue('float');
|
21544
|
+
if (floatStyle !== 'none') {
|
21545
|
+
vNode._isFloated = true;
|
21546
|
+
return true;
|
21547
|
+
}
|
21548
|
+
var floated = isFloated(vNode.parent);
|
21549
|
+
vNode._isFloated = floated;
|
21550
|
+
return floated;
|
21551
|
+
}
|
21536
21552
|
function getPositionOrder(vNode) {
|
21537
21553
|
if (vNode.getComputedStylePropertyValue('position') === 'static') {
|
21538
21554
|
if (vNode.getComputedStylePropertyValue('display').indexOf('inline') !== -1) {
|
21539
21555
|
return 2;
|
21540
21556
|
}
|
21541
|
-
if (vNode
|
21557
|
+
if (isFloated(vNode)) {
|
21542
21558
|
return 1;
|
21543
21559
|
}
|
21544
21560
|
return 0;
|