@ons/design-system 53.0.3 → 53.1.1

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 (56) hide show
  1. package/components/autosuggest/_autosuggest.scss +1 -1
  2. package/components/browser-banner/_browser-banner.scss +39 -0
  3. package/components/browser-banner/_macro.njk +17 -0
  4. package/components/browser-banner/_macro.spec.js +83 -0
  5. package/components/checkboxes/_macro.njk +1 -1
  6. package/components/duration/_macro.njk +1 -1
  7. package/components/duration/_macro.spec.js +1 -1
  8. package/components/fieldset/_fieldset.scss +3 -6
  9. package/components/header/_macro.njk +7 -0
  10. package/components/label/_label.scss +1 -1
  11. package/components/navigation/_macro.njk +4 -4
  12. package/components/navigation/_macro.spec.js +20 -0
  13. package/css/census.css +1 -1
  14. package/css/error.css +1 -1
  15. package/css/ids.css +1 -1
  16. package/css/main.css +1 -1
  17. package/favicons/ids/cy/android-chrome-192x192.png +0 -0
  18. package/favicons/ids/cy/android-chrome-512x512.png +0 -0
  19. package/favicons/ids/cy/apple-touch-icon.png +0 -0
  20. package/favicons/ids/cy/browserconfig.xml +12 -0
  21. package/favicons/ids/cy/favicon-16x16.png +0 -0
  22. package/favicons/ids/cy/favicon-32x32.png +0 -0
  23. package/favicons/ids/cy/favicon.ico +0 -0
  24. package/favicons/ids/cy/manifest.json +20 -0
  25. package/favicons/ids/cy/mstile-150x150.png +0 -0
  26. package/favicons/ids/cy/mstile-310x150.png +0 -0
  27. package/favicons/ids/cy/mstile-310x310.png +0 -0
  28. package/favicons/ids/cy/mstile-70x70.png +0 -0
  29. package/favicons/ids/cy/opengraph.png +0 -0
  30. package/favicons/ids/cy/safari-pinned-tab.svg +27 -0
  31. package/favicons/ids/cy/site.webmanifest +54 -0
  32. package/favicons/ids/cy/twitter.png +0 -0
  33. package/favicons/ids/en/android-chrome-192x192.png +0 -0
  34. package/favicons/ids/en/android-chrome-512x512.png +0 -0
  35. package/favicons/ids/en/apple-touch-icon.png +0 -0
  36. package/favicons/ids/en/browserconfig.xml +12 -0
  37. package/favicons/ids/en/favicon-16x16.png +0 -0
  38. package/favicons/ids/en/favicon-32x32.png +0 -0
  39. package/favicons/ids/en/favicon.ico +0 -0
  40. package/favicons/ids/en/manifest.json +20 -0
  41. package/favicons/ids/en/mstile-150x150.png +0 -0
  42. package/favicons/ids/en/mstile-310x150.png +0 -0
  43. package/favicons/ids/en/mstile-310x310.png +0 -0
  44. package/favicons/ids/en/mstile-70x70.png +0 -0
  45. package/favicons/ids/en/opengraph.png +0 -0
  46. package/favicons/ids/en/safari-pinned-tab.svg +27 -0
  47. package/favicons/ids/en/site.webmanifest +54 -0
  48. package/favicons/ids/en/twitter.png +0 -0
  49. package/js/cookies-settings.js +5 -3
  50. package/js/cookies-settings.spec.js +25 -1
  51. package/layout/_template.njk +1 -0
  52. package/package.json +1 -1
  53. package/scripts/main.es5.js +1 -1
  54. package/scripts/main.js +1 -1
  55. package/scss/main.scss +1 -0
  56. package/scss/vars/_colors.scss +1 -0
@@ -131,7 +131,7 @@
131
131
  box-shadow: 0 0 5px 0 rgba($color-black, 0.6);
132
132
  left: 0;
133
133
  position: absolute;
134
- z-index: 1;
134
+ z-index: 10;
135
135
  }
136
136
  }
137
137
  }
