@ons/design-system 74.0.0-next.1 → 74.0.0-next.10

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 (107) hide show
  1. package/README.md +15 -3
  2. package/components/access-code/example-access-code-error.njk +1 -1
  3. package/components/access-code/example-access-code.njk +1 -1
  4. package/components/address-input/autosuggest.address.spec.js +23 -0
  5. package/components/autosuggest/autosuggest.ui.js +3 -0
  6. package/components/back-to-top/example-full-page-back-to-top.njk +1 -1
  7. package/components/breadcrumbs/_breadcrumbs.scss +4 -7
  8. package/components/breadcrumbs/_macro.njk +29 -25
  9. package/components/breadcrumbs/_macro.spec.js +39 -0
  10. package/components/breadcrumbs/example-breadcrumbs-wide.njk +52 -0
  11. package/components/chart/_chart.scss +0 -9
  12. package/components/chart/_macro.njk +96 -128
  13. package/components/chart/_macro.spec.js +43 -28
  14. package/components/chart/example-area-chart-with-axis-min-and-max-values.njk +6 -3
  15. package/components/chart/example-area-chart.njk +6 -3
  16. package/components/chart/example-bar-chart-with-annotations.njk +6 -3
  17. package/components/chart/example-bar-chart-with-axis-min-and-max-values.njk +6 -3
  18. package/components/chart/example-bar-chart-with-point-range-and-reference-line-annotations.njk +6 -3
  19. package/components/chart/example-bar-chart.njk +6 -3
  20. package/components/chart/example-bar-with-confidence-levels.njk +6 -3
  21. package/components/chart/example-clustered-bar-chart.njk +6 -3
  22. package/components/chart/example-clustered-column-chart.njk +6 -3
  23. package/components/chart/example-column-chart-with-annotations.njk +6 -3
  24. package/components/chart/example-column-chart-with-axis-min-and-max-values.njk +6 -3
  25. package/components/chart/example-column-chart-with-custom-reference-line-value.njk +6 -3
  26. package/components/chart/example-column-chart-with-range-annotations.njk +6 -3
  27. package/components/chart/example-column-chart-with-reference-line-annotations.njk +6 -3
  28. package/components/chart/example-column-chart.njk +6 -3
  29. package/components/chart/example-column-with-confidence-levels.njk +6 -3
  30. package/components/chart/example-column-with-line-chart.njk +6 -3
  31. package/components/chart/example-iframe-chart.njk +6 -3
  32. package/components/chart/example-line-chart-with-annotations.njk +6 -3
  33. package/components/chart/example-line-chart-with-axis-min-and-max-values.njk +6 -3
  34. package/components/chart/example-line-chart-with-custom-reference-line-value.njk +6 -3
  35. package/components/chart/example-line-chart-with-label-format.njk +6 -3
  36. package/components/chart/example-line-chart-with-markers.njk +6 -3
  37. package/components/chart/example-line-chart-with-range-annotations-inside.njk +6 -3
  38. package/components/chart/example-line-chart-with-range-annotations-outside-left-right.njk +6 -3
  39. package/components/chart/example-line-chart-with-range-annotations-outside-top-bottom.njk +6 -3
  40. package/components/chart/example-line-chart-with-reference-line-annotations.njk +6 -3
  41. package/components/chart/example-line-chart.njk +6 -3
  42. package/components/chart/example-scatter-chart-with-axis-min-and-max-values.njk +6 -3
  43. package/components/chart/example-scatter-chart.njk +6 -3
  44. package/components/chart/example-stacked-bar-chart.njk +6 -3
  45. package/components/chart/example-stacked-column-chart.njk +6 -3
  46. package/components/document-list/_macro.njk +2 -2
  47. package/components/document-list/_macro.spec.js +55 -0
  48. package/components/featured-article/_macro.njk +3 -37
  49. package/components/featured-article/example-featured-article-with-chart.njk +19 -14
  50. package/components/featured-article/example-featured-article-with-image.njk +12 -7
  51. package/components/featured-article/featured-article.scss +1 -1
  52. package/components/featured-article/macro.spec.js +44 -67
  53. package/components/figure/_figure.scss +31 -0
  54. package/components/figure/_macro.njk +98 -0
  55. package/components/figure/_macro.spec.js +520 -0
  56. package/components/figure/example-figure-heading-level-2.njk +34 -0
  57. package/components/figure/example-figure-with-div.njk +29 -0
  58. package/components/figure/example-figure-without-footer.njk +12 -0
  59. package/components/figure/example-figure-without-header.njk +24 -0
  60. package/components/figure/example-figure.njk +34 -0
  61. package/components/header/_header.scss +1 -3
  62. package/components/header/_macro.njk +8 -4
  63. package/components/header/_macro.spec.js +48 -0
  64. package/components/hero/_macro.njk +3 -2
  65. package/components/hero/_macro.spec.js +36 -0
  66. package/components/hero/example-hero-dark-wide.njk +17 -0
  67. package/components/hero/example-hero-dark-with-external-breadcrumbs.njk +17 -21
  68. package/components/hero/example-hero-default-full-width.njk +16 -0
  69. package/components/hero/example-hero-default-with-external-breadcrumbs.njk +165 -169
  70. package/components/hero/example-hero-grey-with-external-breadcrumbs.njk +207 -211
  71. package/components/hero/example-hero-navy-blue-with-external-breadcrumbs.njk +163 -167
  72. package/components/hero/example-hero-pale-blue-with-external-breadcrumbs.njk +165 -169
  73. package/components/image/_image.scss +0 -7
  74. package/components/image/_macro.njk +25 -14
  75. package/components/image/_macro.spec.js +122 -7
  76. package/components/image/example-image-with-figure-fields.njk +25 -0
  77. package/components/list/_macro.njk +1 -0
  78. package/components/list/_macro.spec.js +16 -0
  79. package/components/question/example-question-ccs.njk +1 -1
  80. package/components/question/example-question-fieldset.njk +1 -1
  81. package/components/question/example-question-interviewer-note.njk +1 -1
  82. package/components/question/example-question-no-fieldset.njk +1 -1
  83. package/components/relationships/example-relationships-error.njk +1 -1
  84. package/components/relationships/example-relationships-you.njk +1 -1
  85. package/components/relationships/example-relationships.njk +1 -1
  86. package/components/table/_macro.njk +138 -111
  87. package/components/table/_macro.spec.js +175 -16
  88. package/components/table/_table.scss +6 -1
  89. package/components/table/example-table-basic-no-caption.njk +46 -0
  90. package/components/table/example-table-basic-visually-hidden-caption.njk +47 -0
  91. package/components/table/example-table-with-figure-fields.njk +86 -0
  92. package/components/table/table.spec.js +2 -0
  93. package/components/table-of-contents/_macro.njk +6 -4
  94. package/components/table-of-contents/_macro.spec.js +43 -3
  95. package/components/table-of-contents/example-table-of-contents-ordered.njk +64 -0
  96. package/components/table-of-contents/example-table-of-contents-sticky-full-page-ordered.njk +156 -0
  97. package/components/table-of-contents/example-table-of-contents-sticky-full-page.njk +1 -1
  98. package/components/table-of-contents/table-of-contents.spec.js +4 -5
  99. package/css/main.css +1 -1
  100. package/layout/_template.njk +66 -46
  101. package/package.json +45 -36
  102. package/scripts/main.es5.js +3 -3
  103. package/scripts/main.js +2 -2
  104. package/scss/base/_global.scss +8 -0
  105. package/scss/main.scss +1 -0
  106. package/scss/objects/_page.scss +1 -1
  107. package/scss/objects/_spacing.scss +0 -4
