@ons/design-system 67.0.2 → 67.0.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.
- package/README.md +1 -2
- package/components/details/_details.scss +5 -0
- package/components/details/_macro.njk +9 -9
- package/components/header/example-header-external-with-sub-navigation-removed.njk +70 -0
- package/components/header/example-header-external-with-sub-navigation.njk +3 -2
- package/components/input/_input.scss +6 -0
- package/components/input/_macro.njk +32 -2
- package/components/input/example-input-text-width-constrained.njk +1 -1
- package/components/label/_macro.njk +4 -1
- package/components/navigation/_macro.njk +18 -16
- package/components/navigation/navigation.spec.js +89 -14
- 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/components/tabs/_macro.njk +1 -1
- package/components/tabs/_macro.spec.js +0 -10
- package/css/main.css +1 -1
- package/js/analytics.js +26 -24
- package/js/main.js +1 -0
- package/layout/_dsTemplate.njk +33 -0
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/objects/_page.scss +1 -1
|
@@ -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
|
+
});
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<div>
|
|
16
16
|
<ul class="ons-tabs__list">
|
|
17
17
|
{%- for tab in params.tabs -%}
|
|
18
|
-
<li class="ons-tab__list-item"><a href="#{{ tab.id if tab.id else tab.title|trim|replace(' ','-')|lower}}" class="ons-tab"
|
|
18
|
+
<li class="ons-tab__list-item"><a href="#{{ tab.id if tab.id else tab.title|trim|replace(' ','-')|lower}}" class="ons-tab"{% if tab.attributes %}{% for attribute, value in (tab.attributes.items() if tab.attributes is mapping and tab.attributes.items else tab.attributes) %} {{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}>{{ tab.title }}{% if tab.hiddenSpan %}<span class='ons-u-vh'>{{tab.hiddenSpan}}</span>{% endif %}</a></li>
|
|
19
19
|
{%- endfor -%}
|
|
20
20
|
</ul>
|
|
21
21
|
</div>
|
|
@@ -112,16 +112,6 @@ describe('macro: tabs', () => {
|
|
|
112
112
|
expect($('.ons-tab:last').text().trim()).toBe('Tab 2');
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
it('has Google Analytics integration on tab links', () => {
|
|
116
|
-
const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS));
|
|
117
|
-
|
|
118
|
-
const tabItem = $('.ons-tab');
|
|
119
|
-
expect(tabItem.attr('data-ga')).toBe('click');
|
|
120
|
-
expect(tabItem.attr('data-ga-category')).toBe('tabs');
|
|
121
|
-
expect(tabItem.attr('data-ga-action')).toBe('Show: Tab 1');
|
|
122
|
-
expect(tabItem.attr('data-ga-label')).toBe('Show: Tab 1');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
115
|
it('has expected content in tab panels', () => {
|
|
126
116
|
const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS));
|
|
127
117
|
|