@ons/design-system 54.0.0 → 55.1.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/autosuggest/_autosuggest.scss +4 -4
- package/components/autosuggest/autosuggest.spec.js +12 -2
- package/components/autosuggest/autosuggest.ui.js +4 -7
- package/components/browser-banner/_macro.njk +1 -1
- package/components/browser-banner/_macro.spec.js +31 -0
- package/components/button/_button.scss +28 -7
- package/components/button/_macro.njk +1 -1
- package/components/button/_macro.spec.js +2 -2
- package/components/checkboxes/_checkbox.scss +50 -17
- package/components/collapsible/_collapsible.scss +2 -1
- package/components/document-list/document-list.scss +2 -0
- package/components/download-resources/download-resources.js +19 -0
- package/components/download-resources/download-resources.spec.js +95 -0
- package/components/external-link/_macro.njk +1 -1
- package/components/external-link/_macro.spec.js +2 -2
- package/components/fieldset/_fieldset.scss +11 -1
- package/components/fieldset/_macro.njk +9 -8
- package/components/fieldset/_macro.spec.js +27 -5
- package/components/footer/_footer.scss +1 -0
- package/components/footer/_macro.njk +1 -1
- package/components/footer/_macro.spec.js +18 -0
- package/components/header/_header.scss +7 -2
- package/components/header/_macro.njk +34 -8
- package/components/header/_macro.spec.js +82 -14
- package/components/hero/_macro.njk +1 -1
- package/components/hero/_macro.spec.js +1 -1
- package/components/icons/_macro.njk +1 -1
- package/components/input/_input-type.scss +37 -3
- package/components/input/_input.scss +28 -9
- package/components/input/_macro.njk +15 -17
- package/components/label/_label.scss +1 -1
- package/components/label/_macro.njk +27 -15
- package/components/label/_macro.spec.js +31 -0
- package/components/lists/_macro.njk +1 -1
- package/components/lists/_macro.spec.js +2 -2
- package/components/message/_message.scss +1 -0
- package/components/modal/_macro.njk +2 -2
- package/components/modal/_modal.scss +10 -9
- package/components/navigation/_macro.njk +1 -2
- package/components/navigation/_macro.spec.js +0 -1
- package/components/pagination/_pagination.scss +1 -0
- package/components/panel/_macro.njk +6 -9
- package/components/panel/_macro.spec.js +23 -20
- package/components/panel/_panel.scss +13 -5
- package/components/phase-banner/_macro.njk +1 -1
- package/components/phase-banner/_macro.spec.js +31 -0
- package/components/phase-banner/_phase-banner.scss +1 -0
- package/components/radios/_radio.scss +16 -4
- package/components/relationships/_relationships.scss +2 -2
- package/components/reply/_macro.njk +2 -2
- package/components/skip-to-content/_skip.scss +2 -1
- package/components/table/_macro.njk +3 -2
- package/components/table/_macro.spec.js +0 -27
- package/components/table/_table.scss +15 -7
- package/components/table/sortable-table.js +1 -0
- package/components/tabs/_tabs.scss +57 -34
- package/components/tabs/tabs.js +4 -2
- package/components/upload/_upload.scss +2 -2
- package/css/census.css +1 -1
- package/css/ids.css +1 -1
- package/css/main.css +1 -1
- package/layout/_template.njk +25 -12
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_global.scss +1 -0
- package/scss/overrides/hcm.scss +205 -46
- package/scss/patternlib.scss +1 -56
- package/scss/vars/_colors.scss +2 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{% from "components/error/_macro.njk" import onsError %}
|
|
2
2
|
|
|
3
3
|
{% macro onsFieldset(params) %}
|
|
4
|
+
{% set descriptionID = (params.id ~ "-" if params.id else "") ~ "legend-description" %}
|
|
4
5
|
{% set fieldset -%}
|
|
5
6
|
{% if params.dontWrap is defined and params.dontWrap -%}
|
|
6
7
|
<div class="ons-input-items">
|
|
@@ -12,20 +13,20 @@
|
|
|
12
13
|
class="ons-fieldset{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
|
|
13
14
|
{% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
|
|
14
15
|
>
|
|
15
|
-
<legend class="ons-fieldset__legend{% if params.legendIsQuestionTitle
|
|
16
|
+
<legend{% if params.description %} aria-describedBy="{{ descriptionID }}"{% endif %} class="ons-fieldset__legend{% if params.legendIsQuestionTitle %} ons-u-mb-no{% endif %}{% if params.legendClasses is defined and params.legendClasses %} {{ params.legendClasses }}{% endif %}{% if params.description %} ons-fieldset__legend--with-description{% endif %}">
|
|
16
17
|
{%- if params.legendIsQuestionTitle -%}
|
|
17
|
-
<h1 id="fieldset-legend-title" class="ons-fieldset__legend-title
|
|
18
|
+
<h1 id="fieldset-legend-title" class="ons-fieldset__legend-title{% if params.legendTitleClasses is defined and params.legendTitleClasses %} {{ params.legendTitleClasses }}{% endif %}">
|
|
18
19
|
{{- params.legend | safe -}}
|
|
19
20
|
</h1>
|
|
20
21
|
{%- else -%}
|
|
21
|
-
<span class="ons-fieldset__legend-title">{{- params.legend | safe -}}</span>
|
|
22
|
-
{%- endif -%}
|
|
23
|
-
{%- if params.description is defined and params.description -%}
|
|
24
|
-
<div class="ons-fieldset__description{% if params.legendIsQuestionTitle %} ons-fieldset__description--title ons-u-mb-m{% endif %}">
|
|
25
|
-
{{- params.description | safe -}}
|
|
26
|
-
</div>
|
|
22
|
+
<span class="ons-fieldset__legend-title ons-u-pb-no">{{- params.legend | safe -}}</span>
|
|
27
23
|
{%- endif -%}
|
|
28
24
|
</legend>
|
|
25
|
+
{%- if params.description -%}
|
|
26
|
+
<div id="{{ descriptionID }}" class="ons-fieldset__description{% if params.legendIsQuestionTitle %} ons-fieldset__description--title ons-u-mb-m{% endif %}">
|
|
27
|
+
{{- params.description | safe -}}
|
|
28
|
+
</div>
|
|
29
|
+
{%- endif -%}
|
|
29
30
|
{{- caller() if caller -}}
|
|
30
31
|
</fieldset>
|
|
31
32
|
{%- endif %}
|
|
@@ -32,6 +32,13 @@ describe('macro: fieldset', () => {
|
|
|
32
32
|
expect(title).toBe('Fieldset legend');
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
it('has the correct `aria-decribedby` value', () => {
|
|
36
|
+
const $ = cheerio.load(renderComponent('fieldset', EXAMPLE_FIELDSET_BASIC));
|
|
37
|
+
|
|
38
|
+
const ariaDescByVal = $('.ons-fieldset__legend').attr('aria-describedby');
|
|
39
|
+
expect(ariaDescByVal).toBe('example-fieldset-legend-description');
|
|
40
|
+
});
|
|
41
|
+
|
|
35
42
|
it('has the `description` text', () => {
|
|
36
43
|
const $ = cheerio.load(renderComponent('fieldset', EXAMPLE_FIELDSET_BASIC));
|
|
37
44
|
|
|
@@ -41,6 +48,26 @@ describe('macro: fieldset', () => {
|
|
|
41
48
|
expect(title).toBe('A fieldset description');
|
|
42
49
|
});
|
|
43
50
|
|
|
51
|
+
it('has the correct `description` `id` when no `fieldset `id` is provided', () => {
|
|
52
|
+
const $ = cheerio.load(renderComponent('fieldset', { ...EXAMPLE_FIELDSET_BASIC, id: undefined }));
|
|
53
|
+
|
|
54
|
+
const id = $('.ons-fieldset__description').attr('id');
|
|
55
|
+
expect(id).toBe('legend-description');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('has the correct `description` `id` when `fieldset `id` is provided', () => {
|
|
59
|
+
const $ = cheerio.load(renderComponent('fieldset', EXAMPLE_FIELDSET_BASIC));
|
|
60
|
+
|
|
61
|
+
const id = $('.ons-fieldset__description').attr('id');
|
|
62
|
+
expect(id).toBe('example-fieldset-legend-description');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('has the correct `legend` class when `description` is provided', () => {
|
|
66
|
+
const $ = cheerio.load(renderComponent('fieldset', EXAMPLE_FIELDSET_BASIC));
|
|
67
|
+
|
|
68
|
+
expect($('.ons-fieldset__legend').hasClass('ons-fieldset__legend--with-description')).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
|
|
44
71
|
it('has additionally provided style classes', () => {
|
|
45
72
|
const $ = cheerio.load(
|
|
46
73
|
renderComponent('fieldset', {
|
|
@@ -123,11 +150,6 @@ describe('macro: fieldset', () => {
|
|
|
123
150
|
expect(results).toHaveNoViolations();
|
|
124
151
|
});
|
|
125
152
|
|
|
126
|
-
it('has the correct class', () => {
|
|
127
|
-
const $ = cheerio.load(renderComponent('fieldset', { ...EXAMPLE_FIELDSET_BASIC, legendIsQuestionTitle: true }));
|
|
128
|
-
expect($('.ons-fieldset__legend').hasClass('ons-u-mb-no')).toBe(true);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
153
|
it('renders the legend in a H1', () => {
|
|
132
154
|
const $ = cheerio.load(renderComponent('fieldset', { ...EXAMPLE_FIELDSET_BASIC, legendIsQuestionTitle: true }));
|
|
133
155
|
const titleTag = $('.ons-fieldset__legend-title')[0].tagName;
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
{% endif %}
|
|
83
83
|
|
|
84
84
|
<div class="ons-footer__body{{ ' ' + params.classes if params.classes else '' }}" data-analytics="footer" {% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}>
|
|
85
|
-
<div class="ons-container{{ ' ons-container--wide' if params.wide }}">
|
|
85
|
+
<div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
|
|
86
86
|
<div class="ons-grid">
|
|
87
87
|
{% if params.newTabWarning is defined and params.newTabWarning %}
|
|
88
88
|
<div class="ons-grid__col">
|
|
@@ -102,6 +102,24 @@ describe('macro: footer', () => {
|
|
|
102
102
|
expect(hasClass).toBe(false);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
+
it('decorates container block with `fullWidth` modifier when the `fullWidth` parameter is provided', () => {
|
|
106
|
+
const $ = cheerio.load(
|
|
107
|
+
renderComponent('footer', {
|
|
108
|
+
fullWidth: true,
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const hasClass = $('.ons-container').hasClass('ons-container--full-width');
|
|
113
|
+
expect(hasClass).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('does not decorate container block with `fullWidth` modifier when the `fullWidth` parameter is not provided', () => {
|
|
117
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
118
|
+
|
|
119
|
+
const hasClass = $('.ons-container').hasClass('ons-container--full-width');
|
|
120
|
+
expect(hasClass).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
|
|
105
123
|
it('has additionally provided `attributes` on the `body` element', () => {
|
|
106
124
|
const $ = cheerio.load(
|
|
107
125
|
renderComponent('footer', {
|
|
@@ -101,11 +101,12 @@
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
&__grid-top {
|
|
104
|
+
color: $color-text-inverse;
|
|
104
105
|
min-height: 36px;
|
|
105
106
|
a {
|
|
106
|
-
color: $color-
|
|
107
|
+
color: $color-text-inverse;
|
|
107
108
|
&:hover {
|
|
108
|
-
text-decoration: underline solid $color-
|
|
109
|
+
text-decoration: underline solid $color-text-inverse-link-hover 3px;
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
}
|
|
@@ -208,6 +209,10 @@
|
|
|
208
209
|
&:first-child {
|
|
209
210
|
margin-left: 0;
|
|
210
211
|
}
|
|
212
|
+
.ons-svg-icon {
|
|
213
|
+
clip-path: circle(9px at center);
|
|
214
|
+
margin-right: 0.5rem;
|
|
215
|
+
}
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
.ons-language-links {
|
|
@@ -16,12 +16,19 @@
|
|
|
16
16
|
{{
|
|
17
17
|
onsBrowserBanner({
|
|
18
18
|
"lang": currentLanguageISOCode,
|
|
19
|
-
"wide": params.wide
|
|
19
|
+
"wide": params.wide,
|
|
20
|
+
"fullWidth": params.fullWidth
|
|
20
21
|
})
|
|
21
22
|
}}
|
|
22
23
|
{% if params.phase is defined and params.phase %}
|
|
23
24
|
{% from "components/phase-banner/_macro.njk" import onsPhaseBanner %}
|
|
24
|
-
{{ onsPhaseBanner(
|
|
25
|
+
{{ onsPhaseBanner({
|
|
26
|
+
"fullWidth": params.fullWidth,
|
|
27
|
+
"wide": params.wide,
|
|
28
|
+
"hideBadge": params.phase.hideBadge,
|
|
29
|
+
"badge": params.phase.badge,
|
|
30
|
+
"html": params.phase.html
|
|
31
|
+
}) }}
|
|
25
32
|
{% endif %}
|
|
26
33
|
{% if params.noMasthead != true %}
|
|
27
34
|
<div class="ons-header__top">
|
|
@@ -72,14 +79,25 @@
|
|
|
72
79
|
{% endif %}
|
|
73
80
|
<div class="ons-grid__col ons-col-auto{% if controlVisibility == true %} ons-u-d-no@xxs@{{ breakpoint }}{% endif %}">
|
|
74
81
|
<nav class="ons-header-service-nav ons-header-service-nav--main {{ params.serviceLinks.classes }}" aria-label="{{ params.serviceLinks.ariaLabel | default("Service links navigation") }}">
|
|
75
|
-
<ul class="ons-header-service-nav__list"
|
|
82
|
+
<ul class="ons-header-service-nav__list">
|
|
76
83
|
{% for item in (params.serviceLinks.itemsList if params.serviceLinks.itemsList is iterable else params.serviceLinks.itemsList.items()) %}
|
|
77
84
|
<li class="ons-header-service-nav__item">
|
|
85
|
+
{% if item.iconType is defined and item.iconType %}
|
|
86
|
+
{{
|
|
87
|
+
onsIcon({
|
|
88
|
+
"iconType": item.iconType
|
|
89
|
+
})
|
|
90
|
+
}}
|
|
91
|
+
{% endif %}
|
|
92
|
+
{% if item.url is defined and item.url %}
|
|
78
93
|
<a
|
|
79
94
|
href="{{ item.url }}"
|
|
80
95
|
class="ons-header-service-nav__link"
|
|
81
96
|
{% if item.id is defined and item.id %} id="{{ item.id }}"{% endif %}
|
|
82
97
|
>{{ item.title }}</a>
|
|
98
|
+
{% else %}
|
|
99
|
+
{{ item.title }}
|
|
100
|
+
{% endif %}
|
|
83
101
|
</li>
|
|
84
102
|
{% endfor %}
|
|
85
103
|
</ul>
|
|
@@ -101,7 +119,6 @@
|
|
|
101
119
|
"attributes": {
|
|
102
120
|
"aria-label": params.serviceLinks.toggleServicesButton.ariaLabel | default("Toggle menu"),
|
|
103
121
|
"aria-controls": params.serviceLinks.id,
|
|
104
|
-
"aria-haspopup": "true",
|
|
105
122
|
"aria-expanded": "false"
|
|
106
123
|
}
|
|
107
124
|
}) }}
|
|
@@ -114,14 +131,25 @@
|
|
|
114
131
|
</div>
|
|
115
132
|
{% if params.serviceLinks is defined and params.serviceLinks %}
|
|
116
133
|
<nav class="ons-header-service-nav ons-header-service-nav--mobile ons-u-d-no ons-js-services-mobile-nav" id="{{ params.serviceLinks.id }}" aria-label="{{ params.serviceLinks.ariaLabel | default("Service links navigation") }}">
|
|
117
|
-
<ul class="ons-header-service-nav__list"
|
|
134
|
+
<ul class="ons-header-service-nav__list">
|
|
118
135
|
{% for item in (params.serviceLinks.itemsList if params.serviceLinks.itemsList is iterable else params.serviceLinks.itemsList.items()) %}
|
|
119
136
|
<li class="ons-header-service-nav__item ons-header-service-nav__item--mobile">
|
|
137
|
+
{% if item.iconType is defined and item.iconType %}
|
|
138
|
+
{{
|
|
139
|
+
onsIcon({
|
|
140
|
+
"iconType": item.iconType
|
|
141
|
+
})
|
|
142
|
+
}}
|
|
143
|
+
{% endif %}
|
|
144
|
+
{% if item.url is defined and item.url %}
|
|
120
145
|
<a
|
|
121
146
|
href="{{ item.url }}"
|
|
122
147
|
class="ons-header-service-nav__link"
|
|
123
148
|
{% if item.id is defined and item.id %} id="{{ item.id }}"{% endif %}
|
|
124
149
|
>{{ item.title }}</a>
|
|
150
|
+
{% else %}
|
|
151
|
+
{{ item.title }}
|
|
152
|
+
{% endif %}
|
|
125
153
|
</li>
|
|
126
154
|
{% endfor %}
|
|
127
155
|
{% if params.language is defined and params.language %}
|
|
@@ -179,7 +207,7 @@
|
|
|
179
207
|
<p class="ons-header__description">{{ params.description }}</p>
|
|
180
208
|
{% endif %}
|
|
181
209
|
</div>
|
|
182
|
-
|
|
210
|
+
|
|
183
211
|
{% if params.button is defined and params.button %}
|
|
184
212
|
{% if params.variants == 'neutral' %}
|
|
185
213
|
{% set buttonVariant = ["ghost", "ghost-dark"] %}
|
|
@@ -225,7 +253,6 @@
|
|
|
225
253
|
"attributes": {
|
|
226
254
|
"aria-label": "Toggle search" ,
|
|
227
255
|
"aria-controls": "ons-site-search",
|
|
228
|
-
"aria-haspopup": "true",
|
|
229
256
|
"aria-expanded": "false"
|
|
230
257
|
}
|
|
231
258
|
}) }}
|
|
@@ -245,7 +272,6 @@
|
|
|
245
272
|
"attributes": {
|
|
246
273
|
"aria-label": params.navigation.toggleNavigationButton.ariaLabel | default("Toggle main menu") ,
|
|
247
274
|
"aria-controls": params.navigation.id,
|
|
248
|
-
"aria-haspopup": "true",
|
|
249
275
|
"aria-expanded": "false"
|
|
250
276
|
}
|
|
251
277
|
}) }}
|
|
@@ -13,7 +13,6 @@ const EXAMPLE_HEADER_BASIC = {
|
|
|
13
13
|
const EXAMPLE_SERVICE_LINKS_CONFIG = {
|
|
14
14
|
id: 'service-links',
|
|
15
15
|
ariaLabel: 'Services menu',
|
|
16
|
-
ariaListLabel: 'Menu',
|
|
17
16
|
classes: 'custom-class',
|
|
18
17
|
toggleServicesButton: {
|
|
19
18
|
text: 'Menu',
|
|
@@ -21,6 +20,24 @@ const EXAMPLE_SERVICE_LINKS_CONFIG = {
|
|
|
21
20
|
},
|
|
22
21
|
};
|
|
23
22
|
|
|
23
|
+
const EXAMPLE_HEADER_SERVICE_LIST_ITEMS = {
|
|
24
|
+
...EXAMPLE_HEADER_BASIC,
|
|
25
|
+
serviceLinks: {
|
|
26
|
+
...EXAMPLE_SERVICE_LINKS_CONFIG,
|
|
27
|
+
itemsList: [
|
|
28
|
+
{
|
|
29
|
+
title: 'Title 1',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'Title 2',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'Title 3',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
24
41
|
const EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE = {
|
|
25
42
|
...EXAMPLE_HEADER_BASIC,
|
|
26
43
|
serviceLinks: {
|
|
@@ -339,12 +356,51 @@ describe('macro: header', () => {
|
|
|
339
356
|
const faker = templateFaker();
|
|
340
357
|
const phaseSpy = faker.spy('phase-banner');
|
|
341
358
|
|
|
342
|
-
faker.renderComponent('header', {
|
|
359
|
+
faker.renderComponent('header', {
|
|
360
|
+
...EXAMPLE_HEADER_BASIC,
|
|
361
|
+
phase: {
|
|
362
|
+
badge: 'Example',
|
|
363
|
+
html: 'Example content with a <a href="#">link</a>',
|
|
364
|
+
},
|
|
365
|
+
});
|
|
343
366
|
|
|
344
367
|
expect(phaseSpy.occurrences).toContainEqual({
|
|
368
|
+
badge: 'Example',
|
|
345
369
|
html: 'Example content with a <a href="#">link</a>',
|
|
346
370
|
});
|
|
347
371
|
});
|
|
372
|
+
|
|
373
|
+
it('renders the phase banner in the correct container if `wide`', () => {
|
|
374
|
+
const $ = cheerio.load(
|
|
375
|
+
renderComponent('header', {
|
|
376
|
+
...EXAMPLE_HEADER_BASIC,
|
|
377
|
+
wide: true,
|
|
378
|
+
phase: {
|
|
379
|
+
badge: 'Example',
|
|
380
|
+
html: 'Example content with a <a href="#">link</a>',
|
|
381
|
+
},
|
|
382
|
+
}),
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
const phaseContainer = $('.ons-phase-banner .ons-container');
|
|
386
|
+
expect($(phaseContainer).hasClass('ons-container--wide')).toBe(true);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it('renders the phase banner in the correct container if `fullWidth`', () => {
|
|
390
|
+
const $ = cheerio.load(
|
|
391
|
+
renderComponent('header', {
|
|
392
|
+
...EXAMPLE_HEADER_BASIC,
|
|
393
|
+
fullWidth: true,
|
|
394
|
+
phase: {
|
|
395
|
+
badge: 'Example',
|
|
396
|
+
html: 'Example content with a <a href="#">link</a>',
|
|
397
|
+
},
|
|
398
|
+
}),
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
const phaseContainer = $('.ons-phase-banner .ons-container');
|
|
402
|
+
expect($(phaseContainer).hasClass('ons-container--full-width')).toBe(true);
|
|
403
|
+
});
|
|
348
404
|
});
|
|
349
405
|
|
|
350
406
|
describe('mode: with service links', () => {
|
|
@@ -378,10 +434,11 @@ describe('macro: header', () => {
|
|
|
378
434
|
expect($('.ons-header-service-nav--main').attr('aria-label')).toBe('Services menu');
|
|
379
435
|
});
|
|
380
436
|
|
|
381
|
-
it('has the
|
|
382
|
-
const $ = cheerio.load(renderComponent('header',
|
|
437
|
+
it('has the text for each list item', () => {
|
|
438
|
+
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LIST_ITEMS));
|
|
383
439
|
|
|
384
|
-
|
|
440
|
+
const values = mapAll($('.ons-header-service-nav--main .ons-header-service-nav__item'), node => node.text().trim());
|
|
441
|
+
expect(values).toEqual(['Title 1', 'Title 2', 'Title 3']);
|
|
385
442
|
});
|
|
386
443
|
|
|
387
444
|
it('has the link text for each list item', () => {
|
|
@@ -410,12 +467,6 @@ describe('macro: header', () => {
|
|
|
410
467
|
expect($('.ons-header-service-nav--mobile').attr('aria-label')).toBe('Services menu');
|
|
411
468
|
});
|
|
412
469
|
|
|
413
|
-
it('has the provided `aria-label` for the list for mobile', () => {
|
|
414
|
-
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LINKS_SINGLE));
|
|
415
|
-
|
|
416
|
-
expect($('.ons-header-service-nav--mobile .ons-header-service-nav__list').attr('aria-label')).toBe('Menu');
|
|
417
|
-
});
|
|
418
|
-
|
|
419
470
|
it('has the link text for each list item for mobile', () => {
|
|
420
471
|
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE));
|
|
421
472
|
|
|
@@ -445,7 +496,6 @@ describe('macro: header', () => {
|
|
|
445
496
|
attributes: {
|
|
446
497
|
'aria-label': 'Toggle services menu',
|
|
447
498
|
'aria-controls': 'service-links',
|
|
448
|
-
'aria-haspopup': 'true',
|
|
449
499
|
'aria-expanded': 'false',
|
|
450
500
|
},
|
|
451
501
|
});
|
|
@@ -481,6 +531,26 @@ describe('macro: header', () => {
|
|
|
481
531
|
|
|
482
532
|
expect($('.ons-js-toggle-services').length).toBe(0);
|
|
483
533
|
});
|
|
534
|
+
|
|
535
|
+
it('has the correct list item icon', () => {
|
|
536
|
+
const faker = templateFaker();
|
|
537
|
+
const iconsSpy = faker.spy('icons');
|
|
538
|
+
|
|
539
|
+
faker.renderComponent('header', {
|
|
540
|
+
...EXAMPLE_HEADER_BASIC,
|
|
541
|
+
serviceLinks: {
|
|
542
|
+
...EXAMPLE_SERVICE_LINKS_CONFIG,
|
|
543
|
+
itemsList: [
|
|
544
|
+
{
|
|
545
|
+
title: 'Title 1',
|
|
546
|
+
iconType: 'check',
|
|
547
|
+
},
|
|
548
|
+
],
|
|
549
|
+
},
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
expect(iconsSpy.occurrences[2].iconType).toBe('check');
|
|
553
|
+
});
|
|
484
554
|
});
|
|
485
555
|
|
|
486
556
|
describe('mode: with language selector', () => {
|
|
@@ -558,7 +628,6 @@ describe('macro: header', () => {
|
|
|
558
628
|
attributes: {
|
|
559
629
|
'aria-label': 'Toggle main menu',
|
|
560
630
|
'aria-controls': 'main-nav',
|
|
561
|
-
'aria-haspopup': 'true',
|
|
562
631
|
'aria-expanded': 'false',
|
|
563
632
|
},
|
|
564
633
|
});
|
|
@@ -601,7 +670,6 @@ describe('macro: header', () => {
|
|
|
601
670
|
attributes: {
|
|
602
671
|
'aria-label': 'Toggle search',
|
|
603
672
|
'aria-controls': 'ons-site-search',
|
|
604
|
-
'aria-haspopup': 'true',
|
|
605
673
|
'aria-expanded': 'false',
|
|
606
674
|
},
|
|
607
675
|
});
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
<header>
|
|
27
27
|
{% if params.preTitleImage is defined and params.preTitleImage %}
|
|
28
|
-
{% set preTitleImageWithModifier = params.preTitleImage.name
|
|
28
|
+
{% set preTitleImageWithModifier = params.preTitleImage.name ~ "--" ~ skinName ~ ".svg" %}
|
|
29
29
|
<img class="ons-hero__pre-title" src="{{ params.placeholderURL }}/img/{{ preTitleImageWithModifier }}" alt="{{ params.preTitleImage.alt }}">
|
|
30
30
|
{% endif %}
|
|
31
31
|
{% if params.title is defined and params.title %}
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
<path 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"/>
|
|
63
63
|
</svg>
|
|
64
64
|
{% elif params.iconType == "sort-sprite" %}
|
|
65
|
-
<svg id="sort-sprite{% if params.id is defined and params.id %}-{{ params.id | lower }}{% endif %}" class="ons-svg-icon
|
|
65
|
+
<svg id="sort-sprite{% if params.id is defined and params.id %}-{{ params.id | lower }}{% endif %}" class="ons-svg-icon{{ iconClasses }}" viewBox="0 0 12 19" xmlns="http://www.w3.org/2000/svg" focusable="false" fill="currentColor">
|
|
66
66
|
<path class="ons-topTriangle" d="M6 0l6 7.2H0L6 0zm0 18.6l6-7.2H0l6 7.2zm0 3.6l6 7.2H0l6-7.2z"/>
|
|
67
67
|
<path class="ons-bottomTriangle" d="M6 18.6l6-7.2H0l6 7.2zm0 3.6l6 7.2H0l6-7.2z"/>
|
|
68
68
|
</svg>
|
|
@@ -14,7 +14,16 @@
|
|
|
14
14
|
z-index: 1;
|
|
15
15
|
|
|
16
16
|
&:focus {
|
|
17
|
-
|
|
17
|
+
// Overide default input focus so it can wrap prefix/suffix too
|
|
18
|
+
box-shadow: none;
|
|
19
|
+
outline: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Overide default input error style so it can wrap prefix/suffix too
|
|
23
|
+
&.ons-input--error:not(:focus) {
|
|
24
|
+
border-right: $input-border-width solid $color-input-border;
|
|
25
|
+
box-shadow: none;
|
|
26
|
+
outline: none;
|
|
18
27
|
}
|
|
19
28
|
}
|
|
20
29
|
|
|
@@ -36,13 +45,15 @@
|
|
|
36
45
|
|
|
37
46
|
&__type,
|
|
38
47
|
&__type[title] {
|
|
39
|
-
border: 1px solid $color-input;
|
|
48
|
+
border: 1px solid $color-input-border;
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
&__input:focus + &__type::after {
|
|
52
|
+
// Style input + prefix/suffix on focus
|
|
53
|
+
@extend %ons-input-focus;
|
|
54
|
+
|
|
43
55
|
border-radius: $input-radius;
|
|
44
56
|
bottom: 0;
|
|
45
|
-
box-shadow: 0 0 0 3px $color-focus;
|
|
46
57
|
content: '';
|
|
47
58
|
display: block;
|
|
48
59
|
left: 0;
|
|
@@ -75,3 +86,26 @@
|
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
}
|
|
89
|
+
|
|
90
|
+
// Errors
|
|
91
|
+
.ons-input--error:not(:focus) {
|
|
92
|
+
& + .ons-input-type__type,
|
|
93
|
+
& + .ons-input-type__type[title] {
|
|
94
|
+
border-color: $color-errors;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
& + .ons-input-type__type::after {
|
|
98
|
+
border-radius: $input-radius;
|
|
99
|
+
bottom: 0;
|
|
100
|
+
|
|
101
|
+
// Style input + prefix/suffix for errors
|
|
102
|
+
box-shadow: 0 0 0 1px $color-errors;
|
|
103
|
+
content: '';
|
|
104
|
+
display: block;
|
|
105
|
+
left: 0;
|
|
106
|
+
outline: 1px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show box-shadows
|
|
107
|
+
position: absolute;
|
|
108
|
+
right: 0;
|
|
109
|
+
top: 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
%ons-input-focus {
|
|
2
|
-
box-shadow: 0 0 0
|
|
3
|
-
|
|
2
|
+
box-shadow: 0 0 0 $input-border-width $color-input-border, 0 0 0 4px $color-focus;
|
|
3
|
+
|
|
4
|
+
// Add transparent outline because Windows High Contrast Mode doesn't show box-shadows
|
|
5
|
+
outline: 3px solid transparent;
|
|
6
|
+
outline-offset: 1px;
|
|
7
|
+
|
|
8
|
+
@media screen and (forced-colors: active) {
|
|
9
|
+
// To better match the focus states of native controls
|
|
10
|
+
outline-color: Highlight;
|
|
11
|
+
}
|
|
4
12
|
}
|
|
5
13
|
|
|
6
14
|
.ons-input {
|
|
7
|
-
border: $input-border-width solid $color-input;
|
|
15
|
+
border: $input-border-width solid $color-input-border;
|
|
8
16
|
border-radius: $input-radius;
|
|
9
17
|
color: inherit;
|
|
10
18
|
display: block;
|
|
@@ -45,8 +53,9 @@
|
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
&--error:not(:focus) {
|
|
48
|
-
border:
|
|
49
|
-
box-shadow:
|
|
56
|
+
border: $input-border-width solid $color-errors;
|
|
57
|
+
box-shadow: 0 0 0 $input-border-width $color-errors;
|
|
58
|
+
outline: 1px solid transparent; // Add transparent outline because Windows High Contrast Mode doesn't show box-shadows
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
&--with-description {
|
|
@@ -73,7 +82,9 @@
|
|
|
73
82
|
|
|
74
83
|
.ons-input--select {
|
|
75
84
|
appearance: none;
|
|
76
|
-
background: $color-
|
|
85
|
+
background: $color-input-bg
|
|
86
|
+
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11.75 7.7'%3E%3Cpath fill='currentColor' d='m1.37.15 4.5 5.1 4.5-5.1a.37.37 0 0 1 .6 0l.7.7a.45.45 0 0 1 0 .5l-5.5 6.2a.37.37 0 0 1-.6 0l-5.5-6.1a.64.64 0 0 1 0-.6l.7-.7a.64.64 0 0 1 .6 0Z'/%3E%3C/svg%3E")
|
|
87
|
+
no-repeat center right 10px;
|
|
77
88
|
background-size: 1rem;
|
|
78
89
|
line-height: 1.3rem;
|
|
79
90
|
padding: 0.39rem 2rem 0.39rem $input-padding-horizontal;
|
|
@@ -100,10 +111,10 @@
|
|
|
100
111
|
color: transparent;
|
|
101
112
|
}
|
|
102
113
|
&:valid:not(:placeholder-shown) {
|
|
103
|
-
background-color: $color-
|
|
114
|
+
background-color: $color-input-bg;
|
|
104
115
|
}
|
|
105
116
|
&:focus {
|
|
106
|
-
background-color: $color-
|
|
117
|
+
background-color: $color-input-bg;
|
|
107
118
|
}
|
|
108
119
|
}
|
|
109
120
|
|
|
@@ -122,7 +133,7 @@
|
|
|
122
133
|
.ons-input--ghost {
|
|
123
134
|
border: 2px solid rgba(255, 255, 255, 0.6);
|
|
124
135
|
&:focus {
|
|
125
|
-
border: 2px solid $color-input;
|
|
136
|
+
border: 2px solid $color-input-border;
|
|
126
137
|
}
|
|
127
138
|
}
|
|
128
139
|
|
|
@@ -156,3 +167,11 @@
|
|
|
156
167
|
}
|
|
157
168
|
}
|
|
158
169
|
}
|
|
170
|
+
|
|
171
|
+
// Search type inputs - removes the 'X' clear button from webkit browsers
|
|
172
|
+
input[type='search']::-webkit-search-decoration,
|
|
173
|
+
input[type='search']::-webkit-search-cancel-button,
|
|
174
|
+
input[type='search']::-webkit-search-results-button,
|
|
175
|
+
input[type='search']::-webkit-search-results-decoration {
|
|
176
|
+
display: none;
|
|
177
|
+
}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
type="{{ type }}"
|
|
28
28
|
id="{{ params.id }}"
|
|
29
29
|
class="ons-input ons-input--text ons-input-type__input{% if params.error is defined and params.error %} ons-input--error{% endif %}{% if params.searchButton is defined and params.searchButton %} ons-search__input{% endif %}{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}{% if params.width is defined and params.width %} ons-input{% if params.type is defined and (params.type == 'number' or params.type == 'tel') %}-number{% endif %}--w-{{ params.width }}{% endif %}{{ exclusiveClass }}{{ inputPlaceholder }}"
|
|
30
|
-
{% if
|
|
30
|
+
{% if params.prefix is defined and params.prefix and params.prefix.id is defined and params.prefix.id %}aria-labelledby="{{ params.prefix.id }}"{% elif params.suffix is defined and params.suffix and params.suffix.id is defined and params.suffix.id %}aria-labelledby="{{ params.suffix.id }}"{% endif %}
|
|
31
31
|
{% if params.name is defined and params.name %}name="{{ params.name }}"{% endif %}
|
|
32
32
|
{% if params.value is defined and params.value %}value="{{ params.value }}"{% endif %}
|
|
33
33
|
{% if params.accept is defined and params.accept %}accept="{{ params.accept }}"{% endif %}
|
|
@@ -71,25 +71,23 @@
|
|
|
71
71
|
{% endif %}
|
|
72
72
|
|
|
73
73
|
{% if params.prefix is defined and params.prefix or params.suffix is defined and params.suffix %}
|
|
74
|
-
{% if (params.prefix is defined and params.prefix and params.prefix.id is defined and params.prefix.id) or (params.suffix is defined and params.suffix and params.suffix.id is defined and params.suffix.id) %}
|
|
75
|
-
{% if
|
|
76
|
-
{%
|
|
77
|
-
|
|
78
|
-
{% endif %}
|
|
74
|
+
{% if (params.prefix is defined and params.prefix and params.prefix.id is defined and params.prefix.id and params.prefix.title is defined and params.prefix.title) or (params.suffix is defined and params.suffix and params.suffix.id is defined and params.suffix.id and params.suffix.title is defined and params.suffix.title) %}
|
|
75
|
+
{% if params.prefix is defined and params.prefix %}
|
|
76
|
+
{% set prefixClass = " ons-input-type--prefix" %}
|
|
77
|
+
{% endif %}
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
<span class="ons-input-type{{ prefixClass }}">
|
|
80
|
+
<span class="ons-input-type__inner">
|
|
81
|
+
{{ input | safe }}
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
</span>
|
|
83
|
+
{% set abbr = params.prefix or params.suffix %}
|
|
84
|
+
<abbr
|
|
85
|
+
id="{{ abbr.id }}"
|
|
86
|
+
class="ons-input-type__type ons-js-input-abbr"
|
|
87
|
+
title="{{ abbr.title }}"
|
|
88
|
+
>{{ abbr.text or abbr.title }}</abbr>
|
|
91
89
|
</span>
|
|
92
|
-
|
|
90
|
+
</span>
|
|
93
91
|
{% endif %}
|
|
94
92
|
{% elif params.searchButton is defined and params.searchButton %}
|
|
95
93
|
<span class="ons-grid--flex ons-search">
|