govuk_publishing_components 21.63.0 → 21.65.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/images/govuk_publishing_components/action-link-arrow--transparent.svg +1 -0
- data/app/assets/javascripts/govuk_publishing_components/components/govspeak.js +17 -15
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +402 -340
- data/app/assets/javascripts/govuk_publishing_components/dependencies.js +0 -5
- data/app/assets/javascripts/govuk_publishing_components/lib.js +1 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js +18 -11
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +423 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/toggle.js +126 -65
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/closest.js +23 -0
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/indexOf.js +9 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +8 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_panel.scss +7 -1
- data/app/views/govuk_publishing_components/component_guide/example.html.erb +4 -1
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_panel.html.erb +13 -11
- data/app/views/govuk_publishing_components/components/_radio.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_search.html.erb +6 -2
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/docs/action_link.yml +8 -0
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +3 -1
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +19 -5
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +6 -3
- data/app/assets/javascripts/govuk_publishing_components/vendor/magna-charta.min.js +0 -4
@@ -3,7 +3,9 @@ description: Shows that a content page is part of a step by step navigation
|
|
3
3
|
body: |
|
4
4
|
The component indicates to the user that the current page is part of a [step by step navigation](/component-guide/step_by_step_nav), and can provide a link to it.
|
5
5
|
accessibility_criteria: |
|
6
|
-
The component is designed to go into the top of an existing content page
|
6
|
+
The component is designed to go into the top of an existing content page. This component looks like a heading so uses a heading level 2 element.
|
7
|
+
|
8
|
+
An earlier version of the component did not use a heading element – this failed WCAG 2.1 Success Criterion 1.3.1 ("Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text.")
|
7
9
|
|
8
10
|
An early version of the component contained a hidden skip link for keyboard and screen reader users, that jumped to the step by step navigation component in the sidebar (similiar to the 'skip to content' link at the top of all GOV.UK pages). User testing suggested that rather than helping users it confused them, so this has been removed.
|
9
11
|
shared_accessibility_criteria:
|
@@ -12,18 +12,22 @@ module GovukPublishingComponents
|
|
12
12
|
}.freeze
|
13
13
|
|
14
14
|
# Returns the highest priority taxon that has a content_id matching those in PRIORITY_TAXONS
|
15
|
-
def self.call(content_item)
|
16
|
-
new(content_item).breadcrumbs
|
15
|
+
def self.call(content_item, query_parameters = nil)
|
16
|
+
new(content_item, query_parameters).breadcrumbs
|
17
17
|
end
|
18
18
|
|
19
|
-
attr_reader :content_item
|
19
|
+
attr_reader :content_item, :query_parameters
|
20
20
|
|
21
|
-
def initialize(content_item)
|
21
|
+
def initialize(content_item, query_parameters = nil)
|
22
22
|
@content_item = content_item
|
23
|
+
@query_parameters = query_parameters
|
23
24
|
end
|
24
25
|
|
25
26
|
def taxon
|
26
|
-
@taxon ||=
|
27
|
+
@taxon ||= begin
|
28
|
+
default_taxon = priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
|
29
|
+
preferred_taxon || default_taxon
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
def breadcrumbs
|
@@ -39,6 +43,12 @@ module GovukPublishingComponents
|
|
39
43
|
|
40
44
|
private
|
41
45
|
|
46
|
+
def preferred_taxon
|
47
|
+
if preferred_priority_taxon
|
48
|
+
priority_taxons.find { |t| t["content_id"] == preferred_priority_taxon }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
42
52
|
def priority_taxons
|
43
53
|
return [] unless content_item["links"].is_a?(Hash)
|
44
54
|
|
@@ -57,6 +67,10 @@ module GovukPublishingComponents
|
|
57
67
|
def priority_taxon?(taxon)
|
58
68
|
PRIORITY_TAXONS.values.include?(taxon["content_id"])
|
59
69
|
end
|
70
|
+
|
71
|
+
def preferred_priority_taxon
|
72
|
+
query_parameters["priority-taxon"] if query_parameters
|
73
|
+
end
|
60
74
|
end
|
61
75
|
end
|
62
76
|
end
|
@@ -30,7 +30,7 @@ module GovukPublishingComponents
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def priority_breadcrumbs
|
33
|
-
@priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item)
|
33
|
+
@priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item, query_parameters)
|
34
34
|
end
|
35
35
|
|
36
36
|
def topic_breadcrumbs
|
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.65.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-08
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|
@@ -320,6 +320,7 @@ files:
|
|
320
320
|
- app/assets/images/govuk_publishing_components/action-link-arrow--dark.svg
|
321
321
|
- app/assets/images/govuk_publishing_components/action-link-arrow--simple.png
|
322
322
|
- app/assets/images/govuk_publishing_components/action-link-arrow--simple.svg
|
323
|
+
- app/assets/images/govuk_publishing_components/action-link-arrow--transparent.svg
|
323
324
|
- app/assets/images/govuk_publishing_components/action-link-arrow.png
|
324
325
|
- app/assets/images/govuk_publishing_components/action-link-arrow.svg
|
325
326
|
- app/assets/images/govuk_publishing_components/chevron-banner/chevron-banner-small-focus.svg
|
@@ -419,6 +420,7 @@ files:
|
|
419
420
|
- app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js
|
420
421
|
- app/assets/javascripts/govuk_publishing_components/lib/current-location.js
|
421
422
|
- app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
|
423
|
+
- app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js
|
422
424
|
- app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js
|
423
425
|
- app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
|
424
426
|
- app/assets/javascripts/govuk_publishing_components/lib/primary-links.js
|
@@ -428,8 +430,9 @@ files:
|
|
428
430
|
- app/assets/javascripts/govuk_publishing_components/modules.js
|
429
431
|
- app/assets/javascripts/govuk_publishing_components/vendor/html5shiv-printshiv.js
|
430
432
|
- app/assets/javascripts/govuk_publishing_components/vendor/json2.js
|
431
|
-
- app/assets/javascripts/govuk_publishing_components/vendor/magna-charta.min.js
|
432
433
|
- app/assets/javascripts/govuk_publishing_components/vendor/modernizr.js
|
434
|
+
- app/assets/javascripts/govuk_publishing_components/vendor/polyfills/closest.js
|
435
|
+
- app/assets/javascripts/govuk_publishing_components/vendor/polyfills/indexOf.js
|
433
436
|
- app/assets/stylesheets/component_guide/application.scss
|
434
437
|
- app/assets/stylesheets/component_guide/print.scss
|
435
438
|
- app/assets/stylesheets/govuk_publishing_components/_all_components.scss
|
@@ -1,4 +0,0 @@
|
|
1
|
-
/*! Magna Charta - v3.0.0 - 2012-12-04
|
2
|
-
* https://github.com/alphagov/magna-charta
|
3
|
-
*/
|
4
|
-
(function(e){var t=function(){this.init=function(t,n){var r={outOf:65,applyOnInit:!0,toggleText:"Toggle between chart and table",autoOutdent:!1,outdentAll:!1};this.options=e.extend({},r,n);var i=function(){var e,t=3,n=document.createElement("div"),r=n.getElementsByTagName("i");do n.innerHTML="<!--[if gt IE "+ ++t+"]><i></i><![endif]-->";while(t<10&&r[0]);return t>4?t:e}();return this.ENABLED=!(i&&i<8),this.$table=t,this.$graph=e("<div/>").attr("aria-hidden","true"),this.$graph.attr("class",this.$table.attr("class")).addClass("mc-chart"),this.options.stacked=this.$table.hasClass("mc-stacked"),this.options.negative=this.$table.hasClass("mc-negative"),this.options.multiple=!this.options.stacked&&(this.$table.hasClass("mc-multiple")||this.$table.find("tbody tr").first().find("td").length>2),this.options.autoOutdent=this.options.autoOutdent||this.$table.hasClass("mc-auto-outdent"),this.options.outdentAll=this.options.outdentAll||this.$table.hasClass("mc-outdented"),this.options.multiple&&this.$graph.addClass("mc-multiple"),this.options.hasCaption=!!this.$table.find("caption").length,this.ENABLED&&(this.apply(),this.options.applyOnInit||this.toggle()),this}};t.prototype.construct={},t.prototype.construct.thead=function(){var t=e("<div />",{"class":"mc-thead"}),n=e("<div />",{"class":"mc-tr"}),r="";return this.$table.find("th").each(function(t,n){r+='<div class="mc-th">',r+=e(n).html(),r+="</div>"}),n.append(r),t.append(n),t},t.prototype.construct.tbody=function(){var t=e("<div />",{"class":"mc-tbody"}),n="";return this.$table.find("tbody tr").each(function(n,r){var i=e("<div />",{"class":"mc-tr"}),s="";e(r).find("td").each(function(t,n){s+='<div class="mc-td">',s+=e(n).html(),s+="</div>"}),i.append(s),t.append(i)}),t},t.prototype.construct.caption=function(){var e=this.$table.find("caption");return e.clone()},t.prototype.construct.toggleLink=function(){var t=this;return e("<a />",{href:"#","class":"mc-toggle-link",text:this.options.toggleText}).on("click",function(e){t.toggle(e)})},t.prototype.constructChart=function(){var e=this.construct.thead.call(this),t=this.construct.tbody.call(this),n=this.construct.toggleLink.call(this);if(this.options.hasCaption){var r=this.construct.caption.call(this);this.$graph.append(r)}this.$table.before(n),this.$graph.append(e),this.$graph.append(t)},t.prototype.apply=function(){this.ENABLED&&(this.constructChart(),this.addClassesToHeader(),this.calculateMaxWidth(),this.applyWidths(),this.insert(),this.$table.addClass("visually-hidden"),this.applyOutdent())},t.prototype.toggle=function(e){this.$graph.toggle(),this.$table.toggleClass("visually-hidden"),e&&e.preventDefault()},t.prototype.utils={isFloat:function(e){return!isNaN(parseFloat(e))},stripValue:function(e){var t=new RegExp("\\,|£|%|[a-z]","gi");return e.replace(t,"")},returnMax:function(e){var t=0;for(var n=0;n<e.length;n++)e[n]>t&&(t=e[n]);return t},isNegative:function(e){return e<0}},t.prototype.addClassesToHeader=function(){var t=this.$graph.find(".mc-th").filter(":not(:first)");this.options.stacked&&(t.last().addClass("mc-stacked-header mc-header-total"),t=t.filter(":not(:last)")),t.addClass("mc-key-header").filter(":not(.mc-stacked-header)").each(function(t,n){e(n).addClass("mc-key-"+(t+1))})},t.prototype.calculateMaxWidth=function(){var t=this,n=[],r=0;this.$graph.find(".mc-tr").each(function(i,s){var o=e(s),u=o.find(".mc-td:not(:first)");if(t.options.stacked){var a=u.last().addClass("mc-stacked-total");u=u.filter(":not(:last)")}o.find(".mc-td:first").addClass("mc-key-cell");var f=0;u.each(function(i,s){var o=e(s).addClass("mc-bar-cell").addClass("mc-bar-"+(i+1)),u=t.utils.stripValue(o.text());if(t.utils.isFloat(u)){var a=parseFloat(u,10),l=Math.abs(a);a===0&&o.addClass("mc-bar-zero"),t.options.negative&&(t.utils.isNegative(a)?(o.addClass("mc-bar-negative"),l>r&&(r=l)):o.addClass("mc-bar-positive")),a=l,t.options.stacked?f+=a:(f=a,n.push(a))}}),t.options.stacked&&n.push(f)});var i={};return i.max=parseFloat(t.utils.returnMax(n),10),i.single=parseFloat(this.options.outOf/i.max,10),this.options.negative&&(i.marginLeft=parseFloat(r,10)*i.single,i.maxNegative=parseFloat(r,10)),i},t.prototype.applyWidths=function(){this.dimensions=this.calculateMaxWidth();var t=this;this.$graph.find(".mc-tr").each(function(n,r){var i=e(r),s=i.find(".mc-bar-cell:not(.mc-bar-zero)").length;i.find(".mc-bar-cell").each(function(n,r){var i=e(r),s=parseFloat(t.utils.stripValue(i.text()),10),o=s*t.dimensions.single,u=Math.abs(s),a=Math.abs(o);if(t.options.negative)if(i.hasClass("mc-bar-positive"))i.css("margin-left",t.dimensions.marginLeft+"%");else if(u<t.dimensions.maxNegative){var f=(t.dimensions.maxNegative-u)*t.dimensions.single;i.css("margin-left",f+"%")}i.wrapInner("<span />"),i.css("width",a+"%")})})},t.prototype.insert=function(){this.$table.after(this.$graph)},t.prototype.applyOutdent=function(){var t=this,n=this.$graph.find(".mc-bar-cell");this.$graph.find(".mc-bar-cell").each(function(n,r){var i=e(r),s=parseFloat(t.utils.stripValue(i.text()),10),o=i.children("span"),u=o.width()+10,a=i.width(),f=parseFloat(i[0].style.width,10),l=i.height();t.options.stacked?u>a&&s>0&&i.addClass("mc-value-overflow"):(s===0&&i.addClass("mc-bar-outdented"),t.options.autoOutdent&&u>a||t.options.outdentAll?(i.addClass("mc-bar-outdented"),o.css({"margin-left":"100%",display:"inline-block"})):i.addClass("mc-bar-indented"))})},e.magnaCharta=function(e,n){return(new t).init(e,n)}})(jQuery);
|