govuk_publishing_components 24.9.4 → 24.10.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/javascripts/govuk_publishing_components/components/accordion.js +1 -2
- data/app/assets/javascripts/govuk_publishing_components/components/show-password.js +12 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +34 -34
- data/app/assets/stylesheets/govuk_publishing_components/components/_notice.scss +4 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +20 -20
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_px-to-em.scss +2 -0
- data/app/views/govuk_publishing_components/components/_notice.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_show_password.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/docs/show_password.yml +10 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -3
- data/app/assets/javascripts/component_guide/visual-regression.js +0 -71
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da7ab3cbd89ef8a20000b0a9d6ffad43c92532e787106e6821cccd7c8d9f90b2
|
|
4
|
+
data.tar.gz: 1362df93036bb10322e881d5136a0303be0d96a745541afc122ad79949d36820
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a50d991265471b7c0025b59f50c2a51f4599c6fc5e629ad8c0f64158af0570812224938e08ad36193587b46c03a8bf37200def0167d47537868d1a9b31839305
|
|
7
|
+
data.tar.gz: a3104340ed6d431791b48ebf1fc9c8b2d89563c608cbe050082efdafc68a949d13bf5f198be9c39b7ad7b1e1d2b18de1556a9f21c9a9c89e65c1b52db02942ba
|
|
@@ -326,8 +326,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
326
326
|
// Adding an event listener to all anchor link a tags in an accordion is risky but we circumvent this risk partially by only being a layer of accordion behaviour instead of any sort of change to link behaviour
|
|
327
327
|
GemAccordion.prototype.addEventListenersForAnchors = function () {
|
|
328
328
|
var links = this.$module.querySelectorAll('.' + this.sectionInnerContent + ' a[href*="#"]')
|
|
329
|
-
|
|
330
|
-
links.forEach(function (link) {
|
|
329
|
+
nodeListForEach(links, function (link) {
|
|
331
330
|
if (link.pathname === window.location.pathname) {
|
|
332
331
|
link.addEventListener('click', this.openForAnchor.bind(this, link.hash.split('#')[1]))
|
|
333
332
|
}
|
|
@@ -41,6 +41,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
41
41
|
this.wrapper.insertBefore(this.statusText, this.showHide.nextSibling)
|
|
42
42
|
|
|
43
43
|
this.showHide.addEventListener('click', this.$module.togglePassword)
|
|
44
|
+
this.moveDataAttributesToButton()
|
|
44
45
|
|
|
45
46
|
this.parentForm = this.input.form
|
|
46
47
|
var disableFormSubmitCheck = this.$module.getAttribute('data-disable-form-submit-check')
|
|
@@ -65,5 +66,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
65
66
|
this.input.setAttribute('type', 'password')
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
ShowPassword.prototype.moveDataAttributesToButton = function () {
|
|
70
|
+
var attrs = this.input.attributes
|
|
71
|
+
for (var i = attrs.length; i >= 0; i--) {
|
|
72
|
+
var attr = attrs[i]
|
|
73
|
+
if (attr && /^data-button/.test(attr.name)) {
|
|
74
|
+
this.showHide.setAttribute(attr.name.replace('-button', ''), attr.value)
|
|
75
|
+
this.input.removeAttribute(attr.name)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
68
80
|
Modules.ShowPassword = ShowPassword
|
|
69
81
|
})(window.GOVUK.Modules)
|
|
@@ -68,17 +68,17 @@ $gem-c-accordion-bottom-border-width: 1px;
|
|
|
68
68
|
display: inline-block;
|
|
69
69
|
box-sizing: border-box;
|
|
70
70
|
position: relative;
|
|
71
|
-
width: em(20, 14);
|
|
72
|
-
height: em(20, 14);
|
|
73
|
-
margin-left: em(5, 14);
|
|
74
|
-
border: em(1, 14) solid;
|
|
75
|
-
border-radius: em(100, 14);
|
|
71
|
+
width: govuk-em(20, 14);
|
|
72
|
+
height: govuk-em(20, 14);
|
|
73
|
+
margin-left: govuk-em(5, 14);
|
|
74
|
+
border: govuk-em(1, 14) solid;
|
|
75
|
+
border-radius: govuk-em(100, 14);
|
|
76
76
|
// Main icon size across views, yet keep responsive for zoom
|
|
77
77
|
@include govuk-media-query($from: tablet) {
|
|
78
|
-
width: em(20, 16);
|
|
79
|
-
height: em(20, 16);
|
|
80
|
-
margin-left: em(5, 16);
|
|
81
|
-
border: em(1, 16) solid;
|
|
78
|
+
width: govuk-em(20, 16);
|
|
79
|
+
height: govuk-em(20, 16);
|
|
80
|
+
margin-left: govuk-em(5, 16);
|
|
81
|
+
border: govuk-em(1, 16) solid;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
&:after {
|
|
@@ -87,20 +87,20 @@ $gem-c-accordion-bottom-border-width: 1px;
|
|
|
87
87
|
box-sizing: border-box;
|
|
88
88
|
position: absolute;
|
|
89
89
|
overflow: visible;
|
|
90
|
-
width: em(6, 14);
|
|
91
|
-
height: em(6, 14);
|
|
92
|
-
border-top: em(2, 14) solid;
|
|
93
|
-
border-right: em(2, 14) solid;
|
|
90
|
+
width: govuk-em(6, 14);
|
|
91
|
+
height: govuk-em(6, 14);
|
|
92
|
+
border-top: govuk-em(2, 14) solid;
|
|
93
|
+
border-right: govuk-em(2, 14) solid;
|
|
94
94
|
transform: rotate(-45deg);
|
|
95
|
-
left: em(6, 14);
|
|
96
|
-
bottom: em(5, 14);
|
|
95
|
+
left: govuk-em(6, 14);
|
|
96
|
+
bottom: govuk-em(5, 14);
|
|
97
97
|
@include govuk-media-query($from: tablet) {
|
|
98
|
-
width: em(6, 16);
|
|
99
|
-
height: em(6, 16);
|
|
100
|
-
border-top: em(2, 16) solid;
|
|
101
|
-
border-right: em(2, 16) solid;
|
|
102
|
-
left: em(6, 16);
|
|
103
|
-
bottom: em(5, 16);
|
|
98
|
+
width: govuk-em(6, 16);
|
|
99
|
+
height: govuk-em(6, 16);
|
|
100
|
+
border-top: govuk-em(2, 16) solid;
|
|
101
|
+
border-right: govuk-em(2, 16) solid;
|
|
102
|
+
left: govuk-em(6, 16);
|
|
103
|
+
bottom: govuk-em(5, 16);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -227,12 +227,12 @@ $gem-c-accordion-bottom-border-width: 1px;
|
|
|
227
227
|
|
|
228
228
|
// Setting width of the text, so the icon doesn't shift (left / right) when toggled
|
|
229
229
|
.gem-c-accordion__toggle-text {
|
|
230
|
-
min-width: em(40, 16);
|
|
230
|
+
min-width: govuk-em(40, 16);
|
|
231
231
|
display: inline-block;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
.gem-c-accordion__open-all-text {
|
|
235
|
-
min-width: em(120, 16);
|
|
235
|
+
min-width: govuk-em(120, 16);
|
|
236
236
|
display: inline-block;
|
|
237
237
|
text-align: left;
|
|
238
238
|
}
|
|
@@ -277,20 +277,20 @@ $gem-c-accordion-bottom-border-width: 1px;
|
|
|
277
277
|
|
|
278
278
|
// Reduce Chevron size
|
|
279
279
|
.gem-c-accordion-nav__chevron {
|
|
280
|
-
width: em(20, 14);
|
|
281
|
-
height: em(20, 14);
|
|
282
|
-
margin-left: em(5, 14);
|
|
283
|
-
border: em(1, 14) solid;
|
|
284
|
-
border-radius: em(100, 14);
|
|
280
|
+
width: govuk-em(20, 14);
|
|
281
|
+
height: govuk-em(20, 14);
|
|
282
|
+
margin-left: govuk-em(5, 14);
|
|
283
|
+
border: govuk-em(1, 14) solid;
|
|
284
|
+
border-radius: govuk-em(100, 14);
|
|
285
285
|
transform: scale(.875);
|
|
286
286
|
|
|
287
287
|
&:after {
|
|
288
|
-
width: em(6, 14);
|
|
289
|
-
height: em(6, 14);
|
|
290
|
-
border-top: em(2, 14) solid;
|
|
291
|
-
border-right: em(2, 14) solid;
|
|
292
|
-
left: em(6, 14);
|
|
293
|
-
bottom: em(5, 14);
|
|
288
|
+
width: govuk-em(6, 14);
|
|
289
|
+
height: govuk-em(6, 14);
|
|
290
|
+
border-top: govuk-em(2, 14) solid;
|
|
291
|
+
border-right: govuk-em(2, 14) solid;
|
|
292
|
+
left: govuk-em(6, 14);
|
|
293
|
+
bottom: govuk-em(5, 14);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
clear: both;
|
|
7
7
|
border: $govuk-border-width solid govuk-colour("blue");
|
|
8
8
|
|
|
9
|
-
.govuk-govspeak
|
|
9
|
+
.govuk-govspeak {
|
|
10
10
|
p:last-child {
|
|
11
11
|
margin-bottom: 0;
|
|
12
12
|
}
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
a {
|
|
30
|
-
@
|
|
30
|
+
@include govuk-link-common;
|
|
31
|
+
@include govuk-link-style-default;
|
|
32
|
+
@include govuk-link-print-friendly;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -53,8 +53,8 @@ $large-input-size: 50px;
|
|
|
53
53
|
@include govuk-font($size: 19, $line-height: (28 / 19));
|
|
54
54
|
margin: 0;
|
|
55
55
|
width: 100%;
|
|
56
|
-
height: em(40, 16);
|
|
57
|
-
padding: em(6, 16);
|
|
56
|
+
height: govuk-em(40, 16);
|
|
57
|
+
padding: govuk-em(6, 16);
|
|
58
58
|
border: $govuk-border-width-form-element solid $govuk-input-border-colour;
|
|
59
59
|
background: govuk-colour("white");
|
|
60
60
|
border-radius: 0; //otherwise iphones apply an automatic border radius
|
|
@@ -63,8 +63,8 @@ $large-input-size: 50px;
|
|
|
63
63
|
-moz-appearance: none;
|
|
64
64
|
appearance: none;
|
|
65
65
|
@include govuk-media-query($from: tablet) {
|
|
66
|
-
height: em(40, 19);
|
|
67
|
-
padding: em(6, 19);
|
|
66
|
+
height: govuk-em(40, 19);
|
|
67
|
+
padding: govuk-em(6, 19);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// the .focus class is added by JS and ensures that the input remains above the label once clicked/filled in
|
|
@@ -15,12 +15,12 @@ $top-border: solid 1px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
|
15
15
|
|
|
16
16
|
@mixin step-nav-line-position {
|
|
17
17
|
left: 0;
|
|
18
|
-
margin-left: em(($number-circle-size / 2) - ($stroke-width / 2), 16);
|
|
18
|
+
margin-left: govuk-em(($number-circle-size / 2) - ($stroke-width / 2), 16);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
@mixin step-nav-line-position-large {
|
|
22
22
|
left: 0;
|
|
23
|
-
margin-left: em(($number-circle-size-large / 2) - ($stroke-width / 2), 16);
|
|
23
|
+
margin-left: govuk-em(($number-circle-size-large / 2) - ($stroke-width / 2), 16);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// custom mixin as govuk-font does undesirable things at different breakpoints
|
|
@@ -136,10 +136,10 @@ $top-border: solid 1px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
|
136
136
|
.gem-c-step-nav__chevron {
|
|
137
137
|
display: inline-block;
|
|
138
138
|
vertical-align: middle;
|
|
139
|
-
margin-left: em(5, 14);
|
|
139
|
+
margin-left: govuk-em(5, 14);
|
|
140
140
|
|
|
141
141
|
.gem-c-step-nav--large & {
|
|
142
|
-
margin-left: em(5, 16);
|
|
142
|
+
margin-left: govuk-em(5, 16);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
svg {
|
|
@@ -150,18 +150,18 @@ $top-border: solid 1px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
|
150
150
|
.gem-c-step-nav__button-text {
|
|
151
151
|
display: inline-block;
|
|
152
152
|
text-align: left;
|
|
153
|
-
min-width: em(35, 14);
|
|
153
|
+
min-width: govuk-em(35, 14);
|
|
154
154
|
|
|
155
155
|
.gem-c-step-nav--large & {
|
|
156
|
-
min-width: em(40, 16);
|
|
156
|
+
min-width: govuk-em(40, 16);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
.gem-c-step-nav__button-text--all {
|
|
161
|
-
min-width: em(87, 14);
|
|
161
|
+
min-width: govuk-em(87, 14);
|
|
162
162
|
|
|
163
163
|
.gem-c-step-nav--large & {
|
|
164
|
-
min-width: em(100, 16);
|
|
164
|
+
min-width: govuk-em(100, 16);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -172,23 +172,23 @@ $top-border: solid 1px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
|
172
172
|
|
|
173
173
|
.gem-c-step-nav__step {
|
|
174
174
|
position: relative;
|
|
175
|
-
padding-left: em(govuk-spacing(6) + govuk-spacing(3), 16);
|
|
175
|
+
padding-left: govuk-em(govuk-spacing(6) + govuk-spacing(3), 16);
|
|
176
176
|
list-style: none;
|
|
177
177
|
|
|
178
178
|
// line down the side of a step
|
|
179
179
|
&:after {
|
|
180
180
|
@include step-nav-vertical-line;
|
|
181
181
|
@include step-nav-line-position;
|
|
182
|
-
top: em(govuk-spacing(3), 16);
|
|
182
|
+
top: govuk-em(govuk-spacing(3), 16);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
.gem-c-step-nav--large & {
|
|
186
186
|
@include govuk-media-query($from: tablet) {
|
|
187
|
-
padding-left: em(govuk-spacing(9), 16);
|
|
187
|
+
padding-left: govuk-em(govuk-spacing(9), 16);
|
|
188
188
|
|
|
189
189
|
&:after { // stylelint-disable-line max-nesting-depth
|
|
190
190
|
@include step-nav-line-position-large;
|
|
191
|
-
top: em(govuk-spacing(6), 16);
|
|
191
|
+
top: govuk-em(govuk-spacing(6), 16);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -246,8 +246,8 @@ $top-border: solid 1px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
|
246
246
|
z-index: 5;
|
|
247
247
|
top: 3px;
|
|
248
248
|
left: 0;
|
|
249
|
-
width: em($number-circle-size, 16);
|
|
250
|
-
height: em($number-circle-size, 16);
|
|
249
|
+
width: govuk-em($number-circle-size, 16);
|
|
250
|
+
height: govuk-em($number-circle-size, 16);
|
|
251
251
|
color: govuk-colour("black");
|
|
252
252
|
background: govuk-colour("white");
|
|
253
253
|
border-radius: 100px;
|
|
@@ -256,8 +256,8 @@ $top-border: solid 1px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
|
256
256
|
.gem-c-step-nav--large & {
|
|
257
257
|
@include govuk-media-query($from: tablet) {
|
|
258
258
|
top: 11px;
|
|
259
|
-
width: em($number-circle-size-large, 19);
|
|
260
|
-
height: em($number-circle-size-large, 19);
|
|
259
|
+
width: govuk-em($number-circle-size-large, 19);
|
|
260
|
+
height: govuk-em($number-circle-size-large, 19);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
}
|
|
@@ -283,15 +283,15 @@ $top-border: solid 1px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
|
283
283
|
.gem-c-step-nav__circle--logic {
|
|
284
284
|
@include step-nav-font(19, $weight: bold, $line-height: 28px);
|
|
285
285
|
left: 3px;
|
|
286
|
-
width: em($number-circle-size, 19);
|
|
287
|
-
height: em($number-circle-size, 19);
|
|
286
|
+
width: govuk-em($number-circle-size, 19);
|
|
287
|
+
height: govuk-em($number-circle-size, 19);
|
|
288
288
|
|
|
289
289
|
.gem-c-step-nav--large & {
|
|
290
290
|
@include step-nav-font(19, $tablet-size: 24, $weight: bold, $line-height: 28px, $tablet-line-height: 34px);
|
|
291
291
|
|
|
292
292
|
@include govuk-media-query($from: tablet) {
|
|
293
|
-
width: em($number-circle-size-large, 24);
|
|
294
|
-
height: em($number-circle-size-large, 24);
|
|
293
|
+
width: govuk-em($number-circle-size-large, 24);
|
|
294
|
+
height: govuk-em($number-circle-size-large, 24);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Convert pixels to em
|
|
2
2
|
@function em($value, $gem-context-font-size) {
|
|
3
|
+
@warn "This function is deprecated and will be removed in the next major version release - use GOV.UK Frontend's `govuk-em()` instead.";
|
|
4
|
+
|
|
3
5
|
@if (unitless($value)) {
|
|
4
6
|
$value: $value * 1px;
|
|
5
7
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
|
12
12
|
|
|
13
|
-
css_classes = %w
|
|
13
|
+
css_classes = %w[gem-c-notice]
|
|
14
14
|
css_classes << (shared_helper.get_margin_bottom)
|
|
15
15
|
|
|
16
16
|
aria_attributes = aria_live ? {label: 'Notice', live: 'polite'} : {label: 'Notice'}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
hint ||= nil
|
|
10
10
|
error_message ||= nil
|
|
11
11
|
error_items ||= nil
|
|
12
|
+
data ||= nil
|
|
12
13
|
|
|
13
14
|
if !label
|
|
14
15
|
raise ArgumentError, "This component requires a label"
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
error_items: error_items,
|
|
38
39
|
type: "password",
|
|
39
40
|
autocomplete: autocomplete,
|
|
41
|
+
data: data,
|
|
40
42
|
} %>
|
|
41
43
|
<% end %>
|
|
42
44
|
<% end %>
|
|
@@ -79,3 +79,13 @@ examples:
|
|
|
79
79
|
error_items:
|
|
80
80
|
- text: Look I keep telling you
|
|
81
81
|
- text: This isn't your password
|
|
82
|
+
with_data_attributes:
|
|
83
|
+
description: Data attributes can be passed to add to the input element. If the data attribute starts with `data-button-` this attribute will be applied to the show/hide button, instead of the input. Note that if JS is disabled, all attributes are added to the input.
|
|
84
|
+
data:
|
|
85
|
+
label:
|
|
86
|
+
text: Your password
|
|
87
|
+
data:
|
|
88
|
+
example_1: value
|
|
89
|
+
example_2: thing
|
|
90
|
+
button_example_1: wotsit
|
|
91
|
+
button_example_2: doodad
|
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: 24.
|
|
4
|
+
version: 24.10.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: 2021-04-
|
|
11
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: govuk_app_config
|
|
@@ -416,7 +416,6 @@ files:
|
|
|
416
416
|
- app/assets/javascripts/component_guide/filter-components.js
|
|
417
417
|
- app/assets/javascripts/component_guide/vendor/bind-polyfill.js
|
|
418
418
|
- app/assets/javascripts/component_guide/vendor/matches-polyfill.min.js
|
|
419
|
-
- app/assets/javascripts/component_guide/visual-regression.js
|
|
420
419
|
- app/assets/javascripts/govuk_publishing_components/all_components.js
|
|
421
420
|
- app/assets/javascripts/govuk_publishing_components/analytics.js
|
|
422
421
|
- app/assets/javascripts/govuk_publishing_components/analytics/analytics.js
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
(function (window, document) {
|
|
2
|
-
window.GOVUK = window.GOVUK || {}
|
|
3
|
-
|
|
4
|
-
window.GOVUK.VisualDiffTool = function (currentWindowLocation) {
|
|
5
|
-
var visualDiffSelector = 'visual-diff'
|
|
6
|
-
var existingIframe = document.getElementById(visualDiffSelector)
|
|
7
|
-
var windowLocation = currentWindowLocation || window.location
|
|
8
|
-
|
|
9
|
-
if (existingIframe) {
|
|
10
|
-
existingIframe.parentNode.removeChild(existingIframe)
|
|
11
|
-
document.body.style.filter = null
|
|
12
|
-
} else {
|
|
13
|
-
var iframe = document.createElement('iframe')
|
|
14
|
-
iframe.id = visualDiffSelector
|
|
15
|
-
iframe.setAttribute('scrolling', 'no')
|
|
16
|
-
_setElementStyles(iframe, {
|
|
17
|
-
width: '100%',
|
|
18
|
-
height: document.body.scrollHeight + 'px',
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
top: '0',
|
|
21
|
-
'pointer-events': 'none',
|
|
22
|
-
border: '0'
|
|
23
|
-
})
|
|
24
|
-
iframe.style.setProperty('z-index', '999', 'important')
|
|
25
|
-
|
|
26
|
-
// For browsers that support it, do mix-blend-mode diff
|
|
27
|
-
if ('mix-blend-mode' in document.body.style) {
|
|
28
|
-
_setElementStyles(iframe, { 'mix-blend-mode': 'difference' })
|
|
29
|
-
document.body.style.filter = 'invert(100%)'
|
|
30
|
-
} else {
|
|
31
|
-
// Else do a simple overlay of the live page for comparison (IE and Edge)
|
|
32
|
-
_setElementStyles(iframe, { opacity: '0.7' })
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
iframe.src = _processComparisonURL(windowLocation)
|
|
36
|
-
|
|
37
|
-
if (iframe.src) {
|
|
38
|
-
document.body.appendChild(iframe)
|
|
39
|
-
console.log('comparing to ' + iframe.src)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var _processComparisonURL = function (url) {
|
|
45
|
-
var appName
|
|
46
|
-
var href = url.href
|
|
47
|
-
var host = url.host
|
|
48
|
-
|
|
49
|
-
if (href.includes('dev.gov.uk/component-guide')) {
|
|
50
|
-
appName = host.split('.')[0]
|
|
51
|
-
return _forceHTTPS(href.replace(host, appName + '.herokuapp.com'))
|
|
52
|
-
} else if (href.includes('dev.gov.uk')) {
|
|
53
|
-
return _forceHTTPS(href.replace(host, 'www.gov.uk'))
|
|
54
|
-
} else if (href.includes('-pr-')) {
|
|
55
|
-
appName = host.split('-pr')[0]
|
|
56
|
-
return _forceHTTPS(href.replace(host, appName + '.herokuapp.com'))
|
|
57
|
-
} else {
|
|
58
|
-
throw new Error('Visual Diff Tool: You need to run this tool against a page running on your local dev environment')
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var _forceHTTPS = function (href) {
|
|
63
|
-
return href.replace('http://', 'https://')
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
var _setElementStyles = function (element, styles) {
|
|
67
|
-
for (var style in styles) {
|
|
68
|
-
element.style[style] = styles[style]
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
})(window, document)
|