@ons/design-system 72.5.0 → 72.8.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/breadcrumbs/_breadcrumbs.scss +1 -0
- package/components/chart/_chart.scss +56 -0
- package/components/chart/_macro.njk +43 -5
- package/components/chart/_macro.spec.js +420 -0
- package/components/chart/annotations-options.js +78 -0
- package/components/chart/bar-chart.js +15 -2
- package/components/chart/chart.js +119 -27
- package/components/chart/column-chart.js +2 -2
- package/components/chart/common-chart-options.js +104 -51
- package/components/chart/example-bar-chart-with-annotations.njk +62 -0
- package/components/chart/example-bar-chart.njk +1 -0
- package/components/chart/example-bar-with-line-chart.njk +64 -0
- package/components/chart/example-clustered-column-chart.njk +5 -2
- package/components/chart/example-column-chart-with-annotations.njk +63 -0
- package/components/chart/example-column-chart.njk +5 -2
- package/components/chart/example-column-with-line-chart.njk +63 -0
- package/components/chart/example-line-chart-with-annotations.njk +235 -0
- package/components/chart/example-line-chart.njk +7 -3
- package/components/chart/example-stacked-column-chart.njk +3 -1
- package/components/chart/line-chart.js +2 -7
- package/components/details/details.js +5 -0
- package/components/details-panel/_details-panel.scss +107 -0
- package/components/details-panel/_macro.njk +41 -0
- package/components/details-panel/_macro.spec.js +54 -0
- package/components/details-panel/example-details-panel-open.njk +29 -0
- package/components/details-panel/example-details-panel.njk +28 -0
- package/components/hero/_hero.scss +101 -43
- package/components/hero/_macro.njk +21 -10
- package/components/hero/_macro.spec.js +94 -0
- package/components/hero/example-hero-dark.njk +1 -1
- package/components/hero/example-hero-grey.njk +8 -0
- package/components/icon/_macro.njk +1 -1
- package/components/pagination/_macro.njk +1 -1
- package/components/pagination/_pagination.scss +6 -0
- package/components/summary/_macro.njk +2 -2
- package/components/summary/_macro.spec.js +43 -21
- package/components/summary/_summary.scss +5 -1
- package/components/summary/example-summary-grouped.njk +0 -12
- package/components/table-of-contents/_macro.njk +40 -0
- package/components/table-of-contents/_macro.spec.js +72 -0
- package/components/table-of-contents/_table-of-contents.scss +11 -0
- package/components/table-of-contents/example-table-of-contents-related-links-with-button.njk +60 -0
- package/css/main.css +1 -1
- package/js/cookies-functions.js +11 -6
- package/js/cookies-functions.spec.js +44 -0
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -0
- package/scss/vars/_colors.scss +1 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{% macro onsDetailsPanel(params) %}
|
|
2
|
+
<div class="ons-details-panel ons-js-details" {% if params.open %}{{ ' ' }}data-open="true"{% endif %}>
|
|
3
|
+
<div class="ons-details-panel__banner ons-u-pt-s ons-u-pb-s">
|
|
4
|
+
<div class="ons-container ons-details-panel__banner-contents">
|
|
5
|
+
<span class="ons-details-panel__info-icon ons-u-mr-2xs" aria-hidden="true">i</span>
|
|
6
|
+
<div class="ons-details-panel__banner-body">
|
|
7
|
+
<h3 class="ons-details-panel__banner-title ons-u-mb-2xs">{{ params.title }}</h3>
|
|
8
|
+
<div class="ons-details-panel__banner-detail ons-js-details-heading">
|
|
9
|
+
<span class="ons-details-panel__banner-detail-title ons-js-corrections-details-title ons-u-mr-3xs"
|
|
10
|
+
>Show detail</span
|
|
11
|
+
>
|
|
12
|
+
<span class="ons-details-panel__banner-detail-icon">
|
|
13
|
+
{% from "components/icon/_macro.njk" import onsIcon %}
|
|
14
|
+
{{
|
|
15
|
+
onsIcon({
|
|
16
|
+
"iconType": "chevron"
|
|
17
|
+
})
|
|
18
|
+
}}
|
|
19
|
+
</span>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="ons-container ons-details-panel__content ons-js-details-content ons-u-pt-xl ons-u-pb-3xl">
|
|
25
|
+
{% for item in params.detailsItems %}
|
|
26
|
+
<div class="ons-details-panel__item">
|
|
27
|
+
<div class="ons-details-panel__content-meta ons-u-mb-l@2xs@m">
|
|
28
|
+
<h3 class="ons-details-panel__content-heading">{{ item.text }}</h3>
|
|
29
|
+
<time class="ons-details-panel__content-date" datetime="{{ item.date.iso }}">{{ item.date.short }}</time>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="ons-details-panel__content-description">
|
|
32
|
+
<div class="ons-details-panel__content-text ons-u-mb-s">{{ item.description | safe }}</div>
|
|
33
|
+
{% if item.url or item.text == 'Content' %}
|
|
34
|
+
<a class="ons-details-panel__content-url" href="{{ item.url }}"> View superseded version</a>
|
|
35
|
+
{% endif %}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
{% endfor %}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
{% endmacro %}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
2
|
+
import * as cheerio from 'cheerio';
|
|
3
|
+
import axe from '../../tests/helpers/axe';
|
|
4
|
+
import { renderComponent } from '../../tests/helpers/rendering';
|
|
5
|
+
import { EXAMPLE_DETAILS_PANEL } from './_test-examples';
|
|
6
|
+
|
|
7
|
+
describe('FOR: Macro: Details Panel', () => {
|
|
8
|
+
describe('GIVEN: Params: title', () => {
|
|
9
|
+
describe('WHEN: title param is provided', () => {
|
|
10
|
+
const $ = cheerio.load(renderComponent('details-panel', EXAMPLE_DETAILS_PANEL));
|
|
11
|
+
test('THEN: banner has the correct title', () => {
|
|
12
|
+
const contentTitle = $('.ons-details-panel__banner-title').text().replace(/\s+/g, ' ').trim();
|
|
13
|
+
expect(contentTitle).toBe('Correction and Notice');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('GIVEN: Params: detailsItems', () => {
|
|
19
|
+
describe('WHEN: detailsItems is provided', () => {
|
|
20
|
+
const $ = cheerio.load(renderComponent('details-panel', EXAMPLE_DETAILS_PANEL));
|
|
21
|
+
test('THEN: jest-axe tests pass', async () => {
|
|
22
|
+
const results = await axe($.html());
|
|
23
|
+
expect(results).toHaveNoViolations();
|
|
24
|
+
});
|
|
25
|
+
test('THEN: items have correct titles', () => {
|
|
26
|
+
const contentTitle0 = $('.ons-details-panel__content-heading').eq(0).text().trim();
|
|
27
|
+
const contentTitle1 = $('.ons-details-panel__content-heading').eq(1).text().trim();
|
|
28
|
+
expect(contentTitle0).toBe('Correction');
|
|
29
|
+
expect(contentTitle1).toBe('Notice');
|
|
30
|
+
});
|
|
31
|
+
test('THEN: items have correct dates', () => {
|
|
32
|
+
const dateText0 = $('.ons-details-panel__content-date').eq(0).text().trim();
|
|
33
|
+
const dateText1 = $('.ons-details-panel__content-date').eq(1).text().trim();
|
|
34
|
+
|
|
35
|
+
expect(dateText0).toBe('22nd January 2025, 4:30PM');
|
|
36
|
+
expect(dateText1).toBe('22nd January 2025');
|
|
37
|
+
});
|
|
38
|
+
test('THEN: items have correct description text', () => {
|
|
39
|
+
const contentdescriptionText0 = $('.ons-details-panel__content-text').eq(0).text().trim();
|
|
40
|
+
const contentdescriptionText1 = $('.ons-details-panel__content-text').eq(1).text().trim();
|
|
41
|
+
|
|
42
|
+
expect(contentdescriptionText0).toBe('description1');
|
|
43
|
+
expect(contentdescriptionText1).toBe('description2');
|
|
44
|
+
});
|
|
45
|
+
test('THEN: correction item has a valid link and text', () => {
|
|
46
|
+
const correctionLinkText = $('.ons-details-panel__content-url').eq(0).text().trim();
|
|
47
|
+
const correctionLinkUrl = $('.ons-details-panel__content-url').eq(0).attr('href');
|
|
48
|
+
|
|
49
|
+
expect(correctionLinkText).toBe('View superseded version');
|
|
50
|
+
expect(correctionLinkUrl).toBe('#0');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{% from "components/details-panel/_macro.njk" import onsDetailsPanel %}
|
|
2
|
+
|
|
3
|
+
{{
|
|
4
|
+
onsDetailsPanel({
|
|
5
|
+
"open": true,
|
|
6
|
+
"title": "Correction and Notice",
|
|
7
|
+
"detailsItems": [
|
|
8
|
+
{
|
|
9
|
+
"text": 'Correction',
|
|
10
|
+
"date": {
|
|
11
|
+
"iso": '2025-01-22T16:30Z',
|
|
12
|
+
"short": '22nd January 2025, 4:30PM'
|
|
13
|
+
},
|
|
14
|
+
"description": '<p>The Non-Financial Business Economy publication uses estimates from the Annual Business Survey (ABS). A weighting error means these data have now been revised, with the overall impact being minimal.</p>
|
|
15
|
+
<p>ONS apologises for any inconvenience caused.</p>',
|
|
16
|
+
"url": '#0'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"text": 'Notice',
|
|
20
|
+
"date": {
|
|
21
|
+
"iso": '2025-01-22T16:30Z',
|
|
22
|
+
"short": '22nd January 2025, 4:30PM'
|
|
23
|
+
},
|
|
24
|
+
"description": '<p>To improve the timeliness of our publications, we have discontinued the previously published <a href="#0">Non-financial business economy<a>, <a href="#0">UK and regional (Annual Business Survey)</a>.
|
|
25
|
+
We will now deliver the UK and regional elements separately, in our <a href="#0">Non-financial business economy</a>, <a href="#0">UK (Annual Business Survey)</a> and <a href="#0">Non-financial business economy</a>, <a href="#0">regional (Annual Business Survey) bulletins</a>.</p>'
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
}}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{% from "components/details-panel/_macro.njk" import onsDetailsPanel %}
|
|
2
|
+
|
|
3
|
+
{{
|
|
4
|
+
onsDetailsPanel({
|
|
5
|
+
"title": "Correction and Notice",
|
|
6
|
+
"detailsItems": [
|
|
7
|
+
{
|
|
8
|
+
"text": 'Correction',
|
|
9
|
+
"date": {
|
|
10
|
+
"iso": '2025-01-22T16:30Z',
|
|
11
|
+
"short": '22nd January 2025, 4:30PM'
|
|
12
|
+
},
|
|
13
|
+
"description": '<p>The Non-Financial Business Economy publication uses estimates from the Annual Business Survey (ABS). A weighting error means these data have now been revised, with the overall impact being minimal.</p>
|
|
14
|
+
<p>ONS apologises for any inconvenience caused.</p>',
|
|
15
|
+
"url": '#0'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"text": 'Notice',
|
|
19
|
+
"date": {
|
|
20
|
+
"iso": '2025-01-22T16:30Z',
|
|
21
|
+
"short": '22nd January 2025, 4:30PM'
|
|
22
|
+
},
|
|
23
|
+
"description": '<p>To improve the timeliness of our publications, we have discontinued the previously published <a href="#0">Non-financial business economy<a>, <a href="#0">UK and regional (Annual Business Survey)</a>.
|
|
24
|
+
We will now deliver the UK and regional elements separately, in our <a href="#0">Non-financial business economy</a>, <a href="#0">UK (Annual Business Survey)</a> and <a href="#0">Non-financial business economy</a>, <a href="#0">regional (Annual Business Survey) bulletins</a>.</p>'
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
}}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
// Default
|
|
2
|
+
@mixin panel-variant($name, $color, $color-bg) {
|
|
3
|
+
.ons-hero__panel {
|
|
4
|
+
&--#{$name} {
|
|
5
|
+
background: $color-bg;
|
|
6
|
+
border-color: $color !important;
|
|
7
|
+
outline: 1px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show background
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
2
12
|
.ons-hero {
|
|
13
|
+
$root: &;
|
|
14
|
+
|
|
3
15
|
background-color: var(--ons-color-hero-bg);
|
|
4
16
|
display: flex;
|
|
5
17
|
overflow: hidden;
|
|
@@ -71,56 +83,14 @@
|
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
|
|
74
|
-
&__badge-link {
|
|
75
|
-
display: block;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
86
|
&--topic {
|
|
79
87
|
color: var(--ons-color-branded);
|
|
80
88
|
@extend .ons-u-mb-no;
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
&__container {
|
|
84
|
-
align-items: center;
|
|
85
|
-
display: flex;
|
|
86
|
-
min-height: 300px;
|
|
87
|
-
position: relative;
|
|
88
|
-
|
|
89
|
-
&--has-details {
|
|
90
|
-
align-items: flex-start; // Prevents undesired shift if not enough content
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&__content {
|
|
95
|
-
@include mq(l) {
|
|
96
|
-
display: flex;
|
|
97
|
-
justify-content: space-between;
|
|
98
|
-
align-items: flex-start;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&__pre-title {
|
|
103
|
-
margin-bottom: 0.5rem;
|
|
104
|
-
|
|
105
|
-
@include mq('2xs', m) {
|
|
106
|
-
max-width: 145px;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&__details {
|
|
111
|
-
padding-bottom: 3.5rem;
|
|
112
|
-
padding-top: 2rem;
|
|
113
|
-
position: relative;
|
|
114
|
-
z-index: 5;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
&__details:has(.ons-breadcrumbs) {
|
|
118
|
-
padding-top: 1rem;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
91
|
&--dark & {
|
|
122
92
|
&__details {
|
|
123
|
-
color: var(--ons-color-text-inverse)
|
|
93
|
+
color: var(--ons-color-text-inverse);
|
|
124
94
|
|
|
125
95
|
a {
|
|
126
96
|
color: inherit;
|
|
@@ -135,6 +105,9 @@
|
|
|
135
105
|
color: inherit;
|
|
136
106
|
}
|
|
137
107
|
}
|
|
108
|
+
&--topic {
|
|
109
|
+
color: var(--ons-color-light-blue-grey);
|
|
110
|
+
}
|
|
138
111
|
}
|
|
139
112
|
&--navy-blue & {
|
|
140
113
|
&__details {
|
|
@@ -145,6 +118,10 @@
|
|
|
145
118
|
}
|
|
146
119
|
}
|
|
147
120
|
|
|
121
|
+
&--topic {
|
|
122
|
+
color: var(--ons-color-light-blue-grey);
|
|
123
|
+
}
|
|
124
|
+
|
|
148
125
|
&__circle-1 {
|
|
149
126
|
@include mq(l) {
|
|
150
127
|
background-color: var(--ons-color-spring-green);
|
|
@@ -427,6 +404,83 @@
|
|
|
427
404
|
}
|
|
428
405
|
}
|
|
429
406
|
|
|
407
|
+
&--dark,
|
|
408
|
+
&--navy-blue {
|
|
409
|
+
.ons-breadcrumbs__link {
|
|
410
|
+
color: var(--ons-color-text-inverse);
|
|
411
|
+
|
|
412
|
+
&:hover {
|
|
413
|
+
color: var(--ons-color-text-inverse);
|
|
414
|
+
text-decoration: underline solid var(--ons-color-text-inverse) 2px;
|
|
415
|
+
}
|
|
416
|
+
&:focus {
|
|
417
|
+
color: var(--ons-color-text);
|
|
418
|
+
}
|
|
419
|
+
&:focus:hover {
|
|
420
|
+
color: var(--ons-color-text);
|
|
421
|
+
text-decoration: none;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
&__badge-link {
|
|
427
|
+
display: block;
|
|
428
|
+
width: fit-content;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
&__container {
|
|
432
|
+
align-items: center;
|
|
433
|
+
display: flex;
|
|
434
|
+
min-height: 300px;
|
|
435
|
+
position: relative;
|
|
436
|
+
|
|
437
|
+
&--has-details {
|
|
438
|
+
align-items: flex-start; // Prevents undesired shift if not enough content
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
&__content {
|
|
443
|
+
@include mq(l) {
|
|
444
|
+
display: flex;
|
|
445
|
+
justify-content: space-between;
|
|
446
|
+
align-items: flex-start;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
&__information {
|
|
451
|
+
display: flex;
|
|
452
|
+
flex-wrap: wrap;
|
|
453
|
+
column-gap: 1rem;
|
|
454
|
+
|
|
455
|
+
& .ons-hero__panel {
|
|
456
|
+
padding: 0.5rem 1rem;
|
|
457
|
+
border-left: 5px solid transparent;
|
|
458
|
+
@extend .ons-u-fs-r--b;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
& .ons-hero__link {
|
|
462
|
+
padding: 0.5rem 0;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
&__pre-title {
|
|
467
|
+
margin-bottom: 0.5rem;
|
|
468
|
+
|
|
469
|
+
@include mq('2xs', m) {
|
|
470
|
+
max-width: 145px;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
&__details {
|
|
475
|
+
padding-bottom: 3.5rem;
|
|
476
|
+
padding-top: 2rem;
|
|
477
|
+
position: relative;
|
|
478
|
+
z-index: 5;
|
|
479
|
+
#{$root}--with-breadcrumbs & {
|
|
480
|
+
padding-top: 1rem;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
430
484
|
&__title-container {
|
|
431
485
|
@include mq(l) {
|
|
432
486
|
display: grid;
|
|
@@ -435,3 +489,7 @@
|
|
|
435
489
|
}
|
|
436
490
|
}
|
|
437
491
|
}
|
|
492
|
+
|
|
493
|
+
@include panel-variant(ons-red, var(--ons-color-errors), var(--ons-color-errors-tint));
|
|
494
|
+
@include panel-variant(ons-green, var(--ons-color-success), var(--ons-color-success-tint));
|
|
495
|
+
@include panel-variant(ons-orange, var(--ons-color-pending), var(--ons-color-pending-tint));
|
|
@@ -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 %}{% else %}{{ ' ' }}ons-hero--{{ params.variants }}{% endif %}"
|
|
9
|
+
class="ons-hero ons-grid--gutterless{% if params.breadcrumbs %}{{ ' ' }}ons-hero--with-breadcrumbs{% endif %}{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-hero--{{ variant }}{% endfor %}{% else %}{{ ' ' }}ons-hero--{{ params.variants }}{% endif %}"
|
|
10
10
|
>
|
|
11
11
|
{% if params.variants == 'navy-blue' %}
|
|
12
12
|
<div class="ons-hero__circles" aria-hidden="true">
|
|
@@ -77,15 +77,26 @@
|
|
|
77
77
|
</div>
|
|
78
78
|
{% endif %}
|
|
79
79
|
</div>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
{% if params.variants == "grey" %}
|
|
81
|
+
{% if params.censusLogo == true %}
|
|
82
|
+
<div class="ons-hero__census-logo">
|
|
83
|
+
{{-
|
|
84
|
+
onsIcon({
|
|
85
|
+
"iconType": 'census-logo'
|
|
86
|
+
})
|
|
87
|
+
-}}
|
|
88
|
+
</div>
|
|
89
|
+
{% endif %}
|
|
90
|
+
{% if params.informationPanel %}
|
|
91
|
+
<div class="ons-hero__information ons-u-mt-s">
|
|
92
|
+
<div class="ons-hero__panel ons-hero__panel--{{ params.informationPanel.panelType }}">
|
|
93
|
+
{{- params.informationPanel.panelText -}}
|
|
94
|
+
</div>
|
|
95
|
+
<div class="ons-hero__link">
|
|
96
|
+
<a href="{{ params.informationPanel.panelLink.url }}">{{ params.informationPanel.panelLink.text }}</a>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
{% endif %}
|
|
89
100
|
{% endif %}
|
|
90
101
|
|
|
91
102
|
{% if params.button %}
|
|
@@ -112,6 +112,22 @@ describe('macro: hero', () => {
|
|
|
112
112
|
expect($('.ons-hero__badge svg title').text().trim()).toBe('Offical Statistics Badge');
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
+
it('outputs the statistics badge as a link when officialStatisticsBadgeUrl is provided', () => {
|
|
116
|
+
const $ = cheerio.load(
|
|
117
|
+
renderComponent('hero', {
|
|
118
|
+
...EXAMPLE_HERO,
|
|
119
|
+
variants: 'grey',
|
|
120
|
+
officialStatisticsBadge: true,
|
|
121
|
+
officialStatisticsBadgeUrl: 'https://example.com/badge',
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
expect($('.ons-hero__badge-link').length).toBe(1);
|
|
126
|
+
expect($('.ons-hero__badge-link').attr('href')).toBe('https://example.com/badge');
|
|
127
|
+
expect($('.ons-hero__badge-link').attr('target')).toBe('_blank');
|
|
128
|
+
expect($('.ons-hero__badge-link').attr('rel')).toBe('noopener noreferrer');
|
|
129
|
+
});
|
|
130
|
+
|
|
115
131
|
it('outputs the Census 2021 Logo when censusLogo is set to true and variants is set to "grey"', () => {
|
|
116
132
|
const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'grey', censusLogo: true }));
|
|
117
133
|
|
|
@@ -136,6 +152,84 @@ describe('macro: hero', () => {
|
|
|
136
152
|
expect($('.ons-hero--grey').length).toBe(1);
|
|
137
153
|
});
|
|
138
154
|
|
|
155
|
+
describe('when `informationPanel` is provided and the variant is set to `grey`', () => {
|
|
156
|
+
describe('and `panelText` and `panelLink` are provided', () => {
|
|
157
|
+
it('renders the information panel with correct text and link`', () => {
|
|
158
|
+
const $ = cheerio.load(
|
|
159
|
+
renderComponent('hero', {
|
|
160
|
+
...EXAMPLE_HERO,
|
|
161
|
+
variants: 'grey',
|
|
162
|
+
informationPanel: {
|
|
163
|
+
panelText: 'Some panel text',
|
|
164
|
+
panelType: 'ons-green',
|
|
165
|
+
panelLink: {
|
|
166
|
+
text: 'Some link text',
|
|
167
|
+
url: '#0',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
}),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
expect($('.ons-hero__information').length).toBe(1);
|
|
174
|
+
expect($('.ons-hero__panel').length).toBe(1);
|
|
175
|
+
expect($('.ons-hero__panel').text().trim()).toBe('Some panel text');
|
|
176
|
+
expect($('.ons-hero__link > a').text().trim()).toBe('Some link text');
|
|
177
|
+
expect($('.ons-hero__link > a').attr('href')).toBe('#0');
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe('and `panelType` is set to `ons-green`', () => {
|
|
182
|
+
it('renders the green information panel`', () => {
|
|
183
|
+
const $ = cheerio.load(
|
|
184
|
+
renderComponent('hero', {
|
|
185
|
+
...EXAMPLE_HERO,
|
|
186
|
+
variants: 'grey',
|
|
187
|
+
informationPanel: {
|
|
188
|
+
panelText: 'Some panel text',
|
|
189
|
+
panelType: 'ons-green',
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
expect($('.ons-hero__panel').hasClass('ons-hero__panel--ons-green')).toBe(true);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('and `panelType` is set to `ons-red`', () => {
|
|
199
|
+
it('renders the red information panel`', () => {
|
|
200
|
+
const $ = cheerio.load(
|
|
201
|
+
renderComponent('hero', {
|
|
202
|
+
...EXAMPLE_HERO,
|
|
203
|
+
variants: 'grey',
|
|
204
|
+
informationPanel: {
|
|
205
|
+
panelText: 'Some panel text',
|
|
206
|
+
panelType: 'ons-red',
|
|
207
|
+
},
|
|
208
|
+
}),
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
expect($('.ons-hero__panel').hasClass('ons-hero__panel--ons-red')).toBe(true);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
describe('and `panelType` is set to `ons-orange`', () => {
|
|
216
|
+
it('renders the orange information panel`', () => {
|
|
217
|
+
const $ = cheerio.load(
|
|
218
|
+
renderComponent('hero', {
|
|
219
|
+
...EXAMPLE_HERO,
|
|
220
|
+
variants: 'grey',
|
|
221
|
+
informationPanel: {
|
|
222
|
+
panelText: 'Some panel text',
|
|
223
|
+
panelType: 'ons-orange',
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
expect($('.ons-hero__panel').hasClass('ons-hero__panel--ons-orange')).toBe(true);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
139
233
|
it('outputs the correct breadcrumbs', () => {
|
|
140
234
|
const $ = cheerio.load(
|
|
141
235
|
renderComponent('hero', {
|
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
"detailsColumns": '12',
|
|
10
10
|
"officialStatisticsBadge": true,
|
|
11
11
|
"officialStatisticsBadgeUrl": 'https://uksa.statisticsauthority.gov.uk/about-the-authority/uk-statistical-system/types-of-official-statistics/',
|
|
12
|
+
"informationPanel":{
|
|
13
|
+
"panelText": 'Latest release',
|
|
14
|
+
"panelType": 'ons-green',
|
|
15
|
+
"panelLink": {
|
|
16
|
+
"text": 'View previous releases',
|
|
17
|
+
"url": '#0'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
12
20
|
"topic": 'Statistical article',
|
|
13
21
|
"title": 'Retail sales rise amid summer discounts and sporting events, according to a first estimate',
|
|
14
22
|
"text": 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id mattis ligula, nec sollicitudin arcu. Donec non tristique tellus. Donec eget malesuada lorem.',
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
aria-label="Pagination ({{ position }})"
|
|
14
14
|
>
|
|
15
15
|
<div class="ons-pagination__position">{{ position }}</div>
|
|
16
|
-
<ul class="ons-pagination__items">
|
|
16
|
+
<ul class="ons-pagination__items{{ ' ons-pagination__items--no-previous' if currentPageIndex == 1 }}">
|
|
17
17
|
{% if currentPageIndex != 1 %}
|
|
18
18
|
{% set prevPageIndex = currentPageIndex - 2 %}
|
|
19
19
|
<li class="ons-pagination__item ons-pagination__item--previous">
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
</dt>
|
|
78
78
|
{% if item.valueList %}
|
|
79
79
|
<dd
|
|
80
|
-
class="ons-summary__values{{ ' ons-
|
|
80
|
+
class="ons-summary__values{{ ' ons-summary__column-size--2' if not item.actions }}"
|
|
81
81
|
{% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
|
|
82
82
|
>
|
|
83
83
|
{% if item.valueList | length == 1 %}
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
</dd>
|
|
105
105
|
{% endif %}
|
|
106
106
|
{% if item.actions %}
|
|
107
|
-
<dd class="ons-summary__actions">
|
|
107
|
+
<dd class="ons-summary__actions{{ ' ons-summary__column-size--2' if not item.valueList }}" {% if item.id %}id="{{ item.id }}"{% endif %}>
|
|
108
108
|
{% for action in item.actions %}
|
|
109
109
|
{% if loop.index > 1 %}<span class="ons-summary__spacer"></span>{% endif %}
|
|
110
110
|
<a
|