@ons/design-system 59.0.0 → 60.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/uac.scss +1 -1
- package/components/autosuggest/_autosuggest.scss +1 -1
- package/components/button/_button.scss +3 -3
- package/components/download-resources/_download-resources.scss +1 -1
- package/components/fieldset/_fieldset.scss +2 -2
- package/components/footer/_footer.scss +0 -15
- package/components/footer/_macro.njk +62 -103
- package/components/footer/_macro.spec.js +56 -186
- package/components/header/_header.scss +23 -25
- package/components/header/_macro.njk +133 -148
- package/components/header/_macro.spec.js +39 -73
- package/components/hero/_hero.scss +4 -0
- package/components/hero/_macro.njk +35 -92
- package/components/hero/_macro.spec.js +54 -190
- package/components/icons/_macro.njk +0 -499
- package/components/icons/_macro.spec.js +0 -14
- package/components/navigation/_macro.njk +14 -14
- package/components/navigation/_macro.spec.js +3 -5
- package/components/navigation/_navigation.scss +4 -4
- package/components/panel/_panel.scss +1 -1
- package/components/summary/_summary.scss +2 -2
- package/components/table/_table.scss +3 -3
- package/css/main.css +3 -3
- package/fonts/opensans-bold.woff +0 -0
- package/fonts/opensans-bold.woff2 +0 -0
- package/fonts/opensans-regular.woff +0 -0
- package/fonts/opensans-regular.woff2 +0 -0
- package/img/large/placeholder-card.png +0 -0
- package/img/large/placeholder-news-medium.png +0 -0
- package/img/large/placeholder-news.png +0 -0
- package/img/large/placeholder-portrait.png +0 -0
- package/img/small/placeholder-card.png +0 -0
- package/img/small/placeholder-news-medium.png +0 -0
- package/img/small/placeholder-news.png +0 -0
- package/img/small/placeholder-portrait.png +0 -0
- package/js/main.js +0 -1
- package/layout/_template.njk +51 -62
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_typography.scss +1 -0
- package/scss/main.scss +0 -2
- package/scss/patternlib.scss +2 -1
- package/scss/utilities/_typography.scss +1 -1
- package/scss/vars/_colors.scss +9 -4
- package/scss/vars/_typography.scss +1 -1
- package/components/find-a-support-centre/_find-a-support-centre.scss +0 -9
- package/components/promotional-banner/_macro.njk +0 -49
- package/components/promotional-banner/_macro.spec.js +0 -97
- package/components/promotional-banner/_promo-banner.scss +0 -72
- package/components/select/select.js +0 -19
- package/components/select/select.spec.js +0 -56
- package/css/census.css +0 -243
- package/css/ids.css +0 -243
- package/favicons/browserconfig.xml +0 -12
- package/favicons/census/cy/android-chrome-192x192.png +0 -0
- package/favicons/census/cy/android-chrome-512x512.png +0 -0
- package/favicons/census/cy/apple-touch-icon.png +0 -0
- package/favicons/census/cy/browserconfig.xml +0 -12
- package/favicons/census/cy/favicon-16x16.png +0 -0
- package/favicons/census/cy/favicon-32x32.png +0 -0
- package/favicons/census/cy/favicon.ico +0 -0
- package/favicons/census/cy/manifest.json +0 -20
- package/favicons/census/cy/mstitle-150x150.png +0 -0
- package/favicons/census/cy/mstitle-310x150.png +0 -0
- package/favicons/census/cy/mstitle-310x310.png +0 -0
- package/favicons/census/cy/mstitle-70x70.png +0 -0
- package/favicons/census/cy/opengraph.png +0 -0
- package/favicons/census/cy/safari-pinned-tab.svg +0 -3
- package/favicons/census/cy/site.webmanifest +0 -19
- package/favicons/census/cy/twitter.png +0 -0
- package/favicons/census/en/android-chrome-192x192.png +0 -0
- package/favicons/census/en/android-chrome-512x512.png +0 -0
- package/favicons/census/en/apple-touch-icon.png +0 -0
- package/favicons/census/en/browserconfig.xml +0 -12
- package/favicons/census/en/favicon-16x16.png +0 -0
- package/favicons/census/en/favicon-32x32.png +0 -0
- package/favicons/census/en/favicon.ico +0 -0
- package/favicons/census/en/manifest.json +0 -20
- package/favicons/census/en/mstitle-150x150.png +0 -0
- package/favicons/census/en/mstitle-310x150.png +0 -0
- package/favicons/census/en/mstitle-310x310.png +0 -0
- package/favicons/census/en/mstitle-70x70.png +0 -0
- package/favicons/census/en/opengraph.png +0 -0
- package/favicons/census/en/safari-pinned-tab.svg +0 -3
- package/favicons/census/en/site.webmanifest +0 -19
- package/favicons/census/en/twitter.png +0 -0
- package/favicons/census/ni/favicon.ico +0 -0
- package/favicons/ids/cy/android-chrome-192x192.png +0 -0
- package/favicons/ids/cy/android-chrome-512x512.png +0 -0
- package/favicons/ids/cy/apple-touch-icon.png +0 -0
- package/favicons/ids/cy/browserconfig.xml +0 -12
- package/favicons/ids/cy/favicon-16x16.png +0 -0
- package/favicons/ids/cy/favicon-32x32.png +0 -0
- package/favicons/ids/cy/favicon.ico +0 -0
- package/favicons/ids/cy/manifest.json +0 -20
- package/favicons/ids/cy/mstile-150x150.png +0 -0
- package/favicons/ids/cy/mstile-310x150.png +0 -0
- package/favicons/ids/cy/mstile-310x310.png +0 -0
- package/favicons/ids/cy/mstile-70x70.png +0 -0
- package/favicons/ids/cy/opengraph.png +0 -0
- package/favicons/ids/cy/safari-pinned-tab.svg +0 -27
- package/favicons/ids/cy/site.webmanifest +0 -54
- package/favicons/ids/cy/twitter.png +0 -0
- package/favicons/ids/en/android-chrome-192x192.png +0 -0
- package/favicons/ids/en/android-chrome-512x512.png +0 -0
- package/favicons/ids/en/apple-touch-icon.png +0 -0
- package/favicons/ids/en/browserconfig.xml +0 -12
- package/favicons/ids/en/favicon-16x16.png +0 -0
- package/favicons/ids/en/favicon-32x32.png +0 -0
- package/favicons/ids/en/favicon.ico +0 -0
- package/favicons/ids/en/manifest.json +0 -20
- package/favicons/ids/en/mstile-150x150.png +0 -0
- package/favicons/ids/en/mstile-310x150.png +0 -0
- package/favicons/ids/en/mstile-310x310.png +0 -0
- package/favicons/ids/en/mstile-70x70.png +0 -0
- package/favicons/ids/en/opengraph.png +0 -0
- package/favicons/ids/en/safari-pinned-tab.svg +0 -27
- package/favicons/ids/en/site.webmanifest +0 -54
- package/favicons/ids/en/twitter.png +0 -0
- package/favicons/mstitle-150x150.png +0 -0
- package/favicons/mstitle-310x150.png +0 -0
- package/favicons/mstitle-310x310.png +0 -0
- package/favicons/mstitle-70x70.png +0 -0
- package/img/UKOpenGovernmentLicence-grey.svg +0 -4
- package/img/UKOpenGovernmentLicence.svg +0 -13
- package/img/card-placeholder.svg +0 -14
- package/img/census-landscape.svg +0 -4514
- package/img/census-logo-stacked-pos-billingual.png +0 -0
- package/img/census-logo-stacked-pos-cy.png +0 -0
- package/img/census-logo-stacked-pos-en.png +0 -0
- package/img/census-promo-banner.svg +0 -489
- package/img/circle-lines.svg +0 -31
- package/img/dummy-brand-logo.svg +0 -6
- package/img/icons--check.svg +0 -3
- package/img/icons--chevron-down.svg +0 -3
- package/img/its-about-us--dark.svg +0 -4
- package/img/its-about-us--light.svg +0 -4
- package/img/large/hero-man.png +0 -0
- package/img/logo.svg +0 -77
- package/img/ni-syn-cyfrif--dark.svg +0 -3
- package/img/ni-syn-cyfrif--light.svg +0 -3
- package/img/nisra-logo-black-en.svg +0 -4
- package/img/ogl.svg +0 -10
- package/img/ons-logo-black-cy.svg +0 -4
- package/img/ons-logo-black-en.svg +0 -4
- package/img/people-mob.png +0 -0
- package/img/people.png +0 -0
- package/img/rehearsal-areas.svg +0 -11
- package/img/small/hero-man.png +0 -0
- package/scss/census.scss +0 -2
- package/scss/ids.scss +0 -2
- package/scss/settings/_census.scss +0 -159
- package/scss/settings/_ids.scss +0 -52
|
@@ -1,106 +1,49 @@
|
|
|
1
1
|
{% macro onsHero(params) %}
|
|
2
2
|
|
|
3
|
-
{
|
|
3
|
+
{# Set number of columns used for hero content after medium breakpoint #}
|
|
4
|
+
{% set detailsColumns = params.detailsColumns | default ('8') %}
|
|
4
5
|
|
|
5
|
-
{
|
|
6
|
-
{% if params.variants and 'dark' in params.variants %}
|
|
7
|
-
{% set skinName = "dark" %}
|
|
8
|
-
{% else %}
|
|
9
|
-
{% set skinName = "light" %}
|
|
10
|
-
{% endif %}
|
|
6
|
+
<section class="ons-hero ons-grid--gutterless{% if params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-hero--{{ variant }}{% endfor %}{% else %} ons-hero--{{ params.variants }}{% endif %}{% endif %}">
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
{% if params.collapsible %}
|
|
14
|
-
{% set containerClasses = " ons-hero__container--has-collapsible" %}
|
|
15
|
-
{% endif %}
|
|
8
|
+
<div class="ons-hero__container ons-container{{ ' ons-container--wide' if params.wide }}">
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
<div class="ons-hero__details ons-grid__col ons-col-{{ detailsColumns }}@m ons-col-10@s@m">
|
|
11
|
+
<header>
|
|
12
|
+
{% if params.title %}
|
|
13
|
+
<h1 class="ons-hero__title ons-u-fs-xxxl">{{ params.title }}</h1>
|
|
14
|
+
{% endif %}
|
|
15
|
+
{% if params.subtitle %}
|
|
16
|
+
<h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
|
|
17
|
+
{% endif %}
|
|
18
|
+
</header>
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<div class="ons-hero__container ons-container{{ ' ons-container--wide' if params.wide }}{{ containerClasses }}">
|
|
23
|
-
|
|
24
|
-
<div class="ons-hero__details{{ detailsClasses }} ons-grid__col ons-col-{{ detailsColumns }}@m ons-col-10@s@m">
|
|
25
|
-
|
|
26
|
-
<header>
|
|
27
|
-
{% if params.preTitleImage %}
|
|
28
|
-
{% set preTitleImageWithModifier = params.preTitleImage.name ~ "--" ~ skinName ~ ".svg" %}
|
|
29
|
-
<img class="ons-hero__pre-title" src="{{ params.placeholderURL }}/img/{{ preTitleImageWithModifier }}" alt="{{ params.preTitleImage.alt }}">
|
|
20
|
+
{% if params.text %}
|
|
21
|
+
<p class="ons-hero__text">{{ params.text | safe }}</p>
|
|
30
22
|
{% endif %}
|
|
31
|
-
{% if params.title %}
|
|
32
|
-
<h1 class="ons-hero__title ons-u-fs-xxxl">{{ params.title }}</h1>
|
|
33
|
-
{% endif %}
|
|
34
|
-
{% if params.subtitle %}
|
|
35
|
-
<h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
|
|
36
|
-
{% endif %}
|
|
37
|
-
</header>
|
|
38
23
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
24
|
+
{% if params.button %}
|
|
25
|
+
{% from "components/button/_macro.njk" import onsButton %}
|
|
26
|
+
{% set btnClasses = params.button.classes if params.button.classes else '' %}
|
|
27
|
+
{% if params.variants and 'dark' in params.variants %}
|
|
28
|
+
{% set btnClasses = btnClasses + ' ons-btn--ghost' %}
|
|
29
|
+
{% endif %}
|
|
30
|
+
{{
|
|
31
|
+
onsButton({
|
|
32
|
+
"classes": btnClasses,
|
|
33
|
+
"type": 'button',
|
|
34
|
+
"text": params.button.text,
|
|
35
|
+
"url": params.button.url
|
|
36
|
+
})
|
|
37
|
+
}}
|
|
48
38
|
{% endif %}
|
|
49
|
-
{{
|
|
50
|
-
onsButton({
|
|
51
|
-
"classes": btnClasses,
|
|
52
|
-
"type": 'button',
|
|
53
|
-
"text": params.button.text,
|
|
54
|
-
"url": params.button.url
|
|
55
|
-
})
|
|
56
|
-
}}
|
|
57
|
-
{% endif %}
|
|
58
|
-
|
|
59
|
-
{% if params.collapsible %}
|
|
60
|
-
{% from "components/collapsible/_macro.njk" import onsCollapsible %}
|
|
61
|
-
{{
|
|
62
|
-
onsCollapsible({
|
|
63
|
-
"classes": 'ons-u-mb-s ' + params.collapsible.classes,
|
|
64
|
-
"id": params.collapsible.id,
|
|
65
|
-
"title": params.collapsible.title,
|
|
66
|
-
"titleTag": params.collapsible.titleTag,
|
|
67
|
-
"content": params.collapsible.content,
|
|
68
|
-
"button": {
|
|
69
|
-
"close": params.collapsible.closeButtonText | default('Hide this'),
|
|
70
|
-
"contextSuffix": params.collapsible.closeButtonContextSuffix | default('content')
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
}}
|
|
74
|
-
{% endif %}
|
|
75
|
-
|
|
76
|
-
{% if params.suffixText %}
|
|
77
|
-
<p class="ons-hero__suffixText ons-u-fs-s ons-u-mt-m ons-u-mb-no">{{ params.suffixText | safe }}</p>
|
|
78
|
-
{% endif %}
|
|
79
|
-
|
|
80
|
-
</div>
|
|
81
|
-
{% if params.variants and 'census' in params.variants %}
|
|
82
|
-
|
|
83
|
-
{% if params.image %}
|
|
84
|
-
<div class="ons-hero__circle-image">
|
|
85
|
-
<img height="558" width="558" {% if params.image.largeSrc %}srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x" {% endif %}src="{{ params.image.smallSrc }}" alt="">
|
|
86
39
|
</div>
|
|
87
|
-
{% endif %}
|
|
88
40
|
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}}
|
|
94
|
-
|
|
95
|
-
<div class="ons-hero__circle-gradient"></div>
|
|
96
|
-
|
|
97
|
-
{% if (params.variants and 'census' in params.variants) and ('dark' not in params.variants) %}
|
|
98
|
-
<div class="ons-hero__circle"></div>
|
|
41
|
+
{% if caller %}
|
|
42
|
+
<div class="ons-hero__additional">
|
|
43
|
+
{{- caller() -}}
|
|
44
|
+
</div>
|
|
99
45
|
{% endif %}
|
|
46
|
+
</div>
|
|
100
47
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
</div>
|
|
104
|
-
|
|
105
|
-
</section>
|
|
48
|
+
</section>
|
|
106
49
|
{% endmacro %}
|
|
@@ -5,223 +5,87 @@ import * as cheerio from 'cheerio';
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const EXAMPLE_HERO = {
|
|
9
9
|
title: 'Hero title',
|
|
10
10
|
subtitle: 'Hero subtitle',
|
|
11
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
12
|
button: {
|
|
31
13
|
url: '#0',
|
|
32
14
|
text: 'Get started',
|
|
33
15
|
},
|
|
34
16
|
};
|
|
35
17
|
|
|
36
|
-
const EXAMPLE_HERO_WITH_PRETITLE_IMAGE = {
|
|
37
|
-
...EXAMPLE_HERO_MINIMAL,
|
|
38
|
-
preTitleImage: {
|
|
39
|
-
name: 'example',
|
|
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
18
|
describe('macro: hero', () => {
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
});
|
|
19
|
+
it('passes jest-axe checks with', async () => {
|
|
20
|
+
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO));
|
|
125
21
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
22
|
+
const results = await axe($.html());
|
|
23
|
+
expect(results).toHaveNoViolations();
|
|
24
|
+
});
|
|
129
25
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
26
|
+
it('has provided variant style classes', () => {
|
|
27
|
+
const $ = cheerio.load(
|
|
28
|
+
renderComponent('hero', {
|
|
29
|
+
variants: ['variant-a', 'variant-b'],
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
133
32
|
|
|
134
|
-
|
|
135
|
-
|
|
33
|
+
expect($('.ons-hero--variant-a').length).toBe(1);
|
|
34
|
+
expect($('.ons-hero--variant-b').length).toBe(1);
|
|
35
|
+
});
|
|
136
36
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
37
|
+
it('has expected `title`', () => {
|
|
38
|
+
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO));
|
|
140
39
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
40
|
+
const title = $('.ons-hero__title')
|
|
41
|
+
.html()
|
|
42
|
+
.trim();
|
|
43
|
+
expect(title).toBe('Hero title');
|
|
44
|
+
});
|
|
144
45
|
|
|
145
|
-
|
|
46
|
+
it('has expected `subtitle`', () => {
|
|
47
|
+
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO));
|
|
146
48
|
|
|
147
|
-
|
|
148
|
-
|
|
49
|
+
const title = $('.ons-hero__subtitle')
|
|
50
|
+
.html()
|
|
51
|
+
.trim();
|
|
52
|
+
expect(title).toBe('Hero subtitle');
|
|
149
53
|
});
|
|
150
54
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const faker = templateFaker();
|
|
154
|
-
const buttonSpy = faker.spy('button');
|
|
55
|
+
it('has expected `text`', () => {
|
|
56
|
+
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO));
|
|
155
57
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
58
|
+
const title = $('.ons-hero__text')
|
|
59
|
+
.html()
|
|
60
|
+
.trim();
|
|
61
|
+
expect(title).toBe('Hero text');
|
|
62
|
+
});
|
|
161
63
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
64
|
+
it('outputs the expected button', () => {
|
|
65
|
+
const faker = templateFaker();
|
|
66
|
+
const buttonSpy = faker.spy('button');
|
|
165
67
|
|
|
166
|
-
|
|
68
|
+
faker.renderComponent('hero', EXAMPLE_HERO);
|
|
167
69
|
|
|
168
|
-
|
|
169
|
-
|
|
70
|
+
expect(buttonSpy.occurrences[0]).toHaveProperty('text', 'Get started');
|
|
71
|
+
expect(buttonSpy.occurrences[0]).toHaveProperty('url', '#0');
|
|
170
72
|
});
|
|
171
73
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const src = $('.ons-hero__pre-title').attr('src');
|
|
177
|
-
expect(src).toBe('/img/example--light.svg');
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('has expected `src` attribute with dark variant', () => {
|
|
181
|
-
const $ = cheerio.load(
|
|
182
|
-
renderComponent('hero', {
|
|
183
|
-
variants: 'dark',
|
|
184
|
-
...EXAMPLE_HERO_WITH_PRETITLE_IMAGE,
|
|
185
|
-
}),
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
const src = $('.ons-hero__pre-title').attr('src');
|
|
189
|
-
expect(src).toBe('/img/example--dark.svg');
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('has expected `alt` attribute', () => {
|
|
193
|
-
const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_WITH_PRETITLE_IMAGE));
|
|
194
|
-
|
|
195
|
-
const alt = $('.ons-hero__pre-title').attr('alt');
|
|
196
|
-
expect(alt).toBe('svg alt text');
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it('has provided `placeholderURL`', () => {
|
|
200
|
-
const $ = cheerio.load(
|
|
201
|
-
renderComponent('hero', {
|
|
202
|
-
placeholderURL: '/some-path',
|
|
203
|
-
...EXAMPLE_HERO_WITH_PRETITLE_IMAGE,
|
|
204
|
-
}),
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
const src = $('.ons-hero__pre-title').attr('src');
|
|
208
|
-
expect(src).toBe('/some-path/img/example--light.svg');
|
|
209
|
-
});
|
|
210
|
-
});
|
|
74
|
+
it('outputs the correct button class with `dark` variant', () => {
|
|
75
|
+
const faker = templateFaker();
|
|
76
|
+
const buttonSpy = faker.spy('button');
|
|
211
77
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
78
|
+
faker.renderComponent('hero', { ...EXAMPLE_HERO, variants: 'dark' });
|
|
79
|
+
|
|
80
|
+
expect(buttonSpy.occurrences[0]).toHaveProperty('classes', ' ons-btn--ghost');
|
|
81
|
+
});
|
|
216
82
|
|
|
217
|
-
|
|
83
|
+
it('calls with content', () => {
|
|
84
|
+
const $ = cheerio.load(renderComponent('hero', { EXAMPLE_HERO }, 'Example content...'));
|
|
218
85
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
expect(collapsibleSpy.occurrences[0]).toHaveProperty('button.close', 'Hide this');
|
|
224
|
-
expect(collapsibleSpy.occurrences[0]).toHaveProperty('button.contextSuffix', 'content');
|
|
225
|
-
});
|
|
86
|
+
const content = $('.ons-hero__additional')
|
|
87
|
+
.text()
|
|
88
|
+
.trim();
|
|
89
|
+
expect(content).toEqual(expect.stringContaining('Example content...'));
|
|
226
90
|
});
|
|
227
91
|
});
|