@ons/design-system 74.0.0-next.2 → 74.0.0-next.4

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 (28) hide show
  1. package/README.md +13 -3
  2. package/components/access-code/example-access-code-error.njk +1 -1
  3. package/components/access-code/example-access-code.njk +1 -1
  4. package/components/back-to-top/example-full-page-back-to-top.njk +1 -1
  5. package/components/breadcrumbs/_breadcrumbs.scss +4 -7
  6. package/components/breadcrumbs/_macro.njk +29 -25
  7. package/components/breadcrumbs/_macro.spec.js +39 -0
  8. package/components/header/_macro.njk +7 -3
  9. package/components/header/_macro.spec.js +27 -0
  10. package/components/hero/example-hero-dark-with-external-breadcrumbs.njk +17 -21
  11. package/components/hero/example-hero-default-with-external-breadcrumbs.njk +165 -169
  12. package/components/hero/example-hero-grey-with-external-breadcrumbs.njk +207 -211
  13. package/components/hero/example-hero-navy-blue-with-external-breadcrumbs.njk +163 -167
  14. package/components/hero/example-hero-pale-blue-with-external-breadcrumbs.njk +165 -169
  15. package/components/question/example-question-ccs.njk +1 -1
  16. package/components/question/example-question-fieldset.njk +1 -1
  17. package/components/question/example-question-interviewer-note.njk +1 -1
  18. package/components/question/example-question-no-fieldset.njk +1 -1
  19. package/components/relationships/example-relationships-error.njk +1 -1
  20. package/components/relationships/example-relationships-you.njk +1 -1
  21. package/components/relationships/example-relationships.njk +1 -1
  22. package/components/table-of-contents/example-table-of-contents-sticky-full-page.njk +1 -1
  23. package/components/table-of-contents/table-of-contents.spec.js +4 -5
  24. package/css/main.css +1 -1
  25. package/layout/_template.njk +57 -44
  26. package/package.json +1 -1
  27. package/scss/objects/_page.scss +1 -1
  28. package/scss/objects/_spacing.scss +0 -4
package/README.md CHANGED
@@ -143,11 +143,21 @@ Checkout the branch locally and run:
143
143
 
144
144
  `yarn test-visual` - This will run the same tests locally as were run in Github Actions. After they have completed the report will open in your default browser.
145
145
 
146
+ ### Handling VR test failures
147
+
148
+ If the VR tests fail locally, you can review the changes in your browser. Note that the error you'll see if the VR tests fail starts with `Error: docker run --rm -i --add-host=host.docker.internal:host-gateway...`
149
+
150
+ `npx http-server backstop_data/html_report -p 8080` - View the results of the yarn visual tests in your browser. Using http-server rather than simply opening the file ensures the associated JavaScript runs.
151
+
152
+ ### Approving VR test reference image changes
153
+
146
154
  `yarn test-visual:approve` - This will approve the failures/diff caught by the tests.
147
155
 
148
- `git lfs push --all origin` - First commit the files in the normal way then run the command. This will push the new reference images to Git LFS.
156
+ Commit and approve the file changes in the normal way.
157
+
158
+ `git lfs push --all origin` - This will push the new reference images to Git LFS.
149
159
 
150
- You can then commit and push the updated references and your changes to your branch. The test images that would have been created when you ran `yarn test-visual` are gitignored and the new references images will be pushed to Git LFS.
160
+ You can then push the updated references and your changes to your branch. The test images that would have been created when you ran `yarn test-visual` are gitignored and the new references images will be pushed to Git LFS.
151
161
 
152
162
  If your local tests are failing but you have approved them, run `yarn test-visual:reference`. This will update the reference images locally on your machine.
153
163
 
@@ -176,7 +186,7 @@ yarn add @ons/design-system@next
176
186
 
177
187
  ### Publishing the stable major
178
188
 
179
- 1. Merge `next` into `main`.
189
+ 1. Merge `next` into `main`. **Do not squash; use a regular merge commit to preserve history.**
180
190
  2. Create a normal release tag, for example: `74.0.0`.
