@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.
- package/README.md +15 -3
- package/components/access-code/example-access-code-error.njk +1 -1
- package/components/access-code/example-access-code.njk +1 -1
- package/components/address-input/autosuggest.address.spec.js +23 -0
- package/components/autosuggest/autosuggest.ui.js +3 -0
- package/components/back-to-top/example-full-page-back-to-top.njk +1 -1
- package/components/breadcrumbs/_breadcrumbs.scss +4 -7
- package/components/breadcrumbs/_macro.njk +29 -25
- package/components/breadcrumbs/_macro.spec.js +39 -0
- package/components/breadcrumbs/example-breadcrumbs-wide.njk +52 -0
- package/components/chart/_chart.scss +0 -9
- package/components/chart/_macro.njk +96 -128
- package/components/chart/_macro.spec.js +43 -28
- package/components/chart/example-area-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-area-chart.njk +6 -3
- package/components/chart/example-bar-chart-with-annotations.njk +6 -3
- package/components/chart/example-bar-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-bar-chart-with-point-range-and-reference-line-annotations.njk +6 -3
- package/components/chart/example-bar-chart.njk +6 -3
- package/components/chart/example-bar-with-confidence-levels.njk +6 -3
- package/components/chart/example-clustered-bar-chart.njk +6 -3
- package/components/chart/example-clustered-column-chart.njk +6 -3
- package/components/chart/example-column-chart-with-annotations.njk +6 -3
- package/components/chart/example-column-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-column-chart-with-custom-reference-line-value.njk +6 -3
- package/components/chart/example-column-chart-with-range-annotations.njk +6 -3
- package/components/chart/example-column-chart-with-reference-line-annotations.njk +6 -3
- package/components/chart/example-column-chart.njk +6 -3
- package/components/chart/example-column-with-confidence-levels.njk +6 -3
- package/components/chart/example-column-with-line-chart.njk +6 -3
- package/components/chart/example-iframe-chart.njk +6 -3
- package/components/chart/example-line-chart-with-annotations.njk +6 -3
- package/components/chart/example-line-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-line-chart-with-custom-reference-line-value.njk +6 -3
- package/components/chart/example-line-chart-with-label-format.njk +6 -3
- package/components/chart/example-line-chart-with-markers.njk +6 -3
- package/components/chart/example-line-chart-with-range-annotations-inside.njk +6 -3
- package/components/chart/example-line-chart-with-range-annotations-outside-left-right.njk +6 -3
- package/components/chart/example-line-chart-with-range-annotations-outside-top-bottom.njk +6 -3
- package/components/chart/example-line-chart-with-reference-line-annotations.njk +6 -3
- package/components/chart/example-line-chart.njk +6 -3
- package/components/chart/example-scatter-chart-with-axis-min-and-max-values.njk +6 -3
- package/components/chart/example-scatter-chart.njk +6 -3
- package/components/chart/example-stacked-bar-chart.njk +6 -3
- package/components/chart/example-stacked-column-chart.njk +6 -3
- package/components/document-list/_macro.njk +2 -2
- package/components/document-list/_macro.spec.js +55 -0
- package/components/featured-article/_macro.njk +3 -37
- package/components/featured-article/example-featured-article-with-chart.njk +19 -14
- package/components/featured-article/example-featured-article-with-image.njk +12 -7
- package/components/featured-article/featured-article.scss +1 -1
- package/components/featured-article/macro.spec.js +44 -67
- package/components/figure/_figure.scss +31 -0
- package/components/figure/_macro.njk +98 -0
- package/components/figure/_macro.spec.js +520 -0
- package/components/figure/example-figure-heading-level-2.njk +34 -0
- package/components/figure/example-figure-with-div.njk +29 -0
- package/components/figure/example-figure-without-footer.njk +12 -0
- package/components/figure/example-figure-without-header.njk +24 -0
- package/components/figure/example-figure.njk +34 -0
- package/components/header/_header.scss +1 -3
- package/components/header/_macro.njk +8 -4
- package/components/header/_macro.spec.js +48 -0
- package/components/hero/_macro.njk +3 -2
- package/components/hero/_macro.spec.js +36 -0
- package/components/hero/example-hero-dark-wide.njk +17 -0
- package/components/hero/example-hero-dark-with-external-breadcrumbs.njk +17 -21
- package/components/hero/example-hero-default-full-width.njk +16 -0
- package/components/hero/example-hero-default-with-external-breadcrumbs.njk +165 -169
- package/components/hero/example-hero-grey-with-external-breadcrumbs.njk +207 -211
- package/components/hero/example-hero-navy-blue-with-external-breadcrumbs.njk +163 -167
- package/components/hero/example-hero-pale-blue-with-external-breadcrumbs.njk +165 -169
- package/components/image/_image.scss +0 -7
- package/components/image/_macro.njk +25 -14
- package/components/image/_macro.spec.js +122 -7
- package/components/image/example-image-with-figure-fields.njk +25 -0
- package/components/list/_macro.njk +1 -0
- package/components/list/_macro.spec.js +16 -0
- package/components/question/example-question-ccs.njk +1 -1
- package/components/question/example-question-fieldset.njk +1 -1
- package/components/question/example-question-interviewer-note.njk +1 -1
- package/components/question/example-question-no-fieldset.njk +1 -1
- package/components/relationships/example-relationships-error.njk +1 -1
- package/components/relationships/example-relationships-you.njk +1 -1
- package/components/relationships/example-relationships.njk +1 -1
- package/components/table/_macro.njk +138 -111
- package/components/table/_macro.spec.js +175 -16
- package/components/table/_table.scss +6 -1
- package/components/table/example-table-basic-no-caption.njk +46 -0
- package/components/table/example-table-basic-visually-hidden-caption.njk +47 -0
- package/components/table/example-table-with-figure-fields.njk +86 -0
- package/components/table/table.spec.js +2 -0
- package/components/table-of-contents/_macro.njk +6 -4
- package/components/table-of-contents/_macro.spec.js +43 -3
- package/components/table-of-contents/example-table-of-contents-ordered.njk +64 -0
- package/components/table-of-contents/example-table-of-contents-sticky-full-page-ordered.njk +156 -0
- package/components/table-of-contents/example-table-of-contents-sticky-full-page.njk +1 -1
- package/components/table-of-contents/table-of-contents.spec.js +4 -5
- package/css/main.css +1 -1
- package/layout/_template.njk +66 -46
- package/package.json +45 -36
- package/scripts/main.es5.js +3 -3
- package/scripts/main.js +2 -2
- package/scss/base/_global.scss +8 -0
- package/scss/main.scss +1 -0
- package/scss/objects/_page.scss +1 -1
- package/scss/objects/_spacing.scss +0 -4
|
@@ -4,170 +4,165 @@ layout: ~
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
{% from "components/hero/_macro.njk" import onsHero %}
|
|
7
|
-
{% from "components/breadcrumbs/_macro.njk" import onsBreadcrumbs %}
|
|
8
7
|
{% extends "layout/_template.njk" %}
|
|
9
8
|
{%
|
|
10
9
|
set pageConfig = {
|
|
11
10
|
"header": {
|
|
12
11
|
"variants": 'basic',
|
|
13
12
|
"menuLinks": {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
13
|
+
"id": "menu-links",
|
|
14
|
+
"keyLinks": [
|
|
15
|
+
{
|
|
16
|
+
'heading': 'Taking part in a survey?',
|
|
17
|
+
'description': 'It’s never been more important.'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
'heading': 'Release calendar',
|
|
21
|
+
'description': 'View our latest and upcoming releases.'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
'heading': 'Explore local statistics',
|
|
25
|
+
'url': '#0',
|
|
26
|
+
'description': 'Explore statistics across the UK.'
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"columns": [
|
|
30
|
+
{
|
|
31
|
+
"groups": [
|
|
32
|
+
{
|
|
33
|
+
"heading": "People, population and community",
|
|
34
|
+
"groupItems": [
|
|
35
|
+
{
|
|
36
|
+
"text": "Armed forces community"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"text": "Births, deaths and marriages"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"text": "Crime and justice"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"text": "Cultural identity"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"text": "Education and childcare"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"text": "Elections"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"text": "Health and social care"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"text": "Household characteristics"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"text": "Housing"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"text": "Leisure and tourism"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"text": "Personal and household finances"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"text": "Population and migration"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"text": "Well-being"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"groups": [
|
|
80
|
+
{
|
|
81
|
+
"heading": "Business, industry and trade",
|
|
82
|
+
"groupItems": [
|
|
83
|
+
{
|
|
84
|
+
"text": "Business"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"text": "Changes to business"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"text": "Construction industry"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"text": "International trade"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"text": "IT and internet industry"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"text": "Manufacturing and production industry"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"text": "Retail industry",
|
|
103
|
+
"url": "#0"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"text": "Tourism industry"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"heading": "Employment and labour market",
|
|
112
|
+
"url": "#0",
|
|
113
|
+
"groupItems":
|
|
114
|
+
[
|
|
115
|
+
{
|
|
116
|
+
"text": "People in work"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"text": "People not in work"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
%}
|
|
168
|
-
{% block pageContent %}
|
|
169
|
-
{{
|
|
170
|
-
onsBreadcrumbs({
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"groups": [
|
|
128
|
+
{
|
|
129
|
+
"heading": "Economy",
|
|
130
|
+
"groupItems": [
|
|
131
|
+
{
|
|
132
|
+
"text": "Economic output and productivity"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"text": "Government, public sector and taxes"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"text": "Gross Value Added (GVA)"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"text": "Investments, pensions and trusts"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"text": "Regional accounts"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"text": "Environmental accounts"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"text": "Gross Domestic Product (GDP)"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"text": "Inflation and price indices"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"text": "National accounts"
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
breadcrumbs: {
|
|
171
166
|
"ariaLabel": 'Breadcrumbs',
|
|
172
167
|
"variant": "pale-blue",
|
|
173
168
|
"itemsList": [
|
|
@@ -184,18 +179,19 @@ layout: ~
|
|
|
184
179
|
"text": 'Retail industry'
|
|
185
180
|
}
|
|
186
181
|
]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
%}
|
|
185
|
+
|
|
186
|
+
{% block hero %}
|
|
187
|
+
{{
|
|
188
|
+
onsHero({
|
|
189
|
+
"topic": 'Topic',
|
|
190
|
+
"title": 'Retail Industry',
|
|
191
|
+
"text": 'Sales by retailers in Great Britain directly to end consumers, including spending on goods (in store and online)
|
|
192
|
+
(Retail Sales Index) and spending on services (Index of Services). The industry as a whole is used as an indicator
|
|
193
|
+
of how the wider economy is performing and the strength of consumer spending.',
|
|
194
|
+
"variants": 'pale-blue'
|
|
187
195
|
})
|
|
188
196
|
}}
|
|
189
|
-
<main id="main-content">
|
|
190
|
-
{{
|
|
191
|
-
onsHero({
|
|
192
|
-
"topic": 'Topic',
|
|
193
|
-
"title": 'Retail Industry',
|
|
194
|
-
"text": 'Sales by retailers in Great Britain directly to end consumers, including spending on goods (in store and online)
|
|
195
|
-
(Retail Sales Index) and spending on services (Index of Services). The industry as a whole is used as an indicator
|
|
196
|
-
of how the wider economy is performing and the strength of consumer spending.',
|
|
197
|
-
"variants": 'pale-blue'
|
|
198
|
-
})
|
|
199
|
-
}}
|
|
200
|
-
</main>
|
|
201
197
|
{% endblock %}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
{%- macro onsImage(params) -%}
|
|
2
|
-
|
|
3
|
-
{% if params.image %}
|
|
4
|
-
<img
|
|
5
|
-
class="ons-image__img"
|
|
6
|
-
{% if params.image.largeSrc %}srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %}src="{{ params.image.smallSrc }}"
|
|
7
|
-
alt="{{ params.alt if params.alt }}"
|
|
8
|
-
/>
|
|
9
|
-
{% else %}
|
|
10
|
-
<img class="ons-image__img" src="{{ params.src }}" alt="{{ params.alt }}" />
|
|
11
|
-
{% endif %}
|
|
2
|
+
{% from "components/figure/_macro.njk" import onsFigure %}
|
|
12
3
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
{%
|
|
5
|
+
call onsFigure({
|
|
6
|
+
"id": params.id,
|
|
7
|
+
"headingLevel": params.headingLevel,
|
|
8
|
+
"figureNumber": params.figureNumber,
|
|
9
|
+
"title": params.title,
|
|
10
|
+
"subtitle": params.subtitle,
|
|
11
|
+
"caption": params.caption,
|
|
12
|
+
"footnotes": params.footnotes,
|
|
13
|
+
"download": params.download
|
|
14
|
+
})
|
|
15
|
+
%}
|
|
16
|
+
<div class="ons-image">
|
|
17
|
+
{% if params.image %}
|
|
18
|
+
<img
|
|
19
|
+
class="ons-image__img"
|
|
20
|
+
{% if params.image.largeSrc %}srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %}src="{{ params.image.smallSrc }}"
|
|
21
|
+
alt="{{ params.alt if params.alt }}"
|
|
22
|
+
/>
|
|
23
|
+
{% else %}
|
|
24
|
+
<img class="ons-image__img" src="{{ params.src }}" alt="{{ params.alt }}" />
|
|
25
|
+
{% endif %}
|
|
26
|
+
</div>
|
|
27
|
+
{% endcall %}
|
|
17
28
|
{%- endmacro -%}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as cheerio from 'cheerio';
|
|
4
4
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
|
-
import { renderComponent } from '../../tests/helpers/rendering';
|
|
6
|
+
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
8
|
const EXAMPLE_IMAGE_SRC_URL_MINIMAL = {
|
|
9
9
|
src: 'example.png',
|
|
@@ -17,13 +17,14 @@ const EXAMPLE_IMAGE_IMAGE_MINIMAL = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
describe('macro: image', () => {
|
|
20
|
-
it('outputs a `figure` element', () => {
|
|
20
|
+
it('outputs a `figure` element wrapping the image', () => {
|
|
21
21
|
const $ = cheerio.load(renderComponent('image', EXAMPLE_IMAGE_SRC_URL_MINIMAL));
|
|
22
22
|
|
|
23
|
-
expect($('.ons-
|
|
23
|
+
expect($('.ons-figure')[0].tagName).toBe('figure');
|
|
24
|
+
expect($('.ons-figure .ons-image').length).toBe(1);
|
|
24
25
|
});
|
|
25
26
|
|
|
26
|
-
it('outputs a `
|
|
27
|
+
it('outputs a `figcaption` element when `caption` is provided', () => {
|
|
27
28
|
const $ = cheerio.load(
|
|
28
29
|
renderComponent('image', {
|
|
29
30
|
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
@@ -31,10 +32,10 @@ describe('macro: image', () => {
|
|
|
31
32
|
}),
|
|
32
33
|
);
|
|
33
34
|
|
|
34
|
-
expect($('.ons-
|
|
35
|
+
expect($('.ons-figure__caption')[0].tagName).toBe('figcaption');
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
it('outputs a `
|
|
38
|
+
it('outputs a `figcaption` element with provided `caption` text', () => {
|
|
38
39
|
const $ = cheerio.load(
|
|
39
40
|
renderComponent('image', {
|
|
40
41
|
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
@@ -42,7 +43,121 @@ describe('macro: image', () => {
|
|
|
42
43
|
}),
|
|
43
44
|
);
|
|
44
45
|
|
|
45
|
-
expect($('.ons-
|
|
46
|
+
expect($('.ons-figure__caption').text().trim()).toBe('Example image caption');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('figure params', () => {
|
|
50
|
+
it('passes `id` to the figure component', () => {
|
|
51
|
+
const faker = templateFaker();
|
|
52
|
+
const figureSpy = faker.spy('figure');
|
|
53
|
+
|
|
54
|
+
faker.renderComponent('image', {
|
|
55
|
+
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
56
|
+
id: 'my-image',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(figureSpy.occurrences[0].id).toBe('my-image');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('passes `headingLevel` to the figure component', () => {
|
|
63
|
+
const faker = templateFaker();
|
|
64
|
+
const figureSpy = faker.spy('figure');
|
|
65
|
+
|
|
66
|
+
faker.renderComponent('image', {
|
|
67
|
+
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
68
|
+
headingLevel: 4,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(figureSpy.occurrences[0].headingLevel).toBe(4);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('passes `figureNumber` to the figure component', () => {
|
|
75
|
+
const faker = templateFaker();
|
|
76
|
+
const figureSpy = faker.spy('figure');
|
|
77
|
+
|
|
78
|
+
faker.renderComponent('image', {
|
|
79
|
+
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
80
|
+
figureNumber: 'Image 1',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(figureSpy.occurrences[0].figureNumber).toBe('Image 1');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('passes `title` to the figure component', () => {
|
|
87
|
+
const faker = templateFaker();
|
|
88
|
+
const figureSpy = faker.spy('figure');
|
|
89
|
+
|
|
90
|
+
faker.renderComponent('image', {
|
|
91
|
+
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
92
|
+
title: 'Image title',
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(figureSpy.occurrences[0].title).toBe('Image title');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('passes `subtitle` to the figure component', () => {
|
|
99
|
+
const faker = templateFaker();
|
|
100
|
+
const figureSpy = faker.spy('figure');
|
|
101
|
+
|
|
102
|
+
faker.renderComponent('image', {
|
|
103
|
+
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
104
|
+
subtitle: 'Image subtitle',
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
expect(figureSpy.occurrences[0].subtitle).toBe('Image subtitle');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('passes `caption` to the figure component', () => {
|
|
111
|
+
const faker = templateFaker();
|
|
112
|
+
const figureSpy = faker.spy('figure');
|
|
113
|
+
|
|
114
|
+
faker.renderComponent('image', {
|
|
115
|
+
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
116
|
+
caption: 'A caption',
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(figureSpy.occurrences[0].caption).toBe('A caption');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('passes `footnotes` to the figure component', () => {
|
|
123
|
+
const faker = templateFaker();
|
|
124
|
+
const figureSpy = faker.spy('figure');
|
|
125
|
+
|
|
126
|
+
const footnotes = {
|
|
127
|
+
title: 'Footnotes',
|
|
128
|
+
content: 'Some notes about this image.',
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
faker.renderComponent('image', {
|
|
132
|
+
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
133
|
+
footnotes,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect(figureSpy.occurrences[0].footnotes).toEqual(footnotes);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('passes `download` to the figure component', () => {
|
|
140
|
+
const faker = templateFaker();
|
|
141
|
+
const figureSpy = faker.spy('figure');
|
|
142
|
+
|
|
143
|
+
const download = {
|
|
144
|
+
title: 'Download this image',
|
|
145
|
+
itemsList: [
|
|
146
|
+
{
|
|
147
|
+
text: 'High resolution image (JPG, 1.2MB)',
|
|
148
|
+
url: '/img/example.jpg',
|
|
149
|
+
download: 'file',
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
faker.renderComponent('image', {
|
|
155
|
+
...EXAMPLE_IMAGE_SRC_URL_MINIMAL,
|
|
156
|
+
download,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
expect(figureSpy.occurrences[0].download).toEqual(download);
|
|
160
|
+
});
|
|
46
161
|
});
|
|
47
162
|
|
|
48
163
|
describe('mode: src', () => {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{% from "components/image/_macro.njk" import onsImage %}
|
|
2
|
+
{{
|
|
3
|
+
onsImage({
|
|
4
|
+
"id": "image-with-extra-fields",
|
|
5
|
+
"src": '/img/small/woman-in-purple-dress-shirt.jpg',
|
|
6
|
+
"alt": 'Woman in a purple dress shirt using a laptop',
|
|
7
|
+
"title": "Image 1: Working from home",
|
|
8
|
+
"subtitle": "A growing proportion of the workforce now works remotely",
|
|
9
|
+
"caption": "Image 1 - Woman in a purple dress shirt using a laptop",
|
|
10
|
+
"footnotes": {
|
|
11
|
+
"title": "Footnotes",
|
|
12
|
+
"content": "Image is for illustrative purposes only."
|
|
13
|
+
},
|
|
14
|
+
"download": {
|
|
15
|
+
"title": "Download this image",
|
|
16
|
+
"itemsList": [
|
|
17
|
+
{
|
|
18
|
+
"text": "High resolution image (JPG format, 1.2MB)",
|
|
19
|
+
"url": "/img/small/woman-in-purple-dress-shirt.jpg",
|
|
20
|
+
"download": "file"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}}
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
href="{{ item.url }}"
|
|
80
80
|
class="ons-list__link{{ ' ons-js-inpagelink' if item.variants == 'inPageLink' }}{{ ' ' + item.classes if item.classes else '' }}"
|
|
81
81
|
{% if item.target %}target="{{ item.target }}"{% endif %}
|
|
82
|
+
{% if item.download %}download="{{ item.download}}"{% endif %}
|
|
82
83
|
>
|
|
83
84
|
{%- if item.prefix -%}<span class="ons-u-vh">{{- item.prefix -}}</span>{%- endif -%} {{- itemText | safe -}}
|
|
84
85
|
{%- if item.target == "_blank" -%}
|
|
@@ -376,6 +376,22 @@ describe('macro: list', () => {
|
|
|
376
376
|
expect($('.ons-list__link').hasClass('another-extra-class')).toBe(true);
|
|
377
377
|
});
|
|
378
378
|
|
|
379
|
+
it('has the provided `download` attribute', () => {
|
|
380
|
+
const $ = cheerio.load(
|
|
381
|
+
renderComponent('list', {
|
|
382
|
+
itemsList: [
|
|
383
|
+
{
|
|
384
|
+
...item,
|
|
385
|
+
url: '/example.csv',
|
|
386
|
+
download: 'file',
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
}),
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
expect($('.ons-list__link').attr('download')).toBe('file');
|
|
393
|
+
});
|
|
394
|
+
|
|
379
395
|
it('has the provided `target` attribute', () => {
|
|
380
396
|
const $ = cheerio.load(
|
|
381
397
|
renderComponent('list', {
|