@ons/design-system 72.3.0 → 72.5.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.
Files changed (48) hide show
  1. package/components/button/_button.scss +171 -3
  2. package/components/button/_macro.njk +4 -0
  3. package/components/card/_card.scss +5 -0
  4. package/components/card/_macro.njk +10 -2
  5. package/components/card/_macro.spec.js +58 -0
  6. package/components/card/example-card-set-with-headline-figures.njk +62 -0
  7. package/components/chart/_chart.scss +29 -0
  8. package/components/chart/_macro.njk +101 -0
  9. package/components/chart/_macro.spec.js +437 -0
  10. package/components/chart/bar-chart.js +160 -0
  11. package/components/chart/chart-constants.js +21 -0
  12. package/components/chart/chart.dom.js +8 -0
  13. package/components/chart/chart.js +157 -0
  14. package/components/chart/column-chart.js +48 -0
  15. package/components/chart/common-chart-options.js +200 -0
  16. package/components/chart/example-bar-chart.njk +54 -0
  17. package/components/chart/example-clustered-bar-chart.njk +60 -0
  18. package/components/chart/example-clustered-column-chart.njk +72 -0
  19. package/components/chart/example-column-chart.njk +52 -0
  20. package/components/chart/example-line-chart.njk +219 -0
  21. package/components/chart/example-stacked-bar-chart.njk +60 -0
  22. package/components/chart/example-stacked-column-chart.njk +65 -0
  23. package/components/chart/line-chart.js +47 -0
  24. package/components/chart/specific-chart-options.js +22 -0
  25. package/components/description-list/_description-list.scss +2 -0
  26. package/components/footer/_footer.scss +12 -0
  27. package/components/footer/_macro.njk +38 -17
  28. package/components/header/_header.scss +18 -2
  29. package/components/header/_macro.njk +81 -8
  30. package/components/header/_macro.spec.js +97 -0
  31. package/components/header/example-header-with-search-button.njk +190 -0
  32. package/components/header/header.spec.js +128 -0
  33. package/components/hero/_hero.scss +13 -10
  34. package/components/hero/_macro.njk +49 -18
  35. package/components/hero/_macro.spec.js +21 -2
  36. package/components/hero/example-hero-grey.njk +10 -8
  37. package/components/icon/_macro.njk +41 -8
  38. package/components/input/_input.scss +15 -0
  39. package/components/input/_macro.njk +3 -3
  40. package/components/navigation/navigation.dom.js +17 -0
  41. package/components/navigation/navigation.js +72 -2
  42. package/css/main.css +1 -1
  43. package/js/main.js +2 -0
  44. package/package.json +4 -1
  45. package/scripts/main.es5.js +1 -1
  46. package/scripts/main.js +1 -1
  47. package/scss/main.scss +1 -0
  48. package/scss/utilities/_grid.scss +13 -4
@@ -9,6 +9,7 @@ import { mapAll } from '../../tests/helpers/cheerio';
9
9
  import {
10
10
  EXAMPLE_HEADER_BASIC,
11
11
  EXAMPLE_SERVICE_LINKS_CONFIG,
12
+ EXAMPLE_HEADER_SEARCH_LINKS,
12
13
  EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE,
13
14
  EXAMPLE_HEADER_SERVICE_LINKS_SINGLE,
14
15
  EXAMPLE_HEADER_LANGUAGE_CONFIG,
@@ -784,4 +785,100 @@ describe('FOR: Macro: Header', () => {
784
785
  });
785
786
  });
786
787
  });
