@ons/design-system 55.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/browser-banner/_macro.njk +1 -1
- package/components/browser-banner/_macro.spec.js +31 -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 +32 -3
- package/components/header/_macro.spec.js +85 -1
- package/components/navigation/_macro.njk +1 -1
- package/components/panel/_macro.njk +5 -7
- package/components/phase-banner/_macro.njk +1 -1
- package/components/phase-banner/_macro.spec.js +31 -0
- package/css/census.css +1 -1
- package/css/ids.css +1 -1
- package/css/main.css +1 -1
- package/layout/_template.njk +17 -4
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{% endif %}
|
|
11
11
|
|
|
12
12
|
<div class="ons-browser-banner">
|
|
13
|
-
<div class="ons-container{{ ' ons-container--
|
|
13
|
+
<div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
|
|
14
14
|
<p class="ons-browser-banner__content"><span class="ons-browser-banner__lead">{{ bannerLeadingText }}</span><span class="ons-browser-banner__cta"> {{ bannerCTA | safe }}</span></p>
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
@@ -49,6 +49,37 @@ describe('macro: browser-banner', () => {
|
|
|
49
49
|
|
|
50
50
|
expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
|
|
51
51
|
});
|
|
52
|
+
|
|
53
|
+
it('does not have `container--wide` class when `wide` is not set', () => {
|
|
54
|
+
const $ = cheerio.load(
|
|
55
|
+
renderComponent('browser-banner', {
|
|
56
|
+
...EXAMPLE_BROWSER_BANNER_DEFAULT,
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect($('.ons-container').hasClass('ons-container--wide')).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('has `container--full-width` class when `fullWidth` is true', () => {
|
|
64
|
+
const $ = cheerio.load(
|
|
65
|
+
renderComponent('browser-banner', {
|
|
66
|
+
...EXAMPLE_BROWSER_BANNER_DEFAULT,
|
|
67
|
+
fullWidth: true,
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('does not have `container--full-width` class when `fullWidth` is not set', () => {
|
|
75
|
+
const $ = cheerio.load(
|
|
76
|
+
renderComponent('browser-banner', {
|
|
77
|
+
...EXAMPLE_BROWSER_BANNER_DEFAULT,
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(false);
|
|
82
|
+
});
|
|
52
83
|
});
|
|
53
84
|
|
|
54
85
|
describe('mode: Welsh language', () => {
|
|
@@ -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">
|
|
@@ -75,11 +82,22 @@
|
|
|
75
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>
|
|
@@ -116,11 +134,22 @@
|
|
|
116
134
|
<ul class="ons-header-service-nav__list">
|
|
117
135
|
{% for item in (params.serviceLinks.itemsList if params.serviceLinks.itemsList is iterable else params.serviceLinks.itemsList.items()) %}
|
|
118
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 %}
|
|
119
145
|
<a
|
|
120
146
|
href="{{ item.url }}"
|
|
121
147
|
class="ons-header-service-nav__link"
|
|
122
148
|
{% if item.id is defined and item.id %} id="{{ item.id }}"{% endif %}
|
|
123
149
|
>{{ item.title }}</a>
|
|
150
|
+
{% else %}
|
|
151
|
+
{{ item.title }}
|
|
152
|
+
{% endif %}
|
|
124
153
|
</li>
|
|
125
154
|
{% endfor %}
|
|
126
155
|
{% if params.language is defined and params.language %}
|
|
@@ -178,7 +207,7 @@
|
|
|
178
207
|
<p class="ons-header__description">{{ params.description }}</p>
|
|
179
208
|
{% endif %}
|
|
180
209
|
</div>
|
|
181
|
-
|
|
210
|
+
|
|
182
211
|
{% if params.button is defined and params.button %}
|
|
183
212
|
{% if params.variants == 'neutral' %}
|
|
184
213
|
{% set buttonVariant = ["ghost", "ghost-dark"] %}
|
|
@@ -20,6 +20,24 @@ const EXAMPLE_SERVICE_LINKS_CONFIG = {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
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
|
+
|
|
23
41
|
const EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE = {
|
|
24
42
|
...EXAMPLE_HEADER_BASIC,
|
|
25
43
|
serviceLinks: {
|
|
@@ -338,12 +356,51 @@ describe('macro: header', () => {
|
|
|
338
356
|
const faker = templateFaker();
|
|
339
357
|
const phaseSpy = faker.spy('phase-banner');
|
|
340
358
|
|
|
341
|
-
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
|
+
});
|
|
342
366
|
|
|
343
367
|
expect(phaseSpy.occurrences).toContainEqual({
|
|
368
|
+
badge: 'Example',
|
|
344
369
|
html: 'Example content with a <a href="#">link</a>',
|
|
345
370
|
});
|
|
346
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
|
+
});
|
|
347
404
|
});
|
|
348
405
|
|
|
349
406
|
describe('mode: with service links', () => {
|
|
@@ -377,6 +434,13 @@ describe('macro: header', () => {
|
|
|
377
434
|
expect($('.ons-header-service-nav--main').attr('aria-label')).toBe('Services menu');
|
|
378
435
|
});
|
|
379
436
|
|
|
437
|
+
it('has the text for each list item', () => {
|
|
438
|
+
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LIST_ITEMS));
|
|
439
|
+
|
|
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']);
|
|
442
|
+
});
|
|
443
|
+
|
|
380
444
|
it('has the link text for each list item', () => {
|
|
381
445
|
const $ = cheerio.load(renderComponent('header', EXAMPLE_HEADER_SERVICE_LINKS_MULTIPLE));
|
|
382
446
|
|
|
@@ -467,6 +531,26 @@ describe('macro: header', () => {
|
|
|
467
531
|
|
|
468
532
|
expect($('.ons-js-toggle-services').length).toBe(0);
|
|
469
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
|
+
});
|
|
470
554
|
});
|
|
471
555
|
|
|
472
556
|
describe('mode: with language selector', () => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
{% from "components/button/_macro.njk" import onsButton %}
|
|
3
3
|
{% from "components/autosuggest/_macro.njk" import onsAutosuggest %}
|
|
4
4
|
<div class="ons-navigation-wrapper{% if params.variants == 'neutral' %} ons-navigation-wrapper--neutral{% endif %}">
|
|
5
|
-
<div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
|
|
5
|
+
<div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth or params.navigation.fullWidth }}{{ ' ons-container--wide' if params.wide or params.navigation.wide }}">
|
|
6
6
|
{% if params.navigation.siteSearchAutosuggest is defined and params.navigation.siteSearchAutosuggest and isPatternLib is defined and isPatternLib %}
|
|
7
7
|
<div class="ons-navigation-search ons-js-navigation-search">
|
|
8
8
|
{% set autosuggestClasses = "ons-input-search ons-input-search--icon" %}
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<div class="ons-container">
|
|
32
32
|
{% endif %}
|
|
33
33
|
|
|
34
|
-
<div {% if
|
|
34
|
+
<div {% if (params.type == 'error' and params.title) or params.type == 'success' %}aria-labelledby="alert" role="alert" tabindex="-1" {% if params.dsExample != true %}autofocus="autofocus" {% endif %}{% endif %}class="ons-panel{{ typeClass }}{{ iconClass }}{{ noTitleClass }}{{ spaciousClass }}{{ classes }}"{% if params is defined and params and params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params is defined and params and params.attributes is mapping and params.attributes.items is defined and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params is defined and params and params.id is defined and params.id %} id="{{params.id}}"{% endif %}>
|
|
35
35
|
|
|
36
36
|
{% if params is defined and params and params.type == "warn" or params.type == "warn-branded" %}
|
|
37
37
|
<span class="ons-panel__icon" aria-hidden="true">!</span>
|
|
@@ -59,16 +59,14 @@
|
|
|
59
59
|
{% endif %}
|
|
60
60
|
{% set titleTag = params.titleTag | default(defaultTitleTag) %}
|
|
61
61
|
<div class="ons-panel__header">
|
|
62
|
-
<{{ titleTag }} id="alert"
|
|
62
|
+
<{{ titleTag }} id="alert"{% if params.type %} data-qa="{{ params.type }}-header"{% endif %} class="ons-panel__title ons-u-fs-r--b">{{ params.title | safe }}</{{ titleTag }}>
|
|
63
63
|
</div>
|
|
64
64
|
{% else %}
|
|
65
65
|
{% if params.type is not defined or params.type == "branded" or params.type == "info" %}
|
|
66
66
|
<span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Important information: ") }}</span>
|
|
67
|
-
{%
|
|
68
|
-
{%
|
|
69
|
-
|
|
70
|
-
<span id="alert" class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default(defaultText ~ ": ") }}</span>
|
|
71
|
-
{% endif %}
|
|
67
|
+
{% elif params.type == 'error' or params.type == 'success' %}
|
|
68
|
+
{% set defaultText = "Completed" if params.type == "success" else "Error" %}
|
|
69
|
+
<span{% if params.type == "success" %} id="alert"{% endif %} class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default(defaultText ~ ": ") }}</span>
|
|
72
70
|
{% endif %}
|
|
73
71
|
{% endif %}
|
|
74
72
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% macro onsPhaseBanner(params) %}
|
|
2
2
|
<div class="ons-phase-banner">
|
|
3
|
-
<div class="ons-container{{ ' ons-container--wide' if params.wide }}">
|
|
3
|
+
<div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
|
|
4
4
|
<div class="ons-grid ons-grid--flex ons-grid--gutterless ons-grid--vertical-top ons-grid--no-wrap">
|
|
5
5
|
{% if not params.hideBadge %}
|
|
6
6
|
<div class="ons-grid__col ons-col-auto ons-u-flex-no-grow ons-u-flex-no-shrink">
|
|
@@ -70,4 +70,35 @@ describe('macro: phase-banner', () => {
|
|
|
70
70
|
|
|
71
71
|
expect($('.ons-container').hasClass('ons-container--wide')).toBe(true);
|
|
72
72
|
});
|
|
73
|
+
|
|
74
|
+
it('does not have `container--wide` class when `wide` is not set', () => {
|
|
75
|
+
const $ = cheerio.load(
|
|
76
|
+
renderComponent('phase-banner', {
|
|
77
|
+
...EXAMPLE_PHASE_BANNER_MINIMAL,
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
expect($('.ons-container').hasClass('ons-container--wide')).toBe(false);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('has `container--full-width` class when `fullWidth` is true', () => {
|
|
85
|
+
const $ = cheerio.load(
|
|
86
|
+
renderComponent('phase-banner', {
|
|
87
|
+
...EXAMPLE_PHASE_BANNER_MINIMAL,
|
|
88
|
+
fullWidth: true,
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('does not have `container--full-width` class when `fullWidth` is not set', () => {
|
|
96
|
+
const $ = cheerio.load(
|
|
97
|
+
renderComponent('phase-banner', {
|
|
98
|
+
...EXAMPLE_PHASE_BANNER_MINIMAL,
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
expect($('.ons-container').hasClass('ons-container--full-width')).toBe(false);
|
|
103
|
+
});
|
|
73
104
|
});
|