package/README.md CHANGED
@@ -143,11 +143,23 @@ Checkout the branch locally and run:
143
143
 
144
144
  `yarn test-visual` - This will run the same tests locally as were run in Github Actions. After they have completed the report will open in your default browser.
145
145
 
146
+ `VR_SHARD_INDEX=0 VR_SHARD_COUNT=4 yarn test-visual` - This runs only one shard of the visual tests locally. Useful when one shard fails in CI.
147
+
148
+ ### Handling VR test failures
149
+
150
+ If the VR tests fail locally, you'll see an error starting with `Error: docker run --rm -i --add-host=host.docker.internal:host-gateway...`
151
+
152
+ `npx http-server backstop_data -p 8008 -o /html_report/` - View the report in your browser.
153
+
154
+ ### Approving VR test reference image changes
155
+
146
156
  `yarn test-visual:approve` - This will approve the failures/diff caught by the tests.
147
157
 
148
- `git lfs push --all origin` - First commit the files in the normal way then run the command. This will push the new reference images to Git LFS.
158
+ Commit and approve the file changes in the normal way.
159
+
160
+ `git lfs push --all origin` - This will push the new reference images to Git LFS.
149
161
 
150
- You can then commit and push the updated references and your changes to your branch. The test images that would have been created when you ran `yarn test-visual` are gitignored and the new references images will be pushed to Git LFS.
162
+ You can then push the updated references and your changes to your branch. The test images that would have been created when you ran `yarn test-visual` are gitignored and the new references images will be pushed to Git LFS.
151
163
 