788
+ describe('GIVEN: Params: searchLinks', () => {
789
+ describe('WHEN: searchLinks are provided', () => {
790
+ const faker = templateFaker();
791
+ const buttonSpy = faker.spy('button', { suppressOutput: true });
792
+ faker.renderComponent('header', { ...EXAMPLE_HEADER_SEARCH_LINKS, variants: 'basic' });
793
+
794
+ test('THEN: renders search icon button', () => {
795
+ expect(buttonSpy.occurrences[0]).toEqual({
796
+ iconType: 'search',
797
+ classes: 'ons-u-fs-s--b ons-js-toggle-header-search ons-btn--search ons-btn--search-icon',
798
+ type: 'button',
799
+ variants: 'search',
800
+ attributes: {
801
+ 'aria-label': 'Example aria label',
802
+ 'aria-expanded': 'false',
803
+ 'aria-controls': 'search-links-id',
804
+ },
805
+ });
806
+ });
807
+ });
808
+
809
+ describe('WHEN: itemsList are provided in searchLinks', () => {
810
+ const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH_LINKS, variants: 'basic' }));
811
+
812
+ test('THEN: renders items list', () => {
813
+ const itemsList = $('.ons-list--bare .ons-list__item').length;
814
+ expect(itemsList).toBeGreaterThan(0);
815
+ });
816
+
817
+ test('THEN: renders correct links for items list', () => {
818
+ const searchItemsLinks = mapAll($('.ons-list--bare .ons-list__item a'), (node) => node.attr('href'));
819
+ expect(searchItemsLinks).toEqual(['#1', '#2', '#3']);
820
+ });
821
+
822
+ test('THEN: renders correct text for items list', () => {
823
+ const searchItemsText = mapAll($('.ons-list--bare .ons-list__item a'), (node) => node.text().trim());
824
+ expect(searchItemsText).toEqual(['Popular Search 1', 'Popular Search 2', 'Popular Search 3']);
825
+ });
826
+ });
827
+
828
+ describe('WHEN: searchLinks parameter is missing', () => {
829
+ const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_BASIC));
830
+
831
+ test('THEN: does not render search icon button', () => {
832
+ expect($('.ons-js-toggle-services').length).toBe(0);
833
+ });
834
+
835
+ test('THEN: does not render search input form', () => {
836
+ expect($('.ons-header-nav-search').length).toBe(0);
837
+ });
838
+
839
+ test('THEN: does not render items list', () => {
840
+ expect($('.ons-list--bare').length).toBe(0);
841
+ });
842
+ });
843
+
844
+ describe('WHEN: searchLinks are provided and the header variant is not basic', () => {
845
+ const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH_LINKS, variants: 'neutral' }));
846
+
847
+ test('THEN: does not render the search icon button', () => {
848
+ expect($('.ons-js-toggle-services').length).toBe(0);
849
+ });
850
+ });
851
+
852
+ describe('WHEN: heading parameter is provided', () => {
853
+ const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH_LINKS, variants: 'basic' }));
854
+
855
+ test('THEN: it renders heading with provided text', () => {
856
+ expect($('.ons-header-nav-search__heading').text()).toBe('Header Search');
857
+ });
858
+ });
859
+
860
+ describe('WHEN: id parameter is provided', () => {
861
+ const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH_LINKS, variants: 'basic' }));
862
+
863
+ test('THEN: applies id to search links ', () => {
864
+ expect($('#search-links-id').length).toBe(1);
865
+ });
866
+ });
867
+
868
+ describe('WHEN: ariaLabel parameter is provided', () => {
869
+ const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH_LINKS, variants: 'basic' }));
870
+
871
+ test('THEN: applies aria label to the search links', () => {
872
+ expect($('.ons-header-nav-search').attr('aria-label')).toBe('Header Search');
873
+ });
874
+ });
875
+
876
+ describe('WHEN: classes parameter is provided', () => {
877
+ const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH_LINKS, variants: 'basic' }));
878
+
879
+ test('THEN: it renders classes with provided value', () => {
880
+ expect($('.ons-header-nav-search').hasClass('custom-class')).toBe(true);
881
+ });
882
+ });
883
+ });
787
884
  });
