@ons/design-system 73.0.4 → 73.2.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/_macro.njk +64 -31
- 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/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-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 +2 -1
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
EXAMPLE_HEADER_NAVIGATION_WITH_SITESEARCHAUTOSUGGEST,
|
|
19
19
|
EXAMPLE_HEADER_MENU_LINKS,
|
|
20
20
|
EXAMPLE_HEADER_SEARCH_AND_MENU_LINKS,
|
|
21
|
+
EXAMPLE_HEADER_SEARCH,
|
|
21
22
|
} from './_test-examples';
|
|
22
23
|
|
|
23
24
|
describe('FOR: Macro: Header', () => {
|
|
@@ -812,6 +813,228 @@ describe('FOR: Macro: Header', () => {
|
|
|
812
813
|
});
|
|
813
814
|
});
|
|
814
815
|
});
|
|
816
|
+
|
|
817
|
+
describe('GIVEN: Params: search', () => {
|
|
818
|
+
describe('WHEN: search is provided', () => {
|
|
819
|
+
const faker = templateFaker();
|
|
820
|
+
const buttonSpy = faker.spy('button', { suppressOutput: true });
|
|
821
|
+
faker.renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' });
|
|
822
|
+
|
|
823
|
+
test('THEN: renders search icon button', () => {
|
|
824
|
+
expect(buttonSpy.occurrences[0]).toEqual({
|
|
825
|
+
iconType: 'search',
|
|
826
|
+
classes: 'ons-u-fs-s--b ons-js-toggle-header-search ons-btn--close ons-btn--search-icon active disabled',
|
|
827
|
+
type: 'button',
|
|
828
|
+
variants: 'search',
|
|
829
|
+
attributes: {
|
|
830
|
+
'aria-controls': 'search-id',
|
|
831
|
+
'aria-expanded': 'true',
|
|
832
|
+
'aria-label': 'Custom search button aria label',
|
|
833
|
+
'aria-disabled': 'true',
|
|
834
|
+
},
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
describe('WHEN: links are provided in search', () => {
|
|
840
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
841
|
+
|
|
842
|
+
test('THEN: renders items list', () => {
|
|
843
|
+
const itemsList = $('.ons-list--bare .ons-list__item').length;
|
|
844
|
+
expect(itemsList).toBeGreaterThan(0);
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
test('THEN: renders correct links for items list', () => {
|
|
848
|
+
const searchItemsLinks = mapAll($('.ons-list--bare .ons-list__item a'), (node) => node.attr('href'));
|
|
849
|
+
expect(searchItemsLinks).toEqual(['#1', '#2', '#3']);
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
test('THEN: renders correct text for items list', () => {
|
|
853
|
+
const searchItemsText = mapAll($('.ons-list--bare .ons-list__item a'), (node) => node.text().trim());
|
|
854
|
+
expect(searchItemsText).toEqual(['Popular Search 1', 'Popular Search 2', 'Popular Search 3']);
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
describe('WHEN: search parameter is missing', () => {
|
|
859
|
+
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_BASIC));
|
|
860
|
+
|
|
861
|
+
test('THEN: does not render search icon button', () => {
|
|
862
|
+
expect($('.ons-js-toggle-services').length).toBe(0);
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
test('THEN: does not render search input form', () => {
|
|
866
|
+
expect($('.ons-header-nav-search').length).toBe(0);
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
test('THEN: does not render items list', () => {
|
|
870
|
+
expect($('.ons-list--bare').length).toBe(0);
|
|
871
|
+
});
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
describe('WHEN: search is provided and the header variant is not basic', () => {
|
|
875
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'neutral' }));
|
|
876
|
+
|
|
877
|
+
test('THEN: does not render the search icon button', () => {
|
|
878
|
+
expect($('.ons-js-toggle-services').length).toBe(0);
|
|
879
|
+
});
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
describe('WHEN: heading parameter is provided', () => {
|
|
883
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
884
|
+
|
|
885
|
+
test('THEN: it renders heading with provided text', () => {
|
|
886
|
+
expect($('.ons-header-nav-search__heading').text().trim()).toBe('Header Search');
|
|
887
|
+
});
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
describe('WHEN: id parameter is provided', () => {
|
|
891
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
892
|
+
|
|
893
|
+
test('THEN: applies id to search links ', () => {
|
|
894
|
+
expect($('#search-id').length).toBe(1);
|
|
895
|
+
});
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
describe('WHEN: ariaLabel parameter is provided', () => {
|
|
899
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
900
|
+
|
|
901
|
+
test('THEN: applies aria label to the search links', () => {
|
|
902
|
+
expect($('.ons-header-nav-search').attr('aria-label')).toBe('Header Search');
|
|
903
|
+
});
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
describe('WHEN: classes parameter is provided', () => {
|
|
907
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
908
|
+
|
|
909
|
+
test('THEN: it renders classes with provided value', () => {
|
|
910
|
+
expect($('.ons-header-nav-search').hasClass('custom-class')).toBe(true);
|
|
911
|
+
});
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
describe('WHEN: using basic header variant and search is active & disabled by default before JS loads', () => {
|
|
915
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
916
|
+
const $searchBtn = $('.ons-js-toggle-header-search');
|
|
917
|
+
|
|
918
|
+
test('THEN: adds the "active" class to the search toggle button', () => {
|
|
919
|
+
expect($searchBtn.hasClass('active')).toBe(true);
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
test('THEN: adds the "disabled" class to the search toggle button', () => {
|
|
923
|
+
expect($searchBtn.hasClass('disabled')).toBe(true);
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
test('THEN: sets aria-disabled="true" on the search toggle button', () => {
|
|
927
|
+
expect($searchBtn.attr('aria-disabled')).toBe('true');
|
|
928
|
+
});
|
|
929
|
+
});
|
|
930
|
+
|
|
931
|
+
describe('WHEN: search is provided with all custom properties', () => {
|
|
932
|
+
const faker = templateFaker();
|
|
933
|
+
const buttonSpy = faker.spy('button', { suppressOutput: true });
|
|
934
|
+
faker.renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' });
|
|
935
|
+
test('THEN: renders search icon button with custom aria-label', () => {
|
|
936
|
+
expect(buttonSpy.occurrences[0]).toBeDefined();
|
|
937
|
+
expect(buttonSpy.occurrences[0].attributes['aria-label']).toBe('Custom search button aria label');
|
|
938
|
+
});
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
describe('WHEN: toggleAriaLabel is not provided', () => {
|
|
942
|
+
const faker = templateFaker();
|
|
943
|
+
const buttonSpy = faker.spy('button', { suppressOutput: true });
|
|
944
|
+
faker.renderComponent('header', {
|
|
945
|
+
...EXAMPLE_HEADER_SEARCH,
|
|
946
|
+
search: {
|
|
947
|
+
...EXAMPLE_HEADER_SEARCH.links,
|
|
948
|
+
toggleAriaLabel: undefined,
|
|
949
|
+
},
|
|
950
|
+
variants: 'basic',
|
|
951
|
+
});
|
|
952
|
+
test('THEN: renders search icon button with default aria-label', () => {
|
|
953
|
+
expect(buttonSpy.occurrences[0]).toBeDefined();
|
|
954
|
+
expect(buttonSpy.occurrences[0].attributes['aria-label']).toBe('Toggle search');
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
describe('WHEN: navButtonAriaLabel is provided', () => {
|
|
958
|
+
const faker = templateFaker();
|
|
959
|
+
const buttonSpy = faker.spy('button', { suppressOutput: true });
|
|
960
|
+
faker.renderComponent('header', {
|
|
961
|
+
...EXAMPLE_HEADER_SEARCH,
|
|
962
|
+
siteSearchAutosuggest: {},
|
|
963
|
+
});
|
|
964
|
+
test('THEN: renders search navigation button with custom aria-label', () => {
|
|
965
|
+
const found = buttonSpy.occurrences.find(
|
|
966
|
+
(btn) => btn.attributes && btn.attributes['aria-label'] === 'Custom search nav button aria label',
|
|
967
|
+
);
|
|
968
|
+
expect(found).toBeDefined();
|
|
969
|
+
});
|
|
970
|
+
});
|
|
971
|
+
describe('WHEN: navButtonAriaLabel is not provided', () => {
|
|
972
|
+
const faker = templateFaker();
|
|
973
|
+
const buttonSpy = faker.spy('button', { suppressOutput: true });
|
|
974
|
+
faker.renderComponent('header', {
|
|
975
|
+
...EXAMPLE_HEADER_SEARCH,
|
|
976
|
+
search: {
|
|
977
|
+
...EXAMPLE_HEADER_SEARCH.search,
|
|
978
|
+
navButtonAriaLabel: undefined,
|
|
979
|
+
},
|
|
980
|
+
siteSearchAutosuggest: {},
|
|
981
|
+
});
|
|
982
|
+
test('THEN: renders search navigation button with default aria-label', () => {
|
|
983
|
+
const found = buttonSpy.occurrences.find((btn) => btn.attributes && btn.attributes['aria-label'] === 'Toggle search');
|
|
984
|
+
expect(found).toBeDefined();
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
describe('WHEN: inputLabel is provided', () => {
|
|
989
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
990
|
+
test('THEN: renders search input with custom label', () => {
|
|
991
|
+
expect($('#header-search-input-label').text().trim()).toBe('Custom search input label');
|
|
992
|
+
});
|
|
993
|
+
});
|
|
994
|
+
describe('WHEN: inputLabel is not provided', () => {
|
|
995
|
+
const $ = cheerio.load(
|
|
996
|
+
renderComponent('header', {
|
|
997
|
+
...EXAMPLE_HEADER_SEARCH,
|
|
998
|
+
search: {
|
|
999
|
+
...EXAMPLE_HEADER_SEARCH.search,
|
|
1000
|
+
form: { inputLabel: undefined },
|
|
1001
|
+
},
|
|
1002
|
+
variants: 'basic',
|
|
1003
|
+
}),
|
|
1004
|
+
);
|
|
1005
|
+
test('THEN: renders search input with default label', () => {
|
|
1006
|
+
expect($('#header-search-input-label').text().trim()).toBe('Search the ONS');
|
|
1007
|
+
});
|
|
1008
|
+
});
|
|
1009
|
+
describe('WHEN: buttonText is provided', () => {
|
|
1010
|
+
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
1011
|
+
|
|
1012
|
+
test('THEN: renders the visually hidden search navigation button text', () => {
|
|
1013
|
+
const $button = $('.ons-search__btn.ons-btn--header-search');
|
|
1014
|
+
const hiddenText = $button.find('.ons-u-vh').text().trim();
|
|
1015
|
+
expect(hiddenText).toBe(EXAMPLE_HEADER_SEARCH.search.form.buttonText);
|
|
1016
|
+
});
|
|
1017
|
+
});
|
|
1018
|
+
describe('WHEN: buttonText is not provided', () => {
|
|
1019
|
+
const $ = cheerio.load(
|
|
1020
|
+
renderComponent('header', {
|
|
1021
|
+
...EXAMPLE_HEADER_SEARCH,
|
|
1022
|
+
search: {
|
|
1023
|
+
...EXAMPLE_HEADER_SEARCH.search,
|
|
1024
|
+
form: { buttonText: undefined },
|
|
1025
|
+
},
|
|
1026
|
+
variants: 'basic',
|
|
1027
|
+
}),
|
|
1028
|
+
);
|
|
1029
|
+
|
|
1030
|
+
test('THEN: renders the default fallback search navigation button text', () => {
|
|
1031
|
+
const $button = $('.ons-search__btn.ons-btn--header-search');
|
|
1032
|
+
const hiddenText = $button.find('.ons-u-vh').text().trim();
|
|
1033
|
+
expect(hiddenText).toBe('Search');
|
|
1034
|
+
});
|
|
1035
|
+
});
|
|
1036
|
+
});
|
|
1037
|
+
|
|
815
1038
|
describe('GIVEN: Params: searchLinks', () => {
|
|
816
1039
|
describe('WHEN: searchLinks are provided', () => {
|
|
817
1040
|
const faker = templateFaker();
|
|
@@ -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
|
|
|
@@ -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 }}">
|