@ons/design-system 62.2.4 → 64.0.0
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/components/access-code/example-access-code-error.njk +1 -1
- package/components/accordion/_macro.njk +1 -1
- package/components/breadcrumbs/_macro.njk +2 -2
- package/components/breadcrumbs/_macro.spec.js +1 -1
- package/components/button/_macro.njk +1 -1
- package/components/button/_macro.spec.js +6 -6
- package/components/card/_macro.njk +1 -1
- package/components/card/_macro.spec.js +1 -1
- package/components/char-check-limit/_macro.njk +1 -1
- package/components/char-check-limit/_macro.spec.js +1 -1
- package/components/char-check-limit/character-check.spec.js +16 -16
- package/components/checkboxes/_macro.njk +3 -1
- package/components/checkboxes/example-checkboxes-with-descriptions.njk +1 -0
- package/components/collapsible/_macro.spec.js +1 -1
- package/components/content-pagination/_macro.njk +2 -2
- package/components/content-pagination/_macro.spec.js +2 -2
- package/components/cookies-banner/_macro.njk +2 -2
- package/components/cookies-banner/_macro.spec.js +2 -2
- package/components/details/_macro.njk +1 -1
- package/components/details/_macro.spec.js +1 -1
- package/components/document-list/_macro.njk +1 -1
- package/components/footer/_macro.njk +2 -2
- package/components/footer/_macro.spec.js +7 -7
- package/components/header/_macro.njk +3 -3
- package/components/header/_macro.spec.js +5 -6
- package/components/{icons → icon}/_macro.spec.js +7 -7
- package/components/{images → image}/_macro.spec.js +13 -13
- package/components/{images/example-images-for-regular-screens.njk → image/example-image-for-regular-screens.njk} +1 -1
- package/components/{images/example-images-for-retina-screens.njk → image/example-image-for-retina-screens.njk} +1 -1
- package/components/input/_input.scss +6 -0
- package/components/input/_macro.njk +20 -13
- package/components/input/_macro.spec.js +2 -22
- package/components/{search/example-search-with-character-check.njk → input/example-input-search-with-character-check.njk} +1 -2
- package/components/{search/example-search-with-placeholder.njk → input/example-input-search-with-placeholder.njk} +1 -2
- package/components/{search/example-search.njk → input/example-input-search.njk} +1 -2
- package/components/{lists → list}/_macro.njk +3 -3
- package/components/{lists → list}/_macro.spec.js +42 -42
- package/components/message/_macro.njk +2 -2
- package/components/message/_macro.spec.js +0 -1
- package/components/metadata/_macro.njk +1 -1
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +1 -1
- package/components/navigation/_macro.njk +3 -3
- package/components/pagination/_macro.njk +65 -69
- package/components/pagination/_macro.spec.js +18 -16
- package/components/pagination/example-pagination-first.njk +5 -5
- package/components/pagination/example-pagination-last.njk +5 -5
- package/components/pagination/example-pagination-with-no-range-indicator.njk +11 -11
- package/components/pagination/example-pagination.njk +2 -2
- package/components/panel/_macro.njk +2 -2
- package/components/panel/_macro.spec.js +2 -2
- package/components/panel/example-panel-with-error-summary.njk +1 -1
- package/components/phase-banner/_phase-banner.scss +2 -1
- package/components/question/_macro.njk +1 -1
- package/components/question/_macro.spec.js +1 -1
- package/components/quote/_macro.njk +1 -1
- package/components/quote/_macro.spec.js +1 -1
- package/components/related-content/_macro.njk +1 -1
- package/components/related-content/_macro.spec.js +1 -1
- package/components/related-content/example-related-content-general.njk +1 -1
- package/components/relationships/example-relationships-error.njk +1 -1
- package/components/section-navigation/_macro.njk +2 -2
- package/components/select/_macro.njk +1 -2
- package/components/share-page/_macro.njk +1 -1
- package/components/share-page/_macro.spec.js +5 -5
- package/components/summary/_macro.njk +5 -6
- package/components/summary/_macro.spec.js +8 -23
- package/components/summary/example-summary-grouped-total.njk +0 -2
- package/components/summary/example-summary-grouped-with-errors.njk +0 -4
- package/components/summary/example-summary-grouped.njk +0 -19
- package/components/summary/example-summary-household.njk +0 -5
- package/components/summary/example-summary-hub.njk +0 -8
- package/components/summary/example-summary-multiple.njk +0 -4
- package/components/summary/example-summary.njk +0 -4
- package/components/table/_macro.njk +4 -4
- package/components/table/_macro.spec.js +17 -1
- package/components/table/example-table-basic.njk +1 -2
- package/components/table/example-table-numeric.njk +6 -3
- package/components/table-of-contents/_macro.njk +1 -1
- package/components/table-of-contents/_macro.spec.js +2 -2
- package/components/tabs/_macro.njk +6 -5
- package/components/tabs/_macro.spec.js +25 -2
- package/components/tabs/_tabs.scss +11 -15
- package/components/tabs/example-tabs.njk +6 -6
- package/components/tabs/tabs.js +24 -8
- package/components/tabs/tabs.spec.js +40 -2
- package/components/textarea/_macro.njk +2 -2
- package/components/textarea/_macro.spec.js +2 -2
- package/components/textarea/textarea.spec.js +6 -10
- package/components/timeline/_macro.njk +1 -1
- package/components/timeline/_macro.spec.js +1 -1
- package/css/main.css +3 -3
- package/css/print.css +1 -1
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +3 -4
- package/components/search/_macro.njk +0 -30
- package/components/search/_macro.spec.js +0 -69
- package/components/search/_search.scss +0 -9
- /package/components/{icons/_icons.scss → icon/_icon.scss} +0 -0
- /package/components/{icons → icon}/_macro.njk +0 -0
- /package/components/{images/_images.scss → image/_image.scss} +0 -0
- /package/components/{images → image}/_macro.njk +0 -0
- /package/components/{lists → list}/_list.scss +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{% macro onsTableOfContents(params) %}
|
|
2
|
-
{% from "components/
|
|
2
|
+
{% from "components/list/_macro.njk" import onsList %}
|
|
3
3
|
{% from "components/skip-to-content/_macro.njk" import onsSkipToContent %}
|
|
4
4
|
|
|
5
5
|
<aside class="ons-toc-container" role="complementary">
|
|
@@ -114,7 +114,7 @@ describe('macro: table-of-contents', () => {
|
|
|
114
114
|
|
|
115
115
|
it('outputs `lists` component', () => {
|
|
116
116
|
const faker = templateFaker();
|
|
117
|
-
const listsSpy = faker.spy('
|
|
117
|
+
const listsSpy = faker.spy('list');
|
|
118
118
|
|
|
119
119
|
faker.renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_SINGLE);
|
|
120
120
|
|
|
@@ -157,7 +157,7 @@ describe('macro: table-of-contents', () => {
|
|
|
157
157
|
|
|
158
158
|
it('outputs `lists` component for each list', () => {
|
|
159
159
|
const faker = templateFaker();
|
|
160
|
-
const listsSpy = faker.spy('
|
|
160
|
+
const listsSpy = faker.spy('list');
|
|
161
161
|
|
|
162
162
|
faker.renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_MULTIPLE);
|
|
163
163
|
|
|
@@ -12,17 +12,18 @@
|
|
|
12
12
|
>
|
|
13
13
|
{% set titleTag = params.titleTag | default("h2") %}
|
|
14
14
|
<{{ titleTag }} class="ons-tabs__title ons-u-fs-r--b ons-u-mt-no">{{ params.title }}</{{ titleTag }}>
|
|
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 '
|
|
18
|
+
<li class="ons-tab__list-item"><a href="#{{ tab.id if tab.id else tab.title|trim|replace(' ','-')|lower}}" class="ons-tab" data-ga="click" data-ga-category="tabs" data-ga-action="Show: {{ tab.title }}" data-ga-label="Show: {{ tab.title }}">{{ tab.title }}{% if tab.hiddenSpan %}<span class='ons-u-d-no'>{{tab.hiddenSpan}}</span>{% endif %}</a></li>
|
|
19
19
|
{%- endfor -%}
|
|
20
20
|
</ul>
|
|
21
|
-
|
|
21
|
+
</div>
|
|
22
22
|
{% for tab in params.tabs %}
|
|
23
|
-
<section id="{{ tab.id if tab.id else '
|
|
23
|
+
<section id="{{ tab.id if tab.id else tab.title|trim|replace(' ','-')|lower }}" class="ons-tabs__panel">
|
|
24
|
+
{% if tab.showTitle %}<h2 id="{{ tab.title|trim|replace(' ','-')|lower + '-content-title' }}" class="ons-u-vh">{{ tab.title }}</h2>{% endif %}
|
|
24
25
|
{{ tab.content | safe }}
|
|
25
26
|
</section>
|
|
26
|
-
{% endfor %}
|
|
27
|
+
{% endfor %}
|
|
27
28
|
</section>
|
|
28
29
|
{% endmacro %}
|
|
@@ -22,6 +22,23 @@ const EXAMPLE_TABS = {
|
|
|
22
22
|
],
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
const EXAMPLE_TABS_WITH_SHOWTITLE = {
|
|
26
|
+
title: 'Example tabs',
|
|
27
|
+
tabs: [
|
|
28
|
+
{
|
|
29
|
+
id: 'first-tab',
|
|
30
|
+
title: 'Tab 1',
|
|
31
|
+
showTitle: true,
|
|
32
|
+
content: 'Example content...',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'second-tab',
|
|
36
|
+
title: 'Tab 2',
|
|
37
|
+
content: 'Some nested <strong>strong element</strong>...',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
|
|
25
42
|
const EXAMPLE_TABS_WITHOUT_TAB_IDS = {
|
|
26
43
|
title: 'Example tabs',
|
|
27
44
|
tabs: [
|
|
@@ -88,8 +105,8 @@ describe('macro: tabs', () => {
|
|
|
88
105
|
it('has default tab id attribute values when identifiers are not provided', () => {
|
|
89
106
|
const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS_WITHOUT_TAB_IDS));
|
|
90
107
|
|
|
91
|
-
expect($('.ons-tabs__panel:first').attr('id')).toBe('
|
|
92
|
-
expect($('.ons-tabs__panel:last').attr('id')).toBe('
|
|
108
|
+
expect($('.ons-tabs__panel:first').attr('id')).toBe('tab-1');
|
|
109
|
+
expect($('.ons-tabs__panel:last').attr('id')).toBe('tab-2');
|
|
93
110
|
});
|
|
94
111
|
|
|
95
112
|
it('has expected label text in tab links and visually hidden span in tab 1', () => {
|
|
@@ -127,4 +144,10 @@ describe('macro: tabs', () => {
|
|
|
127
144
|
.trim(),
|
|
128
145
|
).toBe('Some nested <strong>strong element</strong>...');
|
|
129
146
|
});
|
|
147
|
+
|
|
148
|
+
it('displays a h2 when showTitle set to true', () => {
|
|
149
|
+
const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS_WITH_SHOWTITLE));
|
|
150
|
+
|
|
151
|
+
expect($('.ons-tabs__panel:first').find('h2').length).toBe(1);
|
|
152
|
+
});
|
|
130
153
|
});
|
|
@@ -11,24 +11,19 @@
|
|
|
11
11
|
margin: 0 0 1rem;
|
|
12
12
|
overflow: visible;
|
|
13
13
|
padding: 0;
|
|
14
|
-
|
|
14
|
+
width: max-content;
|
|
15
15
|
// Tabs
|
|
16
16
|
&--row {
|
|
17
17
|
margin: 0;
|
|
18
18
|
position: relative;
|
|
19
|
-
|
|
20
|
-
&::after {
|
|
21
|
-
background: var(--ons-color-borders);
|
|
22
|
-
bottom: 0;
|
|
23
|
-
box-shadow: 0 1px 0 0 var(--ons-color-page-light);
|
|
24
|
-
content: '';
|
|
25
|
-
height: 1px;
|
|
26
|
-
left: 0;
|
|
27
|
-
position: absolute;
|
|
28
|
-
width: 100%;
|
|
29
|
-
}
|
|
30
19
|
}
|
|
31
20
|
}
|
|
21
|
+
&__container {
|
|
22
|
+
border-bottom: 1px solid var(--ons-color-borders);
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
z-index: -2;
|
|
26
|
+
}
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
.ons-tab__list-item {
|
|
@@ -81,10 +76,12 @@
|
|
|
81
76
|
// Tab when selected
|
|
82
77
|
&[aria-selected='true'] {
|
|
83
78
|
background-color: var(--ons-color-page-light);
|
|
84
|
-
border-bottom:
|
|
79
|
+
border-bottom: 2px white;
|
|
85
80
|
border-color: var(--ons-color-borders);
|
|
86
81
|
border-radius: 3px 3px 0 0;
|
|
82
|
+
position: relative;
|
|
87
83
|
text-decoration: none;
|
|
84
|
+
top: 1px;
|
|
88
85
|
z-index: 1;
|
|
89
86
|
|
|
90
87
|
&:focus {
|
|
@@ -109,7 +106,7 @@
|
|
|
109
106
|
}
|
|
110
107
|
|
|
111
108
|
&:focus {
|
|
112
|
-
box-shadow: 0 0 0
|
|
109
|
+
box-shadow: 0 0 0 0 var(--ons-color-page-light), 0 0 0 2px var(--ons-color-text-link-focus), 0 0 0 6px var(--ons-color-focus);
|
|
113
110
|
outline: 3px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show box-shadows
|
|
114
111
|
z-index: 1;
|
|
115
112
|
}
|
|
@@ -137,7 +134,6 @@
|
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
.ons-tabs__list--row {
|
|
140
|
-
margin-bottom: -1px;
|
|
141
137
|
padding: 0;
|
|
142
138
|
}
|
|
143
139
|
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
{
|
|
8
8
|
"id": "ukis",
|
|
9
9
|
"title": 'UKIS',
|
|
10
|
+
"showTitle": true,
|
|
10
11
|
"hiddenSpan": 'for UKIS',
|
|
11
|
-
"content": '<
|
|
12
|
-
<h3>Aim of this survey</h3>
|
|
12
|
+
"content": '<h3>Aim of this survey</h3>
|
|
13
13
|
<p class="ons-u-fs-r">The aim of the UK Innovation Survey (UKIS) is to collect data from businesses about various aspects of their innovation related activities. Using this data we can measure the level, types and trends in innovation.</p>
|
|
14
14
|
<h3>How we’ll use this data</h3>
|
|
15
15
|
<p class="ons-u-fs-r">The UKIS data is a major source of evidence to inform government policy. It is used to promote innovation activities among businesses to boost economic growth. It is an important contribution to the European-wide Community Innovation Survey (CIS). The CIS is used for international benchmarking and comparison purposes.</p>
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
{
|
|
19
19
|
"id": "vacancy-survey",
|
|
20
20
|
"title": 'Vacancy survey',
|
|
21
|
-
"
|
|
22
|
-
<h3>Purpose</h3>
|
|
21
|
+
"showTitle": true,
|
|
22
|
+
"content": '<h3>Purpose</h3>
|
|
23
23
|
<p class="ons-u-fs-r">The Vacancy Survey is a regular survey of businesses, which provides an accurate and comprehensive measure of the total number of vacancies across the economy and fills a gap in the information available regarding the demand for labour. Before the Vacancy Survey was introduced, the only information available nationally about vacancies was from records of vacancies notified to Job Centres by employers. This provided only a partial picture, possibly less than half of all vacancies, because employers are under no obligation to notify vacancies to Job Centres. This business based survey has a more complete coverage and is included in the monthly ONS Labour Market Statistical Bulletin.</p>
|
|
24
24
|
<p>You can <a href="https://www.ons.gov.uk/surveys/informationforbusinesses/businesssurveys/vacancysurvey">find more information on the Vacancy Survey on the ONS website</a>.</p>'
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"id": "monthly-business-survey",
|
|
28
28
|
"title": 'Monthly Business Survey',
|
|
29
|
-
"
|
|
30
|
-
<h3>Aim of this survey</h3>
|
|
29
|
+
"showTitle": true,
|
|
30
|
+
"content": '<h3>Aim of this survey</h3>
|
|
31
31
|
<p class="ons-u-fs-r">The Monthly Business Survey (MBS) collects monthly information on employment of businesses in Great Britain. Your response contributes to Labour Market Statistics.</p>
|
|
32
32
|
<h4>What you need to know</h4>
|
|
33
33
|
<p class="ons-u-fs-r">To complete the survey, you will need the following information to answer the survey questions:</p>
|
package/components/tabs/tabs.js
CHANGED
|
@@ -10,7 +10,6 @@ const classTabTitle = 'ons-tabs__title';
|
|
|
10
10
|
const classTabList = 'ons-tabs__list';
|
|
11
11
|
const classTabListItems = 'ons-tab__list-item';
|
|
12
12
|
const classTabsPanel = 'ons-tabs__panel';
|
|
13
|
-
|
|
14
13
|
const matchMediaUtil = matchMedia;
|
|
15
14
|
|
|
16
15
|
export default class Tabs {
|
|
@@ -22,6 +21,7 @@ export default class Tabs {
|
|
|
22
21
|
this.tabsTitle = component.querySelector(`.${classTabTitle}`);
|
|
23
22
|
this.tabs = [...component.getElementsByClassName(classTab)];
|
|
24
23
|
this.tabList = component.getElementsByClassName(classTabList);
|
|
24
|
+
this.tabListContainer = this.tabList[0].parentElement;
|
|
25
25
|
this.tabListItems = [...component.getElementsByClassName(classTabListItems)];
|
|
26
26
|
this.tabPanels = [...component.getElementsByClassName(classTabsPanel)];
|
|
27
27
|
|
|
@@ -31,7 +31,6 @@ export default class Tabs {
|
|
|
31
31
|
this.jsTabAsListClass = 'ons-tab--row';
|
|
32
32
|
|
|
33
33
|
this.noInitialActiveTab = this.component.getAttribute('data-no-initial-active-tab');
|
|
34
|
-
|
|
35
34
|
if (matchMediaUtil.hasMatchMedia()) {
|
|
36
35
|
this.setupViewportChecks();
|
|
37
36
|
} else {
|
|
@@ -40,11 +39,22 @@ export default class Tabs {
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
// Set up checks for responsive functionality
|
|
43
|
-
// The tabs will display as tabs
|
|
44
|
-
// Tabs will display as a TOC list and show full content for <
|
|
45
|
-
// Aria tags are added only
|
|
42
|
+
// The tabs will display as tabs up until this.breakpoint is reached
|
|
43
|
+
// Tabs will display as a TOC list and show full content for <this.breakpoint viewports
|
|
44
|
+
// Aria tags are added only in toc view
|
|
46
45
|
setupViewportChecks() {
|
|
47
|
-
|
|
46
|
+
const breakpoint = () => {
|
|
47
|
+
let finalBreakpoint = 0;
|
|
48
|
+
this.tabListItems.forEach(tab => {
|
|
49
|
+
finalBreakpoint += tab.offsetWidth;
|
|
50
|
+
});
|
|
51
|
+
if (finalBreakpoint < 450) {
|
|
52
|
+
return (finalBreakpoint = 450);
|
|
53
|
+
} else {
|
|
54
|
+
return finalBreakpoint;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
this.viewport = matchMediaUtil(`(min-width: ${breakpoint()}px)`);
|
|
48
58
|
this.viewport.addListener(this.checkViewport.bind(this));
|
|
49
59
|
this.checkViewport();
|
|
50
60
|
}
|
|
@@ -62,9 +72,12 @@ export default class Tabs {
|
|
|
62
72
|
this.tabList[0].classList.add(this.jsTabListAsRowClass);
|
|
63
73
|
|
|
64
74
|
this.tabsTitle.classList.add('ons-u-vh');
|
|
65
|
-
|
|
75
|
+
this.tabListContainer.classList.add('ons-tabs__container');
|
|
66
76
|
this.tabPanels.forEach(panel => {
|
|
67
77
|
panel.setAttribute('tabindex', '0');
|
|
78
|
+
if (panel.querySelector('[id*="content-title"]')) {
|
|
79
|
+
panel.firstElementChild.classList.add('ons-u-vh');
|
|
80
|
+
}
|
|
68
81
|
});
|
|
69
82
|
|
|
70
83
|
this.tabListItems.forEach(item => {
|
|
@@ -96,11 +109,14 @@ export default class Tabs {
|
|
|
96
109
|
makeList() {
|
|
97
110
|
this.tabList[0].removeAttribute('role');
|
|
98
111
|
this.tabList[0].classList.remove(this.jsTabListAsRowClass);
|
|
99
|
-
|
|
112
|
+
this.tabListContainer.classList.remove('ons-tabs__container');
|
|
100
113
|
this.tabsTitle.classList.remove('ons-u-vh');
|
|
101
114
|
|
|
102
115
|
this.tabPanels.forEach(panel => {
|
|
103
116
|
panel.removeAttribute('tabindex', '0');
|
|
117
|
+
if (panel.firstElementChild.classList.contains('ons-u-vh')) {
|
|
118
|
+
panel.firstElementChild.classList.remove('ons-u-vh');
|
|
119
|
+
}
|
|
104
120
|
});
|
|
105
121
|
|
|
106
122
|
this.tabListItems.forEach(item => {
|
|
@@ -9,6 +9,7 @@ const EXAMPLE_TABS = {
|
|
|
9
9
|
{
|
|
10
10
|
id: 'tab.id.1',
|
|
11
11
|
title: 'Tab 1',
|
|
12
|
+
showTitle: true,
|
|
12
13
|
content: 'First content...',
|
|
13
14
|
},
|
|
14
15
|
{
|
|
@@ -24,6 +25,38 @@ const EXAMPLE_TABS = {
|
|
|
24
25
|
],
|
|
25
26
|
};
|
|
26
27
|
|
|
28
|
+
const EXAMPLE_TABS_LONGER = {
|
|
29
|
+
title: 'Example tabs',
|
|
30
|
+
tabs: [
|
|
31
|
+
{
|
|
32
|
+
id: 'tab.id.1',
|
|
33
|
+
title: 'Tab 1',
|
|
34
|
+
showTitle: true,
|
|
35
|
+
content: 'First content...',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'tab.id.2',
|
|
39
|
+
title: 'Tab 2',
|
|
40
|
+
content: 'Second content...',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'tab.id.3',
|
|
44
|
+
title: 'Tab 3',
|
|
45
|
+
content: 'Third content...',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'tab.id.4',
|
|
49
|
+
title: 'Tab 4',
|
|
50
|
+
content: 'Fourth content...',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'tab.id.5',
|
|
54
|
+
title: 'Tab 5',
|
|
55
|
+
content: 'Fifth content...',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
|
|
27
60
|
const EXAMPLE_TABS_WITH_NO_INITIAL_ACTIVE_TAB = {
|
|
28
61
|
...EXAMPLE_TABS,
|
|
29
62
|
noInitialActiveTab: true,
|
|
@@ -175,7 +208,7 @@ describe('script: tabs', () => {
|
|
|
175
208
|
beforeEach(async () => {
|
|
176
209
|
await page.emulate(puppeteer.devices['iPhone X']);
|
|
177
210
|
|
|
178
|
-
await setTestPage('/test', renderComponent('tabs',
|
|
211
|
+
await setTestPage('/test', renderComponent('tabs', EXAMPLE_TABS_LONGER));
|
|
179
212
|
});
|
|
180
213
|
|
|
181
214
|
it('has no aria attributes on tabs', async () => {
|
|
@@ -194,11 +227,16 @@ describe('script: tabs', () => {
|
|
|
194
227
|
|
|
195
228
|
it('has no hidden tab panels', async () => {
|
|
196
229
|
const panelCount = await page.$$eval('.ons-tabs__panel', nodes => nodes.length);
|
|
197
|
-
expect(panelCount).toBe(
|
|
230
|
+
expect(panelCount).toBe(5);
|
|
198
231
|
|
|
199
232
|
const hiddenPanelCount = await page.$$eval('.ons-tabs__panel--hidden', nodes => nodes.length);
|
|
200
233
|
expect(hiddenPanelCount).toBe(0);
|
|
201
234
|
});
|
|
235
|
+
|
|
236
|
+
it('displays a h2 element with a unique id', async () => {
|
|
237
|
+
const panelCount = await page.$$eval('#tab-1-content-title', nodes => nodes.length);
|
|
238
|
+
expect(panelCount).toBe(1);
|
|
239
|
+
});
|
|
202
240
|
});
|
|
203
241
|
|
|
204
242
|
describe('when `data-no-initial-active-tab` is present', () => {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
rows="{{ params.rows | default(8) }}"
|
|
27
27
|
{% if params.charCheckLimit and params.charCheckLimit.limit %}
|
|
28
28
|
maxlength="{{ params.charCheckLimit.limit }}"
|
|
29
|
-
data-char-limit-ref="{{ params.id }}-lim
|
|
30
|
-
aria-describedby="{{ params.id }}-lim
|
|
29
|
+
data-char-limit-ref="{{ params.id }}-lim"
|
|
30
|
+
aria-describedby="{{ params.id }}-lim"
|
|
31
31
|
{% endif %}
|
|
32
32
|
{% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
|
|
33
33
|
>{{ params.value if params.value }}</textarea>
|
|
@@ -216,13 +216,13 @@ describe('macro: textarea', () => {
|
|
|
216
216
|
it('has data attribute which references the character limit component', () => {
|
|
217
217
|
const $ = cheerio.load(renderComponent('textarea', EXAMPLE_TEXTAREA_WITH_CHARACTER_LIMIT));
|
|
218
218
|
|
|
219
|
-
expect($('.ons-input--textarea').attr('data-char-limit-ref')).toBe('example-id-lim
|
|
219
|
+
expect($('.ons-input--textarea').attr('data-char-limit-ref')).toBe('example-id-lim');
|
|
220
220
|
});
|
|
221
221
|
|
|
222
222
|
it('has `aria-describedby` attribute which references the character limit component', () => {
|
|
223
223
|
const $ = cheerio.load(renderComponent('textarea', EXAMPLE_TEXTAREA_WITH_CHARACTER_LIMIT));
|
|
224
224
|
|
|
225
|
-
expect($('.ons-input--textarea').attr('aria-describedby')).toBe('example-id-lim
|
|
225
|
+
expect($('.ons-input--textarea').attr('aria-describedby')).toBe('example-id-lim');
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
it('renders character limit component', () => {
|
|
@@ -24,7 +24,7 @@ describe('script: textarea', () => {
|
|
|
24
24
|
|
|
25
25
|
describe('Given that the char limit helper has initialised correctly', () => {
|
|
26
26
|
it('the char limit readout should be visible', async () => {
|
|
27
|
-
const hasClass = await page.$eval('#example-textarea-lim
|
|
27
|
+
const hasClass = await page.$eval('#example-textarea-lim', node => node.classList.contains('ons-u-d-no'));
|
|
28
28
|
expect(hasClass).toBe(false);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
@@ -36,7 +36,7 @@ describe('script: textarea', () => {
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it('then the characters remaining readout reflect the number of characters remaining', async () => {
|
|
39
|
-
const readout = await page.$eval('#example-textarea-lim
|
|
39
|
+
const readout = await page.$eval('#example-textarea-lim', node => node.textContent);
|
|
40
40
|
expect(readout).toBe('You have 12 characters remaining');
|
|
41
41
|
});
|
|
42
42
|
});
|
|
@@ -47,7 +47,7 @@ describe('script: textarea', () => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it('then the characters remaining readout reflect the number of characters remaining', async () => {
|
|
50
|
-
const readout = await page.$eval('#example-textarea-lim
|
|
50
|
+
const readout = await page.$eval('#example-textarea-lim', node => node.textContent);
|
|
51
51
|
expect(readout).toBe('You have 0 characters remaining');
|
|
52
52
|
});
|
|
53
53
|
|
|
@@ -57,9 +57,7 @@ describe('script: textarea', () => {
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
it('then the readout should be given limit reached classes', async () => {
|
|
60
|
-
const hasClass = await page.$eval('#example-textarea-lim
|
|
61
|
-
node.classList.contains('ons-input__limit--reached'),
|
|
62
|
-
);
|
|
60
|
+
const hasClass = await page.$eval('#example-textarea-lim', node => node.classList.contains('ons-input__limit--reached'));
|
|
63
61
|
expect(hasClass).toBe(true);
|
|
64
62
|
});
|
|
65
63
|
});
|
|
@@ -77,7 +75,7 @@ describe('script: textarea', () => {
|
|
|
77
75
|
});
|
|
78
76
|
|
|
79
77
|
it('then the characters remaining readout reflect the number of characters remaining', async () => {
|
|
80
|
-
const readout = await page.$eval('#example-textarea-lim
|
|
78
|
+
const readout = await page.$eval('#example-textarea-lim', node => node.textContent);
|
|
81
79
|
expect(readout).toBe('You have 1 character remaining');
|
|
82
80
|
});
|
|
83
81
|
|
|
@@ -87,9 +85,7 @@ describe('script: textarea', () => {
|
|
|
87
85
|
});
|
|
88
86
|
|
|
89
87
|
it('then the readout should not be given limit reached classes', async () => {
|
|
90
|
-
const hasClass = await page.$eval('#example-textarea-lim
|
|
91
|
-
node.classList.contains('ons-input__limit--reached'),
|
|
92
|
-
);
|
|
88
|
+
const hasClass = await page.$eval('#example-textarea-lim', node => node.classList.contains('ons-input__limit--reached'));
|
|
93
89
|
expect(hasClass).toBe(false);
|
|
94
90
|
});
|
|
95
91
|
});
|
|
@@ -65,7 +65,7 @@ describe('macro: timeline', () => {
|
|
|
65
65
|
|
|
66
66
|
it('has the provided inner item list', () => {
|
|
67
67
|
const faker = templateFaker();
|
|
68
|
-
const listSpy = faker.spy('
|
|
68
|
+
const listSpy = faker.spy('list');
|
|
69
69
|
|
|
70
70
|
faker.renderComponent('timeline', EXAMPLE_TIMELINE);
|
|
71
71
|
|