@ons/design-system 52.0.0 → 53.0.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.
Files changed (39) hide show
  1. package/components/button/_button.scss +75 -33
  2. package/components/button/_macro.njk +1 -1
  3. package/components/button/_macro.spec.js +2 -2
  4. package/components/external-link/_macro.njk +5 -2
  5. package/components/external-link/_macro.spec.js +18 -1
  6. package/components/footer/_footer.scss +19 -4
  7. package/components/footer/_macro.njk +108 -98
  8. package/components/footer/_macro.spec.js +131 -2
  9. package/components/header/_header.scss +65 -46
  10. package/components/header/_macro.njk +172 -120
  11. package/components/header/_macro.spec.js +85 -29
  12. package/components/hero/_hero.scss +30 -140
  13. package/components/hero/_macro.njk +13 -20
  14. package/components/hero/_macro.spec.js +32 -29
  15. package/components/icons/_macro.njk +257 -29
  16. package/components/icons/_macro.spec.js +6 -6
  17. package/components/input/_input.scss +8 -0
  18. package/components/language-selector/_macro.njk +1 -1
  19. package/components/language-selector/_macro.spec.js +9 -1
  20. package/components/navigation/_macro.njk +42 -35
  21. package/components/navigation/_macro.spec.js +34 -32
  22. package/components/navigation/_navigation.scss +20 -4
  23. package/components/related-content/_macro.njk +13 -21
  24. package/components/related-content/_macro.spec.js +18 -27
  25. package/components/related-content/_section-macro.njk +10 -0
  26. package/components/related-content/_section-macro.spec.js +43 -0
  27. package/components/share-page/_macro.njk +4 -2
  28. package/css/census.css +3 -1
  29. package/css/ids.css +2 -0
  30. package/css/main.css +1 -1
  31. package/img/dummy-brand-logo.svg +1 -0
  32. package/layout/_template.njk +9 -4
  33. package/package.json +1 -1
  34. package/scripts/main.es5.js +2 -2
  35. package/scss/ids.scss +2 -0
  36. package/scss/settings/_census.scss +141 -0
  37. package/scss/settings/_ids.scss +48 -0
  38. package/scss/utilities/_margin.scss +1 -0
  39. package/scss/vars/_colors.scss +5 -2