181
191
  3. Publish the GitHub Release (not marked as a pre-release).
182
192
 
@@ -14,7 +14,7 @@ layout: ~
14
14
  }
15
15
  %}
16
16
 
17
- {% block main %}
17
+ {% block mainContent %}
18
18
  {%
19
19
  call onsPanel({
20
20
  "title": "There is a problem with this page",
@@ -16,7 +16,7 @@ layout: ~
16
16
  }
17
17
  %}
18
18
 
19
- {% block main %}
19
+ {% block mainContent %}
20
20
  <h1 class="ons-u-mt-2xl">Start study</h1>
21
21
 
22
22
  {{
@@ -30,7 +30,7 @@ layout: ~
30
30
  }
31
31
  %}
32
32
 
33
- {% block main %}
33
+ {% block mainContent %}
34
34
  <h1 class="ons-u-fs-2xl">
35
35
  <span class="ons-u-fs-m ons-u-db ons-u-mb-2xs ons-u-lighter">Press releases</span>
36
36
  <span class="ons-u-vh">: </span>
@@ -3,7 +3,7 @@ $breadcrumb-chevron-height: 0.65rem;
3
3
  .ons-breadcrumbs-wrapper {
4
4
  position: relative;
5
5
  z-index: 10;
6
- margin-bottom: -2rem;
6
+ margin-bottom: -1rem;
7
7
  &--grey {
8
8
  background-color: var(--ons-color-banner-bg);
9
9
  }
@@ -14,9 +14,9 @@ $breadcrumb-chevron-height: 0.65rem;
14
14
 
15
15
  &--navy-blue {
16
16
  background-color: var(--ons-color-navy-blue-light);
17
- margin-bottom: -1.75rem;
17
+ margin-bottom: -0.75rem;
18
18
  @include mq(l) {
19
- margin-bottom: -3.25rem;
19
+ margin-bottom: -2.25rem;
20
20
  }
21
21
  }
22
22
 
@@ -48,15 +48,12 @@ $breadcrumb-chevron-height: 0.65rem;
48
48
  &--pale-blue {
49
49
  background-color: var(--ons-color-pale-blue);
50
50
  }
51
- .ons-breadcrumbs {
52
- padding: 1rem;
53
- }
54
51
  }
55
52
 
56
53
  .ons-breadcrumbs {
57
54
  align-items: center;
58
55
  display: flex;
59
- padding: 1rem 0;
56
+ padding: 1rem 0 0;
60
57
 
61
58
  &__items {
62
59
  margin: 0;
@@ -1,33 +1,37 @@
1
1
  {% from "components/icon/_macro.njk" import onsIcon %}
2
2
  {% macro onsBreadcrumbs(params) %}
3
3
  {% set breadcrumbs %}
4
- <nav
5
- class="ons-breadcrumbs{{ ' ons-container' if params.variant }}{{ ' ' + params.classes if params.classes else '' }}"
6
- aria-label="{{ params.ariaLabel | default('Breadcrumbs') }}"
7
- {% if params.id %}id="{{ params.id }}"{% endif %}
4
+ <div
5
+ class="ons-container{{ ' ons-container--full-width' if params.fullWidth else "" }}{{ ' ons-container--wide' if params.wide else "" }}"
8
6
  >
9
- <ol class="ons-breadcrumbs__items ons-u-fs-s">
10
- {%- for item in params.itemsList -%}
11
- <li
12
- class="ons-breadcrumbs__item{{ ' ' + item.itemClasses if item.itemClasses else '' }}"
13
- id="breadcrumb-{{ loop.index }}"
14
- >
15
- <a
16
- class="ons-breadcrumbs__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}"
17
- href="{% if not isDesignSystemExample %}{{ item.url }}{% else %}#0{% endif %}"
18
- {% if item.id %}{{ ' ' }}id='{{ item.id }}'{% endif %}
19
- {% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
20
- >{{ item.text }}</a
7
+ <nav
8
+ class="ons-breadcrumbs{{ ' ' + params.classes if params.classes else '' }}"
9
+ aria-label="{{ params.ariaLabel | default('Breadcrumbs') }}"
10
+ {% if params.id %}id="{{ params.id }}"{% endif %}
11
+ >
12
+ <ol class="ons-breadcrumbs__items ons-u-fs-s">
13
+ {%- for item in params.itemsList -%}
14
+ <li
15
+ class="ons-breadcrumbs__item{{ ' ' + item.itemClasses if item.itemClasses else '' }}"
16
+ id="breadcrumb-{{ loop.index }}"
21
17
  >
22
- {{-
23
- onsIcon({
24
- "iconType": "chevron"
25
- })
26
- -}}
27
- </li>
28
- {%- endfor -%}
29
- </ol>
30
- </nav>
18
+ <a
19
+ class="ons-breadcrumbs__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}"
20
+ href="{% if not isDesignSystemExample %}{{ item.url }}{% else %}#0{% endif %}"
21
+ {% if item.id %}{{ ' ' }}id='{{ item.id }}'{% endif %}
22
+ {% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
23
+ >{{ item.text }}</a
24
+ >
25
+ {{-
26
+ onsIcon({
27
+ "iconType": "chevron"
28
+ })
29
+ -}}
30
+ </li>
31
+ {%- endfor -%}
32
+ </ol>
33
+ </nav>
34
+ </div>
31
35
  {% endset %}
32
36
  {% if params.variant %}
33
37
  <div class="ons-breadcrumbs-wrapper ons-breadcrumbs-wrapper--{{ params.variant }}">{{ breadcrumbs | safe }}</div>
@@ -133,6 +133,45 @@ describe('FOR: Macro: Breadcrumbs', () => {
133
133
  });
134
134
  });
135
135
 
136
+ describe('GIVEN: Params: fullWidth', () => {
137
+ describe('WHEN: fullWidth is not provided', () => {
138
+ const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS));
139
+ test('THEN: renders container without full-width class', () => {
140
+ expect($('.ons-container').hasClass('ons-container--full-width')).toBe(false);
141
+ });
142
+ });
143
+ describe('WHEN: fullWidth is set to true', () => {
144
+ const $ = cheerio.load(
145
+ renderComponent('breadcrumbs', {
146
+ ...EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS,
147
+ fullWidth: true,
148
+ }),
149
+ );
150
+ test('THEN: renders container with full-width class', () => {
151
+ expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
152
+ });
153
+ });
154
+ });
155
+ describe('GIVEN: Params: wide', () => {
156
+ describe('WHEN: wide is not provided', () => {
157
+ const $ = cheerio.load(renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS));
158
+ test('THEN: renders container without wide class', () => {
159
+ expect($('.ons-container').hasClass('ons-container--wide')).toBe(false);
160
+ });
161
+ });
162
+ describe('WHEN: wide is set to true', () => {
163
+ const $ = cheerio.load(
164
+ renderComponent('breadcrumbs', {
165
+ ...EXAMPLE_BREADCRUMBS_REQUIRED_PARAMS,
166
+ wide: true,
167
+ }),
168
+ );
169
+ test('THEN: renders container with wide class', () => {
170
+ expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
171
+ });
172
+ });
173
+ });
174
+
136
175
  describe('GIVEN: Params: variant', () => {
137
176
  describe('WHEN: variant is provided', () => {
138
177
  const $ = cheerio.load(
@@ -6,6 +6,7 @@
6
6
  {% set titleTag = "h1" if params.titleAsH1 else "div" %}
7
7
  {% set openingTag = "<" + titleTag %}
8
8
  {% set closingTag = "</" + titleTag + ">" %}
9
+ {% set rootElementTag = "div" if params.useDivForRootElement else "header" %}
9
10
  {% set currentLanguageIsoCode = "en" %}
10
11
  {% set logoAltText = params.mastheadLogoAltText or params.mastheadLogo.altText %}
11
12
 
@@ -13,10 +14,11 @@
13
14
  {% set currentLanguage = params.language.languages | selectattr("current") | first %}
14
15
  {% set currentLanguageIsoCode = currentLanguage.isoCode %}
15
16
  {% endif %}
16
-
17
- <header
17
+ <!-- prettier-ignore-start -->
18
+ <{{ rootElementTag | safe }}
18
19
  class="ons-header{{ ' '+ params.classes if params.classes }}{% if params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-header--{{ variant }}{% endfor %}{% else %}{{ ' ' }}ons-header--{{ params.variants }}{% endif %}"
19
20
  >
21
+ <!-- prettier-ignore-end -->
20
22
  {{
21
23
  onsBrowserBanner({
22
24
  "lang": currentLanguageIsoCode,
@@ -535,5 +537,7 @@
535
537
  {% if params.navigation %}
536
538
  {{ onsNavigation(params) }}
537
539
  {% endif %}
538
- </header>
540
+ <!-- prettier-ignore-start -->
541
+ </{{ rootElementTag | safe }}>
542
+ <!-- prettier-ignore-end -->
539
543
  {% endmacro %}
@@ -36,6 +36,33 @@ describe('FOR: Macro: Header', () => {
36
36
  });
37
37
  });
38
38
 
39
+ describe('GIVEN: Params: useDivForRootElement', () => {
40
+ describe('WHEN: useDivForRootElement is not set', () => {
41
+ const $ = cheerio.load(
42
+ renderComponent('header', {
43
+ ...EXAMPLE_HEADER_BASIC,
44
+ }),
45
+ );
46
+ test('THEN: renders the root element as a header tag', () => {
47
+ expect($('header.ons-header').length).toBe(1);
48
+ });
49
+ });
50
+ describe('WHEN: useDivForRootElement is set to true', () => {
51
+ const $ = cheerio.load(
52
+ renderComponent('header', {
53
+ ...EXAMPLE_HEADER_BASIC,
54
+ useDivForRootElement: true,
55
+ }),
56
+ );
57
+ test('THEN: renders the root element as a div tag', () => {
58
+ expect($('div.ons-header').length).toBe(1);
59
+ });
60
+ test('THEN: does not render a header tag as the root element', () => {
61
+ expect($('header.ons-header').length).toBe(0);
62
+ });
63
+ });
64
+ });
65
+
39
66
  describe('Accessibility: search heading', () => {
40
67
  test('THEN: axe passes when search heading is present (params.search.links.heading)', async () => {
41
68
  const params = {
@@ -4,7 +4,6 @@ layout: ~
4
4
  ---
5
5
 
6
6
  {% from "components/hero/_macro.njk" import onsHero %}
7
- {% from "components/breadcrumbs/_macro.njk" import onsBreadcrumbs %}
8
7
  {% extends "layout/_template.njk" %}
9
8
  {%
10
9
  set pageConfig = {
@@ -162,12 +161,8 @@ layout: ~
162
161
  }
163
162
  ]
164
163
  }
165
- }
166
- }
167
- %}
168
- {% block pageContent %}
169
- {{
170
- onsBreadcrumbs({
164
+ },
165
+ "breadcrumbs": {
171
166
  "ariaLabel": 'Breadcrumbs',
172
167
  "variant": "dark",
173
168
  "itemsList": [
@@ -175,20 +170,21 @@ layout: ~
175
170
  "url": '/',
176
171
  "text": 'Home'
177
172
  }
178
- ]
173
+ ]
174
+ }
175
+ }
176
+ %}
177
+
178
+ {% block hero %}
179
+ {{
180
+ onsHero({
181
+ "title": 'Design and build digital services for the ONS',
182
+ "text": 'Everything you need to make accessible, consistent digital products',
183
+ "button": {
184
+ "url": '#0',
185
+ "text": 'Get started'
186
+ },
187
+ "variants": 'dark'
179
188
  })
180
189
  }}
181
- <main id="main-content">
182
- {{
183
- onsHero({
184
- "title": 'Design and build digital services for the ONS',
185
- "text": 'Everything you need to make accessible, consistent digital products',
186
- "button": {
187
- "url": '#0',
188
- "text": 'Get started'
189
- },
190
- "variants": 'dark'
191
- })
192
- }}
193
- </main>
194
190
  {% endblock %}