@@ -0,0 +1,190 @@
1
+ ---
2
+ 'fullWidth': true
3
+ ---
4
+
5
+ {% from "components/header/_macro.njk" import onsHeader %}
6
+
7
+ {{
8
+ onsHeader({
9
+ "variants": 'basic',
10
+ "menuLinks": {
11
+ "keyLinks": [
12
+ {
13
+ 'heading': 'Taking part in a survey?',
14
+ 'description': 'It’s never been more important.'
15
+ },
16
+ {
17
+ 'heading': 'Release calendar',
18
+ 'description': 'View our latest and upcoming releases.'
19
+ },
20
+ {
21
+ 'heading': 'Explore local statistics',
22
+ 'url': '#0',
23
+ 'description': 'Explore statistics across the UK.'
24
+ }
25
+ ],
26
+ "columns": [
27
+ {
28
+ "groups": [
29
+ {
30
+ "heading": "People, population and community",
31
+ "groupItems": [
32
+ {
33
+ "text": "Armed forces community"
34
+ },
35
+ {
36
+ "text": "Births, deaths and marriages"
37
+ },
38
+ {
39
+ "text": "Crime and justice"
40
+ },
41
+ {
42
+ "text": "Cultural identity"
43
+ },
44
+ {
45
+ "text": "Education and childcare"
46
+ },
47
+ {
48
+ "text": "Elections"
49
+ },
50
+ {
51
+ "text": "Health and social care"
52
+ },
53
+ {
54
+ "text": "Household characteristics"
55
+ },
56
+ {
57
+ "text": "Housing"
58
+ },
59
+ {
60
+ "text": "Leisure and tourism"
61
+ },
62
+ {
63
+ "text": "Personal and household finances"
64
+ },
65
+ {
66
+ "text": "Population and migration"
67
+ },
68
+ {
69
+ "text": "Well-being"
70
+ }
71
+ ]
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "groups": [
77
+ {
78
+ "heading": "Business, industry and trade",
79
+ "groupItems": [
80
+ {
81
+ "text": "Business"
82
+ },
83
+ {
84
+ "text": "Changes to business"
85
+ },
86
+ {
87
+ "text": "Construction industry"
88
+ },
89
+ {
90
+ "text": "International trade"
91
+ },
92
+ {
93
+ "text": "IT and internet industry"
94
+ },
95
+ {
96
+ "text": "Manufacturing and production industry"
97
+ },
98
+ {
99
+ "text": "Retail industry",
100
+ "url": "#0"
101
+ },
102
+ {
103
+ "text": "Tourism industry"
104
+ }
105
+ ]
106
+ },
107
+ {
108
+ "heading": "Employment and labour market",
109
+ "url": "#0",
110
+ "groupItems":
111
+ [
112
+ {
113
+ "text": "People in work"
114
+ },
115
+ {
116
+ "text": "People not in work"
117
+ }
118
+ ]
119
+
120
+ }
121
+ ]
122
+ },
123
+ {
124
+ "groups": [
125
+ {
126
+ "heading": "Economy",
127
+ "groupItems": [
128
+ {
129
+ "text": "Economic output and productivity"
130
+ },
131
+ {
132
+ "text": "Government, public sector and taxes"
133
+ },
134
+ {
135
+ "text": "Gross Value Added (GVA)"
136
+ },
137
+ {
138
+ "text": "Investments, pensions and trusts"
139
+ },
140
+ {
141
+ "text": "Regional accounts"
142
+ },
143
+ {
144
+ "text": "Environmental accounts"
145
+ },
146
+ {
147
+ "text": "Gross Domestic Product (GDP)"
148
+ },
149
+ {
150
+ "text": "Inflation and price indices"
151
+ },
152
+ {
153
+ "text": "National accounts"
154
+ }
155
+ ]
156
+ }
157
+ ]
158
+ }
159
+ ]
160
+ },
161
+ "searchLinks": {
162
+ "id": "search-links",
163
+ "searchNavigationAriaLabel": 'Nav Search',
164
+ "searchButtonAriaLabel": 'Toggle search',
165
+ 'heading': 'Popular searches',
166
+ "itemsList": [
167
+ {
168
+ "url": '#1',
169
+ "text": 'Cost of living'
170
+ },
171
+ {
172
+ "url": '#1',
173
+ "text": 'Inflation'
174
+ },
175
+ {
176
+ "url": '#3',
177
+ "text": 'NHS waiting times'
178
+ },
179
+ {
180
+ "url": '#0',
181
+ "text": 'Wellbeing'
182
+ },
183
+ {
184
+ "url": '#0',
185
+ "text": 'Baby names'
186
+ }
187
+ ]
188
+ }
189
+ })
190
+ }}
@@ -0,0 +1,128 @@
1
+ import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
2
+ import { EXAMPLE_HEADER_SEARCH_AND_MENU_LINKS } from './_test-examples';
3
+ import { getNodeAttributes } from '../../tests/helpers/puppeteer';
4
+
5
+ describe('script: header', () => {
6
+ beforeEach(async () => {
7
+ await setTestPage('/test', renderComponent('header', { ...EXAMPLE_HEADER_SEARCH_AND_MENU_LINKS, variants: 'basic' }));
8
+ });
9
+
10
+ describe('when the search button is clicked', () => {
11
+ beforeEach(async () => {
12
+ await page.click('.ons-js-toggle-header-search');
13
+ });
14
+
15
+ it('then the search input form is visible and does not have the ons-u-d-no class', async () => {
16
+ await page.waitForSelector('.ons-header-nav-search');
17
+ const isSearchNavVisible = await page.$eval('.ons-header-nav-search', (el) => !el.classList.contains('ons-u-d-no'));
18
+ expect(isSearchNavVisible).toBe(true);
19
+ });
20
+
21
+ it('then the button switches to the close icon', async () => {
22
+ const hasCloseIcon = await page.$eval('.ons-js-toggle-header-search svg', (el) => el.classList.contains('ons-icon--close'));
23
+ expect(hasCloseIcon).toBe(true);
24
+ });
25
+
26
+ it('then the button has aria-expanded="true"', async () => {
27
+ const attributes = await getNodeAttributes(page, '.ons-js-toggle-header-search');
28
+ expect(attributes['aria-expanded']).toBe('true');
29
+ });
30
+
31
+ it('then the button has aria-hidden="false"', async () => {
32
+ const attributes = await getNodeAttributes(page, '.ons-js-header-search');
33
+ expect(attributes['aria-hidden']).toBe('false');
34
+ });
35
+
36
+ it('then the search field has full width', async () => {
37
+ await page.waitForSelector('.ons-header-nav-search__input .ons-input');
38
+ const isFullWidth = await page.$eval('.ons-header-nav-search__input .ons-input', (el) =>
39
+ el.classList.contains('ons-input--w-full'),
40
+ );
41
+ expect(isFullWidth).toBe(true);
42
+ });
43
+ });
44
+
45
+ describe('when the search button is not clicked', () => {
46
+ it('then the search form is hidden', async () => {
47
+ const isSearchNavHidden = await page.$eval('.ons-header-nav-search', (el) => el.classList.contains('ons-u-d-no'));
48
+ expect(isSearchNavHidden).toBe(true);
49
+ });
50
+
51
+ it('then the button displays the search icon', async () => {
52
+ const hasSearchIcon = await page.$eval('.ons-js-toggle-header-search svg', (el) => el.classList.contains('ons-icon--search'));
53
+ expect(hasSearchIcon).toBe(true);
54
+ });
55
+
56
+ it('then the button has aria-expanded="false"', async () => {
57
+ const attributes = await getNodeAttributes(page, '.ons-js-toggle-header-search');
58
+ expect(attributes['aria-expanded']).toBe('false');
59
+ });
60
+
61
+ it('then the button has aria-hidden="true"', async () => {
62
+ const attributes = await getNodeAttributes(page, '.ons-js-header-search');
63
+ expect(attributes['aria-hidden']).toBe('true');
64
+ });
65
+ });
66
+
67
+ describe('when the search button is clicked again (to close)', () => {
68
+ beforeEach(async () => {
69
+ await page.click('.ons-js-toggle-header-search'); // Open
70
+ await page.waitForSelector('.ons-header-nav-search');
71
+ await page.click('.ons-js-toggle-header-search'); // Close
72
+ });
73
+
74
+ it('then the search form is hidden', async () => {
75
+ const isSearchNavHidden = await page.$eval('.ons-header-nav-search', (el) => el.classList.contains('ons-u-d-no'));
76
+ expect(isSearchNavHidden).toBe(true);
77
+ });
78
+
79
+ it('then the button switches back to the search icon', async () => {
80
+ const hasSearchIcon = await page.$eval('.ons-js-toggle-header-search svg', (el) => el.classList.contains('ons-icon--search'));
81
+ expect(hasSearchIcon).toBe(true);
82
+ });
83
+
84
+ it('then the button has aria-expanded="false"', async () => {
85
+ const attributes = await getNodeAttributes(page, '.ons-js-toggle-header-search');
86
+ expect(attributes['aria-expanded']).toBe('false');
87
+ });
88
+ });
89
+
90
+ describe('when the menu button is clicked', () => {
91
+ beforeEach(async () => {
92
+ await page.click('.ons-btn--menu');
93
+ });
94
+
95
+ it('then the navigation menu is displayed', async () => {
96
+ await page.waitForSelector('.ons-header-nav-menu');
97
+ const isMenuNavVisible = await page.$eval('.ons-header-nav-menu', (el) => !el.classList.contains('ons-u-d-no'));
98
+ expect(isMenuNavVisible).toBe(true);
99
+ });
100
+
101
+ it('then the menu button is marked as expanded', async () => {
102
+ const menuButtonAriaExpanded = await page.$eval('.ons-btn--menu', (el) => el.getAttribute('aria-expanded'));
103
+ expect(menuButtonAriaExpanded).toBe('true');
104
+ });
105
+
106
+ it('then the navigation menu aria-hidden attribute is set to false', async () => {
107
+ const isAriaHiddenFalse = await page.$eval('.ons-header-nav-menu', (el) => el.getAttribute('aria-hidden') === 'false');
108
+ expect(isAriaHiddenFalse).toBe(true);
109
+ });
110
+ });
111
+
112
+ describe('when the menu button is not clicked', () => {
113
+ it('then the navigation menu is hidden', async () => {
114
+ const isMenuNavHidden = await page.$eval('.ons-header-nav-menu', (el) => el.classList.contains('ons-u-d-no'));
115
+ expect(isMenuNavHidden).toBe(true);
116
+ });
117
+
118
+ it('then the menu button is marked as not expanded', async () => {
119
+ const menuButtonAriaExpanded = await page.$eval('.ons-btn--menu', (el) => el.getAttribute('aria-expanded'));
120
+ expect(menuButtonAriaExpanded).toBe('false');
121
+ });
122
+
123
+ it('then the navigation menu aria-hidden attribute is set to true', async () => {
124
+ const isAriaHiddenTrue = await page.$eval('.ons-header-nav-menu', (el) => el.getAttribute('aria-hidden') === 'true');
125
+ expect(isAriaHiddenTrue).toBe(true);
126
+ });
127
+ });
128
+ });
@@ -64,14 +64,17 @@
64
64
  width: 100%;
65
65
  }
66
66
  }