152
164
  If your local tests are failing but you have approved them, run `yarn test-visual:reference`. This will update the reference images locally on your machine.
153
165
 
@@ -176,7 +188,7 @@ yarn add @ons/design-system@next
176
188
 
177
189
  ### Publishing the stable major
178
190
 
179
- 1. Merge `next` into `main`.
191
+ 1. Merge `next` into `main`. **Do not squash; use a regular merge commit to preserve history.**
180
192
  2. Create a normal release tag, for example: `74.0.0`.
181
193
  3. Publish the GitHub Release (not marked as a pre-release).
182
194
 
@@ -14,7 +14,7 @@ layout: ~
14
14
  }
15
15
  %}
16
16
 
17
- {% block main %}
17
+ {% block mainContent %}
18
18
  {%
19
19
  call onsPanel({
20
20
  "title": "There is a problem with this page",
@@ -16,7 +16,7 @@ layout: ~
16
16
  }
17
17
  %}
18
18
 
19
- {% block main %}
19
+ {% block mainContent %}
20
20
  <h1 class="ons-u-mt-2xl">Start study</h1>
21
21
 
22
22
  {{
@@ -411,6 +411,29 @@ describe('script: address-input', () => {
411
411
  });
412
412
  });
413
413
  });
414
+
415
+ describe('when a grouped suggestion is selected with the mouse', () => {
416
+ beforeEach(async () => {
417
+ const options = await page.$$('.ons-autosuggest__option');
418
+ await options[0].click();
419
+ await setTimeout(400);
420
+ });
421
+
422
+ it('makes expected bucket request', async () => {
423
+ expect(
424
+ await apiFaker.getRequestCount(
425
+ '/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo',
426
+ ),
427
+ ).toBe(1);
428
+ });
429
+
430
+ it('keeps nested suggestion entries after blur timeout', async () => {
431
+ const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) =>
432
+ nodes.map((node) => node.textContent.trim()),
433
+ );
434
+ expect(suggestions).toEqual(['197 College Road, Whitchurch, Cardiff, CF14 2AB']);
435
+ });
436
+ });
414
437
  });
415
438
 
