@ons/design-system 72.10.7 → 72.10.9

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.
Files changed (45) hide show
  1. package/components/accordion/accordion.js +3 -2
  2. package/components/autosuggest/autosuggest.spec.js +2 -0
  3. package/components/autosuggest/autosuggest.ui.js +12 -7
  4. package/components/breadcrumbs/_breadcrumbs.scss +53 -0
  5. package/components/breadcrumbs/_macro.njk +33 -24
  6. package/components/breadcrumbs/_macro.spec.js +25 -0
  7. package/components/chart/_chart.scss +91 -0
  8. package/components/chart/_macro.njk +38 -7
  9. package/components/chart/_macro.spec.js +102 -13
  10. package/components/chart/bar-chart.js +9 -1
  11. package/components/chart/chart-iframe-resize.js +1 -1
  12. package/components/chart/chart.dom.js +5 -3
  13. package/components/chart/chart.js +8 -2
  14. package/components/chart/common-chart-options.js +9 -0
  15. package/components/chart/example-area-chart.njk +2 -1
  16. package/components/chart/example-bar-chart-with-axis-min-and-max-values.njk +0 -1
  17. package/components/chart/example-bar-chart-with-point-range-and-reference-line-annotations.njk +4 -4
  18. package/components/chart/example-bar-chart.njk +0 -1
  19. package/components/chart/example-iframe-chart.njk +2 -1
  20. package/components/chart/example-line-chart.njk +2 -1
  21. package/components/chart/range-annotations-options.js +1 -1
  22. package/components/download-resources/download-resources.spec.js +2 -0
  23. package/components/hero/_hero.scss +17 -22
  24. package/components/hero/_macro.njk +1 -1
  25. package/components/hero/_macro.spec.js +1 -1
  26. package/components/hero/example-hero-dark-with-external-breadcrumbs.njk +194 -0
  27. package/components/hero/example-hero-default-with-external-breadcrumbs.njk +201 -0
  28. package/components/hero/example-hero-grey-with-external-breadcrumbs.njk +243 -0
  29. package/components/hero/example-hero-navy-blue-with-external-breadcrumbs.njk +200 -0
  30. package/components/hero/example-hero-pale-blue-with-external-breadcrumbs.njk +201 -0
  31. package/components/icon/_macro.njk +1 -1
  32. package/components/mutually-exclusive/mutually-exclusive.js +3 -1
  33. package/components/radios/clear-radios.js +4 -2
  34. package/components/relationships/relationships.js +4 -2
  35. package/components/tabs/tabs.js +2 -2
  36. package/components/video/video.js +2 -0
  37. package/css/main.css +1 -1
  38. package/img/small/area-chart-screenshot.png +0 -0
  39. package/img/small/line-chart-screenshot.png +0 -0
  40. package/js/timeout.js +9 -6
  41. package/layout/_template.njk +4 -1
  42. package/package.json +7 -5
  43. package/scripts/main.es5.js +4 -2
  44. package/scripts/main.js +4 -2
  45. package/scss/objects/_page.scss +1 -1
@@ -47,7 +47,14 @@ class BarChart {
47
47
  tickWidth: 0,
48
48
  tickLength: 0,
49
49
  tickColor: 'transparent',
50
- title: { align: 'high', textAlign: 'middle', reserveSpace: false, rotation: 0, y: -25, useHTML: true },
50
+ title: {
51
+ text: '', // Set to an empty string to hide the x-axis title for bar charts
52
+ textAlign: 'middle',
53
+ reserveSpace: false,
54
+ rotation: 0,
55
+ y: -25,
56
+ useHTML: true,
57
+ },
51
58
  },