@@ -0,0 +1,39 @@
1
+ .ons-browser-banner {
2
+ background-color: $color-banner-browser-bg;
3
+ display: none; // Hides unsupported browser banner unless targeted below
4
+ padding: 0.8rem 0;
5
+
6
+ &__content {
7
+ @extend .ons-u-fs-s;
8
+
9
+ color: $color-text-inverse;
10
+ margin: 0;
11
+ }
12
+
13
+ &__lead {
14
+ @extend .ons-u-fw-b;
15
+ }
16
+
17
+ &__link {
18
+ color: $color-text-inverse-link;
19
+
20
+ &:hover {
21
+ color: $color-text-inverse-link-hover;
22
+ text-decoration: underline solid $color-text-inverse-link-hover 2px;
23
+ }
24
+ }
25
+ }
26
+
27
+ // Targets browsers IE10 & IE11 and displays unsupported browser banner
28
+ @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
29
+ .ons-browser-banner {
30
+ display: block;
31
+ }
32
+ }
33
+
34
+ // Targets browsers IE8 & IE9 and displays unsupported browser banner
35
+ @media screen\0 {
36
+ .ons-browser-banner {
37
+ display: block;
38
+ }
39
+ }
@@ -0,0 +1,17 @@
1
+ {% macro onsBrowserBanner(params) %}
2
+ {% if params.lang == "cy" %}
3
+ {% set bannerLeadingText = 'Nid yw’r wefan hon yn cefnogi eich porwr mwyach.' %}
4
+ {% set bannerLinkUrl = 'https://cy.ons.gov.uk/help/browsers' %}
5
+ {% set bannerCTA = 'Gallwch <a class="ons-browser-banner__link" href="' + bannerLinkUrl + '">ddiweddaru eich porwr i’r fersiwn ddiweddaraf</a>.' %}
6
+ {% else %}
7
+ {% set bannerLeadingText = 'This website no longer supports your browser.' %}
8
+ {% set bannerLinkUrl = 'https://www.ons.gov.uk/help/browsers' %}
9
+ {% set bannerCTA = 'You can <a class="ons-browser-banner__link" href="' + bannerLinkUrl + '">upgrade your browser to the latest version</a>.' %}
10
+ {% endif %}
11
+
12
+ <div class="ons-browser-banner">
13
+ <div class="ons-container{{ ' ons-container--wide' if params.wide is defined and params.wide }}">
14
+ <p class="ons-browser-banner__content"><span class="ons-browser-banner__lead">{{ bannerLeadingText }}</span><span class="ons-browser-banner__cta"> {{ bannerCTA | safe }}</span></p>
15
+ </div>
16
+ </div>
17
+ {% endmacro %}
@@ -0,0 +1,83 @@
1
+ /** @jest-environment jsdom */
2
+
3
+ import * as cheerio from 'cheerio';
4
+
5
+ import axe from '../../tests/helpers/axe';
6
+ import { renderComponent } from '../../tests/helpers/rendering';
7
+
8
+ const EXAMPLE_BROWSER_BANNER_DEFAULT = {};
9
+
10
+ describe('macro: browser-banner', () => {
11
+ it('passes jest-axe checks with', async () => {
12
+ const $ = cheerio.load(renderComponent('browser-banner', EXAMPLE_BROWSER_BANNER_DEFAULT));
13
+
14
+ const results = await axe($.html());
15
+ expect(results).toHaveNoViolations();
16
+ });
17
+
18
+ it('has the default `bannerLeadingText`', () => {
19
+ const $ = cheerio.load(renderComponent('browser-banner', EXAMPLE_BROWSER_BANNER_DEFAULT));
20
+
21
+ const bannerLeadingText = $('.ons-browser-banner__lead')
22
+ .text()
23
+ .trim();
24
+ expect(bannerLeadingText).toBe('This website no longer supports your browser.');
25
+ });
26
+
27
+ it('has the default `bannerCTA`', () => {
28
+ const $ = cheerio.load(renderComponent('browser-banner', EXAMPLE_BROWSER_BANNER_DEFAULT));
29
+
30
+ const bannerCtaHtml = $('.ons-browser-banner__cta')
31
+ .text()
32
+ .trim();
33
+ expect(bannerCtaHtml).toBe('You can upgrade your browser to the latest version.');
34
+ });
35
+
36
+ it('has the default `bannerLinkUrl`', () => {
37
+ const $ = cheerio.load(renderComponent('browser-banner', EXAMPLE_BROWSER_BANNER_DEFAULT));
38
+
39
+ expect($('.ons-browser-banner__link').attr('href')).toBe('https://www.ons.gov.uk/help/browsers');
40
+ });
41
+
42
+ it('has `container--wide` class when `wide` is true', () => {
43
+ const $ = cheerio.load(
44
+ renderComponent('browser-banner', {
45
+ ...EXAMPLE_BROWSER_BANNER_DEFAULT,
46
+ wide: true,
47
+ }),
48
+ );
49
+
50
+ expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
51
+ });
52
+ });
53
+
54
+ describe('mode: Welsh language', () => {
55
+ it('has the welsh version of default `bannerLeadingText`', () => {
56
+ const $ = cheerio.load(
57
+ renderComponent('browser-banner', {
58
+ ...EXAMPLE_BROWSER_BANNER_DEFAULT,
59
+ lang: 'cy',
60
+ }),
61
+ );
62
+
63
+ const bannerLeadingText = $('.ons-browser-banner__lead')
64
+ .text()
65
+ .trim();
66
+ expect(bannerLeadingText).toBe('Nid yw’r wefan hon yn cefnogi eich porwr mwyach.');
67
+ });
68
+
69
+ it('has the welsh version of default `bannerCTA`', () => {
70
+ const $ = cheerio.load(renderComponent('browser-banner', { lang: 'cy' }));
71
+
72
+ const bannerCtaHtml = $('.ons-browser-banner__cta')
73
+ .text()
74
+ .trim();
75
+ expect(bannerCtaHtml).toBe('Gallwch ddiweddaru eich porwr i’r fersiwn ddiweddaraf.');
76
+ });
77
+
78
+ it('has the welsh version of default `bannerLinkUrl`', () => {
79
+ const $ = cheerio.load(renderComponent('browser-banner', { lang: 'cy' }));
80
+
81
+ expect($('.ons-browser-banner__link').attr('href')).toBe('https://cy.ons.gov.uk/help/browsers');
82
+ });
83
+ });
@@ -85,7 +85,7 @@
85
85
  "text": checkbox.other.label.text
