@ons/design-system 72.4.0 → 72.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/components/button/_button.scss +171 -3
- package/components/button/_macro.njk +4 -0
- package/components/card/_card.scss +5 -0
- package/components/card/_macro.njk +10 -2
- package/components/card/_macro.spec.js +58 -0
- package/components/card/example-card-set-with-headline-figures.njk +62 -0
- package/components/chart/_chart.scss +80 -0
- package/components/chart/_macro.njk +125 -0
- package/components/chart/_macro.spec.js +825 -0
- package/components/chart/annotations-options.js +78 -0
- package/components/chart/bar-chart.js +164 -0
- package/components/chart/chart-constants.js +21 -0
- package/components/chart/chart.dom.js +8 -0
- package/components/chart/chart.js +242 -0
- package/components/chart/column-chart.js +48 -0
- package/components/chart/common-chart-options.js +247 -0
- package/components/chart/example-bar-chart-with-annotations.njk +62 -0
- package/components/chart/example-bar-chart.njk +55 -0
- package/components/chart/example-bar-with-line-chart.njk +64 -0
- package/components/chart/example-clustered-bar-chart.njk +60 -0
- package/components/chart/example-clustered-column-chart.njk +74 -0
- package/components/chart/example-column-chart-with-annotations.njk +62 -0
- package/components/chart/example-column-chart.njk +54 -0
- package/components/chart/example-column-with-line-chart.njk +62 -0
- package/components/chart/example-line-chart-with-annotations.njk +235 -0
- package/components/chart/example-line-chart.njk +221 -0
- package/components/chart/example-stacked-bar-chart.njk +60 -0
- package/components/chart/example-stacked-column-chart.njk +67 -0
- package/components/chart/line-chart.js +42 -0
- package/components/chart/specific-chart-options.js +22 -0
- package/components/footer/_footer.scss +12 -0
- package/components/footer/_macro.njk +38 -17
- package/components/header/_header.scss +18 -2
- package/components/header/_macro.njk +81 -8
- package/components/header/_macro.spec.js +97 -0
- package/components/header/example-header-with-search-button.njk +190 -0
- package/components/header/header.spec.js +128 -0
- package/components/hero/_hero.scss +39 -7
- package/components/hero/_macro.njk +47 -17
- package/components/hero/_macro.spec.js +94 -0
- package/components/hero/example-hero-grey.njk +9 -0
- package/components/icon/_macro.njk +8 -8
- package/components/input/_input.scss +15 -0
- package/components/input/_macro.njk +3 -3
- package/components/navigation/navigation.dom.js +17 -0
- package/components/navigation/navigation.js +72 -2
- package/components/pagination/_pagination.scss +7 -1
- package/components/summary/_macro.njk +1 -1
- package/components/summary/_macro.spec.js +6 -0
- package/components/table-of-contents/_macro.njk +40 -0
- package/components/table-of-contents/_macro.spec.js +72 -0
- package/components/table-of-contents/_table-of-contents.scss +11 -0
- package/components/table-of-contents/example-table-of-contents-related-links-with-button.njk +60 -0
- package/css/main.css +1 -1
- package/js/cookies-functions.js +11 -6
- package/js/cookies-functions.spec.js +44 -0
- package/js/main.js +2 -0
- package/package.json +4 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -0
- package/scss/utilities/_grid.scss +13 -4
package/js/cookies-functions.js
CHANGED
|
@@ -75,7 +75,6 @@ export function getConsentCookie() {
|
|
|
75
75
|
|
|
76
76
|
export function setConsentCookie(options) {
|
|
77
77
|
const domain = getDomain(document.domain);
|
|
78
|
-
|
|
79
78
|
let cookieConsent = getConsentCookie();
|
|
80
79
|
if (!cookieConsent) {
|
|
81
80
|
cookieConsent = JSON.parse(JSON.stringify(DEFAULT_COOKIE_CONSENT).replace(/'/g, '"'));
|
|
@@ -168,15 +167,21 @@ export function getCookie(name) {
|
|
|
168
167
|
return null;
|
|
169
168
|
}
|
|
170
169
|
|
|
171
|
-
export function getDomain(domain) {
|
|
170
|
+
export function getDomain(domain, cookieHandler = document) {
|
|
171
|
+
if (domain.startsWith('www.')) {
|
|
172
|
+
domain = domain.substring(4);
|
|
173
|
+
}
|
|
172
174
|
let i = 0,
|
|
173
175
|
domainName = domain,
|
|
174
176
|
p = domainName.split('.'),
|
|
175
177
|
s = '_gd' + new Date().getTime();
|
|
176
|
-
while (i < p.length - 1 &&
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
while (i < p.length - 1 && cookieHandler.cookie.indexOf(s + '=' + s) == -1) {
|
|
179
|
+
// Loop until we find a valid cookie set at the domain or until we've checked all possible domains
|
|
180
|
+
domainName = p.slice(i, p.length).join('.');
|
|
181
|
+
cookieHandler.cookie = s + '=' + s + ';domain=' + domainName + ';';
|
|
182
|
+
|
|
183
|
+
i++;
|
|
179
184
|
}
|
|
180
|
-
|
|
185
|
+
cookieHandler.cookie = s + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=' + domainName + ';';
|
|
181
186
|
return domainName;
|
|
182
187
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import { getDomain } from './cookies-functions';
|
|
4
|
+
let mockCookieStore = {};
|
|
5
|
+
|
|
6
|
+
// Mocking document.cookie which is used for setting domain name in `getDomain()`
|
|
7
|
+
export const setMockcookie = {
|
|
8
|
+
get cookie() {
|
|
9
|
+
return Object.entries(mockCookieStore)
|
|
10
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
11
|
+
.join('; ');
|
|
12
|
+
},
|
|
13
|
+
set cookie(value) {
|
|
14
|
+
const domainMatch = value.match(/domain=([^;]+)/i);
|
|
15
|
+
const domain = domainMatch?.[1]?.trim();
|
|
16
|
+
|
|
17
|
+
// Simulate failure to set cookie on this domain
|
|
18
|
+
if (domain === 'new-website.ons.gov.uk') return;
|
|
19
|
+
|
|
20
|
+
const [key, val] = value.split('=');
|
|
21
|
+
mockCookieStore[key] = val.split(';')[0];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('script: getDomain()', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
mockCookieStore = {}; // clear the cookie between tests
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('should return service-manual.ons.gov.uk as the domain name when cookies can be set at the full subdomain', () => {
|
|
31
|
+
const result = getDomain('service-manual.ons.gov.uk', setMockcookie);
|
|
32
|
+
expect(result).toBe('service-manual.ons.gov.uk');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('should remove `www` from the domain name www.ons.gov.uk', () => {
|
|
36
|
+
const result = getDomain('www.ons.gov.uk', setMockcookie);
|
|
37
|
+
expect(result).toBe('ons.gov.uk');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('returns `ons.gov.uk` as the domain name when cookies can not be set at subdomain `new-website.ons.gov.uk`', () => {
|
|
41
|
+
const result = getDomain('new-website.ons.gov.uk', setMockcookie);
|
|
42
|
+
expect(result).toBe('ons.gov.uk');
|
|
43
|
+
});
|
|
44
|
+
});
|
package/js/main.js
CHANGED
|
@@ -30,3 +30,5 @@ import '../components/modal/modal.dom';
|
|
|
30
30
|
import '../components/timeout-modal/timeout-modal.dom';
|
|
31
31
|
import '../components/timeout-panel/timeout-panel.dom';
|
|
32
32
|
import '../components/video/video.dom';
|
|
33
|
+
import '../components/chart/chart';
|
|
34
|
+
import '../components/chart/chart.dom';
|
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": "72.
|
|
4
|
+
"version": "72.6.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -132,5 +132,8 @@
|
|
|
132
132
|
},
|
|
133
133
|
"publishConfig": {
|
|
134
134
|
"access": "public"
|
|
135
|
+
},
|
|
136
|
+
"dependencies": {
|
|
137
|
+
"highcharts": "^12.1.2"
|
|
135
138
|
}
|
|
136
139
|
}
|