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
@@ -1,15 +1,14 @@
|
|
1
|
-
/* eslint-env jquery */
|
2
1
|
/*
|
3
2
|
Toggle the display of elements
|
4
3
|
|
5
|
-
|
4
|
+
Basic use:
|
6
5
|
|
7
6
|
<div data-module="gem-toggle">
|
8
|
-
<a href="#" data-controls="
|
9
|
-
Show
|
7
|
+
<a href="#" data-controls="target1" data-expanded="false">
|
8
|
+
Show/hide
|
10
9
|
</a>
|
11
|
-
<div id="
|
12
|
-
Content
|
10
|
+
<div id="target1" class="js-hidden">
|
11
|
+
Content hidden on page load
|
13
12
|
</div>
|
14
13
|
</div>
|
15
14
|
|
@@ -22,89 +21,151 @@
|
|
22
21
|
the `js-hidden` class to the element you wish to hide in
|
23
22
|
your template, the module will not do this for you.
|
24
23
|
|
25
|
-
`data-controls` can contain more than one element, space
|
26
|
-
separated.
|
27
|
-
|
28
24
|
Use `data-toggle-class` on the parent element to set the
|
29
25
|
class that is toggled. Defaults to `js-hidden`.
|
30
26
|
|
27
|
+
Content shown by default:
|
28
|
+
|
29
|
+
<div data-module="gem-toggle">
|
30
|
+
<a href="#" data-controls="target2" data-expanded="true">
|
31
|
+
Show/hide
|
32
|
+
</a>
|
33
|
+
<div id="target2">
|
34
|
+
Content shown on page load
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
Change text when clicked:
|
39
|
+
|
40
|
+
<div data-module="gem-toggle">
|
41
|
+
<a href="#" data-controls="target3" data-expanded="true" data-toggled-text="Show more">
|
42
|
+
Show less
|
43
|
+
</a>
|
44
|
+
<div id="target3">
|
45
|
+
Content shown on page load, toggle text changes depending on state
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
31
49
|
Use `data-toggled-text` on the trigger element to set the
|
32
50
|
text shown when the element is toggled. Defaults to not
|
33
51
|
changing.
|
34
52
|
|
53
|
+
Show/hide multiple elements:
|
54
|
+
|
55
|
+
<div data-module="gem-toggle">
|
56
|
+
<a href="#" data-controls="target4 target5" data-expanded="false">
|
57
|
+
Show/hide
|
58
|
+
</a>
|
59
|
+
<div id="target4" class="js-hidden">
|
60
|
+
Content hidden on page load
|
61
|
+
</div>
|
62
|
+
<div id="target5" class="js-hidden">
|
63
|
+
Content hidden on page load
|
64
|
+
</div>
|
65
|
+
</div>
|
66
|
+
|
67
|
+
`data-controls` can contain more than one element, space
|
68
|
+
separated.
|
69
|
+
|
70
|
+
With tracking:
|
71
|
+
|
72
|
+
<div data-module="gem-toggle">
|
73
|
+
<a href="#" data-controls="target6" data-expanded="true" data-track-category="category" data-track-action="action" data-toggled-text="Show more">
|
74
|
+
Show less
|
75
|
+
</a>
|
76
|
+
<div id="target6">
|
77
|
+
Content shown on page load, tracked when expanded and collapsed
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
|
35
81
|
Use `data-track-category` and `data-track-action` together
|
36
|
-
to enable analytics on the element. The label will be
|
82
|
+
to enable analytics on the element. The track label will be
|
37
83
|
determined based on the text present within the element
|
38
84
|
at the time it was clicked.
|
39
85
|
*/
|
40
|
-
|
86
|
+
window.GOVUK = window.GOVUK || {}
|
41
87
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
42
88
|
|
43
89
|
(function (Modules) {
|
44
|
-
|
45
|
-
|
46
|
-
Modules.GemToggle = function () {
|
47
|
-
this.start = function ($el) {
|
48
|
-
var toggleSelector = '[data-controls][data-expanded]'
|
49
|
-
var toggleClass = $el.attr('data-toggle-class') || 'js-hidden'
|
50
|
-
var trackable = '[data-track-category][data-track-action]'
|
51
|
-
|
52
|
-
$el.on('click', toggleSelector, toggle)
|
53
|
-
$el.find(toggleSelector).each(addAriaAttrs)
|
54
|
-
|
55
|
-
// Add the ARIA attributes with JavaScript
|
56
|
-
// If the JS fails and there's no interactive elements, having
|
57
|
-
// no aria attributes is an accurate representation.
|
58
|
-
function addAriaAttrs () {
|
59
|
-
var $toggle = $(this)
|
60
|
-
$toggle.attr('role', 'button')
|
61
|
-
$toggle.attr('aria-controls', $toggle.data('controls'))
|
62
|
-
$toggle.attr('aria-expanded', $toggle.data('expanded'))
|
63
|
-
|
64
|
-
var $targets = getTargetElements($toggle)
|
65
|
-
$targets.attr('aria-live', 'polite')
|
66
|
-
$targets.attr('role', 'region')
|
67
|
-
$toggle.data('$targets', $targets)
|
68
|
-
}
|
90
|
+
function GemToggle () { }
|
69
91
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
var $targets = $toggle.data('$targets')
|
74
|
-
|
75
|
-
if (expanded) {
|
76
|
-
$toggle.attr('aria-expanded', false)
|
77
|
-
$targets.addClass(toggleClass)
|
78
|
-
} else {
|
79
|
-
$toggle.attr('aria-expanded', true)
|
80
|
-
$targets.removeClass(toggleClass)
|
81
|
-
}
|
92
|
+
GemToggle.prototype.start = function ($module) {
|
93
|
+
this.$module = $module[0]
|
94
|
+
this.$module.toggleTrigger = this.$module.querySelector('[data-controls][data-expanded]')
|
82
95
|
|
83
|
-
|
84
|
-
|
85
|
-
$toggle.data('toggled-text', $toggle.text())
|
86
|
-
$toggle.text(toggledText)
|
87
|
-
}
|
96
|
+
if (this.$module.toggleTrigger) {
|
97
|
+
this.$module.toggleClass = this.$module.getAttribute('data-toggle-class') || 'js-hidden'
|
88
98
|
|
89
|
-
|
90
|
-
track($toggle)
|
91
|
-
}
|
99
|
+
this.$module.isTrackable = this.$module.toggleTrigger.hasAttribute('data-track-category') && this.$module.toggleTrigger.hasAttribute('data-track-action')
|
92
100
|
|
93
|
-
|
101
|
+
if (this.$module.isTrackable) {
|
102
|
+
this.$module.trackCategory = this.$module.toggleTrigger.getAttribute('data-track-category')
|
103
|
+
this.$module.trackAction = this.$module.toggleTrigger.getAttribute('data-track-action')
|
94
104
|
}
|
95
105
|
|
96
|
-
|
97
|
-
|
98
|
-
|
106
|
+
this.addAriaAttrs()
|
107
|
+
this.toggleOnClick()
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
// Add the ARIA attributes with JavaScript
|
112
|
+
// If the JS fails and there's no interactive elements, having
|
113
|
+
// no aria attributes is an accurate representation.
|
114
|
+
GemToggle.prototype.addAriaAttrs = function () {
|
115
|
+
this.$module.toggleTrigger.setAttribute('role', 'button')
|
116
|
+
this.$module.toggleTrigger.setAttribute('aria-controls', this.$module.toggleTrigger.getAttribute('data-controls'))
|
117
|
+
this.$module.toggleTrigger.setAttribute('aria-expanded', this.$module.toggleTrigger.getAttribute('data-expanded'))
|
118
|
+
this.$module.targets = this.getTargetElements()
|
119
|
+
|
120
|
+
for (var i = 0; i < this.$module.targets.length; i++) {
|
121
|
+
this.$module.targets[i].setAttribute('aria-live', 'polite')
|
122
|
+
this.$module.targets[i].setAttribute('role', 'region')
|
123
|
+
}
|
124
|
+
}
|
99
125
|
|
100
|
-
|
126
|
+
GemToggle.prototype.getTargetElements = function () {
|
127
|
+
var ids = this.$module.toggleTrigger.getAttribute('aria-controls').split(' ')
|
128
|
+
var selector = '#' + ids.join(', #')
|
129
|
+
|
130
|
+
return this.$module.querySelectorAll(selector)
|
131
|
+
}
|
132
|
+
|
133
|
+
GemToggle.prototype.toggleOnClick = function () {
|
134
|
+
var that = this
|
135
|
+
|
136
|
+
this.$module.toggleTrigger.addEventListener('click', function (event) {
|
137
|
+
event.preventDefault()
|
138
|
+
var expanded = this.getAttribute('aria-expanded') === 'true'
|
139
|
+
|
140
|
+
if (expanded) {
|
141
|
+
this.setAttribute('aria-expanded', false)
|
142
|
+
for (var i = 0; i < that.$module.targets.length; i++) {
|
143
|
+
that.$module.targets[i].classList.add(that.$module.toggleClass)
|
144
|
+
}
|
145
|
+
} else {
|
146
|
+
this.setAttribute('aria-expanded', true)
|
147
|
+
for (var j = 0; j < that.$module.targets.length; j++) {
|
148
|
+
that.$module.targets[j].classList.remove(that.$module.toggleClass)
|
149
|
+
}
|
101
150
|
}
|
102
151
|
|
103
|
-
|
104
|
-
var options = { label: $toggle.data('toggled-text') || $toggle.text() }
|
152
|
+
var toggledText = this.getAttribute('data-toggled-text')
|
105
153
|
|
106
|
-
|
154
|
+
if (typeof toggledText === 'string') {
|
155
|
+
this.setAttribute('data-toggled-text', this.innerText)
|
156
|
+
this.innerText = toggledText
|
107
157
|
}
|
108
|
-
|
158
|
+
|
159
|
+
if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent && that.$module.isTrackable) {
|
160
|
+
that.track()
|
161
|
+
}
|
162
|
+
})
|
109
163
|
}
|
164
|
+
|
165
|
+
GemToggle.prototype.track = function () {
|
166
|
+
var options = { label: this.$module.toggleTrigger.getAttribute('data-toggled-text') || this.$module.toggleTrigger.innerText }
|
167
|
+
window.GOVUK.analytics.trackEvent(this.$module.trackCategory, this.$module.trackAction, options)
|
168
|
+
}
|
169
|
+
|
170
|
+
Modules.GemToggle = GemToggle
|
110
171
|
})(window.GOVUK.Modules)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// https://plainjs.com/javascript/traversing/get-closest-element-by-selector-39/
|
2
|
+
// matches polyfill
|
3
|
+
this.Element && function(ElementPrototype) {
|
4
|
+
ElementPrototype.matches = ElementPrototype.matches ||
|
5
|
+
ElementPrototype.matchesSelector ||
|
6
|
+
ElementPrototype.webkitMatchesSelector ||
|
7
|
+
ElementPrototype.msMatchesSelector ||
|
8
|
+
function(selector) {
|
9
|
+
var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
|
10
|
+
while (nodes[++i] && nodes[i] != node);
|
11
|
+
return !!nodes[i];
|
12
|
+
}
|
13
|
+
}(Element.prototype);
|
14
|
+
|
15
|
+
// closest polyfill
|
16
|
+
this.Element && function(ElementPrototype) {
|
17
|
+
ElementPrototype.closest = ElementPrototype.closest ||
|
18
|
+
function(selector) {
|
19
|
+
var el = this;
|
20
|
+
while (el.matches && !el.matches(selector)) el = el.parentNode;
|
21
|
+
return el.matches ? el : null;
|
22
|
+
}
|
23
|
+
}(Element.prototype);
|
@@ -4,13 +4,13 @@
|
|
4
4
|
&:before {
|
5
5
|
content: "";
|
6
6
|
display: table-cell;
|
7
|
-
width:
|
7
|
+
width: 60px;
|
8
8
|
height: 45px;
|
9
9
|
background: image-url("govuk_publishing_components/action-link-arrow.png");
|
10
10
|
background: image-url("govuk_publishing_components/action-link-arrow.svg"), linear-gradient(transparent, transparent);
|
11
11
|
background-repeat: no-repeat;
|
12
12
|
background-position: 0 50%;
|
13
|
-
background-size:
|
13
|
+
background-size: 45px auto;
|
14
14
|
}
|
15
15
|
|
16
16
|
@include govuk-media-query($until: tablet) {
|
@@ -141,6 +141,12 @@
|
|
141
141
|
}
|
142
142
|
}
|
143
143
|
|
144
|
+
.gem-c-action-link--transparent-icon {
|
145
|
+
&:before {
|
146
|
+
background-image: image-url("govuk_publishing_components/action-link-arrow--transparent.svg");
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
144
150
|
.gem-c-action-link--nhs {
|
145
151
|
&:before {
|
146
152
|
width: 80px;
|
@@ -9,6 +9,12 @@
|
|
9
9
|
@include govuk-font($size: 24, $weight: bold);
|
10
10
|
}
|
11
11
|
|
12
|
-
.gem-c-panel__prepend ~ .govuk-panel__title {
|
12
|
+
.gem-c-panel__prepend ~ .govuk-panel__title-text {
|
13
13
|
margin-bottom: govuk-spacing(3);
|
14
14
|
}
|
15
|
+
|
16
|
+
.gem-c-panel__append,
|
17
|
+
.gem-c-panel__prepend,
|
18
|
+
.govuk-panel__title-text {
|
19
|
+
display: block;
|
20
|
+
}
|
@@ -12,7 +12,10 @@
|
|
12
12
|
<div class="component-markdown">
|
13
13
|
<%= raw(@component_example.html_description) %>
|
14
14
|
</div>
|
15
|
-
<h2 class="component-doc-h2">
|
15
|
+
<h2 class="component-doc-h2">
|
16
|
+
How it looks
|
17
|
+
<small>(<a href="<%= component_preview_path(@component_doc.id, @component_example.id) %>" class="govuk-link">preview</a>)</small>
|
18
|
+
</h2>
|
16
19
|
<%= render partial: "govuk_publishing_components/component_guide/component_doc/preview", locals: { component_doc: @component_doc, example: @component_example } %>
|
17
20
|
|
18
21
|
<h2 class="component-doc-h2">How to call this example</h2>
|
@@ -29,7 +29,9 @@
|
|
29
29
|
</div>
|
30
30
|
</div>
|
31
31
|
|
32
|
-
<h2 class="component-doc-h2">
|
32
|
+
<h2 class="component-doc-h2">
|
33
|
+
<a href="<%= component_example_path(@component_doc.id, "default") %>" class="govuk-link">How it looks</a>
|
34
|
+
<small>(<a href="<%= component_preview_path(@component_doc.id, "default") %>" class="govuk-link">preview</a>)</small>
|
33
35
|
<small>(<a href="<%= component_preview_all_path(@component_doc.id) %>" class="govuk-link">preview all</a>)</small>
|
34
36
|
</h2>
|
35
37
|
<%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: @component_doc.example %>
|
@@ -13,6 +13,7 @@
|
|
13
13
|
dark_icon ||= false
|
14
14
|
small_icon ||= false
|
15
15
|
nhs_icon ||= false
|
16
|
+
transparent_icon ||= false
|
16
17
|
data ||= nil
|
17
18
|
classes ||= nil
|
18
19
|
|
@@ -20,6 +21,7 @@
|
|
20
21
|
css_classes << "gem-c-action-link--light-text" if light_text
|
21
22
|
css_classes << "gem-c-action-link--dark-icon" if dark_icon
|
22
23
|
css_classes << "gem-c-action-link--small-icon" if small_icon
|
24
|
+
css_classes << "gem-c-action-link--transparent-icon" if transparent_icon
|
23
25
|
css_classes << "gem-c-action-link--nhs" if nhs_icon
|
24
26
|
css_classes << "gem-c-action-link--simple" if simple
|
25
27
|
css_classes << "gem-c-action-link--with-subtext" if subtext
|
@@ -66,7 +66,7 @@
|
|
66
66
|
</div>
|
67
67
|
|
68
68
|
<div class="gem-c-cookie-banner__confirmation govuk-width-container" tabindex="-1">
|
69
|
-
<p class="gem-c-cookie-banner__confirmation-message"><%= confirmation_message %></p>
|
69
|
+
<p class="gem-c-cookie-banner__confirmation-message" role="alert"><%= confirmation_message %></p>
|
70
70
|
<button class="gem-c-cookie-banner__hide-button" data-hide-cookie-banner="true" data-module="track-click" data-track-category="cookieBanner" data-track-action="Hide cookie banner">Hide</button>
|
71
71
|
</div>
|
72
72
|
</div>
|
@@ -4,22 +4,24 @@
|
|
4
4
|
append ||= false
|
5
5
|
%>
|
6
6
|
<div class="gem-c-panel govuk-panel govuk-panel--confirmation">
|
7
|
-
<% if prepend %>
|
8
|
-
<div class="gem-c-panel__prepend">
|
9
|
-
<%= prepend %>
|
10
|
-
</div>
|
11
|
-
<% end %>
|
12
7
|
<h2 class="govuk-panel__title">
|
13
|
-
|
8
|
+
<% if prepend %>
|
9
|
+
<span class="gem-c-panel__prepend">
|
10
|
+
<%= prepend %>
|
11
|
+
</span>
|
12
|
+
<% end %>
|
13
|
+
<span class="govuk-panel__title-text">
|
14
|
+
<%= title %>
|
15
|
+
</span>
|
16
|
+
<% if append %>
|
17
|
+
<span class="gem-c-panel__append">
|
18
|
+
<%= append %>
|
19
|
+
</span>
|
20
|
+
<% end %>
|
14
21
|
</h2>
|
15
22
|
<% if description %>
|
16
23
|
<div class="govuk-panel__body">
|
17
24
|
<%= description %>
|
18
25
|
</div>
|
19
26
|
<% end %>
|
20
|
-
<% if append %>
|
21
|
-
<div class="gem-c-panel__append">
|
22
|
-
<%= append %>
|
23
|
-
</div>
|
24
|
-
<% end %>
|
25
27
|
</div>
|
@@ -53,7 +53,9 @@
|
|
53
53
|
<%= tag.h1 heading, class: "gem-c-radio__heading-text govuk-fieldset__heading" %>
|
54
54
|
<% end %>
|
55
55
|
<% else %>
|
56
|
-
<%= tag.legend
|
56
|
+
<%= tag.legend class: legend_classes do %>
|
57
|
+
<%= tag.h2 heading, class: "govuk-fieldset__heading" %>
|
58
|
+
<% end %>
|
57
59
|
<% end %>
|
58
60
|
<% end %>
|
59
61
|
|
@@ -2,12 +2,16 @@
|
|
2
2
|
size ||= ""
|
3
3
|
no_border ||= false
|
4
4
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
5
|
-
classes = %w(gem-c-search
|
5
|
+
classes = %w(gem-c-search)
|
6
6
|
classes << (shared_helper.get_margin_top)
|
7
7
|
classes << (shared_helper.get_margin_bottom) if local_assigns[:margin_bottom]
|
8
8
|
classes << "gem-c-search--large" if size == 'large'
|
9
9
|
classes << "gem-c-search--no-border" if no_border
|
10
|
-
|
10
|
+
if local_assigns[:on_govuk_blue].eql?(true)
|
11
|
+
classes << "gem-c-search--on-govuk-blue"
|
12
|
+
else
|
13
|
+
classes << "gem-c-search--on-white"
|
14
|
+
end
|
11
15
|
classes << "gem-c-search--separate-label" if local_assigns.include?(:inline_label)
|
12
16
|
|
13
17
|
value ||= ""
|
@@ -28,7 +28,7 @@
|
|
28
28
|
<%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
|
29
29
|
</script>
|
30
30
|
|
31
|
-
<
|
31
|
+
<h2 class="<%= classes %>" data-module="track-click">
|
32
32
|
<span class="gem-c-step-nav-header__part-of">Part of</span>
|
33
33
|
<% if path %>
|
34
34
|
<a href="<%= path %>"
|
@@ -51,5 +51,5 @@
|
|
51
51
|
<%= title %>
|
52
52
|
</span>
|
53
53
|
<% end %>
|
54
|
-
</
|
54
|
+
</h2>
|
55
55
|
<% end %>
|
@@ -36,6 +36,14 @@ examples:
|
|
36
36
|
light_text: true
|
37
37
|
context:
|
38
38
|
dark_background: true
|
39
|
+
with_transparent_svg:
|
40
|
+
data:
|
41
|
+
text: Find out what you need to do
|
42
|
+
href: "/page"
|
43
|
+
light_text: true
|
44
|
+
transparent_icon: true
|
45
|
+
context:
|
46
|
+
dark_background: true
|
39
47
|
with_subtext:
|
40
48
|
data:
|
41
49
|
text: Emergency something
|