86
86
  },
87
87
  "legend": checkbox.other.legend,
88
- "legendClasses": checkbox.other.legendClasses | default('') + ' ons-u-mb-xs',
88
+ "legendClasses": checkbox.other.legendClasses,
89
89
  "value": checkbox.other.value,
90
90
  "autoSelect": checkbox.other.autoSelect,
91
91
  "selectAllChildren": checkbox.other.selectAllChildren,
@@ -84,7 +84,7 @@
84
84
  "id": params.id,
85
85
  "legend": params.legendOrLabel,
86
86
  "description": params.description,
87
- "legendClasses": 'ons-u-mb-xs ' + (params.legendClasses if params.legendClasses else ''),
87
+ "legendClasses": params.legendClasses,
88
88
  "error": params.error,
89
89
  "legendIsQuestionTitle": params.legendIsQuestionTitle,
90
90
  "dontWrap": params.dontWrap
@@ -127,7 +127,7 @@ describe('macro: duration', () => {
127
127
  id: 'duration',
128
128
  legend: 'How long have you lived at this address?',
129
129
  description: 'Enter “0” into the years field if you have lived at this address for less than a year',
130
- legendClasses: 'ons-u-mb-xs custom-legend-class',
130
+ legendClasses: 'custom-legend-class',
131
131
  dontWrap: true,
132
132
  legendIsQuestionTitle: true,
133
133
  error: false,
@@ -1,6 +1,7 @@
1
1
  .ons-fieldset {
2
2
  &__legend {
3
- @extend .ons-label;
3
+ font-weight: $font-weight-bold;
4
+ margin: 0 0 0.6rem;
4
5
  }
5
6
 
6
7
  &__description:not(&__description--title) {
@@ -11,14 +12,10 @@
11
12
  font-weight: normal;
12
13
  }
13
14
 
14
- .ons-fieldset {
15
- &__legend {
16
- margin: 0 0 0.6rem;
17
- }
15
+ > * .ons-fieldset {
18
16
  .ons-fieldset {
19
17
  &__legend {
20
18
  font-weight: normal;
21
- margin: 0;
22
19
  }
23
20
  }
24
21
  }
@@ -2,6 +2,7 @@
2
2
  {% from "components/button/_macro.njk" import onsButton %}
3
3
  {% from "components/icons/_macro.njk" import onsIcon %}
4
4
  {% from "components/navigation/_macro.njk" import onsNavigation %}
5
+ {% from "components/browser-banner/_macro.njk" import onsBrowserBanner %}
5
6
 
6
7
  {% set title_tag = "h1" if params.titleAsH1 else "div" %}
7
8
  {% set currentLanguageISOCode = "en" %}
@@ -12,6 +13,12 @@
12
13
  {% endif %}
13
14
 
14
15
  <header class="ons-header {% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}{% if params.variants is not string %}{% for variant in params.variants %} ons-header--{{ variant }}{% endfor %}{% else %} ons-header--{{ params.variants }}{% endif %}" role="banner">
16
+ {{
17
+ onsBrowserBanner({
18
+ "lang": currentLanguageISOCode,
19
+ "wide": params.wide
20
+ })
21
+ }}
15
22
  {% if params.phase is defined and params.phase %}
16
23
  {% from "components/phase-banner/_macro.njk" import onsPhaseBanner %}
17
24
  {{ onsPhaseBanner(params.phase) }}
@@ -2,7 +2,7 @@
2
2
  color: inherit;
3
3
  display: block;
4
4
  font-weight: $font-weight-bold;
5
- margin-bottom: 0.4rem;
5
+ margin: 0 0 0.6rem;
6
6
 
7
7
  &__description {
8
8
  @extend .ons-u-fs-s;
@@ -42,7 +42,7 @@
42
42
  <ul class="ons-navigation__list">
43
43
  {% for item in (params.navigation.itemsList if params.navigation.itemsList is iterable else params.navigation.itemsList.items()) %}
44
44
  <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (item.url != (params.navigation.siteBasePath | default('/')) and item.url in params.navigation.currentPath) }}">
45
- <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
45
+ <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}{% if item.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %}>{{ item.title }}</a>
46
46
  </li>
47
47
  {% endfor %}
48
48
  </ul>
@@ -55,7 +55,7 @@
55
55
  <ul class="ons-navigation__list ons-navigation__list">
56
56
  {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
57
57
  <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url != (params.navigation.subNavigation.siteBasePath | default('/')) and item.url in params.navigation.subNavigation.currentPath) }}">
