@ons/design-system 72.9.1 → 72.9.2
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/button/_button.scss +10 -0
- package/components/card/_macro.njk +3 -3
- package/components/card/_macro.spec.js +109 -252
- package/components/card/_test_examples.js +56 -0
- package/components/chart/chart.js +12 -4
- package/components/chart/common-chart-options.js +0 -4
- package/components/details-panel/_macro.njk +5 -1
- package/components/details-panel/_macro.spec.js +22 -0
- package/components/document-list/_document-list.scss +5 -13
- package/components/document-list/_macro.njk +14 -17
- package/components/document-list/_macro.spec.js +3 -3
- package/components/fieldset/_macro.spec.js +200 -120
- package/components/fieldset/_test_examples.js +15 -0
- package/components/header/_header.scss +11 -0
- package/components/header/_macro.njk +11 -6
- package/components/header/_macro.spec.js +113 -3
- package/components/hero/_macro.spec.js +1 -1
- package/components/icon/_macro.njk +14 -24
- package/components/language-selector/_macro.njk +6 -3
- package/components/navigation/navigation.js +57 -58
- package/components/navigation/navigation.spec.js +6 -10
- package/components/summary/_macro.njk +4 -1
- package/components/table-of-contents/_macro.njk +1 -1
- package/components/table-of-contents/_macro.spec.js +7 -0
- package/components/table-of-contents/table-of-contents.js +43 -26
- package/css/main.css +1 -1
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -147,6 +147,15 @@ $button-shadow-size: 3px;
|
|
|
147
147
|
top: ems($button-shadow-size);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
&.disabled {
|
|
151
|
+
cursor: not-allowed;
|
|
152
|
+
border: 0;
|
|
153
|
+
|
|
154
|
+
&:hover {
|
|
155
|
+
border: 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
150
159
|
// Small buttons
|
|
151
160
|
&--small,
|
|
152
161
|
&--mobile {
|
|
@@ -156,6 +165,7 @@ $button-shadow-size: 3px;
|
|
|
156
165
|
&--small & {
|
|
157
166
|
&__inner {
|
|
158
167
|
padding: 0.5rem 0.75rem;
|
|
168
|
+
|
|
159
169
|
.ons-icon {
|
|
160
170
|
height: 16px;
|
|
161
171
|
width: 16px;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
{% set closingHeadingTag = "</h" + headingLevel + ">" %}
|
|
5
5
|
{% set placeholderSrcset = (params.image.placeholderUrl if params.image.placeholderUrl else "") + "/img/small/placeholder-card.png 1x, " + (params.image.placeholderUrl if params.image.placeholderUrl else "") + "/img/large/placeholder-card.png 2x" %}
|
|
6
6
|
|
|
7
|
-
<div class="ons-card
|
|
7
|
+
<div class="ons-card{% if params.variant == 'feature' %}{{ ' ' }}ons-card--feature ons-u-flex-grow{% endif %}">
|
|
8
8
|
{% set imageBlock %}
|
|
9
9
|
{%- if params.image -%}
|
|
10
10
|
{% if params.image.smallSrc %}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
{% endset %}
|
|
39
39
|
|
|
40
40
|
{% if params.title.url %}
|
|
41
|
-
<a href="{{ params.title.url }}" class="ons-card__link
|
|
41
|
+
<a href="{{ params.title.url }}" class="ons-card__link{% if params.title.subtitle %}{{ ' ' }}ons-u-mb-xs{% endif %}">
|
|
42
42
|
{{ imageBlock | safe }}
|
|
43
43
|
{{ titleBlock | safe }}
|
|
44
44
|
</a>
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
<p class="ons-card__figure ons-u-fs-3xl ons-u-fw-b ons-u-mb-no">{{ params.body.figure }}</p>
|
|
56
56
|
{% endif %}
|
|
57
57
|
|
|
58
|
-
<p id="{{ params.body.id }}">{{ params.body.text }}</p>
|
|
58
|
+
<p id="{{ params.body.id }}" class="ons-card__body">{{ params.body.text }}</p>
|
|
59
59
|
|
|
60
60
|
{%- if params.body.itemsList -%}
|
|
61
61
|
{% from "components/list/_macro.njk" import onsList %}
|
|
@@ -1,328 +1,185 @@
|
|
|
1
1
|
/** @jest-environment jsdom */
|
|
2
2
|
|
|
3
3
|
import * as cheerio from 'cheerio';
|
|
4
|
-
|
|
5
4
|
import axe from '../../tests/helpers/axe';
|
|
6
5
|
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE = {
|
|
28
|
-
...EXAMPLE_CARD_WITHOUT_IMAGE,
|
|
29
|
-
image: true,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE_WITH_PATH = {
|
|
33
|
-
...EXAMPLE_CARD_WITHOUT_IMAGE,
|
|
34
|
-
image: {
|
|
35
|
-
placeholderUrl: '/placeholder-image-url',
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const EXAMPLE_CARD_FEATURE_VARIANT = {
|
|
40
|
-
variant: 'feature',
|
|
41
|
-
title: {
|
|
42
|
-
text: 'Feature card title',
|
|
43
|
-
url: 'http://example.com',
|
|
44
|
-
subtitle: 'Optional subtitle',
|
|
45
|
-
},
|
|
46
|
-
body: {
|
|
47
|
-
figure: '123,456',
|
|
48
|
-
text: 'Example feature card text',
|
|
49
|
-
id: 'example-feature-text-id',
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
describe('macro: card', () => {
|
|
54
|
-
describe('mode: without image', () => {
|
|
55
|
-
it('passes jest-axe checks', async () => {
|
|
56
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITHOUT_IMAGE));
|
|
57
|
-
|
|
58
|
-
const results = await axe($.html());
|
|
59
|
-
expect(results).toHaveNoViolations();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('has the provided `title` text', () => {
|
|
63
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITHOUT_IMAGE));
|
|
64
|
-
|
|
65
|
-
expect($('.ons-card__title').text().trim()).toBe('Example card title');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it.each([
|
|
69
|
-
[1, 'h1'],
|
|
70
|
-
[4, 'h4'],
|
|
71
|
-
])('has the correct element type for the provided `headingLevel` (%i -> %s)', (headingLevel, expectedTitleTag) => {
|
|
72
|
-
const $ = cheerio.load(
|
|
73
|
-
renderComponent('card', {
|
|
74
|
-
title: {
|
|
75
|
-
text: 'Example card title',
|
|
76
|
-
headingLevel: headingLevel,
|
|
77
|
-
},
|
|
78
|
-
body: {
|
|
79
|
-
text: 'Example card text.',
|
|
80
|
-
id: 'example-text-id',
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
expect($(`${expectedTitleTag}.ons-card__title`).text().trim()).toBe('Example card title');
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('has the provided `text` accessible via the `textId` identifier', () => {
|
|
89
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITHOUT_IMAGE));
|
|
7
|
+
import {
|
|
8
|
+
EXAMPLE_CARD,
|
|
9
|
+
EXAMPLE_CARD_WITH_IMAGE,
|
|
10
|
+
EXAMPLE_CARD_WITH_LIST,
|
|
11
|
+
EXAMPLE_CARD_FULL_EXAMPLE,
|
|
12
|
+
EXAMPLE_CARD_FEATURE_VARIANT,
|
|
13
|
+
} from './_test_examples';
|
|
14
|
+
|
|
15
|
+
describe('FOR: Macro: Card', () => {
|
|
16
|
+
describe('GIVEN: Params: required', () => {
|
|
17
|
+
describe('WHEN: all required params are provided', () => {
|
|
18
|
+
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD));
|
|
19
|
+
|
|
20
|
+
test('THEN: jest-axe text pass', async () => {
|
|
21
|
+
const results = await axe($.html());
|
|
22
|
+
expect(results).toHaveNoViolations();
|
|
23
|
+
});
|
|
90
24
|
|
|
91
|
-
|
|
92
|
-
|
|
25
|
+
test('THEN: renders the title with the provided text', () => {
|
|
26
|
+
expect($('.ons-card__title').text().trim()).toBe('Example card title');
|
|
27
|
+
});
|
|
93
28
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const listsSpy = faker.spy('list');
|
|
97
|
-
|
|
98
|
-
faker.renderComponent('card', {
|
|
99
|
-
title: {
|
|
100
|
-
text: 'Example card title',
|
|
101
|
-
},
|
|
102
|
-
body: {
|
|
103
|
-
text: 'Example card text.',
|
|
104
|
-
id: 'example-text-id',
|
|
105
|
-
itemsList: [{ text: 'Test item 1' }, { text: 'Test item 2' }],
|
|
106
|
-
},
|
|
29
|
+
test('THEN: renders the body with the provided id', () => {
|
|
30
|
+
expect($('.ons-card__body').attr('id')).toBe('example-text-id');
|
|
107
31
|
});
|
|
108
32
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
itemsList: [{ text: 'Test item 1' }, { text: 'Test item 2' }],
|
|
33
|
+
test('THEN: renders the body with the provided text', () => {
|
|
34
|
+
expect($('.ons-card__body').text().trim()).toBe('Example card text');
|
|
112
35
|
});
|
|
113
36
|
});
|
|
37
|
+
});
|
|
114
38
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
title: {
|
|
119
|
-
text: 'Example card title',
|
|
120
|
-
url: 'https://example.com',
|
|
121
|
-
},
|
|
122
|
-
body: {
|
|
123
|
-
text: 'Example card text.',
|
|
124
|
-
id: 'example-text-id',
|
|
125
|
-
},
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
39
|
+
describe('GIVEN: Params: figure', () => {
|
|
40
|
+
describe('WHEN: figure is provided', () => {
|
|
41
|
+
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FULL_EXAMPLE));
|
|
128
42
|
|
|
129
|
-
|
|
43
|
+
test('THEN: it renders the provided figure', () => {
|
|
44
|
+
expect($('.ons-card__figure').text().trim()).toBe('123,456');
|
|
45
|
+
});
|
|
130
46
|
});
|
|
131
47
|
});
|
|
132
48
|
|
|
133
|
-
describe('
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
49
|
+
describe('GIVEN: Params: headingLevel', () => {
|
|
50
|
+
describe('WHEN: headingLevel is provided', () => {
|
|
51
|
+
it.each([
|
|
52
|
+
[1, 'h1'],
|
|
53
|
+
[4, 'h4'],
|
|
54
|
+
])('THEN: it renders headings with the correct heading tag (%i -> <%s>)', (headingLevel, expectedTag) => {
|
|
55
|
+
const $ = cheerio.load(
|
|
56
|
+
renderComponent('card', {
|
|
57
|
+
...EXAMPLE_CARD,
|
|
58
|
+
title: {
|
|
59
|
+
text: 'Example card title',
|
|
60
|
+
headingLevel,
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
const titleTag = $('.ons-card__title')[0].tagName;
|
|
65
|
+
expect(titleTag).toBe(expectedTag);
|
|
66
|
+
});
|
|
139
67
|
});
|
|
68
|
+
});
|
|
140
69
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
70
|
+
describe('GIVEN: Params: itemsList', () => {
|
|
71
|
+
describe('WHEN: itemsList is provided in the body', () => {
|
|
72
|
+
test('THEN: renders the list with the provided items', () => {
|
|
73
|
+
const faker = templateFaker();
|
|
74
|
+
const listsSpy = faker.spy('list');
|
|
146
75
|
|
|
147
|
-
|
|
148
|
-
[1, 'h1'],
|
|
149
|
-
[4, 'h4'],
|
|
150
|
-
])('has the correct element type for the provided `headingLevel` (%i -> %s)', (headingLevel, expectedTitleTag) => {
|
|
151
|
-
const $ = cheerio.load(
|
|
152
|
-
renderComponent('card', {
|
|
153
|
-
title: {
|
|
154
|
-
text: 'Example card title',
|
|
155
|
-
headingLevel: headingLevel,
|
|
156
|
-
},
|
|
157
|
-
body: {
|
|
158
|
-
text: 'Example card text.',
|
|
159
|
-
id: 'example-text-id',
|
|
160
|
-
},
|
|
161
|
-
image: {
|
|
162
|
-
smallSrc: 'example-small.png',
|
|
163
|
-
largeSrc: 'example-large.png',
|
|
164
|
-
alt: 'Example alt text',
|
|
165
|
-
},
|
|
166
|
-
}),
|
|
167
|
-
);
|
|
76
|
+
faker.renderComponent('card', EXAMPLE_CARD_WITH_LIST);
|
|
168
77
|
|
|
169
|
-
|
|
78
|
+
expect(listsSpy.occurrences[0]).toEqual({
|
|
79
|
+
variants: 'dashed',
|
|
80
|
+
itemsList: [{ text: 'Test item 1' }, { text: 'Test item 2' }],
|
|
81
|
+
});
|
|
82
|
+
});
|
|
170
83
|
});
|
|
84
|
+
});
|
|
171
85
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
expect($('#example-text-id').text().trim()).toBe('Example card text.');
|
|
86
|
+
describe('GIVEN: Params: title', () => {
|
|
87
|
+
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FULL_EXAMPLE));
|
|
88
|
+
describe('WHEN: url is provided', () => {
|
|
89
|
+
test('THEN: renders the title with the provided url', () => {
|
|
90
|
+
expect($('.ons-card__link').attr('href')).toBe('http://example.com');
|
|
91
|
+
});
|
|
180
92
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
title: {
|
|
186
|
-
text: 'Example card title',
|
|
187
|
-
url: 'https://example.com',
|
|
188
|
-
},
|
|
189
|
-
body: {
|
|
190
|
-
text: 'Example card text.',
|
|
191
|
-
id: 'example-text-id',
|
|
192
|
-
},
|
|
193
|
-
}),
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
expect($('.ons-card__link').attr('href')).toBe('https://example.com');
|
|
93
|
+
describe('WHEN: subtitle is provided', () => {
|
|
94
|
+
test('THEN: it renders the subtitle with the provided text', () => {
|
|
95
|
+
expect($('.ons-card__subtitle').text().trim()).toBe('Optional subtitle');
|
|
96
|
+
});
|
|
197
97
|
});
|
|
98
|
+
});
|
|
198
99
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
100
|
+
describe('GIVEN: Params: image', () => {
|
|
101
|
+
describe('WHEN: an image is provided', () => {
|
|
102
|
+
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_IMAGE));
|
|
202
103
|
|
|
203
|
-
|
|
104
|
+
test('THEN: jest-axe checks pass', async () => {
|
|
105
|
+
const results = await axe($.html());
|
|
106
|
+
expect(results).toHaveNoViolations();
|
|
204
107
|
});
|
|
205
108
|
|
|
206
|
-
|
|
207
|
-
|
|
109
|
+
test('THEN: it renders an image element', () => {
|
|
110
|
+
expect($('.ons-card__image')[0].tagName).toBe('img');
|
|
111
|
+
});
|
|
208
112
|
|
|
113
|
+
test('THEN: the image has the expected srcset attribute set', () => {
|
|
209
114
|
expect($('.ons-card__image').attr('srcset')).toBe('example-small.png 1x, example-large.png 2x');
|
|
210
115
|
});
|
|
211
116
|
|
|
212
|
-
|
|
213
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_IMAGE));
|
|
214
|
-
|
|
117
|
+
test('THEN: the image has the expected src attribute source set', () => {
|
|
215
118
|
expect($('.ons-card__image').attr('src')).toBe('example-small.png');
|
|
216
119
|
});
|
|
217
120
|
|
|
218
|
-
|
|
219
|
-
const $ = cheerio.load(
|
|
220
|
-
renderComponent('card', {
|
|
221
|
-
...EXAMPLE_CARD_WITH_IMAGE,
|
|
222
|
-
alt: 'Example alt text',
|
|
223
|
-
}),
|
|
224
|
-
);
|
|
225
|
-
|
|
121
|
+
test('THEN: the image has the expected alt text', () => {
|
|
226
122
|
expect($('.ons-card__image').attr('alt')).toBe('Example alt text');
|
|
227
123
|
});
|
|
228
124
|
});
|
|
229
125
|
|
|
230
|
-
describe('
|
|
231
|
-
|
|
232
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE));
|
|
126
|
+
describe('WHEN: image is set to true', () => {
|
|
127
|
+
const $ = cheerio.load(renderComponent('card', { ...EXAMPLE_CARD, image: true }));
|
|
233
128
|
|
|
129
|
+
test('THEN: it outputs an image element', () => {
|
|
234
130
|
expect($('.ons-card__image')[0].tagName).toBe('img');
|
|
235
131
|
});
|
|
236
132
|
|
|
237
|
-
|
|
238
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE));
|
|
239
|
-
|
|
133
|
+
test('THEN: the card is rendered with the srcset attribute set to the placeholder image', () => {
|
|
240
134
|
expect($('.ons-card__image').attr('srcset')).toBe('/img/small/placeholder-card.png 1x, /img/large/placeholder-card.png 2x');
|
|
241
135
|
});
|
|
242
136
|
|
|
243
|
-
|
|
244
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE));
|
|
245
|
-
|
|
137
|
+
test('THEN: the card is rendered with the src attribute set to the placeholder image', () => {
|
|
246
138
|
expect($('.ons-card__image').attr('src')).toBe('/img/small/placeholder-card.png');
|
|
247
139
|
});
|
|
248
140
|
|
|
249
|
-
|
|
250
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE));
|
|
251
|
-
|
|
141
|
+
test('THEN: the image has an empty alt attribute', () => {
|
|
252
142
|
expect($('.ons-card__image').attr('alt')).toBe('');
|
|
253
143
|
});
|
|
254
144
|
});
|
|
255
145
|
|
|
256
|
-
describe('
|
|
257
|
-
|
|
258
|
-
|
|
146
|
+
describe('WHEN: image placeholderUrl is provided', () => {
|
|
147
|
+
const $ = cheerio.load(
|
|
148
|
+
renderComponent('card', {
|
|
149
|
+
...EXAMPLE_CARD,
|
|
150
|
+
image: {
|
|
151
|
+
placeholderUrl: '/placeholder-image-url',
|
|
152
|
+
},
|
|
153
|
+
}),
|
|
154
|
+
);
|
|
259
155
|
|
|
156
|
+
test('THEN: it outputs an image element', () => {
|
|
260
157
|
expect($('.ons-card__image')[0].tagName).toBe('img');
|
|
261
158
|
});
|
|
262
159
|
|
|
263
|
-
|
|
264
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE_WITH_PATH));
|
|
265
|
-
|
|
160
|
+
test('THEN: the image has the expected srcset attribute set with the custom path', () => {
|
|
266
161
|
expect($('.ons-card__image').attr('srcset')).toBe(
|
|
267
162
|
'/placeholder-image-url/img/small/placeholder-card.png 1x, /placeholder-image-url/img/large/placeholder-card.png 2x',
|
|
268
163
|
);
|
|
269
164
|
});
|
|
270
165
|
|
|
271
|
-
|
|
272
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE_WITH_PATH));
|
|
273
|
-
|
|
166
|
+
test('THEN: the image has the expected src attribute set with the custom path', () => {
|
|
274
167
|
expect($('.ons-card__image').attr('src')).toBe('/placeholder-image-url/img/small/placeholder-card.png');
|
|
275
168
|
});
|
|
276
169
|
|
|
277
|
-
|
|
278
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_WITH_PLACEHOLDER_IMAGE_WITH_PATH));
|
|
279
|
-
|
|
170
|
+
test('THEN: the image has an empty alt attribute', () => {
|
|
280
171
|
expect($('.ons-card__image').attr('alt')).toBe('');
|
|
281
172
|
});
|
|
282
173
|
});
|
|
283
174
|
});
|
|
284
175
|
|
|
285
|
-
describe('
|
|
286
|
-
|
|
287
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FEATURE_VARIANT));
|
|
288
|
-
expect($('.ons-card').hasClass('ons-card--feature')).toBe(true);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it('has the provided `title` text', () => {
|
|
292
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FEATURE_VARIANT));
|
|
293
|
-
|
|
294
|
-
expect($('.ons-card__title').text().trim()).toBe('Feature card title');
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it('has the provided `subitle` text', () => {
|
|
298
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FEATURE_VARIANT));
|
|
299
|
-
|
|
300
|
-
expect($('.ons-card__subtitle').text().trim()).toBe('Optional subtitle');
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
it('outputs a hyperlink with the provided `url`', () => {
|
|
176
|
+
describe('GIVEN: Params: variant', () => {
|
|
177
|
+
describe('WHEN: variant is set to feature', () => {
|
|
304
178
|
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FEATURE_VARIANT));
|
|
305
179
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
it('has the provided `figure`', () => {
|
|
310
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FEATURE_VARIANT));
|
|
311
|
-
|
|
312
|
-
expect($('.ons-card__figure').text().trim()).toBe('123,456');
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it('has the provided `text` accessible via the `textId` identifier', () => {
|
|
316
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FEATURE_VARIANT));
|
|
317
|
-
|
|
318
|
-
expect($('#example-feature-text-id').text().trim()).toBe('Example feature card text');
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('passes jest-axe checks', async () => {
|
|
322
|
-
const $ = cheerio.load(renderComponent('card', EXAMPLE_CARD_FEATURE_VARIANT));
|
|
323
|
-
|
|
324
|
-
const results = await axe($.html());
|
|
325
|
-
expect(results).toHaveNoViolations();
|
|
180
|
+
test('THEN: it renders the card with the feature modifier class', () => {
|
|
181
|
+
expect($('.ons-card').hasClass('ons-card--feature')).toBe(true);
|
|
182
|
+
});
|
|
326
183
|
});
|
|
327
184
|
});
|
|
328
185
|
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const EXAMPLE_CARD = {
|
|
2
|
+
title: {
|
|
3
|
+
text: 'Example card title',
|
|
4
|
+
},
|
|
5
|
+
body: {
|
|
6
|
+
text: 'Example card text',
|
|
7
|
+
id: 'example-text-id',
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const EXAMPLE_CARD_FULL_EXAMPLE = {
|
|
12
|
+
title: {
|
|
13
|
+
text: 'Example card title',
|
|
14
|
+
url: 'http://example.com',
|
|
15
|
+
subtitle: 'Optional subtitle',
|
|
16
|
+
},
|
|
17
|
+
body: {
|
|
18
|
+
figure: '123,456',
|
|
19
|
+
text: 'Example card text',
|
|
20
|
+
id: 'example-text-id',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const EXAMPLE_CARD_WITH_LIST = {
|
|
25
|
+
title: {
|
|
26
|
+
text: 'Example card title',
|
|
27
|
+
},
|
|
28
|
+
body: {
|
|
29
|
+
text: 'Example card text.',
|
|
30
|
+
id: 'example-text-id',
|
|
31
|
+
itemsList: [{ text: 'Test item 1' }, { text: 'Test item 2' }],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const EXAMPLE_CARD_WITH_IMAGE = {
|
|
36
|
+
...EXAMPLE_CARD,
|
|
37
|
+
image: {
|
|
38
|
+
smallSrc: 'example-small.png',
|
|
39
|
+
largeSrc: 'example-large.png',
|
|
40
|
+
alt: 'Example alt text',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const EXAMPLE_CARD_FEATURE_VARIANT = {
|
|
45
|
+
variant: 'feature',
|
|
46
|
+
title: {
|
|
47
|
+
text: 'Feature card title',
|
|
48
|
+
url: 'http://example.com',
|
|
49
|
+
subtitle: 'Optional subtitle',
|
|
50
|
+
},
|
|
51
|
+
body: {
|
|
52
|
+
figure: '123,456',
|
|
53
|
+
text: 'Example feature card text',
|
|
54
|
+
id: 'example-feature-text-id',
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -34,10 +34,18 @@ class HighchartsBaseChart {
|
|
|
34
34
|
}
|
|
35
35
|
this.percentageHeightDesktop = this.node.dataset.highchartsPercentageHeightDesktop;
|
|
36
36
|
this.percentageHeightMobile = this.node.dataset.highchartsPercentageHeightMobile;
|
|
37
|
-
this.xAxisTickIntervalMobile =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.
|
|
37
|
+
this.xAxisTickIntervalMobile = this.node.dataset.highchartsXAxisTickIntervalMobile
|
|
38
|
+
? parseInt(this.node.dataset.highchartsXAxisTickIntervalMobile)
|
|
39
|
+
: undefined;
|
|
40
|
+
this.xAxisTickIntervalDesktop = this.node.dataset.highchartsXAxisTickIntervalDesktop
|
|
41
|
+
? parseInt(this.node.dataset.highchartsXAxisTickIntervalDesktop)
|
|
42
|
+
: undefined;
|
|
43
|
+
this.yAxisTickIntervalMobile = this.node.dataset.highchartsYAxisTickIntervalMobile
|
|
44
|
+
? parseInt(this.node.dataset.highchartsYAxisTickIntervalMobile)
|
|
45
|
+
: undefined;
|
|
46
|
+
this.yAxisTickIntervalDesktop = this.node.dataset.highchartsYAxisTickIntervalDesktop
|
|
47
|
+
? parseInt(this.node.dataset.highchartsYAxisTickIntervalDesktop)
|
|
48
|
+
: undefined;
|
|
41
49
|
this.commonChartOptions = new CommonChartOptions(this.xAxisTickIntervalDesktop, this.yAxisTickIntervalDesktop);
|
|
42
50
|
this.specificChartOptions = new SpecificChartOptions(this.theme, this.chartType, this.config);
|
|
43
51
|
this.lineChart = new LineChart();
|
|
@@ -183,10 +183,6 @@ class CommonChartOptions {
|
|
|
183
183
|
const { label, symbol } = legendItem || {};
|
|
184
184
|
|
|
185
185
|
if (seriesType === 'line') {
|
|
186
|
-
symbol?.attr({
|
|
187
|
-
x: 16, // Position the marker to the right of the line
|
|
188
|
-
});
|
|
189
|
-
|
|
190
186
|
label?.attr({
|
|
191
187
|
x: 30, // Adjust label position to account for longer line
|
|
192
188
|
});
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
<div class="ons-container ons-details-panel__banner-contents">
|
|
5
5
|
<span class="ons-details-panel__info-icon ons-u-mr-2xs" aria-hidden="true">i</span>
|
|
6
6
|
<div class="ons-details-panel__banner-body">
|
|
7
|
-
|
|
7
|
+
{% set titleTag = params.headingLevel | default(2) %}
|
|
8
|
+
{% set openingTag = "<h" ~ titleTag %}
|
|
9
|
+
{% set closingTag = "</h" ~ titleTag ~ ">" %}
|
|
10
|
+
{{ openingTag | safe }}
|
|
11
|
+
class="ons-details-panel__banner-title ons-u-fs-m ons-u-mb-2xs">{{ params.title }}{{ closingTag | safe }}
|
|
8
12
|
<div class="ons-details-panel__banner-detail ons-js-details-heading">
|
|
9
13
|
<span class="ons-details-panel__banner-detail-title ons-js-corrections-details-title ons-u-mr-3xs"
|
|
10
14
|
>Show detail</span
|
|
@@ -15,6 +15,28 @@ describe('FOR: Macro: Details Panel', () => {
|
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
describe('GIVEN: Params: headingLevel', () => {
|
|
19
|
+
describe('WHEN: headingLevel is provided', () => {
|
|
20
|
+
const customParams = {
|
|
21
|
+
...EXAMPLE_DETAILS_PANEL,
|
|
22
|
+
headingLevel: 3,
|
|
23
|
+
};
|
|
24
|
+
const $ = cheerio.load(renderComponent('details-panel', customParams));
|
|
25
|
+
test('THEN: banner title uses the correct heading level', () => {
|
|
26
|
+
const bannerTitle = $('.ons-details-panel__banner-title');
|
|
27
|
+
expect(bannerTitle.prop('tagName')).toBe('H3');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('WHEN: headingLevel is not provided', () => {
|
|
32
|
+
const $ = cheerio.load(renderComponent('details-panel', EXAMPLE_DETAILS_PANEL));
|
|
33
|
+
test('THEN: banner title uses default heading level (h2)', () => {
|
|
34
|
+
const bannerTitle = $('.ons-details-panel__banner-title');
|
|
35
|
+
expect(bannerTitle.prop('tagName')).toBe('H2');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
18
40
|
describe('GIVEN: Params: detailsItems', () => {
|
|
19
41
|
describe('WHEN: detailsItems is provided', () => {
|
|
20
42
|
const $ = cheerio.load(renderComponent('details-panel', EXAMPLE_DETAILS_PANEL));
|