@ons/design-system 67.0.3 → 67.0.5
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.
- package/components/char-check-limit/character-limit.js +5 -5
- package/components/details/_details.scss +5 -0
- package/components/details/_macro.njk +9 -9
- package/components/header/example-header-external-with-sub-navigation-removed.njk +70 -0
- package/components/input/_input.scss +6 -0
- package/components/input/_macro.njk +32 -2
- package/components/input/example-input-text-width-constrained.njk +1 -1
- package/components/label/_macro.njk +4 -1
- package/components/navigation/_macro.njk +17 -15
- package/components/navigation/navigation.spec.js +89 -14
- package/components/tabs/_macro.njk +1 -1
- package/components/tabs/_macro.spec.js +0 -10
- package/css/main.css +1 -1
- package/js/analytics.js +26 -24
- package/js/main.js +1 -0
- package/package.json +5 -8
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
package/js/analytics.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import domready from './domready';
|
|
2
2
|
|
|
3
|
-
export let trackEvent = (
|
|
4
|
-
console.log(
|
|
5
|
-
console.log(data); // eslint-disable-line no-console
|
|
3
|
+
export let trackEvent = () => {
|
|
4
|
+
console.log('Google analytics not connected'); // eslint-disable-line no-console
|
|
6
5
|
};
|
|
6
|
+
setTimeout(() => {
|
|
7
|
+
if (window.google_tag_manager !== 'undefined') {
|
|
8
|
+
console.log('GA active');
|
|
9
|
+
window.dataLayer = window.dataLayer || [];
|
|
10
|
+
trackEvent = (data) => {
|
|
11
|
+
console.log('Data sent to Data Layer');
|
|
12
|
+
window.dataLayer.push({ data });
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}, 300);
|
|
7
16
|
|
|
8
|
-
|
|
9
|
-
trackEvent
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export const trackElement = (el) => {
|
|
15
|
-
return trackEvent('send', {
|
|
16
|
-
hitType: 'event',
|
|
17
|
-
eventCategory: el.getAttribute('data-ga-category') || '',
|
|
18
|
-
eventAction: el.getAttribute('data-ga-action') || '',
|
|
19
|
-
eventLabel: el.getAttribute('data-ga-label') || '',
|
|
17
|
+
export const trackElement = (el, type) => {
|
|
18
|
+
return trackEvent({
|
|
19
|
+
event_type: type,
|
|
20
|
+
event_category: el.getAttribute('data-ga-category') || '',
|
|
21
|
+
event_action: el.getAttribute('data-ga-action') || '',
|
|
22
|
+
event_label: el.getAttribute('data-ga-label') || '',
|
|
20
23
|
});
|
|
21
24
|
};
|
|
22
25
|
|
|
@@ -25,27 +28,26 @@ export default function initAnalytics() {
|
|
|
25
28
|
|
|
26
29
|
const interval = window.setInterval(() => {
|
|
27
30
|
trackVisibleElements = trackVisibleElements.filter((element) => {
|
|
28
|
-
return element ? trackElement(element) && false : true;
|
|
31
|
+
return element ? trackElement(element, 'visible') && false : true;
|
|
29
32
|
});
|
|
30
33
|
if (trackVisibleElements.length === 0) {
|
|
31
34
|
window.clearInterval(interval);
|
|
32
35
|
}
|
|
33
36
|
}, 200);
|
|
34
37
|
|
|
35
|
-
[...document.querySelectorAll('[data-ga=error]')].map(trackElement);
|
|
36
|
-
|
|
37
38
|
document.body.addEventListener('click', ({ target }) => {
|
|
38
39
|
if (target.getAttribute('data-ga') === 'click') {
|
|
39
|
-
trackElement(target);
|
|
40
|
+
trackElement(target, target.getAttribute('data-ga'));
|
|
40
41
|
}
|
|
41
42
|
});
|
|
43
|
+
[...document.querySelectorAll('[data-ga=error]')].map((element) => trackElement(element, 'error'));
|
|
42
44
|
|
|
43
45
|
const afterPrint = () => {
|
|
44
|
-
return trackEvent(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
return trackEvent({
|
|
47
|
+
event_tracked: 'true',
|
|
48
|
+
event_category: 'Print Intent',
|
|
49
|
+
event_action: 'Print Intent',
|
|
50
|
+
event_label: window.location.pathname.split('/').slice(-3).join('/'),
|
|
49
51
|
});
|
|
50
52
|
};
|
|
51
53
|
|
package/js/main.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ons/design-system",
|
|
3
3
|
"description": "ONS Design System built CSS, JS, and Nunjucks templates",
|
|
4
|
-
"version": "67.0.
|
|
4
|
+
"version": "67.0.5",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -33,18 +33,15 @@
|
|
|
33
33
|
"lint-staged": {
|
|
34
34
|
"*.js": [
|
|
35
35
|
"prettier --print-width 140 --single-quote --parser babel --write",
|
|
36
|
-
"eslint --fix"
|
|
37
|
-
"git add"
|
|
36
|
+
"eslint --fix"
|
|
38
37
|
],
|
|
39
38
|
"*.md": [
|
|
40
39
|
"prettier --write",
|
|
41
|
-
"remark"
|
|
42
|
-
"git add"
|
|
40
|
+
"remark"
|
|
43
41
|
],
|
|
44
42
|
"*.scss": [
|
|
45
43
|
"prettier --print-width 140 --single-quote --parser scss --write",
|
|
46
|
-
"yarn run stylelint-fix"
|
|
47
|
-
"git add"
|
|
44
|
+
"yarn run stylelint-fix"
|
|
48
45
|
]
|
|
49
46
|
},
|
|
50
47
|
"browserslist": [
|
|
@@ -102,7 +99,7 @@
|
|
|
102
99
|
"jest-environment-jsdom": "^29.6.1",
|
|
103
100
|
"jest-puppeteer": "^9.0.0",
|
|
104
101
|
"lighthouse": "^11.0.0",
|
|
105
|
-
"lint-staged": "^
|
|
102
|
+
"lint-staged": "^15.2.0",
|
|
106
103
|
"lodash": "^4.17.21",
|
|
107
104
|
"mdn-polyfills": "^5.14.0",
|
|
108
105
|
"normalize.css": "^8.0.1",
|