67
- }
68
- &__badge {
69
- @include mq(xs, l) {
70
- margin-top: 2.5rem;
71
- margin-bottom: 1rem;
67
+ .ons-hero__title-container {
68
+ @include mq(l) {
69
+ width: 85%;
70
+ }
72
71
  }
73
72
  }
74
73
 
74
+ &__badge-link {
75
+ display: block;
76
+ }
77
+
75
78
  &--topic {
76
79
  color: var(--ons-color-branded);
77
80
  @extend .ons-u-mb-no;
@@ -89,7 +92,11 @@
89
92
  }
90
93
 
91
94
  &__content {
92
- height: 100%;
95
+ @include mq(l) {
96
+ display: flex;
97
+ justify-content: space-between;
98
+ align-items: flex-start;
99
+ }
93
100
  }
94
101
 
95
102
  &__pre-title {
@@ -425,10 +432,6 @@
425
432
  display: grid;
426
433
  align-items: start;
427
434
  justify-content: space-between;
428
-
429
- &.ons-hero__title-badge {
430
- grid-template-columns: 1fr auto;
431
- }
432
435
  }
433
436
  }
434
437
  }
@@ -1,3 +1,5 @@
1
+ {% from "components/icon/_macro.njk" import onsIcon %}
2
+
1
3
  {% macro onsHero(params) %}
