@ons/design-system 67.0.2 → 67.0.3
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/README.md +1 -2
- package/components/header/example-header-external-with-sub-navigation.njk +3 -2
- package/components/navigation/_macro.njk +1 -1
- package/components/table-of-contents/example-table-of-contents-sticky-full-page.njk +114 -0
- package/components/table-of-contents/toc.spec.js +113 -3
- package/css/main.css +1 -1
- package/layout/_dsTemplate.njk +33 -0
- package/package.json +1 -1
- package/scss/objects/_page.scss +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ To enable this we use [nvm (Node Version Manager)](https://github.com/creationix
|
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
yarn install
|
|
36
|
-
husky install
|
|
36
|
+
yarn husky install
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
### Start a local server
|
|
@@ -130,7 +130,6 @@ Checkout the branch locally and run:
|
|
|
130
130
|
|
|
131
131
|
`yarn test-visual:approve` - This will approve the failures/diff caught by the tests.
|
|
132
132
|
|
|
133
|
-
|
|
134
133
|
`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.
|
|
135
134
|
|
|
136
135
|
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.
|
|
@@ -41,9 +41,10 @@
|
|
|
41
41
|
},
|
|
42
42
|
"subNavigation": {
|
|
43
43
|
"id": 'sub-nav',
|
|
44
|
-
"overviewURL": '#
|
|
44
|
+
"overviewURL": '#design-system',
|
|
45
45
|
"overviewText": 'Overview',
|
|
46
46
|
"ariaLabel": 'Section menu',
|
|
47
|
+
"currentPath": '#access-codes',
|
|
47
48
|
"itemsList": [
|
|
48
49
|
{
|
|
49
50
|
"text": 'Guidance',
|
|
@@ -129,4 +130,4 @@
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
})
|
|
132
|
-
}}
|
|
133
|
+
}}
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
<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">
|
|
89
89
|
<div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
|
|
90
90
|
<ul class="ons-navigation__list ons-navigation__list--parent">
|
|
91
|
-
<li class="ons-navigation__item">
|
|
91
|
+
<li class="ons-navigation__item{{ ' ons-navigation__item--active' if (params.navigation.subNavigation.overviewURL == params.navigation.subNavigation.currentPath)}}">
|
|
92
92
|
<a class="ons-navigation__link" href="{{ params.navigation.subNavigation.overviewURL }}">{{ params.navigation.subNavigation.overviewText | default('Overview') }}</a>
|
|
93
93
|
</li>
|
|
94
94
|
{% for item in params.navigation.subNavigation.itemsList %}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Example: Table of contents on full page"
|
|
3
|
+
layout: ~
|
|
4
|
+
---
|
|
5
|
+
{% from "components/table-of-contents/_macro.njk" import onsTableOfContents %}
|
|
6
|
+
|
|
7
|
+
{% extends "layout/_template.njk" %}
|
|
8
|
+
|
|
9
|
+
{% set pageConfig = {
|
|
10
|
+
"header": {
|
|
11
|
+
"title": "What is the census?"
|
|
12
|
+
},
|
|
13
|
+
"breadcrumbs": {
|
|
14
|
+
"ariaLabel": 'Back',
|
|
15
|
+
"itemsList": [
|
|
16
|
+
{
|
|
17
|
+
"url": '/',
|
|
18
|
+
"id": "back-example-feedback-form-error",
|
|
19
|
+
"text": 'Back',
|
|
20
|
+
"attributes": {
|
|
21
|
+
"data-attribute": "Example attribute"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"footer": {
|
|
27
|
+
"OGLLink": {
|
|
28
|
+
"pre": 'All content is available under the',
|
|
29
|
+
"link": 'Open Government Licence v3.0',
|
|
30
|
+
"url": 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/',
|
|
31
|
+
"post": ', except where otherwise stated'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} %}
|
|
35
|
+
|
|
36
|
+
{% block main %}
|
|
37
|
+
<div class="ons-page__container ons-container">
|
|
38
|
+
<div class="ons-grid ons-js-toc-container">
|
|
39
|
+
<div class="ons-grid__col ons-grid__col--sticky@m ons-col-4@m">
|
|
40
|
+
{{
|
|
41
|
+
onsTableOfContents({
|
|
42
|
+
"title": 'Contents',
|
|
43
|
+
"ariaLabel": 'Sections in this page',
|
|
44
|
+
"itemsList": [
|
|
45
|
+
{
|
|
46
|
+
"url": '#section1',
|
|
47
|
+
"text": 'What is the census?'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"url": '#section2',
|
|
51
|
+
"text": 'The online census has now closed'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"url": '#section3',
|
|
55
|
+
"text": 'What happens after Census Day'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"url": '#section4',
|
|
59
|
+
"text": 'The census in Northern Ireland and Scotland'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"url": '#section5',
|
|
63
|
+
"text": 'The last census'
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
})
|
|
67
|
+
}}
|
|
68
|
+
</div>
|
|
69
|
+
<div class="ons-grid__col ons-col-7@m ons-push-1@m">
|
|
70
|
+
<section id="section1">
|
|
71
|
+
<h2>What is the census?</h2>
|
|
72
|
+
<p>The census is a survey that happens every 10 years and gives us a picture of all the people and households in England and Wales.</p>
|
|
73
|
+
|
|
74
|
+
<p>Your answers to the census questions will help organisations make decisions on planning and funding public services in your area, including transport, education and healthcare.</p>
|
|
75
|
+
</section>
|
|
76
|
+
<section id="section2">
|
|
77
|
+
<h2>The online census has now closed</h2>
|
|
78
|
+
<p>Census Day was on Sunday 21 March 2021.</p>
|
|
79
|
+
|
|
80
|
+
<p>If you still have a paper census questionnaire, fill it in as soon as you can and return it to FREEPOST, Census 2021.</p>
|
|
81
|
+
</section>
|
|
82
|
+
<section id="section3">
|
|
83
|
+
<h2>What happens after Census Day</h2>
|
|
84
|
+
<p>Two follow-up surveys, the <a href="#0">Census Coverage Survey</a> and the <a href="#0">Census Quality Survey</a>, help to improve the quality and accuracy of the census results.</p>
|
|
85
|
+
|
|
86
|
+
<p>Over the next year, we work hard to process the answers from all the census questionnaires. This is so that we can publish the initial Census 2021 findings one year after the census and the main releases two years after the census.</p>
|
|
87
|
+
|
|
88
|
+
<p>To make sure the Census 2021 statistics we publish meet the needs of those who use them, we also run an outputs consultation.</p>
|
|
89
|
+
</section>
|
|
90
|
+
<section id="section4">
|
|
91
|
+
<h2>The census in Northern Ireland and Scotland</h2>
|
|
92
|
+
<p>The Office for National Statistics (ONS) runs the census in England and Wales.</p>
|
|
93
|
+
|
|
94
|
+
<p>If you live in Northern Ireland, visit the Northern Ireland Statistics Agency (NISRA) census website to find out about the census for Northern Ireland.</p>
|
|
95
|
+
|
|
96
|
+
<p>If you live in Scotland, visit the National Records of Scotland census website to find out how to take part in the census for Scotland.</p>
|
|
97
|
+
</section>
|
|
98
|
+
<section id="section5">
|
|
99
|
+
<h2>The last census</h2>
|
|
100
|
+
<p>The last census took place in 2011. Many people and organisations used information from the 2011 Census in a variety of ways.</p>
|
|
101
|
+
|
|
102
|
+
<p>For example, Bristol City Council used it to inform decisions on how to fund local housing improvements. It was also essential for the charity Redbridge Council for Voluntary Services to help people from ethnic minority groups learn more about dementia.</p>
|
|
103
|
+
|
|
104
|
+
<p>To read more about the benefits that information from the 2011 Census helped to create, visit the Office for National Statistics (ONS) website.</p>
|
|
105
|
+
<p>The Census Coverage Survey (CCS) was a short, separate survey that we at the Office for National Statistics (ONS) started six to eight weeks after Census Day.</p>
|
|
106
|
+
|
|
107
|
+
<p>The CCS helps make sure everyone is counted and our census results are as accurate as possible. It asked similar questions to the main census, just fewer of them, at addresses in a selection of postcodes across England and Wales.</p>
|
|
108
|
+
|
|
109
|
+
<p>The CCS has now closed.</p>
|
|
110
|
+
</section>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
{% endblock %}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
1
|
+
import { renderBaseTemplate, renderComponent, setTestPage } from '../../tests/helpers/rendering';
|
|
2
2
|
|
|
3
3
|
describe('script: table-of-contents', () => {
|
|
4
4
|
beforeEach(async () => {
|
|
@@ -52,10 +52,120 @@ describe('script: table-of-contents', () => {
|
|
|
52
52
|
['section2', 'Second section'],
|
|
53
53
|
['section3', 'Third section'],
|
|
54
54
|
])('marks "%s" as the current section', async (sectionId, sectionTitle) => {
|
|
55
|
-
await page.$eval(`#${sectionId}`, node => node.scrollIntoView());
|
|
55
|
+
await page.$eval(`#${sectionId}`, (node) => node.scrollIntoView());
|
|
56
56
|
await page.waitForTimeout(250);
|
|
57
57
|
|
|
58
|
-
const activeSection = await page.$eval('.ons-toc__link-active', node => node.innerText.trim());
|
|
58
|
+
const activeSection = await page.$eval('.ons-toc__link-active', (node) => node.innerText.trim());
|
|
59
59
|
expect(activeSection).toBe(sectionTitle);
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
describe('script: table-of-contents-fixed-position', () => {
|
|
64
|
+
beforeEach(async () => {
|
|
65
|
+
await setTestPage(
|
|
66
|
+
'/test',
|
|
67
|
+
`
|
|
68
|
+
<div class="ons-page__container ons-container">
|
|
69
|
+
<div class="ons-grid ons-js-toc-container">
|
|
70
|
+
<div id="sticky-container" class="ons-grid__col ons-grid__col--sticky@m ons-col-4@m">
|
|
71
|
+
${renderComponent('table-of-contents', {
|
|
72
|
+
title: 'Contents',
|
|
73
|
+
ariaLabel: 'Sections in this page',
|
|
74
|
+
itemsList: [
|
|
75
|
+
{
|
|
76
|
+
url: '#section1',
|
|
77
|
+
text: 'What is the census?',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
url: '#section2',
|
|
81
|
+
text: 'The online census has now closed',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
url: '#section3',
|
|
85
|
+
text: 'What happens after Census Day',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
url: '#section4',
|
|
89
|
+
text: 'The census in Northern Ireland and Scotland',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
url: '#section5',
|
|
93
|
+
text: 'The last census',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
})}
|
|
97
|
+
</div>
|
|
98
|
+
<div class="ons-grid__col ons-col-7@m ons-push-1@m">
|
|
99
|
+
<section id="section1">
|
|
100
|
+
<h2>What is the census?</h2>
|
|
101
|
+
<p>The census is a survey that happens every 10 years and gives us a picture of all the people and households in England and Wales.</p>
|
|
102
|
+
|
|
103
|
+
<p>Your answers to the census questions will help organisations make decisions on planning and funding public services in your area, including transport, education and healthcare.</p>
|
|
104
|
+
</section>
|
|
105
|
+
<section id="section2">
|
|
106
|
+
<h2>The online census has now closed</h2>
|
|
107
|
+
<p>Census Day was on Sunday 21 March 2021.</p>
|
|
108
|
+
|
|
109
|
+
<p>If you still have a paper census questionnaire, fill it in as soon as you can and return it to FREEPOST, Census 2021.</p>
|
|
110
|
+
</section>
|
|
111
|
+
<section id="section3">
|
|
112
|
+
<h2>What happens after Census Day</h2>
|
|
113
|
+
<p>Two follow-up surveys, the <a href="#0">Census Coverage Survey</a> and the <a href="#0">Census Quality Survey</a>, help to improve the quality and accuracy of the census results.</p>
|
|
114
|
+
|
|
115
|
+
<p>Over the next year, we work hard to process the answers from all the census questionnaires. This is so that we can publish the initial Census 2021 findings one year after the census and the main releases two years after the census.</p>
|
|
116
|
+
|
|
117
|
+
<p>To make sure the Census 2021 statistics we publish meet the needs of those who use them, we also run an outputs consultation.</p>
|
|
118
|
+
</section>
|
|
119
|
+
<section id="section4">
|
|
120
|
+
<h2>The census in Northern Ireland and Scotland</h2>
|
|
121
|
+
<p>The Office for National Statistics (ONS) runs the census in England and Wales.</p>
|
|
122
|
+
|
|
123
|
+
<p>If you live in Northern Ireland, visit the Northern Ireland Statistics Agency (NISRA) census website to find out about the census for Northern Ireland.</p>
|
|
124
|
+
|
|
125
|
+
<p>If you live in Scotland, visit the National Records of Scotland census website to find out how to take part in the census for Scotland.</p>
|
|
126
|
+
</section>
|
|
127
|
+
<section id="section5">
|
|
128
|
+
<h2>The last census</h2>
|
|
129
|
+
<p>The last census took place in 2011. Many people and organisations used information from the 2011 Census in a variety of ways.</p>
|
|
130
|
+
|
|
131
|
+
<p>For example, Bristol City Council used it to inform decisions on how to fund local housing improvements. It was also essential for the charity Redbridge Council for Voluntary Services to help people from ethnic minority groups learn more about dementia.</p>
|
|
132
|
+
|
|
133
|
+
<p>To read more about the benefits that information from the 2011 Census helped to create, visit the Office for National Statistics (ONS) website.</p>
|
|
134
|
+
<p>The Census Coverage Survey (CCS) was a short, separate survey that we at the Office for National Statistics (ONS) started six to eight weeks after Census Day.</p>
|
|
135
|
+
|
|
136
|
+
<p>The CCS helps make sure everyone is counted and our census results are as accurate as possible. It asked similar questions to the main census, just fewer of them, at addresses in a selection of postcodes across England and Wales.</p>
|
|
137
|
+
|
|
138
|
+
<p>The CCS has now closed.</p>
|
|
139
|
+
</section>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
`,
|
|
144
|
+
'main',
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('when the "ons-grid__col--sticky" class is used, then the ToC stays in a fixed position while scrolling', async () => {
|
|
149
|
+
await page.evaluate(() => {
|
|
150
|
+
window.scrollTo(0, 1000);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
await page.waitForTimeout(250);
|
|
154
|
+
const leftColumn = await page.$('#sticky-container');
|
|
155
|
+
const boundingBox = await leftColumn.boundingBox();
|
|
156
|
+
|
|
157
|
+
const viewport = await page.evaluate(() => ({
|
|
158
|
+
width: window.innerWidth,
|
|
159
|
+
height: window.innerHeight,
|
|
160
|
+
}));
|
|
161
|
+
|
|
162
|
+
const isInViewport =
|
|
163
|
+
boundingBox &&
|
|
164
|
+
boundingBox.x < viewport.width &&
|
|
165
|
+
boundingBox.y < viewport.height &&
|
|
166
|
+
boundingBox.x + boundingBox.width > 0 &&
|
|
167
|
+
boundingBox.y + boundingBox.height > 0;
|
|
168
|
+
|
|
169
|
+
expect(isInViewport).toBeTruthy();
|
|
170
|
+
});
|
|
171
|
+
});
|