govuk_publishing_components 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 231f4e05eaee81049ea4f72bf5ec1ced16026e3f
|
4
|
+
data.tar.gz: f1564c8de553159a32af562e96dcca4931f2a554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a32780c774231f52e107781140fa301643437b5ff976b63f7fc3f3e2b3a41ecbb786aa742c738039dac6bff514b770f1d7a70cd468e16b56be704ebd1ab04d81
|
7
|
+
data.tar.gz: '0724197ba6f3f37e563bd7b24826d1fb9c8b1942b39332d3fe21d9b6c12d3a1751ebd2dcccba59c45bd248d3ae6777327299283554a6b25d47b725f9517ebbe9'
|
data/README.md
CHANGED
@@ -121,6 +121,17 @@ if !Rails.env.production? || ENV['HEROKU_APP_NAME'].present?
|
|
121
121
|
end
|
122
122
|
```
|
123
123
|
|
124
|
+
## Automated Testing
|
125
|
+
### Visual Diff Tool
|
126
|
+
The component guide includes a visual diff tool that should make it easier to spot when you are introducing visual regressions in your components.
|
127
|
+
|
128
|
+
It can be run on a locally running version of the component guide, to compare it to the heroku master deploy. For example: [government-frontend.dev.gov.uk/component-guide](government-frontend.dev.gov.uk/component-guide) will be compared to [government-frontend.herokuapp.com/component-guide](government-frontend.herokuapp.com/component-guide).
|
129
|
+
|
130
|
+
The tool can be run via the console using the following command:
|
131
|
+
```js
|
132
|
+
window.GOVUK.VisualDiffTool()`
|
133
|
+
```
|
134
|
+
|
124
135
|
## Licence
|
125
136
|
|
126
137
|
[MIT Licence](LICENCE.md)
|
@@ -0,0 +1,75 @@
|
|
1
|
+
(function (window, document) {
|
2
|
+
window.GOVUK = window.GOVUK || {}
|
3
|
+
|
4
|
+
window.GOVUK.VisualDiffTool = function (currentWindowLocation) {
|
5
|
+
const 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 href = url.href;
|
46
|
+
var host = url.host;
|
47
|
+
|
48
|
+
if (href.includes('dev.gov.uk/component-guide')) {
|
49
|
+
var appName = host.split('.')[0];
|
50
|
+
|
51
|
+
if (appName === 'static') {
|
52
|
+
appName = 'govuk-static';
|
53
|
+
}
|
54
|
+
|
55
|
+
return _forceHTTPS(href.replace(host, appName + '.herokuapp.com'));
|
56
|
+
} else if (href.includes('dev.gov.uk')) {
|
57
|
+
return _forceHTTPS(href.replace(host, 'www.gov.uk'));
|
58
|
+
} else if (href.includes('-pr-')) {
|
59
|
+
var appName = host.split('-pr')[0];
|
60
|
+
return _forceHTTPS(href.replace(host, appName + '.herokuapp.com'));
|
61
|
+
} else {
|
62
|
+
throw new Error('Visual Diff Tool: You need to run this tool against a page running on your local dev environment');
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
var _forceHTTPS = function(href) {
|
67
|
+
return href.replace('http://', 'https://');
|
68
|
+
}
|
69
|
+
|
70
|
+
var _setElementStyles = function(element, styles) {
|
71
|
+
for (var style in styles) {
|
72
|
+
element.style[style] = styles[style];
|
73
|
+
}
|
74
|
+
};
|
75
|
+
})(window, document);
|
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: 1.
|
4
|
+
version: 1.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: 2017-09-
|
11
|
+
date: 2017-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- app/assets/javascripts/govuk_publishing_components/application.js
|
195
195
|
- app/assets/javascripts/govuk_publishing_components/vendor/axe.min.js
|
196
196
|
- app/assets/javascripts/govuk_publishing_components/vendor/matches-polyfill.min.js
|
197
|
+
- app/assets/javascripts/govuk_publishing_components/visual-regression.js
|
197
198
|
- app/assets/stylesheets/govuk_publishing_components/application.scss
|
198
199
|
- app/controllers/govuk_publishing_components/application_controller.rb
|
199
200
|
- app/controllers/govuk_publishing_components/component_guide_controller.rb
|