@ons/design-system 50.0.1 → 53.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/README.md +35 -15
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +162 -0
- package/components/access-code/uac.spec.js +26 -0
- package/components/accordion/_macro.spec.js +224 -0
- package/components/accordion/accordion.spec.js +134 -0
- package/components/address-input/_macro.njk +1 -1
- package/components/address-input/_macro.spec.js +465 -0
- package/components/address-input/autosuggest.address.js +5 -4
- package/components/address-input/autosuggest.address.setter.js +9 -3
- package/components/address-input/autosuggest.address.spec.js +733 -0
- package/components/address-output/_macro.njk +6 -6
- package/components/address-output/_macro.spec.js +122 -0
- package/components/autosuggest/_macro.njk +1 -1
- package/components/autosuggest/_macro.spec.js +229 -0
- package/components/autosuggest/autosuggest.helpers.js +2 -3
- package/components/autosuggest/autosuggest.helpers.spec.js +85 -0
- package/components/autosuggest/autosuggest.js +4 -2
- package/components/autosuggest/autosuggest.spec.js +625 -0
- package/components/autosuggest/autosuggest.ui.js +6 -2
- package/components/breadcrumbs/_macro.spec.js +129 -0
- package/components/button/_button.scss +75 -33
- package/components/button/_macro.njk +6 -6
- package/components/button/_macro.spec.js +446 -0
- package/components/button/button.spec.js +290 -0
- package/components/call-to-action/_macro.njk +3 -1
- package/components/call-to-action/_macro.spec.js +52 -0
- package/components/card/_macro.njk +26 -19
- package/components/card/_macro.spec.js +261 -0
- package/components/char-check-limit/_macro.spec.js +73 -0
- package/components/char-check-limit/character-check.spec.js +196 -0
- package/components/char-check-limit/character-limit.js +1 -1
- package/components/checkboxes/_checkbox-macro.spec.js +419 -0
- package/components/checkboxes/_macro.njk +1 -3
- package/components/checkboxes/_macro.spec.js +306 -0
- package/components/checkboxes/checkbox-with-autoselect.js +2 -1
- package/components/checkboxes/checkboxes.spec.js +208 -0
- package/components/code-highlight/_macro.spec.js +56 -0
- package/components/code-highlight/code-highlight.spec.js +18 -0
- package/components/collapsible/_macro.spec.js +204 -0
- package/components/collapsible/collapsible.js +2 -1
- package/components/collapsible/collapsible.spec.js +236 -0
- package/components/content-pagination/_macro.spec.js +199 -0
- package/components/cookies-banner/_macro.njk +1 -1
- package/components/cookies-banner/_macro.spec.js +171 -0
- package/components/cookies-banner/cookies-banner.spec.js +90 -0
- package/components/date-input/_macro.njk +6 -3
- package/components/date-input/_macro.spec.js +286 -0
- package/components/document-list/_macro.njk +3 -5
- package/components/document-list/_macro.spec.js +491 -0
- package/components/download-resources/download-resources.spec.js +540 -0
- package/components/duration/_macro.njk +7 -6
- package/components/duration/_macro.spec.js +251 -0
- package/components/error/_macro.spec.js +97 -0
- package/components/external-link/_macro.njk +5 -2
- package/components/external-link/_macro.spec.js +77 -0
- package/components/feedback/_macro.njk +5 -3
- package/components/feedback/_macro.spec.js +122 -0
- package/components/field/_macro.njk +2 -2
- package/components/field/_macro.spec.js +97 -0
- package/components/fieldset/_macro.njk +3 -3
- package/components/fieldset/_macro.spec.js +173 -0
- package/components/footer/_footer.scss +19 -4
- package/components/footer/_macro.njk +106 -137
- package/components/footer/_macro.spec.js +678 -0
- package/components/header/_header.scss +65 -46
- package/components/header/_macro.njk +173 -121
- package/components/header/_macro.spec.js +618 -0
- package/components/hero/_hero.scss +30 -143
- package/components/hero/_macro.njk +12 -23
- package/components/hero/_macro.spec.js +218 -0
- package/components/icons/_macro.njk +258 -30
- package/components/icons/_macro.spec.js +140 -0
- package/components/images/_macro.njk +1 -1
- package/components/images/_macro.spec.js +121 -0
- package/components/input/_input-type.scss +12 -5
- package/components/input/_input.scss +8 -0
- package/components/input/_macro.njk +4 -5
- package/components/input/_macro.spec.js +658 -0
- package/components/label/_macro.spec.js +189 -0
- package/components/language-selector/_macro.njk +1 -1
- package/components/language-selector/_macro.spec.js +137 -0
- package/components/lists/_list.scss +4 -0
- package/components/lists/_macro.njk +4 -7
- package/components/lists/_macro.spec.js +618 -0
- package/components/message/_macro.spec.js +137 -0
- package/components/message-list/_macro.njk +7 -7
- package/components/message-list/_macro.spec.js +159 -0
- package/components/metadata/_macro.spec.js +167 -0
- package/components/modal/_macro.njk +6 -6
- package/components/modal/_macro.spec.js +87 -0
- package/components/modal/modal.spec.js +59 -0
- package/components/mutually-exclusive/_macro.njk +2 -2
- package/components/mutually-exclusive/_macro.spec.js +184 -0
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +203 -0
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +142 -0
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +141 -0
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +117 -0
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +213 -0
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +125 -0
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +131 -0
- package/components/navigation/_macro.njk +45 -38
- package/components/navigation/_macro.spec.js +329 -0
- package/components/navigation/_navigation.scss +20 -4
- package/components/navigation/navigation.dom.js +1 -1
- package/components/navigation/navigation.spec.js +232 -0
- package/components/pagination/_macro.njk +1 -1
- package/components/pagination/_macro.spec.js +411 -0
- package/components/panel/_macro.njk +6 -6
- package/components/panel/_macro.spec.js +423 -0
- package/components/password/_macro.spec.js +137 -0
- package/components/password/password.spec.js +40 -0
- package/components/phase-banner/_macro.spec.js +73 -0
- package/components/promotional-banner/_macro.spec.js +97 -0
- package/components/question/_macro.njk +16 -22
- package/components/question/_macro.spec.js +309 -0
- package/components/quote/_macro.spec.js +81 -0
- package/components/radios/_macro.njk +3 -6
- package/components/radios/_macro.spec.js +575 -0
- package/components/radios/radios.spec.js +180 -0
- package/components/related-content/_macro.njk +14 -21
- package/components/related-content/_macro.spec.js +133 -0
- package/components/related-content/_section-macro.njk +10 -0
- package/components/related-content/_section-macro.spec.js +43 -0
- package/components/relationships/_macro.spec.js +108 -0
- package/components/relationships/relationships.spec.js +84 -0
- package/components/reply/_macro.njk +2 -2
- package/components/reply/_macro.spec.js +69 -0
- package/components/reply/reply.spec.js +78 -0
- package/components/search/_macro.njk +14 -12
- package/components/search/_macro.spec.js +44 -0
- package/components/search/_search.scss +7 -7
- package/components/section-navigation/_macro.njk +7 -2
- package/components/section-navigation/_macro.spec.js +206 -0
- package/components/select/_macro.njk +3 -3
- package/components/select/_macro.spec.js +203 -0
- package/components/select/select.spec.js +56 -0
- package/components/share-page/_macro.njk +6 -4
- package/components/share-page/_macro.spec.js +110 -0
- package/components/skip-to-content/_macro.spec.js +57 -0
- package/components/skip-to-content/skip-to-content.spec.js +44 -0
- package/components/status/_macro.spec.js +77 -0
- package/components/summary/_macro.njk +5 -5
- package/components/summary/_macro.spec.js +472 -0
- package/components/table/_macro.njk +2 -2
- package/components/table/_macro.spec.js +557 -0
- package/components/table/table.spec.js +155 -0
- package/components/table-of-contents/_macro.njk +35 -35
- package/components/table-of-contents/_macro.spec.js +178 -0
- package/components/table-of-contents/toc.js +29 -25
- package/components/table-of-contents/toc.spec.js +61 -0
- package/components/tabs/_macro.njk +1 -1
- package/components/tabs/_macro.spec.js +79 -0
- package/components/tabs/tabs.spec.js +162 -0
- package/components/text-indent/_macro.spec.js +52 -0
- package/components/textarea/_macro.njk +5 -3
- package/components/textarea/_macro.spec.js +300 -0
- package/components/textarea/textarea.spec.js +98 -0
- package/components/timeline/_macro.njk +3 -3
- package/components/timeline/_macro.spec.js +81 -0
- package/components/timeout-modal/_macro.spec.js +68 -0
- package/components/timeout-modal/timeout-modal.spec.js +226 -0
- package/components/timeout-panel/_macro.njk +0 -1
- package/components/timeout-panel/_macro.spec.js +54 -0
- package/components/timeout-panel/timeout-panel.dom.js +1 -2
- package/components/timeout-panel/timeout-panel.spec.js +161 -0
- package/components/upload/_macro.spec.js +75 -0
- package/components/video/_macro.spec.js +34 -0
- package/css/census.css +3 -1
- package/css/ids.css +2 -0
- package/css/main.css +1 -1
- package/img/dummy-brand-logo.svg +1 -0
- package/js/cookies-settings.spec.js +154 -0
- package/layout/_template.njk +7 -4
- package/package.json +10 -23
- package/scripts/main.es5.js +2 -2
- package/scripts/main.js +1 -1
- package/scss/ids.scss +2 -0
- package/scss/settings/_census.scss +141 -0
- package/scss/settings/_ids.scss +48 -0
- package/scss/utilities/_margin.scss +1 -0
- package/scss/vars/_colors.scss +5 -2
|
@@ -1,100 +1,49 @@
|
|
|
1
1
|
// Default
|
|
2
2
|
.ons-hero {
|
|
3
3
|
background-color: $color-banner-bg;
|
|
4
|
-
padding: 2rem 0;
|
|
5
|
-
|
|
6
|
-
&__content {
|
|
7
|
-
height: 100%;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.ons-hero__pre-title {
|
|
12
|
-
margin-bottom: 0.5rem;
|
|
13
|
-
|
|
14
|
-
@include mq(xxs, m) {
|
|
15
|
-
max-width: 145px;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.ons-hero__title {
|
|
20
|
-
font-size: 2.3rem;
|
|
21
|
-
line-height: 1.2;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Census theme
|
|
25
|
-
.ons-hero--census {
|
|
26
|
-
background-image: linear-gradient(46deg, $color-branded-tertiary 0%, $color-branded 100%);
|
|
27
4
|
display: flex;
|
|
28
|
-
margin-bottom: 2px;
|
|
29
|
-
margin-top: 2px;
|
|
30
5
|
overflow: hidden;
|
|
31
6
|
padding: 0;
|
|
32
7
|
position: relative;
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
|
|
9
|
+
&__container {
|
|
10
|
+
align-items: center;
|
|
35
11
|
display: flex;
|
|
36
|
-
min-height:
|
|
12
|
+
min-height: 300px;
|
|
37
13
|
position: relative;
|
|
38
|
-
}
|
|
39
|
-
.ons-hero__circle-image,
|
|
40
|
-
.ons-hero__circle-gradient,
|
|
41
|
-
.ons-hero__circle-lined,
|
|
42
|
-
.ons-hero__circle {
|
|
43
|
-
position: absolute;
|
|
44
|
-
}
|
|
45
|
-
.ons-hero__circle-image {
|
|
46
|
-
background-color: $color-white;
|
|
47
|
-
border-radius: 50%;
|
|
48
|
-
height: 300px;
|
|
49
|
-
right: -4px;
|
|
50
|
-
top: -98px;
|
|
51
|
-
width: 300px;
|
|
52
|
-
z-index: 2;
|
|
53
14
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
display: block;
|
|
57
|
-
height: 100%;
|
|
15
|
+
&--has-collapsible {
|
|
16
|
+
align-items: flex-start; // Prevents undesired shift if not enough content
|
|
58
17
|
}
|
|
59
18
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
display: block;
|
|
64
|
-
height: 182px;
|
|
65
|
-
right: -91px; // Half width of circle
|
|
66
|
-
top: 0.7rem;
|
|
67
|
-
width: 182px;
|
|
68
|
-
z-index: 3;
|
|
19
|
+
|
|
20
|
+
&__content {
|
|
21
|
+
height: 100%;
|
|
69
22
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
top: 27px;
|
|
78
|
-
width: 990px;
|
|
79
|
-
z-index: 1;
|
|
23
|
+
|
|
24
|
+
&__pre-title {
|
|
25
|
+
margin-bottom: 0.5rem;
|
|
26
|
+
|
|
27
|
+
@include mq(xxs, m) {
|
|
28
|
+
max-width: 145px;
|
|
29
|
+
}
|
|
80
30
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
right: -24px;
|
|
86
|
-
top: 114px;
|
|
87
|
-
width: 133px;
|
|
88
|
-
z-index: 4;
|
|
31
|
+
|
|
32
|
+
&__title {
|
|
33
|
+
font-size: 2.3rem;
|
|
34
|
+
line-height: 1.2;
|
|
89
35
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
padding-
|
|
36
|
+
|
|
37
|
+
&__details {
|
|
38
|
+
padding-bottom: 3rem;
|
|
39
|
+
padding-top: 2rem;
|
|
93
40
|
position: relative;
|
|
94
41
|
z-index: 5;
|
|
42
|
+
}
|
|
95
43
|
|
|
96
|
-
|
|
97
|
-
|
|
44
|
+
&--dark & {
|
|
45
|
+
&__details {
|
|
46
|
+
color: $color-text-inverse !important;
|
|
98
47
|
|
|
99
48
|
a {
|
|
100
49
|
color: inherit;
|
|
@@ -105,72 +54,10 @@
|
|
|
105
54
|
color: $color-text-inverse-link-hover;
|
|
106
55
|
text-decoration-thickness: 2px;
|
|
107
56
|
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
@include mq(m) {
|
|
112
|
-
.ons-hero__title {
|
|
113
|
-
font-size: 3rem;
|
|
114
|
-
}
|
|
115
|
-
.ons-hero__details {
|
|
116
|
-
padding-top: 2rem;
|
|
117
|
-
}
|
|
118
|
-
.ons-hero__circle-image {
|
|
119
|
-
height: 382px;
|
|
120
|
-
right: -8px;
|
|
121
|
-
top: -117px;
|
|
122
|
-
width: 382px;
|
|
123
|
-
}
|
|
124
|
-
.ons-hero__circle-gradient {
|
|
125
|
-
height: 234px;
|
|
126
|
-
right: -117px; // Half width of circle
|
|
127
|
-
top: 1rem;
|
|
128
|
-
width: 234px;
|
|
129
|
-
}
|
|
130
|
-
.ons-hero__circle {
|
|
131
|
-
left: -331px;
|
|
132
|
-
margin: auto; // Reset
|
|
133
|
-
top: -288px;
|
|
134
|
-
}
|
|
135
|
-
.ons-hero__circle-lined {
|
|
136
|
-
height: 171px;
|
|
137
|
-
right: -24px;
|
|
138
|
-
top: 148px;
|
|
139
|
-
width: 171px;
|
|
140
|
-
}
|
|
141
|
-
.ons-hero__container {
|
|
142
|
-
align-items: center;
|
|
143
57
|
|
|
144
|
-
|
|
145
|
-
|
|
58
|
+
.ons-collapsible__heading {
|
|
59
|
+
color: inherit;
|
|
146
60
|
}
|
|
147
61
|
}
|
|
148
62
|
}
|
|
149
|
-
|
|
150
|
-
@include mq(l) {
|
|
151
|
-
.ons-hero__details {
|
|
152
|
-
padding-right: 2.5rem;
|
|
153
|
-
}
|
|
154
|
-
.ons-hero__circle-image {
|
|
155
|
-
height: 558px;
|
|
156
|
-
margin: auto;
|
|
157
|
-
right: 0;
|
|
158
|
-
top: -176px;
|
|
159
|
-
width: 558px;
|
|
160
|
-
}
|
|
161
|
-
.ons-hero__circle-gradient {
|
|
162
|
-
height: 342px;
|
|
163
|
-
right: -171px; // Half width of circle
|
|
164
|
-
width: 342px;
|
|
165
|
-
}
|
|
166
|
-
.ons-hero__circle {
|
|
167
|
-
top: -369px;
|
|
168
|
-
}
|
|
169
|
-
.ons-hero__circle-lined {
|
|
170
|
-
height: 243px;
|
|
171
|
-
right: 0;
|
|
172
|
-
top: 292px; // Reset
|
|
173
|
-
width: 243px;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
63
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{% from "components/icons/_macro.njk" import onsIcon %}
|
|
4
4
|
|
|
5
5
|
{# style adjustments if dark or light skin #}
|
|
6
|
-
{% if params.
|
|
6
|
+
{% if params.variants is defined and 'dark' in params.variants %}
|
|
7
7
|
{% set skinName = "dark" %}
|
|
8
8
|
{% else %}
|
|
9
9
|
{% set skinName = "light" %}
|
|
@@ -14,36 +14,25 @@
|
|
|
14
14
|
{% set containerClasses = " ons-hero__container--has-collapsible" %}
|
|
15
15
|
{% endif %}
|
|
16
16
|
|
|
17
|
-
{#
|
|
18
|
-
{%
|
|
19
|
-
{% set detailsColumns = "6" %}
|
|
20
|
-
{% else %}
|
|
21
|
-
{% set detailsColumns = "8" %}
|
|
22
|
-
{% endif %}
|
|
23
|
-
|
|
24
|
-
{# if hero style is a dark theme, change theme #}
|
|
25
|
-
{% if params.censusThemeDark is defined and params.censusThemeDark %}
|
|
26
|
-
{% set detailsClasses = " ons-hero__details--ondark" %}
|
|
27
|
-
{% endif %}
|
|
17
|
+
{# Set number of columns used for hero content after medium breakpoint #}
|
|
18
|
+
{% set detailsColumns = params.detailsColumns | default ('8') %}
|
|
28
19
|
|
|
29
|
-
<section class="ons-hero ons-grid--gutterless{% if params.
|
|
20
|
+
<section class="ons-hero ons-grid--gutterless{% if params.variants is defined and params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-hero--{{ variant }}{% endfor %}{% else %} ons-hero--{{ params.variants }}{% endif %}{% endif %}">
|
|
30
21
|
|
|
31
22
|
<div class="ons-hero__container ons-container{{ ' ons-container--wide' if params.wide }}{{ containerClasses }}">
|
|
32
23
|
|
|
33
|
-
<div class="ons-hero__details{{ detailsClasses }} ons-grid__col ons-col-{{ detailsColumns }}@m">
|
|
24
|
+
<div class="ons-hero__details{{ detailsClasses }} ons-grid__col ons-col-{{ detailsColumns }}@m ons-col-10@s@m">
|
|
34
25
|
|
|
35
26
|
<header>
|
|
36
27
|
{% if params.preTitleImage is defined and params.preTitleImage %}
|
|
37
28
|
{% set preTitleImageWithModifier = params.preTitleImage.name|replace(r/(\.[^\.]+)$/, "--" + skinName + "$1") %}
|
|
38
29
|
<img class="ons-hero__pre-title" src="{{ params.placeholderURL }}/img/{{ preTitleImageWithModifier }}" alt="{{ params.preTitleImage.alt }}">
|
|
39
30
|
{% endif %}
|
|
40
|
-
{% if params.
|
|
41
|
-
<h1 class="ons-u-fs-xxxl">{{ params.title }}</h1>
|
|
42
|
-
{% else %}
|
|
43
|
-
<h1 class="ons-hero__title">{{ params.title }}</h1>
|
|
31
|
+
{% if params.title is defined and params.title %}
|
|
32
|
+
<h1 class="ons-hero__title ons-u-fs-xxxl">{{ params.title }}</h1>
|
|
44
33
|
{% endif %}
|
|
45
34
|
{% if params.subtitle is defined and params.subtitle %}
|
|
46
|
-
<h2 class="ons-u-fs-r--b">{{ params.subtitle }}</h2>
|
|
35
|
+
<h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
|
|
47
36
|
{% endif %}
|
|
48
37
|
</header>
|
|
49
38
|
|
|
@@ -55,7 +44,7 @@
|
|
|
55
44
|
{% from "components/button/_macro.njk" import onsButton %}
|
|
56
45
|
{{
|
|
57
46
|
onsButton({
|
|
58
|
-
"classes": params.button.classes,
|
|
47
|
+
"classes": params.button.classes if params.button.classes is defined and params.button.classes else '',
|
|
59
48
|
"type": 'button',
|
|
60
49
|
"text": params.button.text,
|
|
61
50
|
"url": params.button.url
|
|
@@ -85,11 +74,11 @@
|
|
|
85
74
|
{% endif %}
|
|
86
75
|
|
|
87
76
|
</div>
|
|
88
|
-
{% if params.
|
|
77
|
+
{% if params.variants is defined and 'census' in params.variants %}
|
|
89
78
|
|
|
90
79
|
{% if params.image is defined and params.image %}
|
|
91
80
|
<div class="ons-hero__circle-image">
|
|
92
|
-
<img height="558" width="558" srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x" src="{{ params.image.smallSrc }}" alt="">
|
|
81
|
+
<img height="558" width="558" {% if params.image.largeSrc is defined and params.image.largeSrc %}srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x" {% endif %}src="{{ params.image.smallSrc }}" alt="">
|
|
93
82
|
</div>
|
|
94
83
|
{% endif %}
|
|
95
84
|
|
|
@@ -101,7 +90,7 @@
|
|
|
101
90
|
|
|
102
91
|
<div class="ons-hero__circle-gradient"></div>
|
|
103
92
|
|
|
104
|
-
{% if params.
|
|
93
|
+
{% if (params.variants is defined and 'census' in params.variants) and ('dark' not in params.variants) %}
|
|
105
94
|
<div class="ons-hero__circle"></div>
|
|
106
95
|
{% endif %}
|
|
107
96
|
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import * as cheerio from 'cheerio';
|
|
4
|
+
|
|
5
|
+
import axe from '../../tests/helpers/axe';
|
|
6
|
+
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
7
|
+
|
|
8
|
+
const EXAMPLE_HERO_MINIMAL = {
|
|
9
|
+
title: 'Hero title',
|
|
10
|
+
subtitle: 'Hero subtitle',
|
|
11
|
+
text: 'Hero text',
|
|
12
|
+
suffixText: 'Hero suffix text',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const EXAMPLE_HERO_CENSUS_VARIANT = {
|
|
16
|
+
variants: 'census',
|
|
17
|
+
...EXAMPLE_HERO_MINIMAL,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE = {
|
|
21
|
+
...EXAMPLE_HERO_CENSUS_VARIANT,
|
|
22
|
+
image: {
|
|
23
|
+
smallSrc: 'example-small.png',
|
|
24
|
+
largeSrc: 'example-large.png',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const EXAMPLE_HERO_WITH_BUTTON = {
|
|
29
|
+
...EXAMPLE_HERO_MINIMAL,
|
|
30
|
+
button: {
|
|
31
|
+
url: '#0',
|
|
32
|
+
text: 'Get started',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const EXAMPLE_HERO_WITH_PRETITLE_IMAGE = {
|
|
37
|
+
...EXAMPLE_HERO_MINIMAL,
|
|
38
|
+
preTitleImage: {
|
|
39
|
+
name: 'example.svg',
|
|
40
|
+
alt: 'svg alt text',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const EXAMPLE_HERO_WITH_COLLAPSIBLE = {
|
|
45
|
+
...EXAMPLE_HERO_MINIMAL,
|
|
46
|
+
collapsible: {
|
|
47
|
+
classes: 'ons-u-mt-s',
|
|
48
|
+
id: 'collapsible',
|
|
49
|
+
title: 'Collapsible title',
|
|
50
|
+
titleTag: 'h2',
|
|
51
|
+
content: 'Collapsible content',
|
|
52
|
+
closeButtonText: 'Hide this',
|
|
53
|
+
closeButtonContextSuffix: 'content',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
describe('macro: hero', () => {
|
|
58
|
+
describe.each([
|
|
59
|
+
['with text', EXAMPLE_HERO_MINIMAL],
|
|
60
|
+
['with census variant', EXAMPLE_HERO_CENSUS_VARIANT],
|
|
61
|
+
['with census variants and image', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE],
|
|
62
|
+
['with button', EXAMPLE_HERO_WITH_BUTTON],
|
|
63
|
+
['with pre-title image', EXAMPLE_HERO_WITH_PRETITLE_IMAGE],
|
|
64
|
+
['with collapsible', EXAMPLE_HERO_WITH_COLLAPSIBLE],
|
|
65
|
+
])('mode: %s', (_, params) => {
|
|
66
|
+
it('passes jest-axe checks with', async () => {
|
|
67
|
+
const $ = cheerio.load(renderComponent('hero', params));
|
|
68
|
+
|
|
69
|
+
const results = await axe($.html());
|
|
70
|
+
expect(results).toHaveNoViolations();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('has provided variant style classes', () => {
|
|
74
|
+
const $ = cheerio.load(
|
|
75
|
+
renderComponent('hero', {
|
|
76
|
+
variants: ['variant-a', 'variant-b'],
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
expect($('.ons-hero--variant-a').length).toBe(1);
|
|
81
|
+
expect($('.ons-hero--variant-b').length).toBe(1);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('has expected `title`', () => {
|
|
85
|
+
const $ = cheerio.load(renderComponent('hero', params));
|
|
86
|
+
|
|
87
|
+
const title = $('.ons-hero__title')
|
|
88
|
+
.html()
|
|
89
|
+
.trim();
|
|
90
|
+
expect(title).toBe('Hero title');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('has expected `subtitle`', () => {
|
|
94
|
+
const $ = cheerio.load(renderComponent('hero', params));
|
|
95
|
+
|
|
96
|
+
const title = $('.ons-hero__subtitle')
|
|
97
|
+
.html()
|
|
98
|
+
.trim();
|
|
99
|
+
expect(title).toBe('Hero subtitle');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('has expected `text`', () => {
|
|
103
|
+
const $ = cheerio.load(renderComponent('hero', params));
|
|
104
|
+
|
|
105
|
+
const title = $('.ons-hero__text')
|
|
106
|
+
.html()
|
|
107
|
+
.trim();
|
|
108
|
+
expect(title).toBe('Hero text');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('has expected `suffixText`', () => {
|
|
112
|
+
const $ = cheerio.load(renderComponent('hero', params));
|
|
113
|
+
|
|
114
|
+
const title = $('.ons-hero__suffixText')
|
|
115
|
+
.html()
|
|
116
|
+
.trim();
|
|
117
|
+
expect(title).toBe('Hero suffix text');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('has expected class if `wide`', () => {
|
|
121
|
+
const $ = cheerio.load(renderComponent('hero', { wide: true, ...params }));
|
|
122
|
+
expect($('.ons-hero__container').hasClass('ons-container--wide')).toBe(true);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('mode: with census variant and image', () => {
|
|
127
|
+
it('has expected `srcset` attribute', () => {
|
|
128
|
+
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE));
|
|
129
|
+
|
|
130
|
+
const srcset = $('.ons-hero__circle-image img').attr('srcset');
|
|
131
|
+
expect(srcset).toBe('example-small.png 1x, example-large.png 2x');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('has expected `src` attribute', () => {
|
|
135
|
+
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE));
|
|
136
|
+
|
|
137
|
+
const src = $('.ons-hero__circle-image img').attr('src');
|
|
138
|
+
expect(src).toBe('example-small.png');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('has a "circle-lined" icon', () => {
|
|
142
|
+
const faker = templateFaker();
|
|
143
|
+
const iconsSpy = faker.spy('icons');
|
|
144
|
+
|
|
145
|
+
faker.renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE);
|
|
146
|
+
|
|
147
|
+
expect(iconsSpy.occurrences[0].iconType).toBe('circle-lined');
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe('mode: with button', () => {
|
|
152
|
+
it('outputs the expected button', () => {
|
|
153
|
+
const faker = templateFaker();
|
|
154
|
+
const buttonSpy = faker.spy('button');
|
|
155
|
+
|
|
156
|
+
faker.renderComponent('hero', EXAMPLE_HERO_WITH_BUTTON);
|
|
157
|
+
|
|
158
|
+
expect(buttonSpy.occurrences[0]).toHaveProperty('text', 'Get started');
|
|
159
|
+
expect(buttonSpy.occurrences[0]).toHaveProperty('url', '#0');
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('mode: with pre-title image', () => {
|
|
164
|
+
it('has expected `src` attribute', () => {
|
|
165
|
+
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_WITH_PRETITLE_IMAGE));
|
|
166
|
+
|
|
167
|
+
const src = $('.ons-hero__pre-title').attr('src');
|
|
168
|
+
expect(src).toBe('/img/example--light.svg');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('has expected `src` attribute with dark variant', () => {
|
|
172
|
+
const $ = cheerio.load(
|
|
173
|
+
renderComponent('hero', {
|
|
174
|
+
variants: 'dark',
|
|
175
|
+
...EXAMPLE_HERO_WITH_PRETITLE_IMAGE,
|
|
176
|
+
}),
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
const src = $('.ons-hero__pre-title').attr('src');
|
|
180
|
+
expect(src).toBe('/img/example--dark.svg');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('has expected `alt` attribute', () => {
|
|
184
|
+
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_WITH_PRETITLE_IMAGE));
|
|
185
|
+
|
|
186
|
+
const alt = $('.ons-hero__pre-title').attr('alt');
|
|
187
|
+
expect(alt).toBe('svg alt text');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('has provided `placeholderURL`', () => {
|
|
191
|
+
const $ = cheerio.load(
|
|
192
|
+
renderComponent('hero', {
|
|
193
|
+
placeholderURL: '/some-path',
|
|
194
|
+
...EXAMPLE_HERO_WITH_PRETITLE_IMAGE,
|
|
195
|
+
}),
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const src = $('.ons-hero__pre-title').attr('src');
|
|
199
|
+
expect(src).toBe('/some-path/img/example--light.svg');
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
describe('mode: with collapsible', () => {
|
|
204
|
+
it('outputs the expected collapsible', () => {
|
|
205
|
+
const faker = templateFaker();
|
|
206
|
+
const collapsibleSpy = faker.spy('collapsible');
|
|
207
|
+
|
|
208
|
+
faker.renderComponent('hero', EXAMPLE_HERO_WITH_COLLAPSIBLE);
|
|
209
|
+
|
|
210
|
+
expect(collapsibleSpy.occurrences[0]).toHaveProperty('classes', 'ons-u-mb-s ons-u-mt-s');
|
|
211
|
+
expect(collapsibleSpy.occurrences[0]).toHaveProperty('id', 'collapsible');
|
|
212
|
+
expect(collapsibleSpy.occurrences[0]).toHaveProperty('title', 'Collapsible title');
|
|
213
|
+
expect(collapsibleSpy.occurrences[0]).toHaveProperty('titleTag', 'h2');
|
|
214
|
+
expect(collapsibleSpy.occurrences[0]).toHaveProperty('button.close', 'Hide this');
|
|
215
|
+
expect(collapsibleSpy.occurrences[0]).toHaveProperty('button.contextSuffix', 'content');
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|