@ons/design-system 74.0.0-next.6 → 74.0.0-next.7

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 (63) hide show
  1. package/components/chart/_chart.scss +0 -9
  2. package/components/chart/_macro.njk +96 -128
  3. package/components/chart/_macro.spec.js +43 -28
  4. package/components/chart/example-area-chart-with-axis-min-and-max-values.njk +6 -3
  5. package/components/chart/example-area-chart.njk +6 -3
  6. package/components/chart/example-bar-chart-with-annotations.njk +6 -3
  7. package/components/chart/example-bar-chart-with-axis-min-and-max-values.njk +6 -3
  8. package/components/chart/example-bar-chart-with-point-range-and-reference-line-annotations.njk +6 -3
  9. package/components/chart/example-bar-chart.njk +6 -3
  10. package/components/chart/example-bar-with-confidence-levels.njk +6 -3
  11. package/components/chart/example-clustered-bar-chart.njk +6 -3
  12. package/components/chart/example-clustered-column-chart.njk +6 -3
  13. package/components/chart/example-column-chart-with-annotations.njk +6 -3
  14. package/components/chart/example-column-chart-with-axis-min-and-max-values.njk +6 -3
  15. package/components/chart/example-column-chart-with-custom-reference-line-value.njk +6 -3
  16. package/components/chart/example-column-chart-with-range-annotations.njk +6 -3
  17. package/components/chart/example-column-chart-with-reference-line-annotations.njk +6 -3
  18. package/components/chart/example-column-chart.njk +6 -3
  19. package/components/chart/example-column-with-confidence-levels.njk +6 -3
  20. package/components/chart/example-column-with-line-chart.njk +6 -3
  21. package/components/chart/example-iframe-chart.njk +6 -3
  22. package/components/chart/example-line-chart-with-annotations.njk +6 -3
  23. package/components/chart/example-line-chart-with-axis-min-and-max-values.njk +6 -3
  24. package/components/chart/example-line-chart-with-custom-reference-line-value.njk +6 -3
  25. package/components/chart/example-line-chart-with-label-format.njk +6 -3
  26. package/components/chart/example-line-chart-with-markers.njk +6 -3
  27. package/components/chart/example-line-chart-with-range-annotations-inside.njk +6 -3
  28. package/components/chart/example-line-chart-with-range-annotations-outside-left-right.njk +6 -3
  29. package/components/chart/example-line-chart-with-range-annotations-outside-top-bottom.njk +6 -3
  30. package/components/chart/example-line-chart-with-reference-line-annotations.njk +6 -3
  31. package/components/chart/example-line-chart.njk +6 -3
  32. package/components/chart/example-scatter-chart-with-axis-min-and-max-values.njk +6 -3
  33. package/components/chart/example-scatter-chart.njk +6 -3
  34. package/components/chart/example-stacked-bar-chart.njk +6 -3
  35. package/components/chart/example-stacked-column-chart.njk +6 -3
  36. package/components/document-list/_macro.njk +2 -2
  37. package/components/document-list/_macro.spec.js +55 -0
  38. package/components/featured-article/_macro.njk +3 -37
  39. package/components/featured-article/example-featured-article-with-chart.njk +19 -14
  40. package/components/featured-article/example-featured-article-with-image.njk +12 -7
  41. package/components/featured-article/featured-article.scss +1 -1
  42. package/components/featured-article/macro.spec.js +44 -67
  43. package/components/figure/_figure.scss +31 -0
  44. package/components/figure/_macro.njk +98 -0
  45. package/components/figure/_macro.spec.js +520 -0
  46. package/components/figure/example-figure-heading-level-2.njk +34 -0
  47. package/components/figure/example-figure-with-div.njk +29 -0
  48. package/components/figure/example-figure-without-footer.njk +12 -0
  49. package/components/figure/example-figure-without-header.njk +24 -0
  50. package/components/figure/example-figure.njk +34 -0
  51. package/components/image/_image.scss +0 -7
  52. package/components/image/_macro.njk +25 -14
  53. package/components/image/_macro.spec.js +122 -7
  54. package/components/image/example-image-with-figure-fields.njk +25 -0
  55. package/components/list/_macro.njk +1 -0
  56. package/components/list/_macro.spec.js +16 -0
  57. package/components/table/_macro.njk +138 -111
  58. package/components/table/_macro.spec.js +172 -2
  59. package/components/table/_table.scss +6 -1
  60. package/components/table/example-table-with-figure-fields.njk +86 -0
  61. package/css/main.css +1 -1
  62. package/package.json +2 -2
  63. package/scss/main.scss +1 -0