52
59
  yAxis: {
53
60
  labels: {
@@ -71,6 +78,7 @@ class BarChart {
71
78
  };
72
79
 
73
80
  // Updates the config to move the data labels inside the bars, but only if the bar is wide enough
81
+ // See the checkHideDataLabels function in chart.js for more details about when this function is run
74
82
  // This also runs when the chart is resized
75
83
  postLoadDataLabels = (currentChart) => {
76
84
  const insideOptions = this.getBarChartLabelsInsideOptions();
@@ -2,7 +2,7 @@ import pym from 'pym.js';
2
2
 
3
3
  class ChartIframeResize {
4
4
  static selector() {
5
- return '[data-chart-iframe]';
5
+ return '.ons-chart__iframe-wrapper';
6
6
  }
7
7
 
8
8
  constructor(node) {
@@ -1,8 +1,10 @@
1
1
  import HighchartsBaseChart from './chart';
2
2
  import domready from '../../js/domready';
3
3
 
4
- domready(async () => {
5
- [HighchartsBaseChart].forEach((Component) => {
6
- document.querySelectorAll(Component.selector()).forEach((el) => new Component(el));
4
+ document.fonts.ready.then(() => {
5
+ domready(async () => {
6
+ [HighchartsBaseChart].forEach((Component) => {
7
+ document.querySelectorAll(Component.selector()).forEach((el) => new Component(el));
8
+ });
7
9
  });
8
10
  });
@@ -192,9 +192,15 @@ class HighchartsBaseChart {
192
192
  };
193
193
 
194
194
  // Check if the data labels should be hidden
195
- // They should be hidden for clustered bar charts with more than 2 series, and also for stacked bar charts
195
+ // They should be hidden where there are more than 20 data points in a series, for clustered bar charts with more than 2 series, and also for stacked bar charts
196
196
  checkHideDataLabels = () => {
197
- return (this.chartType === 'bar' && this.config.series.length > 2) || this.useStackedLayout === true;
197
+ let hideDataLabels = (this.chartType === 'bar' && this.config.series.length > 2) || this.useStackedLayout === true;
198
+ this.config.series.forEach((series) => {
199
+ if (series.data.length > 20) {
200
+ hideDataLabels = true;
201
+ }
202
+ });
203
+ return hideDataLabels;
198
204
  };
199
205
 
200
206
  // Adjust font size and annotations for smaller width of chart
@@ -57,6 +57,15 @@ class CommonChartOptions {
57
57
  },
58
58
  accessibility: {
59
59
  enabled: true,
60
+ keyboardNavigation: {
61
+ focusBorder: {
62
+ enabled: false,
63
+ },
64
+ enabled: true,
65
+ seriesNavigation: {
66
+ mode: 'serialize',
67
+ },
68
+ },
60
69
  },
61
70
  yAxis: {
62
71
  labels: {
@@ -63,6 +63,7 @@
63
63
  "title": "Y axis title"
64
64
  },
65
65
  "percentageHeightDesktop": 50,
66
- "percentageHeightMobile": 120
66
+ "percentageHeightMobile": 120,
67
+ "fallbackImageUrl": '/img/small/area-chart-screenshot.png'
67
68
  })
68
69
  }}
@@ -38,7 +38,6 @@
38
38
  "Non-store retailing",
39
39
  "Automotive fuel"
40
40
  ],
41
- "title": "Retailing",
42
41
  "type": "linear"
43
42
  },
44
43
  "yAxis": {
@@ -54,8 +54,8 @@
54
54
  {
55
55
  "text": "A test point annotation",
56
56
  "point": {"x": 2, "y": 3},
57
- "labelOffsetX": 40,
58
- "labelOffsetY": -30
57
+ "labelOffsetX": 50,
58
+ "labelOffsetY": 60
59
59
  }
60
60
  ],
61
61
  "rangeAnnotations": [
@@ -71,7 +71,7 @@
71
71
  "range": {"axisValue1": 5, "axisValue2": 6},
72
72
  "axis": "y",
73
73
  "labelOffsetX": -80,
74
- "labelOffsetY": 220,
74
+ "labelOffsetY": 230,
75
75
  "labelWidth": 80
76
76
  }
77
77
  ],
@@ -88,7 +88,7 @@
88
88
  "axis": "y",
89
89
  "labelWidth": 100,
90
90
  "labelOffsetX": 10,
91
- "labelOffsetY": 140
91
+ "labelOffsetY": 170
92
92
  }
93
93
  ]
94
94
  })
