@ons/design-system 73.4.1 → 73.6.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.
- package/README.md +23 -0
- package/components/accordion/accordion.js +1 -0
- package/components/chart/_chart.scss +1 -3
- package/components/cookies-banner/_macro.njk +7 -2
- package/components/cookies-banner/_macro.spec.js +6 -0
- package/components/description-list/_description-list.scss +1 -1
- package/components/details/details.js +1 -0
- package/components/details/details.spec.js +3 -1
- package/components/header/_header.scss +0 -10
- package/components/hero/_hero.scss +2 -2
- package/components/icon/_macro.njk +159 -5
- package/components/list/_list.scss +0 -6
- package/components/skip-to-content/_macro.njk +4 -2
- package/components/summary/_summary.scss +2 -3
- package/components/table-of-contents/_macro.njk +1 -1
- package/components/table-of-contents/_macro.spec.js +17 -0
- package/css/main.css +1 -1
- package/js/cookies-functions.js +18 -1
- package/js/cookies-functions.spec.js +21 -0
- package/layout/_template.njk +1 -1
- package/package.json +12 -11
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +3 -3
- package/scss/base/_global.scss +1 -1
- package/scss/utilities/_highlight.scss +1 -1
- package/scss/vars/_grid.scss +1 -1
- package/scss/vars/_typography.scss +18 -18
package/js/cookies-functions.js
CHANGED
|
@@ -167,10 +167,27 @@ export function getCookie(name) {
|
|
|
167
167
|
return null;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
function getCookieDomainPolicy() {
|
|
171
|
+
const banner = document.querySelector('.ons-cookies-banner');
|
|
172
|
+
const policy = banner ? banner.getAttribute('data-ons-cookie-domain-policy') : null;
|
|
173
|
+
|
|
174
|
+
// plan: add 'exact-host' policy in future and retire 'legacy' and 'day1'
|
|
175
|
+
switch (policy) {
|
|
176
|
+
case 'legacy':
|
|
177
|
+
case 'day1':
|
|
178
|
+
return policy;
|
|
179
|
+
default:
|
|
180
|
+
return 'legacy';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
170
184
|
export function getDomain(domain, cookieHandler = document) {
|
|
171
|
-
|
|
185
|
+
const cookieDomainPolicy = getCookieDomainPolicy();
|
|
186
|
+
|
|
187
|
+
if (cookieDomainPolicy === 'legacy' && domain.startsWith('www.')) {
|
|
172
188
|
domain = domain.substring(4);
|
|
173
189
|
}
|
|
190
|
+
|
|
174
191
|
let i = 0,
|
|
175
192
|
domainName = domain,
|
|
176
193
|
p = domainName.split('.'),
|
|
@@ -25,6 +25,7 @@ export const setMockcookie = {
|
|
|
25
25
|
describe('script: getDomain()', () => {
|
|
26
26
|
beforeEach(() => {
|
|
27
27
|
mockCookieStore = {}; // clear the cookie between tests
|
|
28
|
+
document.body.innerHTML = '';
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
test('should return service-manual.ons.gov.uk as the domain name when cookies can be set at the full subdomain', () => {
|
|
@@ -37,6 +38,26 @@ describe('script: getDomain()', () => {
|
|
|
37
38
|
expect(result).toBe('ons.gov.uk');
|
|
38
39
|
});
|
|
39
40
|
|
|
41
|
+
test('removes `www` when cookieDomainPolicy is `legacy`', () => {
|
|
42
|
+
const banner = document.createElement('div');
|
|
43
|
+
banner.className = 'ons-cookies-banner';
|
|
44
|
+
banner.setAttribute('data-ons-cookie-domain-policy', 'legacy');
|
|
45
|
+
document.body.appendChild(banner);
|
|
46
|
+
|
|
47
|
+
const result = getDomain('www.ons.gov.uk', setMockcookie);
|
|
48
|
+
expect(result).toBe('ons.gov.uk');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('does not remove `www` when cookieDomainPolicy is `day1`', () => {
|
|
52
|
+
const banner = document.createElement('div');
|
|
53
|
+
banner.className = 'ons-cookies-banner';
|
|
54
|
+
banner.setAttribute('data-ons-cookie-domain-policy', 'day1');
|
|
55
|
+
document.body.appendChild(banner);
|
|
56
|
+
|
|
57
|
+
const result = getDomain('www.ons.gov.uk', setMockcookie);
|
|
58
|
+
expect(result).toBe('www.ons.gov.uk');
|
|
59
|
+
});
|
|
60
|
+
|
|
40
61
|
test('returns `ons.gov.uk` as the domain name when cookies can not be set at subdomain `new-website.ons.gov.uk`', () => {
|
|
41
62
|
const result = getDomain('new-website.ons.gov.uk', setMockcookie);
|
|
42
63
|
expect(result).toBe('ons.gov.uk');
|
package/layout/_template.njk
CHANGED
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
<head>
|
|
63
63
|
<meta charset="utf-8" />
|
|
64
64
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
65
|
-
<meta name="viewport" content="width=device-width, initial-scale=1
|
|
65
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
66
66
|
<title>{{ pageTitle }}</title>
|
|
67
67
|
<link rel="stylesheet" href="{{ assetsUrl }}/css/main.css" />
|
|
68
68
|
<link rel="stylesheet" media="print" href="{{ assetsUrl }}/css/print.css" />
|
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": "73.
|
|
4
|
+
"version": "73.6.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"not dead"
|
|
55
55
|
],
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@babel/core": "7.
|
|
58
|
-
"@babel/eslint-parser": "7.
|
|
59
|
-
"@babel/node": "7.
|
|
57
|
+
"@babel/core": "7.29.0",
|
|
58
|
+
"@babel/eslint-parser": "7.28.6",
|
|
59
|
+
"@babel/node": "7.29.0",
|
|
60
60
|
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
61
61
|
"@babel/plugin-syntax-dynamic-import": "7.8.3",
|
|
62
|
-
"@babel/plugin-transform-modules-commonjs": "7.
|
|
63
|
-
"@babel/plugin-transform-runtime": "7.
|
|
64
|
-
"@babel/preset-env": "7.
|
|
65
|
-
"@babel/register": "7.
|
|
66
|
-
"@babel/runtime": "7.
|
|
67
|
-
"@eslint/eslintrc": "3.3.
|
|
62
|
+
"@babel/plugin-transform-modules-commonjs": "7.28.6",
|
|
63
|
+
"@babel/plugin-transform-runtime": "7.29.0",
|
|
64
|
+
"@babel/preset-env": "7.29.3",
|
|
65
|
+
"@babel/register": "7.29.3",
|
|
66
|
+
"@babel/runtime": "7.29.2",
|
|
67
|
+
"@eslint/eslintrc": "3.3.5",
|
|
68
68
|
"@eslint/js": "9.39.2",
|
|
69
69
|
"abortcontroller-polyfill": "1.7.8",
|
|
70
70
|
"autoprefixer": "10.4.21",
|
|
@@ -143,6 +143,7 @@
|
|
|
143
143
|
"pym.js": "1.3.2"
|
|
144
144
|
},
|
|
145
145
|
"resolutions": {
|
|
146
|
-
"basic-ftp": "5.2.0"
|
|
146
|
+
"basic-ftp": "5.2.0",
|
|
147
|
+
"axios": "1.15.2"
|
|
147
148
|
}
|
|
148
149
|
}
|