@@ -0,0 +1,520 @@
1
+ /** @jest-environment jsdom */
2
+
3
+ import * as cheerio from 'cheerio';
4
+
5
+ import axe from '../../tests/helpers/axe';
6
+ import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
7
+
8
+ const EXAMPLE_FIGURE_BASIC = {
9
+ title: 'Figure title',
10
+ id: 'example-figure',
11
+ };
12
+
13
+ const EXAMPLE_FIGURE_FULL = {
14
+ id: 'example-figure',
15
+ headingLevel: 3,
16
+ figureNumber: 'Figure 1',
17
+ title: 'Remote working trends, 2019 to 2023',
18
+ subtitle: 'Percentage of workforce working from home at least one day per week',
19
+ caption: 'Source: Office for National Statistics',
20
+ audioDescription: 'A line chart showing the percentage of workers working from home rising from 12% in 2019 to 28% in 2023',
21
+ footnotes: {
22
+ title: 'Footnotes',
23
+ content: 'Data is seasonally adjusted.',
24
+ },
25
+ download: {
26
+ title: 'Download this chart',
27
+ itemsList: [
28
+ {
29
+ text: 'Remote working trends (CSV format, 2KB)',
30
+ url: '/data/remote-working.csv',
31
+ download: 'file',
32
+ },
33
+ ],
34
+ },
35
+ };
36
+
37
+ const CALLER_CONTENT = '<div class="test-content">Nested content</div>';
38
+
39
+ describe('macro: figure', () => {
40
+ it('passes jest-axe checks', async () => {
41
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_FULL, CALLER_CONTENT));
42
+
43
+ const results = await axe($.html());
44
+ expect(results).toHaveNoViolations();
45
+ });
46
+
47
+ describe('figure element', () => {
48
+ it('renders a <figure> element', () => {
49
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
50
+
51
+ expect($('figure.ons-figure').length).toBe(1);
52
+ });
53
+
54
+ it('has the provided `id` attribute', () => {
55
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
56
+
57
+ expect($('.ons-figure').attr('id')).toBe('example-figure');
58
+ });
59
+
60
+ it('renders caller content inside the content area', () => {
61
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
62
+
63
+ expect($('.ons-figure__content .test-content').length).toBe(1);
64
+ expect($('.ons-figure__content .test-content').text()).toBe('Nested content');
65
+ });
66
+ });
67
+
68
+ describe('useDivForRootElement', () => {
69
+ it('defaults to a <figure> element', () => {
70
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
71
+
72
+ expect($('.ons-figure')[0].tagName).toBe('figure');
73
+ });
74
+
75
+ it('renders a <div> when useDivForRootElement is true', () => {
76
+ const $ = cheerio.load(
77
+ renderComponent(
78
+ 'figure',
79
+ {
80
+ ...EXAMPLE_FIGURE_BASIC,
81
+ useDivForRootElement: true,
82
+ },
83
+ CALLER_CONTENT,
84
+ ),
85
+ );
86
+
87
+ expect($('.ons-figure')[0].tagName).toBe('div');
88
+ });
89
+
90
+ it('renders caption in a <figcaption> by default', () => {
91
+ const $ = cheerio.load(
92
+ renderComponent(
93
+ 'figure',
94
+ {
95
+ ...EXAMPLE_FIGURE_BASIC,
96
+ caption: 'A caption',
97
+ },
98
+ CALLER_CONTENT,
99
+ ),
100
+ );
101
+
102
+ expect($('.ons-figure__caption')[0].tagName).toBe('figcaption');
103
+ });
104
+
105
+ it('renders caption in a <span> when useDivForRootElement is true', () => {
106
+ const $ = cheerio.load(
107
+ renderComponent(
108
+ 'figure',
109
+ {
110
+ ...EXAMPLE_FIGURE_BASIC,
111
+ useDivForRootElement: true,
112
+ caption: 'A caption',
113
+ },
114
+ CALLER_CONTENT,
115
+ ),
116
+ );
117
+
118
+ expect($('.ons-figure__caption')[0].tagName).toBe('span');
119
+ expect($('.ons-figure__caption').text().trim()).toBe('A caption');
120
+ });
121
+ });
122
+
123
+ // Caption rendering is covered by the useDivForRootElement tests above
124
+ it('does not render a figcaption when caption is not provided', () => {
125
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
126
+
127
+ expect($('figcaption').length).toBe(0);
128
+ });
129
+
130
+ describe('figure number', () => {
131
+ it('renders the figure number when provided', () => {
132
+ const $ = cheerio.load(
133
+ renderComponent(
134
+ 'figure',
135
+ {
136
+ ...EXAMPLE_FIGURE_BASIC,
137
+ figureNumber: 'Figure 1',
138
+ },
139
+ CALLER_CONTENT,
140
+ ),
141
+ );
142
+
143
+ expect($('.ons-figure__number').text()).toBe('Figure 1');
144
+ });
145
+
146
+ it('does not render the figure number when not provided', () => {
147
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
148
+
149
+ expect($('.ons-figure__number').length).toBe(0);
150
+ });
151
+ });
152
+
153
+ describe('title', () => {
154
+ it('renders the title', () => {
155
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
156
+
157
+ expect($('.ons-figure__title').text()).toBe('Figure title');
158
+ });
159
+
160
+ it('does not render the title when not provided', () => {
161
+ const $ = cheerio.load(
162
+ renderComponent(
163
+ 'figure',
164
+ {
165
+ id: 'example-figure',
166
+ },
167
+ CALLER_CONTENT,
168
+ ),
169
+ );
170
+
171
+ expect($('.ons-figure__title').length).toBe(0);
172
+ });
173
+ });
174
+
175
+ describe('subtitle', () => {
176
+ it('renders the subtitle when title is also provided', () => {
177
+ const $ = cheerio.load(
178
+ renderComponent(
179
+ 'figure',
180
+ {
181
+ ...EXAMPLE_FIGURE_BASIC,
182
+ subtitle: 'A subtitle',
183
+ },
184
+ CALLER_CONTENT,
185
+ ),
186
+ );
187
+
188
+ expect($('.ons-figure__subtitle').text()).toBe('A subtitle');
189
+ });
190
+
191
+ it('does not render the subtitle when not provided', () => {
192
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
193
+
194
+ expect($('.ons-figure__subtitle').length).toBe(0);
195
+ });
196
+
197
+ it('does not render the subtitle when title is not provided', () => {
198
+ const $ = cheerio.load(
199
+ renderComponent(
200
+ 'figure',
201
+ {
202
+ id: 'example-figure',
203
+ subtitle: 'A subtitle',
204
+ },
205
+ CALLER_CONTENT,
206
+ ),
207
+ );
208
+
209
+ expect($('.ons-figure__subtitle').length).toBe(0);
210
+ });
211
+ });
212
+
213
+ describe('heading levels', () => {
214
+ it('defaults to h2 for the title and h3 for the subtitle', () => {
215
+ const $ = cheerio.load(
216
+ renderComponent(
217
+ 'figure',
218
+ {
219
+ ...EXAMPLE_FIGURE_BASIC,
220
+ subtitle: 'A subtitle',
221
+ },
222
+ CALLER_CONTENT,
223
+ ),
224
+ );
225
+
226
+ expect($('.ons-figure__title')[0].tagName).toBe('h2');
227
+ expect($('.ons-figure__subtitle')[0].tagName).toBe('h3');
228
+ });
229
+
230
+ it('uses the provided headingLevel for the title', () => {
231
+ const $ = cheerio.load(
232
+ renderComponent(
233
+ 'figure',
234
+ {
235
+ ...EXAMPLE_FIGURE_BASIC,
236
+ headingLevel: 3,
237
+ },
238
+ CALLER_CONTENT,
239
+ ),
240
+ );
241
+
242
+ expect($('.ons-figure__title')[0].tagName).toBe('h3');
243
+ });
244
+
245
+ it('renders the subtitle one level below the title', () => {
246
+ const $ = cheerio.load(
247
+ renderComponent(
248
+ 'figure',
249
+ {
250
+ ...EXAMPLE_FIGURE_BASIC,
251
+ headingLevel: 4,
252
+ subtitle: 'A subtitle',
253
+ },
254
+ CALLER_CONTENT,
255
+ ),
256
+ );
257
+
258
+ expect($('.ons-figure__title')[0].tagName).toBe('h4');
259
+ expect($('.ons-figure__subtitle')[0].tagName).toBe('h5');
260
+ });
261
+
262
+ it('renders footnotes heading two levels below when title and subtitle are provided', () => {
263
+ const faker = templateFaker();
264
+ const detailsSpy = faker.spy('details');
265
+
266
+ faker.renderComponent(
267
+ 'figure',
268
+ {
269
+ ...EXAMPLE_FIGURE_BASIC,
270
+ headingLevel: 3,
271
+ subtitle: 'A subtitle',
272
+ footnotes: {
273
+ title: 'Footnotes',
274
+ content: 'Some notes.',
275
+ },
276
+ },
277
+ CALLER_CONTENT,
278
+ );
279
+
280
+ expect(detailsSpy.occurrences[0].headingLevel).toBe(5);
281
+ });
282
+
283
+ it('renders footnotes heading one level below when only title is provided', () => {
284
+ const faker = templateFaker();
285
+ const detailsSpy = faker.spy('details');
286
+
287
+ faker.renderComponent(
288
+ 'figure',
289
+ {
290
+ ...EXAMPLE_FIGURE_BASIC,
291
+ headingLevel: 3,
292
+ footnotes: {
293
+ title: 'Footnotes',
294
+ content: 'Some notes.',
295
+ },
296
+ },
297
+ CALLER_CONTENT,
298
+ );
299
+
300
+ expect(detailsSpy.occurrences[0].headingLevel).toBe(4);
301
+ });
302
+
303
+ it('renders footnotes at the base heading level when no title or subtitle is provided', () => {
304
+ const faker = templateFaker();
305
+ const detailsSpy = faker.spy('details');
306
+
307
+ faker.renderComponent(
308
+ 'figure',
309
+ {
310
+ id: 'example-figure',
311
+ headingLevel: 3,
312
+ footnotes: {
313
+ title: 'Footnotes',
314
+ content: 'Some notes.',
315
+ },
316
+ },
317
+ CALLER_CONTENT,
318
+ );
319
+
320
+ expect(detailsSpy.occurrences[0].headingLevel).toBe(3);
321
+ });
322
+
323
+ it('renders download heading two levels below when title and subtitle are provided', () => {
324
+ const faker = templateFaker();
325
+ const detailsSpy = faker.spy('details');
326
+
327
+ faker.renderComponent(
328
+ 'figure',
329
+ {
330
+ ...EXAMPLE_FIGURE_BASIC,
331
+ headingLevel: 3,
332
+ subtitle: 'A subtitle',
333
+ download: {
334
+ title: 'Downloads',
335
+ itemsList: [{ text: 'A file', url: '/file.csv', download: 'file' }],
336
+ },
337
+ },
338
+ CALLER_CONTENT,
339
+ );
340
+
341
+ expect(detailsSpy.occurrences[0].headingLevel).toBe(5);
342
+ });
343
+
344
+ it('renders download heading one level below when only title is provided', () => {
345
+ const faker = templateFaker();
346
+ const detailsSpy = faker.spy('details');
347
+
348
+ faker.renderComponent(
349
+ 'figure',
350
+ {
351
+ ...EXAMPLE_FIGURE_BASIC,
352
+ headingLevel: 3,
353
+ download: {
354
+ title: 'Downloads',
355
+ itemsList: [{ text: 'A file', url: '/file.csv', download: 'file' }],
356
+ },
357
+ },
358
+ CALLER_CONTENT,
359
+ );
360
+
361
+ expect(detailsSpy.occurrences[0].headingLevel).toBe(4);
362
+ });
363
+
364
+ it('renders download at the base heading level when no title or subtitle is provided', () => {
365
+ const faker = templateFaker();
366
+ const detailsSpy = faker.spy('details');
367
+
368
+ faker.renderComponent(
369
+ 'figure',
370
+ {
371
+ id: 'example-figure',
372
+ headingLevel: 3,
373
+ download: {
374
+ title: 'Downloads',
375
+ itemsList: [{ text: 'A file', url: '/file.csv', download: 'file' }],
376
+ },
377
+ },
378
+ CALLER_CONTENT,
379
+ );
380
+
381
+ expect(detailsSpy.occurrences[0].headingLevel).toBe(3);
382
+ });
383
+ });
384
+
385
+ describe('audio description', () => {
386
+ it('renders a visually hidden description with the correct id', () => {
387
+ const $ = cheerio.load(
388
+ renderComponent(
389
+ 'figure',
390
+ {
391
+ ...EXAMPLE_FIGURE_BASIC,
392
+ audioDescription: 'A detailed description of the content',
393
+ },
394
+ CALLER_CONTENT,
395
+ ),
396
+ );
397
+
398
+ expect($('.ons-u-vh').text()).toBe('A detailed description of the content');
399
+ expect($('.ons-u-vh').attr('id')).toBe('figure-audio-description-example-figure');
400
+ });
401
+
402
+ it('sets aria-describedby on the figure element', () => {
403
+ const $ = cheerio.load(
404
+ renderComponent(
405
+ 'figure',
406
+ {
407
+ ...EXAMPLE_FIGURE_BASIC,
408
+ audioDescription: 'A detailed description of the content',
409
+ },
410
+ CALLER_CONTENT,
411
+ ),
412
+ );
413
+
414
+ expect($('.ons-figure').attr('aria-describedby')).toBe('figure-audio-description-example-figure');
415
+ });
416
+
417
+ it('does not render audio description when not provided', () => {
418
+ const $ = cheerio.load(renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT));
419
+
420
+ expect($('.ons-u-vh').length).toBe(0);
421
+ expect($('.ons-figure').attr('aria-describedby')).toBeUndefined();
422
+ });
423
+ });
424
+
425
+ describe('footnotes', () => {
426
+ it('renders footnotes using the details component', () => {
427
+ const faker = templateFaker();
428
+ const detailsSpy = faker.spy('details');
429
+
430
+ faker.renderComponent(
431
+ 'figure',
432
+ {
433
+ ...EXAMPLE_FIGURE_BASIC,
434
+ footnotes: {
435
+ title: 'Footnotes',
436
+ content: 'Some footnote content.',
437
+ },
438
+ },
439
+ CALLER_CONTENT,
440
+ );
441
+
442
+ expect(detailsSpy.occurrences[0]).toEqual(
443
+ expect.objectContaining({
444
+ id: 'figure-footnotes--example-figure',
445
+ title: 'Footnotes',
446
+ content: 'Some footnote content.',
447
+ }),
448
+ );
449
+ });
450
+
451
+ it('does not render footnotes when not provided', () => {
452
+ const faker = templateFaker();
453
+ const detailsSpy = faker.spy('details');
454
+
455
+ faker.renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT);
456
+
457
+ expect(detailsSpy.occurrences.filter(Boolean).length).toBe(0);
458
+ });
459
+ });
460
+
461
+ describe('download', () => {
462
+ it('renders downloads using the details and list components', () => {
463
+ const faker = templateFaker();
464
+ const detailsSpy = faker.spy('details');
465
+
466
+ faker.renderComponent(
467
+ 'figure',
468
+ {
469
+ ...EXAMPLE_FIGURE_BASIC,
470
+ download: {
471
+ title: 'Download this image',
472
+ itemsList: [
473
+ {
474
+ text: 'Image (JPG, 1.2MB)',
475
+ url: '/img/example.jpg',
476
+ download: 'file',
477
+ },
478
+ ],
479
+ },
480
+ },
481
+ CALLER_CONTENT,
482
+ );
483
+
484
+ expect(detailsSpy.occurrences[0]).toEqual(
485
+ expect.objectContaining({
486
+ id: 'figure-downloads--example-figure',
487
+ title: 'Download this image',
488
+ }),
489
+ );
490
+ });
491
+
492
+ it('does not render downloads when not provided', () => {
493
+ const faker = templateFaker();
494
+ const detailsSpy = faker.spy('details');
495
+
496
+ faker.renderComponent('figure', EXAMPLE_FIGURE_BASIC, CALLER_CONTENT);
497
+
498
+ expect(detailsSpy.occurrences.filter(Boolean).length).toBe(0);
499
+ });
500
+
501
+ it('does not render downloads when itemsList is empty', () => {
502
+ const faker = templateFaker();
503
+ const detailsSpy = faker.spy('details');
504
+
505
+ faker.renderComponent(
506
+ 'figure',
507
+ {
508
+ ...EXAMPLE_FIGURE_BASIC,
509
+ download: {
510
+ title: 'Download this image',
511
+ itemsList: [],
512
+ },
513
+ },
514
+ CALLER_CONTENT,
515
+ );
516
+
517
+ expect(detailsSpy.occurrences.filter(Boolean).length).toBe(0);
518
+ });
519
+ });
520
+ });
@@ -0,0 +1,34 @@
1
+ {% from "components/figure/_macro.njk" import onsFigure %}
2
+
3
+ {%
4
+ call onsFigure({
5
+ "headingLevel": 2,
6
+ "figureNumber": "Figure 1",
7
+ "title": "Image 1: Working from home",
8
+ "subtitle": "A growing proportion of the workforce now works remotely",
9
+ "id": "figure-with-image",
10
+ "caption": "Image 1 - Woman in a purple dress shirt using a laptop",
11
+ "download": {
12
+ "title": "Download this image",
13
+ "itemsList": [
14
+ {
15
+ "text": "High resolution image (JPG format, 1.2MB)",
16
+ "url": "/img/small/woman-in-purple-dress-shirt.jpg",
17
+ "download": "file"
18
+ },
19
+ {
20
+ "text": "High resolution image (JPG format, 1.2MB)",
21
+ "url": "/img/small/woman-in-purple-dress-shirt.jpg",
22
+ "download": "file"
23
+ }
24
+ ]
25
+ },
26
+ "footnotes": {
27
+ "title": "Footnotes",
28
+ "content": "Image is for illustrative purposes only."
29
+ }
30
+ })
31
+ %}
32
+ {# Note that for the sake if the example the image here is rendered directly in an image tag, because onsImage already renders using the figure component #}
33
+ <img class="ons-image__img" src="/img/small/woman-in-purple-dress-shirt.jpg" alt="Woman in a purple dress shirt using a laptop" />
34
+ {% endcall %}
@@ -0,0 +1,29 @@
1
+ {% from "components/figure/_macro.njk" import onsFigure %}
2
+
3
+ {%
4
+ call onsFigure({
5
+ "useDivForRootElement": true,
6
+ "headingLevel": 3,
7
+ "figureNumber": "Figure 1",
8
+ "title": "Image 1: Working from home",
9
+ "subtitle": "A growing proportion of the workforce now works remotely",
10
+ "id": "figure-with-div",
11
+ "caption": "Image 1 - Woman in a purple dress shirt using a laptop",
12
+ "download": {
13
+ "title": "Download this image",
14
+ "itemsList": [
15
+ {
16
+ "text": "High resolution image (JPG format, 1.2MB)",
17
+ "url": "/img/small/woman-in-purple-dress-shirt.jpg",
18
+ "download": "file"
19
+ }
20
+ ]
21
+ },
22
+ "footnotes": {
23
+ "title": "Footnotes",
24
+ "content": "Image is for illustrative purposes only."
25
+ }
26
+ })
27
+ %}
28
+ <img class="ons-image__img" src="/img/small/woman-in-purple-dress-shirt.jpg" alt="Woman in a purple dress shirt using a laptop" />
29
+ {% endcall %}
@@ -0,0 +1,12 @@
1
+ {% from "components/figure/_macro.njk" import onsFigure %}
2
+
3
+ {%
4
+ call onsFigure({
5
+ "headingLevel": 3,
6
+ "figureNumber": "Figure 1",
7
+ "title": "Image 1: Working from home",
8
+ "subtitle": "A growing proportion of the workforce now works remotely"
9
+ })
10
+ %}
11
+ <img class="ons-image__img" src="/img/small/woman-in-purple-dress-shirt.jpg" alt="Woman in a purple dress shirt using a laptop" />
12
+ {% endcall %}
@@ -0,0 +1,24 @@
1
+ {% from "components/figure/_macro.njk" import onsFigure %}
2
+
3
+ {%
4
+ call onsFigure({
5
+ "id": "figure-without-header",
6
+ "caption": "Image 1 - Woman in a purple dress shirt using a laptop",
7
+ "footnotes": {
8
+ "title": "Footnotes",
9
+ "content": "Image is for illustrative purposes only."
10
+ },
11
+ "download": {
12
+ "title": "Download this image",
13
+ "itemsList": [
14
+ {
15
+ "text": "High resolution image (JPG format, 1.2MB)",
16
+ "url": "/img/small/woman-in-purple-dress-shirt.jpg",
17
+ "download": "file"
18
+ }
19
+ ]
20
+ }
21
+ })
22
+ %}
23
+ <img class="ons-image__img" src="/img/small/woman-in-purple-dress-shirt.jpg" alt="Woman in a purple dress shirt using a laptop" />
24
+ {% endcall %}
@@ -0,0 +1,34 @@
1
+ {% from "components/figure/_macro.njk" import onsFigure %}
2
+
3
+ {%
4
+ call onsFigure({
5
+ "headingLevel": 3,
6
+ "figureNumber": "Figure 1",
7
+ "title": "Image 1: Working from home",
8
+ "subtitle": "A growing proportion of the workforce now works remotely",
9
+ "id": "figure-with-image",
10
+ "caption": "Image 1 - Woman in a purple dress shirt using a laptop",
11
+ "download": {
12
+ "title": "Download this image",
13
+ "itemsList": [
14
+ {
15
+ "text": "High resolution image (JPG format, 1.2MB)",
16
+ "url": "/img/small/woman-in-purple-dress-shirt.jpg",
17
+ "download": "file"
18
+ },
19
+ {
20
+ "text": "High resolution image (JPG format, 1.2MB)",
21
+ "url": "/img/small/woman-in-purple-dress-shirt.jpg",
22
+ "download": "file"
23
+ }
24
+ ]
25
+ },
26
+ "footnotes": {
27
+ "title": "Footnotes",
28
+ "content": "Image is for illustrative purposes only."
29
+ }
30
+ })
31
+ %}
32
+ {# Note that for the sake if the example the image here is rendered directly in an image tag, because onsImage already renders using the figure component #}
33
+ <img class="ons-image__img" src="/img/small/woman-in-purple-dress-shirt.jpg" alt="Woman in a purple dress shirt using a laptop" />
34
+ {% endcall %}
@@ -7,11 +7,4 @@
7
7
  display: block;
8
8
  max-width: 100%;
9
9
  }
10
-
11
- &__caption {
12
- @extend .ons-u-fs-s;
13
-
14
- display: block;
15
- padding: 0.5rem 0 0;
16
- }
17
10
  }