416
439
  describe('when there is an error retrieving the address', () => {
@@ -201,6 +201,8 @@ export default class AutosuggestUI {
201
201
  }
202
202
 
203
203
  handleFocus() {
204
+ this.blurring = false;
205
+
204
206
  if (this.allowMultiple === 'true' && this.allSelections.length && this.input.value.slice(-1) !== ' ' && this.input.value !== '') {
205
207
  this.input.value = `${this.input.value}, `;
206
208
  }
@@ -513,6 +515,7 @@ export default class AutosuggestUI {
513
515
 
514
516
  selectResult(index) {
515
517
  if (this.results.length) {
518
+ clearTimeout(this.blurTimeout);
516
519
  this.settingResult = true;
517
520
  const result = this.results[index || this.highlightedResultIndex || 0];
518
521
  const resultItem = result.item ?? result;
@@ -30,7 +30,7 @@ layout: ~
30
30
  }
31
31
  %}
32
32
 
33
- {% block main %}
33
+ {% block mainContent %}
34
34
  <h1 class="ons-u-fs-2xl">
35
35
  <span class="ons-u-fs-m ons-u-db ons-u-mb-2xs ons-u-lighter">Press releases</span>
36
36
  <span class="ons-u-vh">: </span>
@@ -3,7 +3,7 @@ $breadcrumb-chevron-height: 0.65rem;
3
3
  .ons-breadcrumbs-wrapper {
4
4
  position: relative;
5
5
  z-index: 10;
6
- margin-bottom: -2rem;
6
+ margin-bottom: -1rem;
7
7
  &--grey {
8
8
  background-color: var(--ons-color-banner-bg);
9
9
  }
@@ -14,9 +14,9 @@ $breadcrumb-chevron-height: 0.65rem;
14
14
 
15
15
  &--navy-blue {
16
16
  background-color: var(--ons-color-navy-blue-light);
17
- margin-bottom: -1.75rem;
17
+ margin-bottom: -0.75rem;
18
18
  @include mq(l) {
19
- margin-bottom: -3.25rem;
19
+ margin-bottom: -2.25rem;
20
20
  }
21
21
  }
22
22
 
@@ -48,15 +48,12 @@ $breadcrumb-chevron-height: 0.65rem;
48
48
  &--pale-blue {
49
49
  background-color: var(--ons-color-pale-blue);
50
50
  }
51
- .ons-breadcrumbs {
52
- padding: 1rem;
53
- }
54
51
  }
55
52
 
56
53
  .ons-breadcrumbs {
57
54
  align-items: center;
58
55
  display: flex;
59
- padding: 1rem 0;
56
+ padding: 1rem 0 0;
60
57
 
61
58
  &__items {
62
59
  margin: 0;
@@ -1,33 +1,37 @@
1
1
  {% from "components/icon/_macro.njk" import onsIcon %}
2
2
  {% macro onsBreadcrumbs(params) %}
3
3
  {% set breadcrumbs %}
4
- <nav
5
- class="ons-breadcrumbs{{ ' ons-container' if params.variant }}{{ ' ' + params.classes if params.classes else '' }}"
6
- aria-label="{{ params.ariaLabel | default('Breadcrumbs') }}"
7
- {% if params.id %}id="{{ params.id }}"{% endif %}
4
+ <div
5
+ class="ons-container{{ ' ons-container--full-width' if params.fullWidth else "" }}{{ ' ons-container--wide' if params.wide else "" }}"
8
6
  >
9
- <ol class="ons-breadcrumbs__items ons-u-fs-s">
10
- {%- for item in params.itemsList -%}
11
- <li
12
- class="ons-breadcrumbs__item{{ ' ' + item.itemClasses if item.itemClasses else '' }}"
13
- id="breadcrumb-{{ loop.index }}"
14
- >
15
- <a
16
- class="ons-breadcrumbs__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}"
17
- href="{% if not isDesignSystemExample %}{{ item.url }}{% else %}#0{% endif %}"
18
- {% if item.id %}{{ ' ' }}id='{{ item.id }}'{% endif %}
19
- {% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
20
- >{{ item.text }}</a
7
+ <nav
8
+ class="ons-breadcrumbs{{ ' ' + params.classes if params.classes else '' }}"
9
+ aria-label="{{ params.ariaLabel | default('Breadcrumbs') }}"
10
+ {% if params.id %}id="{{ params.id }}"{% endif %}
11
+ >
12
+ <ol class="ons-breadcrumbs__items ons-u-fs-s">
13
+ {%- for item in params.itemsList -%}
14
+ <li
15
+ class="ons-breadcrumbs__item{{ ' ' + item.itemClasses if item.itemClasses else '' }}"
16
+ id="breadcrumb-{{ loop.index }}"
21
17
  >
22
- {{-
23
- onsIcon({
24
- "iconType": "chevron"
25
- })
26
- -}}
27
- </li>
28
- {%- endfor -%}
29
- </ol>
30
- </nav>
18
+ <a
19
+ class="ons-breadcrumbs__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}"
20
+ href="{% if not isDesignSystemExample %}{{ item.url }}{% else %}#0{% endif %}"
21
+ {% if item.id %}{{ ' ' }}id='{{ item.id }}'{% endif %}
22
+ {% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
23
+ >{{ item.text }}</a
24
+ >
25
+ {{-
26
+ onsIcon({
27
+ "iconType": "chevron"
28
+ })
29
+ -}}
30
+ </li>
31
+ {%- endfor -%}
32
+ </ol>
33
+ </nav>
34
+ </div>
31
35
  {% endset %}
32
36
  {% if params.variant %}
33
37
  <div class="ons-breadcrumbs-wrapper ons-breadcrumbs-wrapper--{{ params.variant }}">{{ breadcrumbs | safe }}</div>
@@ -133,6 +133,45 @@ describe('FOR: Macro: Breadcrumbs', () => {
133
133
  });
134
134
  });
135
135
 
136
+ describe('GIVEN: Params: fullWidth', () => {
137
+ describe('WHEN: fullWidth is not provided', () => {
138
+ const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS));
139
+ test('THEN: renders container without full-width class', () => {
140
+ expect($('.ons-container').hasClass('ons-container--full-width')).toBe(false);
141
+ });
142
+ });
143
+ describe('WHEN: fullWidth is set to true', () => {
144
+ const $ = cheerio.load(
145
+ renderComponent('breadcrumbs', {
146
+ ...EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS,
147
+ fullWidth: true,
148
+ }),
149
+ );
150
+ test('THEN: renders container with full-width class', () => {
151
+ expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
152
+ });
153
+ });
154
+ });
155
+ describe('GIVEN: Params: wide', () => {
156
+ describe('WHEN: wide is not provided', () => {
157
+ const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS));
158
+ test('THEN: renders container without wide class', () => {
159
+ expect($('.ons-container').hasClass('ons-container--wide')).toBe(false);
160
+ });
161
+ });
162
+ describe('WHEN: wide is set to true', () => {
163
+ const $ = cheerio.load(
164
+ renderComponent('breadcrumbs', {
165
+ ...EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS,
166
+ wide: true,
167
+ }),
168
+ );
169
+ test('THEN: renders container with wide class', () => {
170
+ expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
171
+ });
172
+ });
173
+ });
174
+
136
175
  describe('GIVEN: Params: variant', () => {
137
176
  describe('WHEN: variant is provided', () => {
138
177
  const $ = cheerio.load(
@@ -0,0 +1,52 @@
1
+ ---
2
+ title: 'Example: Breadcrumbs override wide'
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
+ "title": 'Service title',
13
+ "mastheadLogoUrl": '#0',
14
+ "titleUrl": '#0',
15
+ "serviceLinks": {
16
+ "id": "service-links-internal",
17
+ "ariaLabel": 'Services menu',
18
+ "ariaListLabel": 'Menu',
19
+ "toggleServicesButton": {
20
+ "text": 'Account',
21
+ "ariaLabel": 'Toggle services menu'
22
+ },
23
+ "itemsList": [
24
+ {
25
+ "text": "Jacky Turner",
26
+ "iconType": 'person'
27
+ },
28
+ {
29
+ "text": "Sign out",
30
+ "url": "#0"
31
+ }
32
+ ]
33
+ }
34
+ },
35
+ "wide": true
36
+ }
37
+ %}
38
+
39
+ {% block breadcrumbs %}
40
+ {{
41
+ onsBreadcrumbs({
42
+ "wide": true,
43
+ "ariaLabel": 'Breadcrumbs',
44
+ "itemsList": [
45
+ {
46
+ "url": '/',
47
+ "text": 'Home'
48
+ }
49
+ ]
50
+ })
51
+ }}
52
+ {% endblock %}
@@ -29,15 +29,6 @@
29
29
  outline-offset: 2px;
30
30
  }
31
31
 
32
- &__download-title {
33
- @extend .ons-u-pt-l;
34
- @extend .ons-u-fs-r--b;
35
- }
36
-
37
- &__caption {
38
- color: var(--ons-color-grey-75);
39
- }
40
-
41
32
  &__annotations-footnotes-number {
42
33
  // !important is necessary for some range annotation labels at mobile, otherwise
43
34
  // the inline-styled block display takes precedence. This inline style is only
@@ -1,21 +1,11 @@
1
- {% from "components/list/_macro.njk" import onsList %}
2
- {% from "components/details/_macro.njk" import onsDetails %}
3
-
4
1
  {% macro onsChart(params) %}
2
+ {% from "components/figure/_macro.njk" import onsFigure %}
5
3
  {% set supportedChartTypes = ['line', 'bar', 'column', 'scatter', 'area', 'columnrange', 'boxplot'] %}
6
4
  {% set supportedChartTypesWithLine = ['column'] %}
7
5
  {% set supportedChartTypesWithScatter = ['columnrange'] %}
8
6
  {% set supportedChartTypesWithXAxisMinAndMax = ['scatter'] %}
9
7
  {% set supportedChartTypesWithYAxisMinAndMax = ['line', 'bar', 'column', 'scatter', 'area', 'columnrange', 'boxplot'] %}
10
8
  {% set supportedAspectRatios = ['16-9', '4-3', '21-9', '1-1', '3-2', '9-16'] %}
11
- {% set headingLevel = params.headingLevel | default(2) %}
12
- {% set openingTitleTag = "<h" ~ headingLevel %}
13
- {% set closingTitleTag = "</h" ~ headingLevel ~ ">" %}
14
- {% set openingSubtitleTag = "<h" ~ (headingLevel + 1) %}
15
- {% set closingSubtitleTag = "</h" ~ (headingLevel + 1) ~ ">" %}
16
- {% set openingDownloadTitleTag = "<h" ~ (headingLevel + 2) %}
17
- {% set closingDownloadTitleTag = "</h" ~ (headingLevel + 2) ~ ">" %}
18
- {% set audioDescriptionId = "chart-audio-description-" ~ params.id %}
19
9
  {% set instructionsId = "chart-instructions-" ~ params.id %}
20
10
  {% set iframeAspectRatio = params.iframeAspectRatio if params.iframeAspectRatio in supportedAspectRatios else '16-9' %}
21
11
  {% set instructions = params.instructions | default('Use the Tab key to move focus into the chart. Once inside, use the arrow keys to navigate between data points. As you move, tooltips will be announced to describe each point. Touch device users, explore by touch or with swipe gestures.') %}
@@ -54,132 +44,110 @@
54
44
  {% endif %}
55
45
  {% endif %}
56
46
  >
57
- <figure class="ons-chart" aria-describedby="{{ audioDescriptionId }}">
58
- {{ openingTitleTag | safe }} class="ons-chart__title">{{ params.title }}{{ closingTitleTag | safe }}
59
- {% if params.subtitle %}
60
- {{ openingSubtitleTag | safe }}
61
- class="ons-chart__subtitle">{{ params.subtitle }}{{ closingSubtitleTag | safe }}
62
- {% endif %}
63
-
64
- <p class="ons-u-vh" id="{{ audioDescriptionId }}">{{ params.description }}</p>
65
-
66
- {% if params.iframeUrl %}
67
- <div
68
- class="ons-chart__iframe-wrapper{{ ' ons-chart__non-js-hide' if params.fallbackImageUrl else '' }}"
69
- id="{{ params.id }}"
70
- >
71
- <iframe
72
- src="{{ params.iframeUrl }}"
73
- title="{{ params.title }}"
74
- class="ons-chart__iframe ons-chart__iframe--{{ iframeAspectRatio }}"
75
- frameborder="0"
76
- scrolling="no"
77
- ></iframe>
78
- </div>
79
- {% else %}
80
- {% if params.chartType == 'boxplot' and (params.estimateLineLabel or params.uncertaintyRangeLabel) and params.legend == true %}
81
- <div class="ons-chart__boxplot-legend">
82
- {% if params.uncertaintyRangeLabel %}
83
- <div class="ons-chart__boxplot-legend-item">
84
- <span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--uncertainty"></span>
85
- <span class="ons-chart__boxplot-legend-label">{{ params.uncertaintyRangeLabel }}</span>
86
- </div>
87
- {% endif %}
88
- {% if params.estimateLineLabel %}
89
- <div class="ons-chart__boxplot-legend-item">
90
- <span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--estimate"></span>
91
- <span class="ons-chart__boxplot-legend-label">{{ params.estimateLineLabel }}</span>
92
- </div>
93
- {% endif %}
94
- </div>
95
- {% endif %}
96
- {% if params.chartType in supportedChartTypes %}
47
+ {%
48
+ call onsFigure({
49
+ "id": params.id,
50
+ "headingLevel": params.headingLevel,
51
+ "figureNumber": params.figureNumber,
52
+ "title": params.title,
53
+ "subtitle": params.subtitle,
54
+ "audioDescription": params.description,
55
+ "caption": params.caption,
56
+ "footnotes": params.footnotes,
57
+ "download": params.download
58
+ })
59
+ %}
60
+ <div class="ons-chart">
61
+ {% if params.iframeUrl %}
97
62
  <div
98
- data-highcharts-chart-container
99
- class="ons-chart__container"
100
- tabindex="0"
101
- role="region"
102
- aria-label="chart container"
103
- aria-describedby="{{ instructionsId }}"
63
+ class="ons-chart__iframe-wrapper{{ ' ons-chart__non-js-hide' if params.fallbackImageUrl else '' }}"
64
+ id="iframe--{{ params.id }}"
104
65
  >
105
- <div id="{{ instructionsId }}" class="ons-u-vh">{{ instructions }}</div>
106
- <div data-highcharts-chart class="ons-chart__chart"></div>
66
+ <iframe
67
+ src="{{ params.iframeUrl }}"
68
+ title="{{ params.title }}"
69
+ class="ons-chart__iframe ons-chart__iframe--{{ iframeAspectRatio }}"
70
+ frameborder="0"
71
+ scrolling="no"
72
+ ></iframe>
107
73
  </div>
108
74
  {% else %}
109
- <p data-invalid-chart-type data-unsupported-chart-text>
110
- <b>{{ '"' + params.chartType + '" - ' + (params.unsupportedChartText or 'chart type is not supported') }}</b>
111
- </p>
75
+ {% if params.chartType == 'boxplot' and (params.estimateLineLabel or params.uncertaintyRangeLabel) and params.legend == true %}
76
+ <div class="ons-chart__boxplot-legend">
77
+ {% if params.uncertaintyRangeLabel %}
78
+ <div class="ons-chart__boxplot-legend-item">
79
+ <span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--uncertainty"></span>
80
+ <span class="ons-chart__boxplot-legend-label">{{ params.uncertaintyRangeLabel }}</span>
81
+ </div>
82
+ {% endif %}
83
+ {% if params.estimateLineLabel %}
84
+ <div class="ons-chart__boxplot-legend-item">
85
+ <span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--estimate"></span>
86
+ <span class="ons-chart__boxplot-legend-label">{{ params.estimateLineLabel }}</span>
87
+ </div>
88
+ {% endif %}
89
+ </div>
90
+ {% endif %}
91
+ {% if params.chartType in supportedChartTypes %}
92
+ <div
93
+ data-highcharts-chart-container
94
+ class="ons-chart__container"
95
+ tabindex="0"
96
+ role="region"
97
+ aria-label="chart container"
98
+ aria-describedby="{{ instructionsId }}"
99
+ >
100
+ <div id="{{ instructionsId }}" class="ons-u-vh">{{ instructions }}</div>
101
+ <div data-highcharts-chart class="ons-chart__chart"></div>
102
+ </div>
103
+ {% else %}
104
+ <p data-invalid-chart-type data-unsupported-chart-text>
105
+ <b>{{ '"' + params.chartType + '" - ' + (params.unsupportedChartText or 'chart type is not supported') }}</b>
106
+ </p>
107
+ {% endif %}
112
108
  {% endif %}
113
- {% endif %}
114
109
 
115
- {% if params.fallbackImageUrl %}
116
- {% set fallbackImageId = ["fallback-image--", params.id] | join %}
117
- <noscript id="{{ fallbackImageId }}">
118
- {# Note that a more detailed description of the chart is provided in the audio description above #}
119
- <img
120
- src="{{ params.fallbackImageUrl }}"
121
- alt="{{ params.fallbackImageAlt or 'Fallback image for the chart as JavaScript is disabled' }}"
122
- class="ons-chart__fallback-image"
123
- />
124
- </noscript>
125
- {% endif %}
126
- {#
110
+ {% if params.fallbackImageUrl %}
111
+ {% set fallbackImageId = ["fallback-image--", params.id] | join %}
112
+ <noscript id="{{ fallbackImageId }}">
113
+ {# Note that a more detailed description of the chart is provided in the figure's audio description #}
114
+ <img
115
+ src="{{ params.fallbackImageUrl }}"
116
+ alt="{{ params.fallbackImageAlt or 'Fallback image for the chart as JavaScript is disabled' }}"
117
+ class="ons-chart__fallback-image"
118
+ />
119
+ </noscript>
120
+ {% endif %}
121
+ {#
127
122
  Footnotes for the annotations at mobile
128
123
  Hidden from screen readers because the full text will be read out where they appear in the chart
129
124
  #}
130
- {% if (params.annotations or params.rangeAnnotations or params.referenceLineAnnotations) and not params.iframeUrl %}
131
- <ul class="ons-chart__annotations-footnotes" aria-hidden="true" data-annotations-footnotes>
132
- {% for annotation in params.annotations %}
133
- <li class="ons-chart__annotations-footnotes_item">
134
- <span class="ons-chart__annotations-footnotes-number">{{ loop.index }}</span>
135
- {{ annotation.text }}
136
- </li>
137
- {% endfor %}
138
- {% for rangeAnnotation in params.rangeAnnotations %}
139
- <li class="ons-chart__annotations-footnotes_item">
140
- <span class="ons-chart__annotations-footnotes-number">{{ loop.index + params.annotations | length }}</span>
141
- {{ rangeAnnotation.text }}
142
- </li>
143
- {% endfor %}
144
- {% for referenceLineAnnotation in params.referenceLineAnnotations %}
145
- <li class="ons-chart__annotations-footnotes_item">
146
- <span class="ons-chart__annotations-footnotes-number"
147
- >{{ loop.index + params.annotations | length + params.rangeAnnotations | length }}</span
148
- >
149
- {{ referenceLineAnnotation.text }}
150
- </li>
151
- {% endfor %}
152
- </ul>
153
- {% endif %}
154
- {% if params.caption %}
155
- <figcaption class="ons-chart__caption">{{ params.caption }}</figcaption>
156
- {% endif %}
157
- </figure>
158
-
159
- {% if params.download.title and params.download.itemsList | length > 0 %}
160
- {{ openingDownloadTitleTag | safe }}
161
- class="ons-chart__download-title">{{ params.download.title }}{{ closingDownloadTitleTag | safe }}
162
- {{
163
- onsList({
164
- "element": "ol",
165
- "itemsList": params.download.itemsList
166
- })
167
- }}
168
- {% endif %}
169
-
170
- {% if params.footnotes %}
171
- {% set footnotesId = ["footnotes--", params.id] | join %}
172
-
173
- {{
174
- onsDetails({
175
- "id": footnotesId,
176
- "title": params.footnotes.title,
177
- "content": params.footnotes.content,
178
- "headingLevel": headingLevel + 2,
179
- "classes": "ons-u-mt-xl"
180
- })
181
- }}
182
- {% endif %}
125
+ {% if (params.annotations or params.rangeAnnotations or params.referenceLineAnnotations) and not params.iframeUrl %}
126
+ <ul class="ons-chart__annotations-footnotes" aria-hidden="true" data-annotations-footnotes>
127
+ {% for annotation in params.annotations %}
128
+ <li class="ons-chart__annotations-footnotes_item">
129
+ <span class="ons-chart__annotations-footnotes-number">{{ loop.index }}</span>
130
+ {{ annotation.text }}
131
+ </li>
132
+ {% endfor %}
133
+ {% for rangeAnnotation in params.rangeAnnotations %}
134
+ <li class="ons-chart__annotations-footnotes_item">
135
+ <span class="ons-chart__annotations-footnotes-number">{{ loop.index + params.annotations | length }}</span>
136
+ {{ rangeAnnotation.text }}
137
+ </li>
138
+ {% endfor %}
139
+ {% for referenceLineAnnotation in params.referenceLineAnnotations %}
140
+ <li class="ons-chart__annotations-footnotes_item">
141
+ <span class="ons-chart__annotations-footnotes-number"
142
+ >{{ loop.index + params.annotations | length + params.rangeAnnotations | length }}</span
143
+ >
144
+ {{ referenceLineAnnotation.text }}
145
+ </li>
146
+ {% endfor %}
147
+ </ul>
148
+ {% endif %}
149
+ </div>
150
+ {% endcall %}
183
151
 
184
152
  {% if (params.chartType in supportedChartTypes) and not params.iframeUrl %}
185
153
  {% set series = [] %}