@ons/design-system 73.0.4 → 73.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/chart/_chart.scss +2 -2
- package/components/chart/_macro.spec.js +32 -0
- package/components/chart/annotations-options.js +1 -0
- package/components/chart/area-chart.js +3 -0
- package/components/chart/bar-chart.js +1 -0
- package/components/chart/chart.js +6 -4
- package/components/chart/column-chart.js +3 -0
- package/components/chart/example-area-chart.njk +2 -2
- package/components/chart/example-line-chart-with-label-format.njk +89 -0
- package/components/chart/reference-line-annotations-options.js +1 -0
- package/components/chart/specific-chart-options.js +8 -1
- package/components/details-panel/_macro.njk +6 -6
- package/components/header/_header.scss +3 -3
- package/components/header/_macro.njk +153 -143
- package/components/header/_macro.spec.js +223 -0
- package/components/header/example-header-basic-with-search-and-language-DEPRECATED.njk +207 -0
- package/components/header/example-header-basic-with-search-and-language.njk +36 -27
- package/components/header/example-header-basic-with-search-button.njk +35 -27
- package/components/hero/_macro.njk +4 -1
- package/components/hero/_macro.spec.js +26 -0
- package/components/list/_list.scss +0 -3
- package/components/panel/_panel.scss +5 -0
- package/components/phase-banner/_macro.njk +10 -1
- package/components/phase-banner/_macro.spec.js +27 -0
- package/components/phase-banner/example-phase-banner-beta-with-feedback-link.njk +18 -0
- package/components/phase-banner/example-phase-banner-beta-without-feedback-link.njk +7 -0
- package/components/question/_question.scss +1 -0
- package/components/radios/_macro.njk +1 -1
- package/components/skip-to-content/_macro.njk +1 -1
- package/components/skip-to-content/_skip.scss +0 -2
- package/components/table/_macro.njk +6 -3
- package/components/table/_macro.spec.js +58 -0
- package/components/table/_table.scss +9 -1
- package/components/table/example-table-with-valign-property.njk +142 -0
- package/components/table-of-contents/example-table-of-contents-grouped-with-single-list-item.njk +34 -0
- package/css/main.css +1 -1
- package/js/cookies-settings.js +5 -5
- package/package.json +18 -12
- package/scripts/main.es5.js +5 -3
- package/scripts/main.js +2 -2
- package/scss/utilities/_highlight.scss +1 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
---
|
|
2
|
+
'fullWidth': true
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
{% from "components/header/_macro.njk" import onsHeader %}
|
|
6
|
+
|
|
7
|
+
{{
|
|
8
|
+
onsHeader({
|
|
9
|
+
"variants": 'basic',
|
|
10
|
+
"language": {
|
|
11
|
+
"languages": [
|
|
12
|
+
{
|
|
13
|
+
"url": '#0',
|
|
14
|
+
"isoCode": 'en',
|
|
15
|
+
"text": 'English',
|
|
16
|
+
"current": false
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"url": '#0',
|
|
20
|
+
"isoCode": 'cy',
|
|
21
|
+
"text": 'Cymraeg',
|
|
22
|
+
"current": true
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"menuLinks": {
|
|
27
|
+
"id": "menu-links",
|
|
28
|
+
"keyLinks": [
|
|
29
|
+
{
|
|
30
|
+
'heading': 'Taking part in a survey?',
|
|
31
|
+
'description': 'It’s never been more important.'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
'heading': 'Release calendar',
|
|
35
|
+
'description': 'View our latest and upcoming releases.'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
'heading': 'Explore local statistics',
|
|
39
|
+
'url': '#0',
|
|
40
|
+
'description': 'Explore statistics across the UK.'
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"columns": [
|
|
44
|
+
{
|
|
45
|
+
"groups": [
|
|
46
|
+
{
|
|
47
|
+
"heading": "People, population and community",
|
|
48
|
+
"groupItems": [
|
|
49
|
+
{
|
|
50
|
+
"text": "Armed forces community"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"text": "Births, deaths and marriages"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"text": "Crime and justice"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"text": "Cultural identity"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"text": "Education and childcare"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"text": "Elections"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"text": "Health and social care"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"text": "Household characteristics"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"text": "Housing"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"text": "Leisure and tourism"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"text": "Personal and household finances"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"text": "Population and migration"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"text": "Well-being"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"groups": [
|
|
94
|
+
{
|
|
95
|
+
"heading": "Business, industry and trade",
|
|
96
|
+
"groupItems": [
|
|
97
|
+
{
|
|
98
|
+
"text": "Business"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"text": "Changes to business"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"text": "Construction industry"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"text": "International trade"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"text": "IT and internet industry"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"text": "Manufacturing and production industry"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"text": "Retail industry",
|
|
117
|
+
"url": "#0"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"text": "Tourism industry"
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"heading": "Employment and labour market",
|
|
126
|
+
"url": "#0",
|
|
127
|
+
"groupItems":
|
|
128
|
+
[
|
|
129
|
+
{
|
|
130
|
+
"text": "People in work"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"text": "People not in work"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"groups": [
|
|
142
|
+
{
|
|
143
|
+
"heading": "Economy",
|
|
144
|
+
"groupItems": [
|
|
145
|
+
{
|
|
146
|
+
"text": "Economic output and productivity"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"text": "Government, public sector and taxes"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"text": "Gross Value Added (GVA)"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"text": "Investments, pensions and trusts"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"text": "Regional accounts"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"text": "Environmental accounts"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"text": "Gross Domestic Product (GDP)"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"text": "Inflation and price indices"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"text": "National accounts"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
"searchLinks": {
|
|
179
|
+
"id": "search-links",
|
|
180
|
+
"searchNavigationAriaLabel": 'Nav Search',
|
|
181
|
+
"searchButtonAriaLabel": 'Toggle search',
|
|
182
|
+
'heading': 'Popular searches',
|
|
183
|
+
"itemsList": [
|
|
184
|
+
{
|
|
185
|
+
"url": '#1',
|
|
186
|
+
"text": 'Cost of living'
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"url": '#1',
|
|
190
|
+
"text": 'Inflation'
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"url": '#3',
|
|
194
|
+
"text": 'NHS waiting times'
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"url": '#0',
|
|
198
|
+
"text": 'Wellbeing'
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"url": '#0',
|
|
202
|
+
"text": 'Baby names'
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
}}
|
|
@@ -175,33 +175,42 @@
|
|
|
175
175
|
}
|
|
176
176
|
]
|
|
177
177
|
},
|
|
178
|
-
"
|
|
179
|
-
"id": "search
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
178
|
+
"search": {
|
|
179
|
+
"id": "search",
|
|
180
|
+
"navAriaLabel": 'Nav Search',
|
|
181
|
+
"toggleAriaLabel": 'Toggle search',
|
|
182
|
+
"form": {
|
|
183
|
+
"action": "https://www.ons.gov.uk/search" ,
|
|
184
|
+
"inputName": "q",
|
|
185
|
+
"inputLabel": "Search the ONS",
|
|
186
|
+
"buttonText": "Search",
|
|
187
|
+
"buttonAriaLabel": "Submit search"
|
|
188
|
+
},
|
|
189
|
+
"links": {
|
|
190
|
+
'heading': 'Popular searches',
|
|
191
|
+
"itemsList": [
|
|
192
|
+
{
|
|
193
|
+
"url": '#1',
|
|
194
|
+
"text": 'Cost of living'
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"url": '#1',
|
|
198
|
+
"text": 'Inflation'
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"url": '#3',
|
|
202
|
+
"text": 'NHS waiting times'
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"url": '#0',
|
|
206
|
+
"text": 'Wellbeing'
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"url": '#0',
|
|
210
|
+
"text": 'Baby names'
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
205
214
|
}
|
|
206
215
|
})
|
|
207
216
|
}}
|
|
@@ -159,33 +159,41 @@
|
|
|
159
159
|
}
|
|
160
160
|
]
|
|
161
161
|
},
|
|
162
|
-
"
|
|
163
|
-
"id": "search
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
162
|
+
"search": {
|
|
163
|
+
"id": "search",
|
|
164
|
+
"navAriaLabel": 'Nav Search',
|
|
165
|
+
"toggleAriaLabel": 'Toggle search',
|
|
166
|
+
"form": {
|
|
167
|
+
"action": "https://www.ons.gov.uk/search" ,
|
|
168
|
+
"inputName": "q",
|
|
169
|
+
"inputLabel": "Search the ONS",
|
|
170
|
+
"buttonText": "Search"
|
|
171
|
+
},
|
|
172
|
+
"links": {
|
|
173
|
+
'heading': 'Popular searches',
|
|
174
|
+
"itemsList": [
|
|
175
|
+
{
|
|
176
|
+
"url": '#1',
|
|
177
|
+
"text": 'Cost of living'
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"url": '#1',
|
|
181
|
+
"text": 'Inflation'
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"url": '#3',
|
|
185
|
+
"text": 'NHS waiting times'
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"url": '#0',
|
|
189
|
+
"text": 'Wellbeing'
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"url": '#0',
|
|
193
|
+
"text": 'Baby names'
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
189
197
|
}
|
|
190
198
|
})
|
|
191
199
|
}}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
{% set detailsColumns = params.detailsColumns | default ('8') %}
|
|
7
7
|
|
|
8
8
|
<section
|
|
9
|
-
class="ons-hero ons-grid--gutterless{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-hero--{{ variant }}{% endfor %}{%
|
|
9
|
+
class="ons-hero ons-grid--gutterless{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-hero--{{ variant }}{% endfor %}{% elif params.variants %}{{ ' ' }}ons-hero--{{ params.variants }}{% endif %}"
|
|
10
10
|
>
|
|
11
11
|
{% if params.variants == 'navy-blue' %}
|
|
12
12
|
<div class="ons-hero__circles" aria-hidden="true">
|
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
|
|
42
42
|
{% if params.text %}
|
|
43
43
|
<p class="ons-hero__text">{{ params.text | safe }}</p>
|
|
44
|
+
{% elif params.richText %}
|
|
45
|
+
<div class="ons-hero__richtext">{{ params.richText | safe }}</div>
|
|
44
46
|
{% endif %}
|
|
47
|
+
|
|
45
48
|
</div>
|
|
46
49
|
|
|
47
50
|
{% if params.variants == "grey" and params.officialStatisticsBadge == true %}
|
|
@@ -55,6 +55,32 @@ describe('macro: hero', () => {
|
|
|
55
55
|
expect(title).toBe('Hero text');
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
+
it('has expected `richText` when `text` is not provided', () => {
|
|
59
|
+
const $ = cheerio.load(
|
|
60
|
+
renderComponent('hero', {
|
|
61
|
+
...EXAMPLE_HERO,
|
|
62
|
+
text: undefined,
|
|
63
|
+
richText: '<p>Hero <strong>rich</strong> text</p>',
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
expect($('.ons-hero__text').length).toBe(0);
|
|
68
|
+
expect($('.ons-hero__richtext').length).toBe(1);
|
|
69
|
+
expect($('.ons-hero__richtext').html().trim()).toBe('<p>Hero <strong>rich</strong> text</p>');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('does not render `richText` when `text` is provided', () => {
|
|
73
|
+
const $ = cheerio.load(
|
|
74
|
+
renderComponent('hero', {
|
|
75
|
+
...EXAMPLE_HERO,
|
|
76
|
+
richText: '<p>Hero rich text</p>',
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
expect($('.ons-hero__text').length).toBe(1);
|
|
81
|
+
expect($('.ons-hero__richtext').length).toBe(0);
|
|
82
|
+
});
|
|
83
|
+
|
|
58
84
|
it('has expected `html`', () => {
|
|
59
85
|
const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, html: '<span class="some-html">some html</span>' }));
|
|
60
86
|
|
|
@@ -8,7 +8,16 @@
|
|
|
8
8
|
</div>
|
|
9
9
|
{% endif %}
|
|
10
10
|
<div class="ons-grid__col ons-col-auto ons-u-flex-shrink">
|
|
11
|
-
<p class="ons-phase-banner__desc ons-u-fs-s ons-u-mb-no">
|
|
11
|
+
<p class="ons-phase-banner__desc ons-u-fs-s ons-u-mb-no">
|
|
12
|
+
{% if params.html %}
|
|
13
|
+
{{ params.html | safe }}
|
|
14
|
+
{% else %}
|
|
15
|
+
{{ params.text }}
|
|
16
|
+
{% if params.feedbackLink %}
|
|
17
|
+
{{ params.feedbackLink | safe }}
|
|
18
|
+
{% endif %}
|
|
19
|
+
{% endif %}
|
|
20
|
+
</p>
|
|
12
21
|
</div>
|
|
13
22
|
</div>
|
|
14
23
|
</div>
|
|
@@ -24,6 +24,33 @@ describe('macro: phase-banner', () => {
|
|
|
24
24
|
expect(htmlContent).toBe('Example content with a <a href="#">link</a>');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
it('renders text content when `text` is provided', () => {
|
|
28
|
+
const $ = cheerio.load(
|
|
29
|
+
renderComponent('phase-banner', {
|
|
30
|
+
text: 'Example text content',
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const textContent = $('.ons-phase-banner__desc').text().trim();
|
|
35
|
+
expect(textContent).toBe('Example text content');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders feedbackLink when provided with text', () => {
|
|
39
|
+
const $ = cheerio.load(
|
|
40
|
+
renderComponent('phase-banner', {
|
|
41
|
+
text: 'Example text content',
|
|
42
|
+
feedbackLink: '<a href="#">give feedback</a>',
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const textContent = $('.ons-phase-banner__desc').text().replace(/\s+/g, ' ').trim();
|
|
47
|
+
expect(textContent).toBe('Example text content give feedback');
|
|
48
|
+
|
|
49
|
+
const link = $('.ons-phase-banner__desc a');
|
|
50
|
+
expect(link.length).toBe(1);
|
|
51
|
+
expect(link.text()).toBe('give feedback');
|
|
52
|
+
});
|
|
53
|
+
|
|
27
54
|
it('has the "Beta" badge by default', () => {
|
|
28
55
|
const $ = cheerio.load(renderComponent('phase-banner', EXAMPLE_PHASE_BANNER_MINIMAL));
|
|
29
56
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{% from "components/phase-banner/_macro.njk" import onsPhaseBanner %}
|
|
2
|
+
{% from "components/external-link/_macro.njk" import onsExternalLink %}
|
|
3
|
+
|
|
4
|
+
{% set feedbackLink %}
|
|
5
|
+
{{
|
|
6
|
+
onsExternalLink({
|
|
7
|
+
"url": "#0",
|
|
8
|
+
"text": "give feedback"
|
|
9
|
+
})
|
|
10
|
+
}}
|
|
11
|
+
{% endset %}
|
|
12
|
+
|
|
13
|
+
{{
|
|
14
|
+
onsPhaseBanner({
|
|
15
|
+
"text": "This is a new service. To help us improve it,",
|
|
16
|
+
"feedbackLink": feedbackLink
|
|
17
|
+
})
|
|
18
|
+
}}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<div class="ons-radios__items">
|
|
19
19
|
{% for radio in params.radios %}
|
|
20
20
|
{% if params.or and loop.revindex0 == 0 %}
|
|
21
|
-
<span class="ons-radios__label ons-u-mt-
|
|
21
|
+
<span class="ons-radios__label ons-u-mt-2xs ons-u-fs-r--b" aria-hidden="true">{{ params.or }}</span>
|
|
22
22
|
{% endif %}
|
|
23
23
|
<span class="ons-radios__item{{ " ons-radios__item--no-border" if params.borderless }}">
|
|
24
24
|
<span class="ons-radio{{ " ons-radio--no-border" if params.borderless }}">
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
{% for th in headerCols.ths %}
|
|
36
36
|
<th
|
|
37
37
|
scope="col"
|
|
38
|
-
class="ons-table__header{{ ' ' + th.thClasses if th.thClasses else '' }}{{ ' ons-table__header--numeric' if th.numeric }}"
|
|
38
|
+
class="ons-table__header ons-table__header--{{ th.valign | default('top') }}{{ ' ' + th.thClasses if th.thClasses else '' }}{{ ' ons-table__header--numeric' if th.numeric }}"
|
|
39
39
|
{% if th.colspan %}colspan="{{ th.colspan }}"{% endif %}
|
|
40
40
|
{% if th.rowspan %}rowspan="{{ th.rowspan }}"{% endif %}
|
|
41
41
|
{% if 'sortable' in variants %}aria-sort="{{ th.ariaSort | default('none') }}"{% endif %}
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
{% set isFirstRow = loop.index == 0 and td.rowspan %}
|
|
74
74
|
{% set rowSpan = isFirstRow and loop.index0 == rowspanCount %}
|
|
75
75
|
{{ openingTag | safe }}
|
|
76
|
-
class="ons-table__cell
|
|
76
|
+
class="ons-table__cell
|
|
77
|
+
ons-table__cell--{{ td.valign | default('top') }}{{ ' ' + td.tdClasses if td.tdClasses else '' }}{{ ' ons-table__cell--numeric' if td.numeric }}"
|
|
77
78
|
{% if td.id %}id="{{ td.id }}"{% endif %}
|
|
78
79
|
{% if td.data %}{{ ' ' }}data-th="{{ td.data }}"{% endif %}
|
|
79
80
|
{% if td.colspan %}colspan="{{ td.colspan }}"{% endif %}
|
|
@@ -107,7 +108,9 @@
|
|
|
107
108
|
<tfoot class="ons-table__foot">
|
|
108
109
|
<tr class="ons-table__row">
|
|
109
110
|
{% for tfootCell in params.tfoot %}
|
|
110
|
-
<td class="ons-table__cell ons-
|
|
111
|
+
<td class="ons-table__cell ons-table__cell--{{ tfootCell.valign | default('top') }} ons-u-fs-s">
|
|
112
|
+
{{ tfootCell.value }}
|
|
113
|
+
</td>
|
|
111
114
|
{% endfor %}
|
|
112
115
|
</tr>
|
|
113
116
|
</tfoot>
|
|
@@ -90,6 +90,51 @@ describe('macro: table', () => {
|
|
|
90
90
|
expect($('.ons-table-scrollable__content').attr('aria-label')).toBe('Example table caption. Special table');
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
describe('Vertical Alignment', () => {
|
|
94
|
+
it('adds "ons-table__header--middle" class to column header when valign is set', () => {
|
|
95
|
+
const $ = cheerio.load(
|
|
96
|
+
renderComponent('table', {
|
|
97
|
+
...EXAMPLE_TABLE,
|
|
98
|
+
ths: [
|
|
99
|
+
{
|
|
100
|
+
value: 'Column 1',
|
|
101
|
+
valign: 'middle',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
expect($('.ons-table__header').hasClass('ons-table__header--middle')).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('adds "ons-table__header--top" class to column header when valign is not set', () => {
|
|
111
|
+
const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
|
|
112
|
+
|
|
113
|
+
expect($('.ons-table__header').hasClass('ons-table__header--top')).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('adds "ons-table__cell--middle" class to row when valign is middle', () => {
|
|
117
|
+
const $ = cheerio.load(
|
|
118
|
+
renderComponent('table', {
|
|
119
|
+
...EXAMPLE_TABLE,
|
|
120
|
+
trs: [
|
|
121
|
+
{
|
|
122
|
+
tds: [{ value: 'Row 1 Cell 1', valign: 'middle' }],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
expect($('.ons-table__cell').hasClass('ons-table__cell--middle')).toBe(true);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('adds "ons-table__cell--top" class to row when valign is not set', () => {
|
|
132
|
+
const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
|
|
133
|
+
|
|
134
|
+
expect($('.ons-table__cell').hasClass('ons-table__cell--top')).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
93
138
|
describe('header row', () => {
|
|
94
139
|
it('renders header cells with expected text', () => {
|
|
95
140
|
const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
|
|
@@ -529,6 +574,19 @@ describe('macro: table', () => {
|
|
|
529
574
|
const footerCellValues = mapAll($('.ons-table__foot .ons-table__cell'), (node) => node.text().trim());
|
|
530
575
|
expect(footerCellValues).toEqual(['Footer Cell 1', 'Footer Cell 2', 'Footer Cell 3']);
|
|
531
576
|
});
|
|
577
|
+
it('adds "ons-table__cell--middle" class to row when valign is middle', () => {
|
|
578
|
+
const $ = cheerio.load(
|
|
579
|
+
renderComponent('table', {
|
|
580
|
+
...EXAMPLE_TABLE,
|
|
581
|
+
tfoot: [
|
|
582
|
+
{ value: 'Footer Cell 1', valign: 'middle' },
|
|
583
|
+
{ value: 'Footer Cell 2', valign: 'middle' },
|
|
584
|
+
],
|
|
585
|
+
}),
|
|
586
|
+
);
|
|
587
|
+
|
|
588
|
+
expect($('.ons-table__cell').hasClass('ons-table__cell--middle')).toBe(true);
|
|
589
|
+
});
|
|
532
590
|
});
|
|
533
591
|
|
|
534
592
|
describe('sortable variant', () => {
|