@@ -32,9 +32,8 @@ describe('macro: icons', () => {
32
32
  'ons-logo-cy',
33
33
  'ons-logo-stacked-en',
34
34
  'ons-logo-stacked-cy',
35
- 'nisra-logo-en',
36
- 'nisra-logo-en-mobile',
37
- 'nisra-logo-black-en',
35
+ 'nisra-logo',
36
+ 'nisra-logo-mobile',
38
37
  'ni-finance-logo',
39
38
  'ni-finance-logo-mobile',
40
39
  'crest',
@@ -104,13 +103,14 @@ describe('macro: icons', () => {
104
103
  ['ons-logo-cy', 'Logo Swyddfa Ystadegau Gwladol'],
105
104
  ['ons-logo-stacked-en', 'Office for National Statistics logo'],
106
105
  ['ons-logo-stacked-cy', 'Logo Swyddfa Ystadegau Gwladol'],
107
- ['nisra-logo-en', 'Nisra logo'],
108
- ['nisra-logo-en-mobile', 'Nisra logo'],
109
- ['nisra-logo-black-en', 'Nisra logo'],
106
+ ['nisra-logo', 'Nisra logo'],
107
+ ['nisra-logo-mobile', 'Nisra logo'],
110
108
  ['ni-finance-logo', 'Northern Ireland Department of Finance logo'],
111
109
  ['ni-finance-logo-mobile', 'Northern Ireland Department of Finance logo'],
112
110
  ['crest', 'Royal coat of arms of the United Kingdom'],
113
111
  ['ogl', 'Open Government License logo'],
112
+ ['hm-gov-logo-en', 'HM Government logo'],
113
+ ['hm-gov-logo-cy', 'Logo Llywodraeth EM'],
114
114
  ])('icon type: %s', (iconType, expectedAltText) => {
115
115
  it(`has default alt text '${expectedAltText}'`, () => {
116
116
  const $ = cheerio.load(renderComponent('icons', { iconType }));
@@ -128,6 +128,7 @@
128
128
 
129
129
  .ons-input-search {
130
130
  @extend .ons-input--block;
131
+ @extend .ons-input--ghost;
131
132
 
132
133
  &--icon {
133
134
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='%23ffffff'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath d='M11.86 10.23 8.62 6.99a4.63 4.63 0 1 0-6.34 1.64 4.55 4.55 0 0 0 2.36.64 4.65 4.65 0 0 0 2.33-.65l3.24 3.23a.46.46 0 0 0 .65 0l1-1a.48.48 0 0 0 0-.62Zm-5-3.32a3.28 3.28 0 0 1-2.31.93 3.22 3.22 0 1 1 2.35-.93Z'/%3E%3C/svg%3E");
@@ -147,4 +148,11 @@
147
148
  box-shadow: 0 0 0 3px $color-focus;
148
149
  }
149
150
  }
151
+
152
+ &--dark {
153
+ border: 2px solid $color-black;
154
+ &.ons-input-search--icon {
155
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='%23000000'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath d='M11.86 10.23 8.62 6.99a4.63 4.63 0 1 0-6.34 1.64 4.55 4.55 0 0 0 2.36.64 4.65 4.65 0 0 0 2.33-.65l3.24 3.23a.46.46 0 0 0 .65 0l1-1a.48.48 0 0 0 0-.62Zm-5-3.32a3.28 3.28 0 0 1-2.31.93 3.22 3.22 0 1 1 2.35-.93Z'/%3E%3C/svg%3E");
156
+ }
157
+ }
150
158
  }
@@ -5,7 +5,7 @@
5
5
  <ul class="ons-language-links{% if languageNumber and languageNumber != 2 %} ons-u-d-no@xxs@m{% endif %}">
6
6
  {% for language in alternativeLanguages %}
7
7
  <li class="ons-language-links__item">
8
- <a href="{{ language.url }}" lang="{{ language.ISOCode }}" {% if language.attributes is defined and language.attributes %}{% for attribute, value in (language.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}>{{ language.text }}</a>
8
+ <a href="{{ language.url }}" lang="{{ language.ISOCode }}" {% if language.attributes is defined and language.attributes %}{% for attribute, value in (language.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}>{% if language.abbrText %}<span class="ons-u-d-no@s">{{ language.abbrText }}</span><span class="ons-u-d-no@xxs@s">{{ language.text }}</span>{% else %}{{ language.text }}{% endif %}</a>
9
9
  </li>
10
10
  {% endfor %}
11
11
  </ul>
@@ -11,12 +11,14 @@ const EXAMPLE_WITH_TWO_LANGUAGES = {
11
11
  url: '/english',
12
12
  ISOCode: 'en',
13
13
  text: 'English',
14
+ abbrText: 'EN',
14
15
  current: true,
15
16
  },
16
17
  {
17
18
  url: '/cymraeg',
18
19
  ISOCode: 'cy',
19
20
  text: 'Cymraeg',
21
+ abbrText: 'CY',
20
22
  current: false,
21
23
  attributes: {
22
24
  a: 123,
@@ -68,7 +70,7 @@ describe('macro: language-selector', () => {
68
70
  it('does not show the current language', () => {
69
71
  const $ = cheerio.load(renderComponent('language-selector', EXAMPLE_WITH_TWO_LANGUAGES));
70
72
 
71
- expect($('.ons-language-links__item a').text()).toBe('Cymraeg');
73
+ expect($('.ons-language-links__item a span:last-child').text()).toBe('Cymraeg');
72
74
  });
73
75
 
74
76
  it('has the expected hyperlink URL', async () => {
@@ -96,6 +98,12 @@ describe('macro: language-selector', () => {
96
98
 
97
99
  expect($('.ons-language-links').hasClass('ons-u-d-no@xxs@m')).toBe(false);
98
100
  });
101
+
102
+ it('has the `abbrText` rendered', () => {
103
+ const $ = cheerio.load(renderComponent('language-selector', EXAMPLE_WITH_TWO_LANGUAGES));
104
+
105
+ expect($('.ons-language-links__item a span:first-child').text()).toBe('CY');
106
+ });
99
107
  });
100
108
 
101
109
  describe('mode: with three languages', () => {
@@ -1,40 +1,47 @@
1
1
  {% macro onsNavigation(params) %}
2
2
  {% from "components/button/_macro.njk" import onsButton %}
3
3
  {% from "components/autosuggest/_macro.njk" import onsAutosuggest %}
4
- <div class="ons-navigation-wrapper">
5
- <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
6
- {% if params.siteSearchAutosuggest is defined and params.siteSearchAutosuggest and isPatternLib is defined and isPatternLib %}
4
+ <div class="ons-navigation-wrapper{% if params.variants == 'neutral' %} ons-navigation-wrapper--neutral{% endif %}">
5
+ <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
6
+ {% if params.navigation.siteSearchAutosuggest is defined and params.navigation.siteSearchAutosuggest and isPatternLib is defined and isPatternLib %}
7
7
  <div class="ons-navigation-search ons-js-navigation-search">
8
+ {% set autosuggestClasses = "ons-input-search ons-input-search--icon" %}
9
+ {% set autosuggestLabelClasses = "ons-u-pl-m" %}
10
+ {% if params.variants == "neutral" %}
11
+ {% set autosuggestClasses = autosuggestClasses + ' ons-input-search--dark' %}
12
+ {% else %}
13
+ {% set autosuggestLabelClasses = autosuggestLabelClasses + ' ons-label--white' %}
14
+ {% endif %}
8
15
  {{ onsAutosuggest({
9
16
  "id": "ons-site-search",
10
17
  "containerClasses": "ons-autosuggest-input--header",
11
- "classes": "ons-input--ghost ons-input-search ons-input-search--icon",
18
+ "classes": autosuggestClasses,
12
19
  "label": {
13
- "text": params.siteSearchAutosuggest.label,
20
+ "text": params.navigation.siteSearchAutosuggest.label,
14
21
  "id": "ons-site-search-label",
15
- "classes": "ons-label--white ons-u-pl-m"
22
+ "classes": autosuggestLabelClasses
16
23
  },
17
24
  "accessiblePlaceholder": true,
18
25
  "autocomplete": "off",
19
- "instructions": params.siteSearchAutosuggest.instructions,
20
- "ariaYouHaveSelected":params.siteSearchAutosuggest.ariaYouHaveSelected,
21
- "ariaMinChars": params.siteSearchAutosuggest.ariaMinChars,
22
- "ariaResultsLabel": params.siteSearchAutosuggest.ariaResultsLabel,
23
- "ariaOneResult": params.siteSearchAutosuggest.ariaOneResult,
24
- "ariaNResults": params.siteSearchAutosuggest.ariaNResults,
25
- "ariaLimitedResults": params.siteSearchAutosuggest.ariaLimitedResults,
26
- "moreResults": params.siteSearchAutosuggest.moreResults,
27
- "resultsTitle": params.siteSearchAutosuggest.resultsTitle,
28
- "autosuggestData": params.siteSearchAutosuggest.autosuggestData,
29
- "noResults": params.siteSearchAutosuggest.noResults,
30
- "typeMore": params.siteSearchAutosuggest.typeMore
26
+ "instructions": params.navigation.siteSearchAutosuggest.instructions,
27
+ "ariaYouHaveSelected":params.navigation.siteSearchAutosuggest.ariaYouHaveSelected,
28
+ "ariaMinChars": params.navigation.siteSearchAutosuggest.ariaMinChars,
29
+ "ariaResultsLabel": params.navigation.siteSearchAutosuggest.ariaResultsLabel,
30
+ "ariaOneResult": params.navigation.siteSearchAutosuggest.ariaOneResult,
31
+ "ariaNResults": params.navigation.siteSearchAutosuggest.ariaNResults,
32
+ "ariaLimitedResults": params.navigation.siteSearchAutosuggest.ariaLimitedResults,
33
+ "moreResults": params.navigation.siteSearchAutosuggest.moreResults,
34
+ "resultsTitle": params.navigation.siteSearchAutosuggest.resultsTitle,
35
+ "autosuggestData": params.navigation.siteSearchAutosuggest.autosuggestData,
36
+ "noResults": params.navigation.siteSearchAutosuggest.noResults,
37
+ "typeMore": params.navigation.siteSearchAutosuggest.typeMore
31
38
  }) }}
32
39
  </div>
33
40
  {% endif %}
34
- <nav class="ons-navigation ons-navigation--main ons-js-navigation" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Main menu") }}" data-analytics="header-navigation">
41
+ <nav class="ons-navigation ons-navigation--main ons-js-navigation" id="{{ params.navigation.id }}" aria-label="{{ params.navigation.ariaLabel | default("Main menu") }}" data-analytics="header-navigation">
35
42
  <ul class="ons-navigation__list">
36
- {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
37
- <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.currentPath) or (item.url != (params.siteBasePath | default('/')) and item.url in params.currentPath) }}">
43
+ {% for item in (params.navigation.itemsList if params.navigation.itemsList is iterable else params.navigation.itemsList.items()) %}
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) }}">
38
45
  <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
39
46
  </li>
40
47
  {% endfor %}
@@ -42,45 +49,45 @@
42
49
  </nav>
43
50
  </div>
44
51
  </div>
45
- {% if params.subNavigation is defined and params.subNavigation %}
46
- <nav class="ons-navigation ons-navigation--sub ons-u-d-no@xxs@l{{ ' ' + params.subNavigation.classes if params.subNavigation.classes is defined and params.subNavigation.classes }}" id="{{ params.subNavigation.id }}" aria-label="{{ params.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
47
- <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
52
+ {% if params.navigation.subNavigation is defined and params.navigation.subNavigation %}
53
+ <nav class="ons-navigation ons-navigation--sub ons-u-d-no@xxs@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes is defined and params.navigation.subNavigation.classes }}" id="{{ params.navigation.subNavigation.id }}" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
54
+ <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
48
55
  <ul class="ons-navigation__list ons-navigation__list">
49
- {% for item in (params.subNavigation.itemsList if params.subNavigation.itemsList is iterable else params.subNavigation.itemsList.items()) %}
50
- <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.subNavigation.currentPath) or (item.url != (params.subNavigation.siteBasePath | default('/')) and item.url in params.subNavigation.currentPath) }}">
56
+ {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
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) }}">
51
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>
52
59
  </li>
53
60
  {% endfor %}
54
61
  </ul>
55
62
  </div>
56
63
  </nav>
57
- <div class="ons-u-d-no@l{{ ' ' + params.subNavigation.classes if params.subNavigation.classes is defined and params.subNavigation.classes }}">
64
+ <div class="ons-u-d-no@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes is defined and params.navigation.subNavigation.classes }}">
58
65
  {{ onsButton({
59
- "text": params.currentPageTitle,
66
+ "text": params.navigation.currentPageTitle,
60
67
  "classes": "ons-u-d-no ons-js-sub-navigation-button ons-btn--dropdown",
61
68
  "buttonStyle": "mobile",
62
69
  "attributes": {
63
70
  "aria-label": "Toggle section navigation",
64
- "aria-controls": params.subNavigation.id,
71
+ "aria-controls": params.navigation.subNavigation.id,
65
72
  "aria-haspopup": "true",
66
73
  "aria-expanded": "false"
67
74
  }
68
75
  }) }}
69
- <nav class="ons-navigation ons-navigation--sub-mobile ons-u-d-no ons-js-secondary-nav ons-u-mt-xs" id="{{ params.subNavigation.id }}--mobile" aria-hidden="true" aria-label="{{ params.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
70
- <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
76
+ <nav class="ons-navigation ons-navigation--sub-mobile ons-u-d-no ons-js-secondary-nav ons-u-mt-xs" id="{{ params.navigation.subNavigation.id }}--mobile" aria-hidden="true" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
77
+ <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
71
78
  <ul class="ons-navigation__list ons-navigation__list--parent">
72
79
  <li class="ons-navigation__item">
73
- <a class="ons-navigation__link" href="{{ params.subNavigation.overviewURL }}">{{ params.subNavigation.overviewText | default('Overview') }}</a>
80
+ <a class="ons-navigation__link" href="{{ params.navigation.subNavigation.overviewURL }}">{{ params.navigation.subNavigation.overviewText | default('Overview') }}</a>
74
81
  </li>
75
- {% for item in (params.subNavigation.itemsList if params.subNavigation.itemsList is iterable else params.subNavigation.itemsList.items()) %}
76
- <li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.subNavigation.currentPath) or (item.url != (params.subNavigation.siteBasePath | default('/')) and item.url in params.subNavigation.currentPath) }}">
82
+ {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
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) }}">
77
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>
78
85
  {% if item.sections %}