2
4
 
3
5
  {# Set number of columns used for hero content after medium breakpoint #}
@@ -35,28 +37,57 @@
35
37
  {% if params.topic %}
36
38
  <h2 class="ons-hero--topic">{{ params.topic | safe }}</h2>
37
39
  {% endif %}
38
- <div class="ons-hero__title-container {% if params.officialStatisticsBadge %}ons-hero__title-badge{% endif %}">
39
- <header>
40
- <h1 class="ons-hero__title ons-u-fs-3xl">{{ params.title }}</h1>
41
- {% if params.subtitle %}
42
- <h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
40
+
41
+ <div class="ons-hero__content">
42
+ <div class="ons-hero__title-container">
43
+ <header>
44
+ <h1 class="ons-hero__title ons-u-fs-3xl">{{ params.title }}</h1>
45
+ {% if params.subtitle %}
46
+ <h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
47
+ {% endif %}
48
+ </header>
49
+
50
+ {% if params.text %}
51
+ <p class="ons-hero__text">{{ params.text | safe }}</p>
43
52
  {% endif %}
44
- </header>
45
- {% if params.officialStatisticsBadge == true %}
46
- {% from "components/icon/_macro.njk" import onsIcon %}
47
- <div class="ons-hero__badge">
48
- {{-
49
- onsIcon({
50
- "iconType": 'official-statistics'
51
- })
52
- -}}
53
+ </div>
54
+
55
+ {% if params.variants == "grey" and params.officialStatisticsBadge == true %}
56
+ <div class="ons-hero__badge ons-u-mb-s">
57
+ {% if params.officialStatisticsBadgeUrl %}
58
+ <a
59
+ href="{{ params.officialStatisticsBadgeUrl }}"
60
+ target="_blank"
61
+ rel="noopener noreferrer"
62
+ class="ons-hero__badge-link"
63
+ >
64
+ {{-
65
+ onsIcon({
66
+ "iconType": 'official-statistics'
67
+ })
68
+ -}}
69
+ </a>
70
+ {% else %}
71
+ {{-
72
+ onsIcon({
73
+ "iconType": 'official-statistics'
74
+ })
75
+ -}}
76
+ {% endif %}
53
77
  </div>
54
78
  {% endif %}
55
- {% if params.text %}
56
- <p class="ons-hero__text">{{ params.text | safe }}</p>
57
- {% endif %}
58
79
  </div>
59
80
 
81
+ {% if params.variants == "grey" and params.censusLogo == true %}
82
+ <div class="ons-hero__census-logo">
83
+ {{-
84
+ onsIcon({
85
+ "iconType": 'census-logo'
86
+ })
87
+ -}}
88
+ </div>
89
+ {% endif %}
90
+
60
91
  {% if params.button %}
61
92
  {% from "components/button/_macro.njk" import onsButton %}
62
93
  {% set btnClasses = params.button.classes if params.button.classes else '' %}
@@ -80,7 +111,7 @@
80
111
  {% from "components/description-list/_macro.njk" import onsDescriptionList %}
81
112
  {{
82
113
  onsDescriptionList({
83
- "classes": "ons-u-mb-no",
114
+ "classes": "ons-u-mb-no ons-u-mt-s ons-u-mt-l@l",
84
115
  "variant": 'inline',
85
116
  "termCol": params.descriptionList.termCol,
86
117
  "descriptionCol": params.descriptionList.descriptionCol,
@@ -105,13 +105,32 @@ describe('macro: hero', () => {
105
105
  expect(content).toBe('Topic Text');
106
106
  });
107
107
 
108
- it('outputs the official statistics badge when officialStatisticsBadge is set to true', () => {
109
- const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, officialStatisticsBadge: true }));
108
+ it('outputs the official statistics badge when officialStatisticsBadge is set to true and variants is set to "grey"', () => {
109
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'grey', officialStatisticsBadge: true }));
110
110
 
111
111
  expect($('.ons-hero__badge').length).toBe(1);
112
112
  expect($('.ons-hero__badge svg title').text().trim()).toBe('Offical Statistics Badge');
113
113
  });
114
114
 
115
+ it('outputs the Census 2021 Logo when censusLogo is set to true and variants is set to "grey"', () => {
116
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'grey', censusLogo: true }));
117
+
118
+ expect($('.ons-hero__census-logo').length).toBe(1);
119
+ expect($('.ons-hero__census-logo svg title').text().trim()).toBe('Census 2021 Logo');
120
+ });
121
+
122
+ it('does not render the official statistics badge when officialStatisticsBadge is set to true and variants is not set', () => {
123
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, censusLogo: true }));
124
+
125
+ expect($('.ons-hero__badge').length).toBe(0);
126
+ });
127
+
128
+ it('does not render the Census 2021 Logo when censusLogo is set to true and variants is not set', () => {
129
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, censusLogo: true }));
130
+
131
+ expect($('.ons-hero__census-logo').length).toBe(0);
132
+ });
133
+
115
134
  it('renders curved gradient when variant is `grey`', () => {
116
135
  const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'grey' }));