@@ -42,7 +42,6 @@
42
42
  "Non-store retailing",
43
43
  "Automotive fuel"
44
44
  ],
45
- "title": "Retailing",
46
45
  "type": "linear"
47
46
  },
48
47
  "yAxis": {
@@ -27,6 +27,7 @@ may not be available in the future once Florence is decommissioned. #}
27
27
  }
28
28
  ]
29
29
  },
30
- "iframeUrl": "https://www.ons.gov.uk/visualisations/dvc3294/fig01/index.html"
30
+ "iframeUrl": "https://www.ons.gov.uk/visualisations/dvc3294/fig01/index.html",
31
+ "fallbackImageUrl": "/img/small/line-chart-screenshot.png"
31
32
  })
32
33
  }}
@@ -222,6 +222,7 @@
222
222
  }
223
223
  ],
224
224
  "percentageHeightDesktop": 35,
225
- "percentageHeightMobile": 90
225
+ "percentageHeightMobile": 90,
226
+ "fallbackImageUrl": '/img/small/line-chart-screenshot.png'
226
227
  })
227
228
  }}
@@ -160,7 +160,7 @@ class RangeAnnotationsOptions {
160
160
  }
161
161
 
162
162
  // Create and add the connecting line
163
- const line = document.createElement('div');
163
+ const line = document.createElement('tspan');
164
164
  line.classList.add('ons-chart__connector-line');
165
165
  line.setAttribute('data-range-annotation-line', true);
166
166
  labelElement.appendChild(line);
@@ -432,11 +432,13 @@ describe('script: download-resources', () => {
432
432
  });
433
433
 
434
434
  describe('"Reset all filters" button', () => {
435
+ const { setTimeout } = require('node:timers/promises');
435
436
  beforeEach(async () => {
436
437
  await setTestPage('/test', RENDERED_EXAMPLE_PAGE);
437
438
  await page.click('#general-public');
438
439
  await page.click('#logo');
439
440
  await page.click('.ons-js-adv-filter__reset');
441
+ await setTimeout(50);
440
442
  });
441
443
 
442
444
  it('resets state of all filter checkboxes ', async () => {
@@ -88,7 +88,8 @@
88
88
  @extend .ons-u-mb-no;
89
89
  }
90
90
 
91
- &--dark & {
91
+ &--dark &,
92
+ &--navy-blue & {
92
93
  &__details {
93
94
  color: var(--ons-color-text-inverse);
94
95
 
@@ -97,10 +98,16 @@
97
98
  }
98
99
 
99
100
  a:hover {
100
- color: var(--ons-color-text-inverse-link-hover);
101
- text-decoration-thickness: 2px;
101
+ text-decoration: underline solid var(--ons-color-text-inverse-link-hover) 2px;
102
+ }
103
+
104
+ a:focus {
105
+ color: var(--ons-color-text);
102
106
  }
103
107
 
108
+ a:focus:hover {
109
+ text-decoration: none;
110
+ }
104
111
  .ons-details__heading {
105
112
  color: inherit;
106
113
  }
@@ -129,7 +136,7 @@
129
136
  height: 59px;
130
137
  position: absolute;
131
138
  right: 289px;
132
- top: -11px;
139
+ top: 58px;
133
140
  width: 59px;
134
141
  }
135
142
  }
@@ -141,7 +148,7 @@
141
148
  position: absolute;
142
149
  height: 30px;
143
150
  right: 193px;
144
- top: 11px;
151
+ top: 65px;
145
152
  width: 30px;
146
153
  }
147
154
  }
@@ -150,7 +157,7 @@
150
157
  @include mq(l) {
151
158
  height: 60px;
152
159
  right: 112px;
153
- top: 25px;
160
+ top: 75px;
154
161
  width: 60px;
155
162
  background-color: var(--ons-color-white);
156
163
  border-radius: 50%;
@@ -165,7 +172,7 @@
165
172
  height: 60px;
166
173
  position: absolute;
167
174
  right: 208px;
168
- top: 80px;
175
+ top: 130px;
169
176
  width: 60px;
170
177
  }
171
178
 
@@ -191,7 +198,7 @@
191
198
  height: 14px;
192
199
  position: absolute;
193
200
  right: 222px;
194
- top: 187px;
201
+ top: 237px;
195
202
  width: 14px;
196
203
  }