58
- <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
58
+ <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
59
59
  </li>
60
60
  {% endfor %}
61
61
  </ul>
@@ -81,14 +81,14 @@
81
81
  </li>
82
82
  {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
83
83
  <li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url != (params.navigation.subNavigation.siteBasePath | default('/')) and item.url in params.navigation.subNavigation.currentPath) }}">
84
- <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
84
+ <a class="ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id is defined and item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
85
85
  {% if item.sections %}
86
86
  {% for section in item.sections %}
87
87
  {% if section.sectionTitle %}<h3 class="ons-navigation__list-header">{{ section.sectionTitle }}</h3>{% endif %}
88
88
  <ul class="ons-navigation__list ons-navigation__list--child ons-list--dashed ons-u-ml-s ons-u-mt-xs">
89
89
  {% for child in section.children %}
90
90
  <li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.navigation.subNavigation.currentPath) or (child.url != (params.navigation.subNavigation.sitsiteBasePatheBasePath | default('/')) and child.url in params.navigation.subNavigation.currentPath) }}">
91
- <a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.id is defined and child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
91
+ <a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.ariaLabel is defined and child.ariaLabel %}aria-label="{{ child.ariaLabel }}" {% endif %} {% if child.id is defined and child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
92
92
  </li>
93
93
  {% endfor %}
94
94
  </ul>
@@ -14,12 +14,14 @@ const PARAMS = {
14
14
  itemsList: [
15
15
  {
16
16
  title: 'Main nav item 1',
17
+ ariaLabel: 'Main nav ariaLabel 1',
17
18
  url: '#0',
18
19
  classes: 'custom-class-main-item-1',
19
20
  id: 'main-item-1',
20
21
  },
21
22
  {
22
23
  title: 'Main nav item 2',
24
+ ariaLabel: 'Main nav ariaLabel 2',
23
25
  url: '#1',
24
26
  classes: 'custom-class-main-item-2',
25
27
  id: 'main-item-2',
@@ -34,12 +36,14 @@ const PARAMS = {
34
36
  itemsList: [
35
37
  {
36
38
  title: 'Sub nav item 1',
39
+ ariaLabel: 'Sub nav ariaLabel 1',
37
40
  url: '#0',
38
41
  classes: 'custom-class-sub-item-1',
39
42
  id: 'sub-item-1',
40
43
  },
41
44
  {
42
45
  title: 'Sub nav item 2',
46
+ ariaLabel: 'Sub nav ariaLabel 2',
43
47
  url: '#1',
44
48
  classes: 'custom-class-sub-item-2',
45
49
  id: 'sub-item-2',
@@ -49,10 +53,12 @@ const PARAMS = {
49
53
  children: [
50
54
  {
51
55
  title: 'Child item 1',
56
+ ariaLabel: 'Child item ariaLabel 1',
52
57
  url: '#0',
53
58
  },
54
59
  {
55
60
  title: 'Child item 2',
61
+ ariaLabel: 'Child item ariaLabel 2',
56
62
  url: '#1',
57
63
  },
58
64
  ],
@@ -157,6 +163,13 @@ describe('macro: navigation', () => {
157
163
  expect(values).toEqual(['Main nav item 1', 'Main nav item 2']);
158
164
  });
159
165
 
166
+ it('has the correct aria-label for each list item', () => {
167
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
168
+
169
+ const values = mapAll($('.ons-navigation--main .ons-navigation__link'), node => node.attr('aria-label'));
170
+ expect(values).toEqual(['Main nav ariaLabel 1', 'Main nav ariaLabel 2']);
171
+ });
172
+
160
173
  it('has the provided custom class for each list item', () => {
161
174
  const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
162
175
 
@@ -230,6 +243,13 @@ describe('macro: navigation', () => {
230
243
  expect(values).toEqual(['Sub nav item 1', 'Sub nav item 2']);
231
244
  });
232
245
 
246
+ it('has the correct aria-label for each list item', () => {
247
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
248
+
249
+ const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.attr('aria-label'));
250
+ expect(values).toEqual(['Sub nav ariaLabel 1', 'Sub nav ariaLabel 2']);
251
+ });
252
+
233
253
  it('has the provided custom class for each list item', () => {
234
254
  const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
235
255