117
136
  expect($('.ons-hero--grey').length).toBe(1);
@@ -8,9 +8,11 @@
8
8
  "variants": 'grey',
9
9
  "detailsColumns": '12',
10
10
  "officialStatisticsBadge": true,
11
+ "officialStatisticsBadgeUrl": 'https://uksa.statisticsauthority.gov.uk/about-the-authority/uk-statistical-system/types-of-official-statistics/',
11
12
  "topic": 'Statistical article',
12
13
  "title": 'Retail sales rise amid summer discounts and sporting events, according to a first estimate',
13
14
  "text": 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id mattis ligula, nec sollicitudin arcu. Donec non tristique tellus. Donec eget malesuada lorem.',
15
+ "censusLogo": true,
14
16
  "breadcrumbs": {
15
17
  "ariaLabel": 'Breadcrumbs',
16
18
  "itemsList": [
@@ -41,34 +43,34 @@
41
43
  ]
42
44
  },
43
45
  {
44
- "term": "Edition:",
46
+ "term": "Next release:",
45
47
  "descriptions": [
46
48
  {
47
- "description": "Latest"
49
+ "description": "20 September 2024"
48
50
  }
49
51
  ]
50
52
  },
51
53
  {
52
- "term": "Contact:",
54
+ "term": "Edition:",
53
55
  "descriptions": [
54
56
  {
55
- "description": "Retail Sales team"
57
+ "description": "Latest"
56
58
  }
57
59
  ]
58
60
  },
59
61
  {
60
- "term": "Next release:",
62
+ "term": "Releases:",
61
63
  "descriptions": [
62
64
  {
63
- "description": "20 September 2024"
65
+ "description": "View previous releases"
64
66
  }
65
67
  ]
66
68
  },
67
69
  {
68
- "term": "Releases:",
70
+ "term": "Contact:",
69
71
  "descriptions": [
70
72
  {
71
- "description": "View previous releases"
73
+ "description": "Retail Sales team"
72
74
  }
73
75
  ]
74
76
  }