197
204
 
@@ -217,7 +224,7 @@
217
224
  height: 15px;
218
225
  position: absolute;
219
226
  right: 135px;
220
- top: 188px;
227
+ top: 238px;
221
228
  width: 15px;
222
229
  }
223
230
  }
@@ -342,18 +349,6 @@
342
349
  }
343
350
 
344
351
  &__circle-1 {
345
- @include mq(l) {
346
- background-color: var(--ons-color-soft-blue-grey);
347
- border-radius: 50%;
348
- height: 440px;
349
- position: absolute;
350
- right: 59px;
351
- top: -339px;
352
- width: 440px;
353
- }
354
- }
355
-
356
- &__circle-2 {
357
352
  background-color: var(--ons-color-light-orange);
358
353
  border-radius: 50%;
359
354
  bottom: 4%;
@@ -379,7 +374,7 @@
379
374
  }
380
375
  }
381
376
 
382
- &__circle-3 {
377
+ &__circle-2 {
383
378
  background-color: var(--ons-color-ocean-blue);
384
379
  border-radius: 50%;
385
380
  bottom: 7%;
@@ -16,7 +16,7 @@
16
16
  </div>
17
17
  {% elif params.variants == 'pale-blue' %}
18
18
  <div class="ons-hero__circles" aria-hidden="true">
19
- {% for i in range(1, 4) %}
19
+ {% for i in range(1, 3) %}
20
20
  <div class="ons-hero__circle-{{ i }}"></div>
21
21
  {% endfor %}
22
22
  </div>
@@ -109,7 +109,7 @@ describe('macro: hero', () => {
109
109
  const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'grey', officialStatisticsBadge: true }));
110
110
 
111
111
  expect($('.ons-hero__badge').length).toBe(1);
112
- expect($('.ons-hero__badge svg title').text().trim()).toBe('Official Statistics Badge');
112
+ expect($('.ons-hero__badge svg title').text().trim()).toBe('Official Statistics Badge - Accredited');
113
113
  });
114
114
 