79
86
  {% for section in item.sections %}
80
87
  {% if section.sectionTitle %}<h3 class="ons-navigation__list-header">{{ section.sectionTitle }}</h3>{% endif %}
81
88
  <ul class="ons-navigation__list ons-navigation__list--child ons-list--dashed ons-u-ml-s ons-u-mt-xs">
82
89
  {% for child in section.children %}
83
- <li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.subNavigation.currentPath) or (child.url != (params.subNavigation.sitsiteBasePatheBasePath | default('/')) and child.url in params.subNavigation.currentPath) }}">
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) }}">
84
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>
85
92
  </li>
86
93
  {% endfor %}
@@ -83,20 +83,20 @@ const SITE_SEARCH_AUTOSUGGEST = {
83
83
  describe('macro: navigation', () => {
84
84
  describe('level: container', () => {
85
85
  it('passes jest-axe checks', async () => {
86
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
86
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
87
87
 
88
88
  const results = await axe($.html());
89
89
  expect(results).toHaveNoViolations();
90
90
  });
91
91
 
92
92
  it('has the correct container if `fullWidth`', () => {
93
- const $ = cheerio.load(renderComponent('navigation', { ...PARAMS, fullWidth: true }));
93
+ const $ = cheerio.load(renderComponent('navigation', { navigation: { ...PARAMS, fullWidth: true } }));
94
94
 
95
95
  expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
96
96
  });
97
97
 
98
98
  it('has the correct container if `wide`', () => {
99
- const $ = cheerio.load(renderComponent('navigation', { ...PARAMS, wide: true }));
99
+ const $ = cheerio.load(renderComponent('navigation', { navigation: { ...PARAMS, wide: true } }));
100
100
 
101
101
  expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
102
102
  });
@@ -106,9 +106,11 @@ describe('macro: navigation', () => {
106
106
  const autosuggestSpy = faker.spy('autosuggest', { suppressOutput: true });
107
107
 
108
108
  faker.renderComponent('navigation', {
109
- ...PARAMS,
110
- siteSearchAutosuggest: {
111
- ...SITE_SEARCH_AUTOSUGGEST,
109
+ navigation: {
110
+ ...PARAMS,
111
+ siteSearchAutosuggest: {
112
+ ...SITE_SEARCH_AUTOSUGGEST,
113
+ },
112
114
  },
113
115
  });
114
116
 
@@ -118,11 +120,11 @@ describe('macro: navigation', () => {
118
120
  autocomplete: 'off',
119
121
  id: 'ons-site-search',
120
122
  containerClasses: 'ons-autosuggest-input--header',
121
- classes: 'ons-input--ghost ons-input-search ons-input-search--icon',
123
+ classes: 'ons-input-search ons-input-search--icon',
122
124
  label: {
123
125
  text: 'Search the design system',
124
126
  id: 'ons-site-search-label',
125
- classes: 'ons-label--white ons-u-pl-m',
127
+ classes: 'ons-u-pl-m ons-label--white',
126
128
  },
127
129
  });
128
130
  });
@@ -130,33 +132,33 @@ describe('macro: navigation', () => {
130
132
 
131
133
  describe('level: main navigation', () => {
132
134
  it('has the provided `id` attribute', () => {
133
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
135
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
134
136
 
135
137
  expect($('.ons-navigation--main').attr('id')).toBe('main-nav');
136
138
  });
137
139
 
138
140
  it('has the provided `aria-label` attribute', () => {
139
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
141
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
140
142
 
141
143
  expect($('.ons-navigation--main').attr('aria-label')).toBe('Main menu');
142
144
  });
143
145
 
144
146
  it('has the correct link href for each list item', () => {
145
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
147
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
146
148
 
147
149
  const values = mapAll($('.ons-navigation--main .ons-navigation__link'), node => node.attr('href'));
148
150
  expect(values).toEqual(['#0', '#1']);
149
151
  });
150
152
 
151
153
  it('has the correct link text for each list item', () => {
152
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
154
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
153
155
 
154
156
  const values = mapAll($('.ons-navigation--main .ons-navigation__link'), node => node.text().trim());
155
157
  expect(values).toEqual(['Main nav item 1', 'Main nav item 2']);
156
158
  });
157
159
 
158
160
  it('has the provided custom class for each list item', () => {
159
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
161
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
160
162
 
161
163
  expect($('.ons-navigation--main .ons-navigation__list > .ons-navigation__item').hasClass('custom-class-main-item-1')).toBe(true);
162
164
  expect($('.ons-navigation--main .ons-navigation__list .ons-navigation__item:last-child').hasClass('custom-class-main-item-2')).toBe(
@@ -165,7 +167,7 @@ describe('macro: navigation', () => {
165
167
  });
166
168
 
167
169
  it('has the provided id for each list item', () => {
168
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
170
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
169
171
 
170
172
  expect($('.ons-navigation--main .ons-navigation__list > .ons-navigation__item .ons-navigation__link').attr('id')).toBe('main-item-1');
171
173
  expect($('.ons-navigation--main .ons-navigation__list .ons-navigation__item:last-child .ons-navigation__link').attr('id')).toBe(
@@ -174,7 +176,7 @@ describe('macro: navigation', () => {
174
176
  });
175
177
 
176
178
  it('has the active class on the correct item', () => {
177
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
179
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
178
180
 
179
181
  expect(
180
182
  $('.ons-navigation--main .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
@@ -187,7 +189,7 @@ describe('macro: navigation', () => {
187
189
  const faker = templateFaker();
188
190
  const buttonSpy = faker.spy('button', { suppressOutput: true });
189
191
 
190
- faker.renderComponent('navigation', PARAMS);
192
+ faker.renderComponent('navigation', { navigation: PARAMS });
191
193
 
192
194
  expect(buttonSpy.occurrences).toContainEqual({
193
195
  text: 'Main nav item 2',
@@ -203,33 +205,33 @@ describe('macro: navigation', () => {
203
205
  });
204
206
 
205
207
  it('has the provided `id` attribute', () => {
206
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
208
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
207
209
 
208
210
  expect($('.ons-navigation--sub').attr('id')).toBe('sub-nav');
209
211
  });
210
212
 
211
213
  it('has the provided `aria-label` attribute', () => {
212
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
214
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
213
215
 
214
216
  expect($('.ons-navigation--sub').attr('aria-label')).toBe('Section menu');
215
217
  });
216
218
 
217
219
  it('has the correct link href for each list item', () => {
218
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
220
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
219
221
 
220
222
  const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.attr('href'));
221
223
  expect(values).toEqual(['#0', '#1']);
222
224
  });
223
225
 
224
226
  it('has the correct link text for each list item', () => {
225
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
227
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
226
228
 
227
229
  const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.text().trim());
228
230
  expect(values).toEqual(['Sub nav item 1', 'Sub nav item 2']);
229
231
  });
230
232
 
231
233
  it('has the provided custom class for each list item', () => {
232
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
234
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
233
235
 
234
236
  expect($('.ons-navigation--sub .ons-navigation__list > .ons-navigation__item').hasClass('custom-class-sub-item-1')).toBe(true);
235
237
  expect($('.ons-navigation--sub .ons-navigation__list .ons-navigation__item:last-child').hasClass('custom-class-sub-item-2')).toBe(
@@ -238,7 +240,7 @@ describe('macro: navigation', () => {
238
240
  });
239
241
 
240
242
  it('has the provided id for each list item', () => {
241
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
243
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
242
244
 
243
245
  expect($('.ons-navigation--sub .ons-navigation__list > .ons-navigation__item .ons-navigation__link').attr('id')).toBe('sub-item-1');
244
246
  expect($('.ons-navigation--sub .ons-navigation__list .ons-navigation__item:last-child .ons-navigation__link').attr('id')).toBe(
@@ -247,7 +249,7 @@ describe('macro: navigation', () => {
247
249
  });
248
250
 
249
251
  it('has the active class on the correct item', () => {
250
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
252
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
251
253
 
252
254
  expect(
253
255
  $('.ons-navigation--sub .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
@@ -257,19 +259,19 @@ describe('macro: navigation', () => {
257
259
 
258
260
  describe('level: sub navigation mobile', () => {
259
261
  it('has the provided `id` attribute', () => {
260
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
262
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
261
263
 
262
264
  expect($('.ons-navigation--sub-mobile').attr('id')).toBe('sub-nav--mobile');
263
265
  });
264
266
 
265
267
  it('has the provided `aria-label` attribute', () => {
266
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
268
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
267
269
 
268
270
  expect($('.ons-navigation--sub-mobile').attr('aria-label')).toBe('Section menu');
269
271
  });
270
272
 
271
273
  it('has the correct link href for each list item', () => {
272
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
274
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
273
275
 
274
276
  const values = mapAll(
275
277
  $('.ons-navigation__list--parent > li a').not('.ons-navigation__list--parent li .ons-navigation__list--child a'),
@@ -279,7 +281,7 @@ describe('macro: navigation', () => {
279
281
  });
280
282
 
281
283
  it('has the correct link text for each list item', () => {
282
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
284
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
283
285
 
284
286
  const values = mapAll(
285
287
  $('.ons-navigation__list--parent > li a').not('.ons-navigation__list--parent li .ons-navigation__list--child a'),
@@ -289,7 +291,7 @@ describe('macro: navigation', () => {
289
291
  });
290
292
 
291
293
  it('has the active class on the correct item', () => {
292
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
294
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
293
295
 
294
296
  expect(
295
297
  $('.ons-navigation--sub-mobile .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
@@ -297,27 +299,27 @@ describe('macro: navigation', () => {
297
299
  });
298
300
 
299
301
  it('has the correct text for the child section title', () => {
300
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
302
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
301
303
 
302
304
  expect($('.ons-navigation__list-header').text()).toBe('Section 1');
303
305
  });
304
306
 
305
307
  it('has the correct link href for each child list item', () => {
306
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
308
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
307
309
 
308
310
  const values = mapAll($('.ons-navigation__list--child > li a'), node => node.attr('href'));
309
311
  expect(values).toEqual(['#0', '#1']);
310
312
  });
311
313
 
312
314
  it('has the correct link text for each child list item', () => {
313
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
315
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
314
316
 
315
317
  const values = mapAll($('.ons-navigation__list--child > li a'), node => node.text().trim());
316
318
  expect(values).toEqual(['Child item 1', 'Child item 2']);
317
319
  });
318
320
 
319
321
  it('has the active class on the correct child item', () => {
320
- const $ = cheerio.load(renderComponent('navigation', PARAMS));
322
+ const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
321
323
 
322
324
  expect(
323
325
  $('.ons-navigation--sub-mobile .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
@@ -18,6 +18,7 @@
18
18
  padding: 1rem;
19
19
 
20
20
  @include mq(l) {
21
+ background: none;
21
22
  bottom: 65px;
22
23
  padding: 0;
23
24
  position: absolute;
@@ -80,7 +81,7 @@
80
81
  .ons-navigation--sub & {
81
82
  &:hover,
82
83
  &--active {
83
- border-color: $color-text-link;
84
+ border-color: $color-branded;
84
85
  }
85
86
  }
86
87
  }
@@ -89,8 +90,8 @@
89
90
  &__link {
90
91
  color: $color-white;
91
92
  display: block;
92
- margin: 0 0.35rem;
93
- padding: 0.1rem 0.55rem;
93
+ margin: 0 0.75rem;
94
+ padding: 0.1rem 0;
94
95
  text-decoration: none;
95
96
 
96
97
  &--section {
@@ -109,7 +110,7 @@
109
110
  color: $color-text-link;
110
111
  &:hover,
111
112
  &:focus {
112
- color: $color-text-link;
113
+ color: $color-text-link-hover;
113
114
  }
114
115
  }
115
116
 
@@ -124,4 +125,19 @@
124
125
  &__item--active > &__link {
125
126
  font-weight: 700;
126
127
  }
128
+
129
+ &-wrapper {
130
+ &--neutral {
131
+ background: $color-header-light;
132
+ .ons-navigation__item {
133
+ &--active,
134
+ &:hover {
135
+ border-color: $color-branded;
136
+ }
137
+ .ons-navigation__link {
138
+ color: $color-branded-text;
139
+ }
140
+ }
141
+ }
142
+ }
127
143
  }
@@ -1,23 +1,23 @@
1
1
  {% macro onsRelatedContent(params) %}
2
2
 
3
- {% from "components/lists/_macro.njk" import onsList %}
4
-
5
- {% if params is defined and params and params.classes is defined and params.classes %}
6
- {% set classes = ' ' + params.classes %}
7
- {% endif %}
3
+ {% if params is defined and params and params.classes is defined and params.classes %}
4
+ {% set classes = ' ' + params.classes %}
5
+ {% endif %}
8
6
 
9
7
  <aside class="ons-related-content{{ classes }}" aria-label="{{ params.ariaLabel | default("Related content") }}">
10
8
 
11
9
  <div class="ons-related-content__body">
12
-
13
10
  {% if params.rows is defined and params.rows %}
14
-
15
11
  {% for row in params.rows %}
16
- <div class="ons-related-content__section">
17
- {% if row.title %}
18
- <h2 class="ons-related-content__title ons-u-fs-r--b ons-u-mb-xs" id="{{ row.id }}">{{ row.title }}</h2>
19
- {% endif %}
12
+ {% from "components/related-content/_section-macro.njk" import onsRelatedContentSection %}
13
+ {% call onsRelatedContentSection(
14
+ {
15
+ "title": row.title,
16
+ "id": row.id
17
+ }
18
+ ) %}
20
19
  <nav class="ons-related-content__navigation" aria-labelledby="{{ row.id }}">
20
+ {% from "components/lists/_macro.njk" import onsList %}
21
21
  {{
22
22
  onsList({
23
23
  "variants": 'bare',
@@ -28,19 +28,11 @@
28
28
  })
29
29
  }}
30
30
  </nav>
31
- </div>
31
+ {% endcall %}
32
32
  {% endfor %}
33
-
34
33
  {% else %}
35
-
36
- <h2 class="ons-related-content__title ons-u-fs-r--b ons-u-mb-xs">{{ params.title }}</h2>
37
-
38
- <div class="ons-related-content__body">
39
- {{ (params.body if params else "") | safe }}{{ caller() if caller }}
40
- </div>
41
-
34
+ {{ caller() if caller }}
42
35
  {% endif %}
43
-
44
36
  </div>
45
37
 
46
38
  </aside>