115
115
  it('outputs the statistics badge as a link when officialStatisticsBadgeUrl is provided', () => {
@@ -0,0 +1,194 @@
1
+ ---
2
+ title: 'Example: Table of contents on full page'
3
+ layout: ~
4
+ ---
5
+
6
+ {% from "components/hero/_macro.njk" import onsHero %}
7
+ {% from "components/breadcrumbs/_macro.njk" import onsBreadcrumbs %}
8
+ {% extends "layout/_template.njk" %}
9
+ {%
10
+ set pageConfig = {
11
+ "header": {
12
+ "variants": 'basic',
13
+ "menuLinks": {
14
+ "id": "menu-links",
15
+ "keyLinks": [
16
+ {
17
+ 'heading': 'Taking part in a survey?',
18
+ 'description': 'It’s never been more important.'
19
+ },
20
+ {
21
+ 'heading': 'Release calendar',
22
+ 'description': 'View our latest and upcoming releases.'
23
+ },
24
+ {
25
+ 'heading': 'Explore local statistics',
26
+ 'url': '#0',
27
+ 'description': 'Explore statistics across the UK.'
28
+ }
29
+ ],
30
+ "columns": [
31
+ {
32
+ "groups": [
33
+ {
34
+ "heading": "People, population and community",
35
+ "groupItems": [
36
+ {
37
+ "text": "Armed forces community"
38
+ },
39
+ {
40
+ "text": "Births, deaths and marriages"
41
+ },
42
+ {
43
+ "text": "Crime and justice"
44
+ },
45
+ {
46
+ "text": "Cultural identity"
47
+ },
48
+ {
49
+ "text": "Education and childcare"
50
+ },
51
+ {
52
+ "text": "Elections"
53
+ },
54
+ {
55
+ "text": "Health and social care"
56
+ },
57
+ {
58
+ "text": "Household characteristics"
59
+ },
60
+ {
61
+ "text": "Housing"
62
+ },
63
+ {
64
+ "text": "Leisure and tourism"
65
+ },
66
+ {
67
+ "text": "Personal and household finances"
68
+ },
69
+ {
70
+ "text": "Population and migration"
71
+ },
72
+ {
73
+ "text": "Well-being"
74
+ }
75
+ ]
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ "groups": [
81
+ {
82
+ "heading": "Business, industry and trade",
83
+ "groupItems": [
84
+ {
85
+ "text": "Business"
86
+ },
87
+ {
88
+ "text": "Changes to business"
89
+ },
90
+ {
91
+ "text": "Construction industry"
92
+ },
93
+ {
94
+ "text": "International trade"
95
+ },
96
+ {
97
+ "text": "IT and internet industry"
98
+ },
99
+ {
100
+ "text": "Manufacturing and production industry"
101
+ },
102
+ {
103
+ "text": "Retail industry",
104
+ "url": "#0"
105
+ },
106
+ {
107
+ "text": "Tourism industry"
108
+ }
109
+ ]
110
+ },
111
+ {
112
+ "heading": "Employment and labour market",
113
+ "url": "#0",
114
+ "groupItems":
115
+ [
116
+ {
117
+ "text": "People in work"
118
+ },
119
+ {
120
+ "text": "People not in work"
121
+ }
122
+ ]
123
+
124
+ }
125
+ ]
126
+ },
127
+ {
128
+ "groups": [
129
+ {
130
+ "heading": "Economy",
131
+ "groupItems": [
132
+ {
133
+ "text": "Economic output and productivity"
134
+ },
135
+ {
136
+ "text": "Government, public sector and taxes"
137
+ },
138
+ {
139
+ "text": "Gross Value Added (GVA)"
140
+ },
141
+ {
142
+ "text": "Investments, pensions and trusts"
143
+ },
144
+ {
145
+ "text": "Regional accounts"
146
+ },
147
+ {
148
+ "text": "Environmental accounts"
149
+ },
150
+ {
151
+ "text": "Gross Domestic Product (GDP)"
152
+ },
153
+ {
154
+ "text": "Inflation and price indices"
155
+ },
156
+ {
157
+ "text": "National accounts"
158
+ }
159
+ ]
160
+ }
161
+ ]
162
+ }
163
+ ]
164
+ }
165
+ }
166
+ }
167
+ %}
168
+ {% block pageContent %}
169
+ {{
170
+ onsBreadcrumbs({
171
+ "ariaLabel": 'Breadcrumbs',
172
+ "variant": "dark",
173
+ "itemsList": [
174
+ {
175
+ "url": '/',
176
+ "text": 'Home'
177
+ }
178
+ ]
179
+ })
180
+ }}
181
+ <main id="main-content">
182
+ {{
183
+ onsHero({
184
+ "title": 'Design and build digital services for the ONS',
185
+ "text": 'Everything you need to make accessible, consistent digital products',
186
+ "button": {
187
+ "url": '#0',
188
+ "text": 'Get started'
189
+ },
190
+ "variants": 'dark'
191
+ })
192
+ }}
193
+ </main>
194
+ {% endblock %}