@ons/design-system 55.1.0 → 56.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/_macro.njk +3 -3
- package/components/accordion/_macro.njk +1 -1
- package/components/address-input/_macro.njk +7 -7
- package/components/address-output/_macro.njk +7 -7
- package/components/autosuggest/_macro.njk +19 -19
- package/components/breadcrumbs/_macro.njk +3 -3
- package/components/button/_button.scss +49 -51
- package/components/button/_macro.njk +61 -35
- package/components/button/_macro.spec.js +24 -24
- package/components/button/button.spec.js +11 -11
- package/components/call-to-action/_macro.njk +1 -1
- package/components/card/_macro.njk +10 -10
- package/components/checkboxes/_checkbox-macro.njk +9 -9
- package/components/checkboxes/_macro.njk +10 -10
- package/components/checkboxes/checkbox-with-fieldset.js +6 -5
- package/components/checkboxes/checkboxes.dom.js +6 -9
- package/components/code-highlight/_macro.njk +1 -1
- package/components/collapsible/_macro.njk +7 -7
- package/components/date-input/_macro.njk +5 -5
- package/components/document-list/_macro.njk +29 -29
- package/components/duration/_macro.njk +9 -9
- package/components/duration/_macro.spec.js +0 -3
- package/components/error/_macro.njk +1 -1
- package/components/external-link/_macro.njk +1 -1
- package/components/feedback/_macro.njk +2 -2
- package/components/field/_macro.njk +5 -5
- package/components/fieldset/_fieldset.scss +5 -0
- package/components/fieldset/_macro.njk +8 -8
- package/components/footer/_macro.njk +19 -23
- package/components/footer/_macro.spec.js +0 -6
- package/components/header/_macro.njk +39 -41
- package/components/header/_macro.spec.js +4 -8
- package/components/hero/_macro.njk +15 -15
- package/components/icons/_macro.njk +2 -2
- package/components/images/_macro.njk +3 -3
- package/components/input/_input-type.scss +4 -0
- package/components/input/_macro.njk +41 -34
- package/components/input/_macro.spec.js +66 -59
- package/components/label/_macro.njk +1 -1
- package/components/language-selector/_macro.njk +1 -1
- package/components/lists/_macro.njk +22 -22
- package/components/message/_macro.njk +6 -6
- package/components/message-list/_macro.njk +1 -1
- package/components/metadata/_macro.njk +2 -2
- package/components/modal/_macro.njk +4 -4
- package/components/mutually-exclusive/_macro.njk +1 -1
- package/components/mutually-exclusive/mutually-exclusive.js +3 -1
- package/components/navigation/_macro.njk +11 -10
- package/components/navigation/_macro.spec.js +3 -2
- package/components/pagination/_macro.njk +3 -3
- package/components/panel/_macro.njk +37 -39
- package/components/panel/_macro.spec.js +1 -13
- package/components/promotional-banner/_macro.njk +2 -2
- package/components/question/_macro.njk +20 -20
- package/components/question/_macro.spec.js +2 -2
- package/components/question/_question.scss +1 -1
- package/components/quote/_macro.njk +2 -2
- package/components/radios/_macro.njk +8 -8
- package/components/radios/check-radios.js +5 -1
- package/components/related-content/_macro.njk +2 -2
- package/components/relationships/_macro.njk +4 -3
- package/components/search/_macro.njk +12 -2
- package/components/search/_macro.spec.js +27 -2
- package/components/section-navigation/_macro.njk +2 -2
- package/components/select/_macro.njk +8 -8
- package/components/share-page/_macro.njk +2 -2
- package/components/status/_macro.njk +2 -2
- package/components/summary/_macro.njk +25 -25
- package/components/table/_macro.njk +10 -10
- package/components/table-of-contents/_macro.njk +4 -4
- package/components/textarea/_macro.njk +8 -8
- package/components/timeline/_macro.njk +1 -1
- package/components/video/_macro.njk +1 -1
- package/css/census.css +1 -1
- package/css/ids.css +1 -1
- package/css/main.css +1 -1
- package/layout/_template.njk +35 -35
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/patternlib.scss +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% macro onsPanel(params) %}
|
|
2
2
|
|
|
3
|
-
{% if params
|
|
3
|
+
{% if params.classes %}
|
|
4
4
|
{% set classes = ' ' + params.classes %}
|
|
5
5
|
{% endif %}
|
|
6
6
|
|
|
@@ -8,37 +8,37 @@
|
|
|
8
8
|
{% set noTitleClass = ' ons-panel--no-title' %}
|
|
9
9
|
{% endif %}
|
|
10
10
|
|
|
11
|
-
{% if params
|
|
11
|
+
{% if params.type %}
|
|
12
12
|
{% set typeClass = ' ons-panel--' + params.type %}
|
|
13
13
|
{% else %}
|
|
14
14
|
{% set typeClass = ' ons-panel--info' %}
|
|
15
15
|
{% endif %}
|
|
16
16
|
|
|
17
|
-
{% if params
|
|
17
|
+
{% if params.type == "warn-branded" %}
|
|
18
18
|
{% set containerClass = 'ons-branded-warning' %}
|
|
19
19
|
{% endif %}
|
|
20
20
|
|
|
21
|
-
{% if params
|
|
21
|
+
{% if params.type == "announcement" %}
|
|
22
22
|
{% set containerClass = 'ons-announcement' %}
|
|
23
23
|
{% endif %}
|
|
24
24
|
|
|
25
|
-
{% if params
|
|
25
|
+
{% if params.spacious %}
|
|
26
26
|
{% set spaciousClass = ' ons-panel--spacious' %}
|
|
27
27
|
{% endif %}
|
|
28
28
|
|
|
29
|
-
{% if params
|
|
29
|
+
{% if params.type == "warn-branded" or params.type == "announcement" %}
|
|
30
30
|
<div class="{{containerClass}}">
|
|
31
31
|
<div class="ons-container">
|
|
32
32
|
{% endif %}
|
|
33
33
|
|
|
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
|
|
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 and params.attributes %}{% for attribute, value in (params.attributes.items() if params and params.attributes is mapping and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params and params.id %} id="{{params.id}}"{% endif %}>
|
|
35
35
|
|
|
36
|
-
{% if params
|
|
36
|
+
{% if params.type == "warn" or params.type == "warn-branded" %}
|
|
37
37
|
<span class="ons-panel__icon" aria-hidden="true">!</span>
|
|
38
38
|
<span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Warning: ") }}</span>
|
|
39
39
|
{% endif %}
|
|
40
40
|
|
|
41
|
-
{% if params
|
|
41
|
+
{% if params.type == "announcement" %}
|
|
42
42
|
{% from "components/icons/_macro.njk" import onsIcon %}
|
|
43
43
|
<span class="ons-panel__icon" aria-hidden="true">
|
|
44
44
|
{{
|
|
@@ -50,45 +50,43 @@
|
|
|
50
50
|
<span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Announcement: ") }}</span>
|
|
51
51
|
{% endif %}
|
|
52
52
|
|
|
53
|
-
{% if params
|
|
54
|
-
{% if params.
|
|
55
|
-
{%
|
|
56
|
-
{% set defaultTitleTag = "h2" %}
|
|
57
|
-
{% else %}
|
|
58
|
-
{% set defaultTitleTag = "div" %}
|
|
59
|
-
{% endif %}
|
|
60
|
-
{% set titleTag = params.titleTag | default(defaultTitleTag) %}
|
|
61
|
-
<div class="ons-panel__header">
|
|
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
|
-
</div>
|
|
53
|
+
{% if params.title %}
|
|
54
|
+
{% if params.type == 'error' %}
|
|
55
|
+
{% set defaultTitleTag = "h2" %}
|
|
64
56
|
{% else %}
|
|
65
|
-
{%
|
|
66
|
-
<span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Important information: ") }}</span>
|
|
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>
|
|
70
|
-
{% endif %}
|
|
57
|
+
{% set defaultTitleTag = "div" %}
|
|
71
58
|
{% endif %}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{%
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</span>
|
|
59
|
+
{% set titleTag = params.titleTag | default(defaultTitleTag) %}
|
|
60
|
+
<div class="ons-panel__header">
|
|
61
|
+
<{{ 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 }}>
|
|
62
|
+
</div>
|
|
63
|
+
{% else %}
|
|
64
|
+
{% if not params.type or params.type == "branded" or params.type == "info" or params.type == "bare" %}
|
|
65
|
+
<span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Important information: ") }}</span>
|
|
66
|
+
{% elif params.type == 'error' or params.type == 'success' %}
|
|
67
|
+
{% set defaultText = "Completed" if params.type == "success" else "Error" %}
|
|
68
|
+
<span{% if params.type == "success" %} id="alert"{% endif %} class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default(defaultText ~ ": ") }}</span>
|
|
83
69
|
{% endif %}
|
|
84
70
|
{% endif %}
|
|
85
71
|
|
|
86
|
-
|
|
72
|
+
{% if params.iconType %}
|
|
73
|
+
{% from "components/icons/_macro.njk" import onsIcon %}
|
|
74
|
+
<span class= "ons-panel__icon ons-u-fs-{{ params.iconSize | default('r') }}">
|
|
75
|
+
{{
|
|
76
|
+
onsIcon({
|
|
77
|
+
"iconType": params.iconType,
|
|
78
|
+
"iconSize": params.iconSize
|
|
79
|
+
})
|
|
80
|
+
}}
|
|
81
|
+
</span>
|
|
82
|
+
{% endif %}
|
|
83
|
+
|
|
84
|
+
<div class="ons-panel__body{% if params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}">{{ (params.body if params else "") | safe }}
|
|
87
85
|
{{ caller() if caller }}
|
|
88
86
|
</div>
|
|
89
87
|
</div>
|
|
90
88
|
|
|
91
|
-
{% if params
|
|
89
|
+
{% if params.type == "warn-branded" or params.type == "announcement" %}
|
|
92
90
|
</div>
|
|
93
91
|
</div>
|
|
94
92
|
{% endif %}
|
|
@@ -13,6 +13,7 @@ const EXAMPLE_PANEL_BASIC = {
|
|
|
13
13
|
describe('macro: panel', () => {
|
|
14
14
|
describe.each([
|
|
15
15
|
['info', 'Important information:'],
|
|
16
|
+
['bare', 'Important information:'],
|
|
16
17
|
['error', 'Error:'],
|
|
17
18
|
['warn', 'Warning:'],
|
|
18
19
|
['warn-branded', 'Warning:'],
|
|
@@ -316,19 +317,6 @@ describe('macro: panel', () => {
|
|
|
316
317
|
});
|
|
317
318
|
});
|
|
318
319
|
|
|
319
|
-
describe('mode: bare', () => {
|
|
320
|
-
it('has the correct class set', () => {
|
|
321
|
-
const $ = cheerio.load(
|
|
322
|
-
renderComponent('panel', {
|
|
323
|
-
...EXAMPLE_PANEL_BASIC,
|
|
324
|
-
type: 'bare',
|
|
325
|
-
}),
|
|
326
|
-
);
|
|
327
|
-
|
|
328
|
-
expect($('.ons-panel').hasClass('ons-panel--bare')).toBe(true);
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
|
|
332
320
|
describe('mode: warn', () => {
|
|
333
321
|
it('has a default "!" prefix', () => {
|
|
334
322
|
const $ = cheerio.load(
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<div class="ons-grid ons-grid--gutterless">
|
|
8
8
|
|
|
9
|
-
{% if params.image
|
|
9
|
+
{% if params.image %}
|
|
10
10
|
|
|
11
11
|
<div class="ons-grid__col ons-col-7@s">
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<div class="ons-grid__col ons-col-4@s ons-push-1@s ons-u-d-no@xxs@s">
|
|
20
20
|
|
|
21
21
|
<div class="ons-promo-banner__image">
|
|
22
|
-
{% if params.image.smallSrc
|
|
22
|
+
{% if params.image.smallSrc %}
|
|
23
23
|
<img srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x" src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}">
|
|
24
24
|
{% else %}
|
|
25
25
|
<img src="{{ params.image.src }}" alt="{{ params.image.alt }}">
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{% macro onsQuestion(params) %}
|
|
2
2
|
|
|
3
|
-
{%- set titleHtml -%}{% if params.readDescriptionFirst
|
|
3
|
+
{%- set titleHtml -%}{% if params.readDescriptionFirst == true and params.description %}
|
|
4
4
|
<div class="ons-question__description ons-u-vh">{{ params.description | safe }} </div>{% endif %}{{- params.title | safe -}}
|
|
5
5
|
{%- endset -%}
|
|
6
6
|
|
|
7
|
-
{%- set descHtml -%}{% if params.readDescriptionFirst
|
|
7
|
+
{%- set descHtml -%}{% if params.readDescriptionFirst == true %}
|
|
8
8
|
<div aria-hidden="true" {% if params.legendIsQuestionTitle is not defined %}class="ons-question__description ons-question__description--aria-hidden"{% endif %}>{{- params.description | safe -}}</div>
|
|
9
9
|
{% elif params.legendIsQuestionTitle is not defined %}
|
|
10
10
|
<div class="ons-question__description ons-u-mb-m">{{- params.description | safe -}}</div>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<div class="ons-question__instruction ons-u-mb-m">{{ params.instruction | safe }}</div>
|
|
17
17
|
{% endset %}
|
|
18
18
|
|
|
19
|
-
{% if params.definition
|
|
19
|
+
{% if params.definition %}
|
|
20
20
|
{% set questionDefinition %}
|
|
21
21
|
{% from "components/collapsible/_macro.njk" import onsCollapsible %}
|
|
22
22
|
{% call onsCollapsible({
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
{% endset %}
|
|
32
32
|
{% endif %}
|
|
33
33
|
|
|
34
|
-
{% if params.guidance
|
|
34
|
+
{% if params.guidance %}
|
|
35
35
|
{% set questionGuidance %}
|
|
36
36
|
{% from "components/panel/_macro.njk" import onsPanel %}
|
|
37
37
|
{% call onsPanel({
|
|
38
38
|
"classes": "ons-question-guidance ons-u-mb-m"
|
|
39
39
|
}) %}
|
|
40
|
-
{% if params.guidance.content
|
|
40
|
+
{% if params.guidance.content %}
|
|
41
41
|
{{ params.guidance.content | safe }}
|
|
42
42
|
{% endif %}
|
|
43
|
-
{% if params.guidance.lists
|
|
43
|
+
{% if params.guidance.lists %}
|
|
44
44
|
{%- for item in params.guidance.lists -%}
|
|
45
|
-
{% if item.listHeading
|
|
45
|
+
{% if item.listHeading %}
|
|
46
46
|
<h2 class="ons-question-guidance__list-heading ons-u-fs-r--b">{{ item.listHeading }}</h2>
|
|
47
47
|
{% endif %}
|
|
48
|
-
{% if item.listLeadingLine
|
|
48
|
+
{% if item.listLeadingLine %}
|
|
49
49
|
<p class="ons-question-guidance__list-leading-line">{{ item.listLeadingLine }}</p>
|
|
50
50
|
{% endif %}
|
|
51
51
|
{% from "components/lists/_macro.njk" import onsList %}
|
|
@@ -61,20 +61,20 @@
|
|
|
61
61
|
{% endif %}
|
|
62
62
|
|
|
63
63
|
<div
|
|
64
|
-
{% if params.id
|
|
65
|
-
class="ons-question ons-u-mb-l{% if params.classes
|
|
66
|
-
{% if params.attributes
|
|
64
|
+
{% if params.id %} id="{{ params.id }}"{% endif %}
|
|
65
|
+
class="ons-question ons-u-mb-l{% if params.classes %} {{ params.classes }}{% endif %}"
|
|
66
|
+
{% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
|
|
67
67
|
>
|
|
68
|
-
{% if params.legendIsQuestionTitle
|
|
68
|
+
{% if params.legendIsQuestionTitle %}
|
|
69
69
|
{% from "components/fieldset/_macro.njk" import onsFieldset %}
|
|
70
70
|
|
|
71
|
-
{# Resolves caller issue in
|
|
71
|
+
{# Resolves caller issue in Jinja: https://github.com/pallets/jinja/issues/371 #}
|
|
72
72
|
{% set content = caller() if caller %}
|
|
73
73
|
<div class="ons-question__answer ons-u-mb-m">
|
|
74
74
|
{% call onsFieldset({
|
|
75
75
|
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
76
76
|
"legend": titleHtml,
|
|
77
|
-
"description": descHtml if params.description
|
|
77
|
+
"description": descHtml if params.description else '',
|
|
78
78
|
"legendClasses": params.legendClasses,
|
|
79
79
|
"legendTitleClasses": params.legendTitleClasses
|
|
80
80
|
}) %}
|
|
@@ -87,19 +87,19 @@
|
|
|
87
87
|
{{- titleHtml | safe -}}
|
|
88
88
|
</h1>
|
|
89
89
|
|
|
90
|
-
{% if params.description
|
|
90
|
+
{% if params.description %}
|
|
91
91
|
{{- descHtml | safe -}}
|
|
92
92
|
{% endif %}
|
|
93
93
|
|
|
94
|
-
{% if params.instruction
|
|
94
|
+
{% if params.instruction %}
|
|
95
95
|
{{- instHtml | safe -}}
|
|
96
96
|
{% endif %}
|
|
97
97
|
|
|
98
|
-
{% if params.definition
|
|
98
|
+
{% if params.definition %}
|
|
99
99
|
{{- questionDefinition | safe -}}
|
|
100
100
|
{% endif %}
|
|
101
101
|
|
|
102
|
-
{% if params.guidance
|
|
102
|
+
{% if params.guidance %}
|
|
103
103
|
{{- questionGuidance | safe -}}
|
|
104
104
|
{% endif %}
|
|
105
105
|
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
</div>
|
|
109
109
|
{% endif %}
|
|
110
110
|
|
|
111
|
-
{% if params.justification
|
|
111
|
+
{% if params.justification %}
|
|
112
112
|
{% from "components/collapsible/_macro.njk" import onsCollapsible %}
|
|
113
113
|
{% call onsCollapsible({
|
|
114
114
|
"id": params.justification.id,
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
{{
|
|
126
126
|
onsButton({
|
|
127
127
|
"id": params.submitButton.id,
|
|
128
|
-
"
|
|
128
|
+
"variants": params.submitButton.variants,
|
|
129
129
|
"text": params.submitButton.text | default ('Save and continue'),
|
|
130
130
|
"classes": params.submitButton.classes,
|
|
131
131
|
"attributes": params.submitButton.attributes
|
|
@@ -47,7 +47,7 @@ const EXAMPLE_QUESTION_BUTTON = {
|
|
|
47
47
|
...EXAMPLE_QUESTION_BASIC,
|
|
48
48
|
submitButton: {
|
|
49
49
|
id: 'button-id',
|
|
50
|
-
|
|
50
|
+
variants: 'timer',
|
|
51
51
|
text: 'Button text',
|
|
52
52
|
},
|
|
53
53
|
};
|
|
@@ -252,7 +252,7 @@ describe('macro: question', () => {
|
|
|
252
252
|
|
|
253
253
|
faker.renderComponent('question', EXAMPLE_QUESTION_BUTTON);
|
|
254
254
|
|
|
255
|
-
expect(buttonSpy.occurrences[0]).toHaveProperty('
|
|
255
|
+
expect(buttonSpy.occurrences[0]).toHaveProperty('variants', 'timer');
|
|
256
256
|
expect(buttonSpy.occurrences[0]).toHaveProperty('id', 'button-id');
|
|
257
257
|
expect(buttonSpy.occurrences[0]).toHaveProperty('text', 'Button text');
|
|
258
258
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"iconType": 'quote'
|
|
7
7
|
})
|
|
8
8
|
}}
|
|
9
|
-
<span class="ons-quote__text ons-u-fs-{{ params.textFontSize if params.textFontSize
|
|
10
|
-
{% if params.ref
|
|
9
|
+
<span class="ons-quote__text ons-u-fs-{{ params.textFontSize if params.textFontSize else 'l' }}">{{ caller() if caller else params.text | safe }}</span>
|
|
10
|
+
{% if params.ref %}<span class="ons-quote__ref">— {{ params.ref | safe }}</span>{% endif %}
|
|
11
11
|
</blockquote>
|
|
12
12
|
{% endmacro %}
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
}) %}
|
|
16
16
|
<div class="ons-radios__items">
|
|
17
17
|
{% for radio in params.radios %}
|
|
18
|
-
{% if params.or
|
|
18
|
+
{% if params.or and loop.revindex0 == 0 %}
|
|
19
19
|
<span class="ons-radios__label ons-u-mt-s ons-u-fs-r--b" aria-hidden="true">{{ params.or }}</span>
|
|
20
20
|
{% endif %}
|
|
21
21
|
<span class="ons-radios__item{{ " ons-radios__item--no-border" if params.borderless }}">
|
|
22
22
|
<span class="ons-radio{{ " ons-radio--no-border" if params.borderless }}">
|
|
23
|
-
{% if radio.other
|
|
23
|
+
{% if radio.other and radio.other.selectAllChildren == true %}
|
|
24
24
|
{% set selectAllClass = ' ons-js-select-all-children' %}
|
|
25
25
|
{% else %}
|
|
26
26
|
{% set selectAllClass = '' %}
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
<input
|
|
29
29
|
type="radio"
|
|
30
30
|
id="{{ radio.id }}"
|
|
31
|
-
class="ons-radio__input ons-js-radio{{ ' ' + params.inputClasses if params.inputClasses
|
|
31
|
+
class="ons-radio__input ons-js-radio{{ ' ' + params.inputClasses if params.inputClasses else '' }}{{ ' ' + radio.classes if radio.classes else '' }}{{ ' ons-js-other' if radio.other else '' }}{{ selectAllClass }}"
|
|
32
32
|
value="{{ radio.value }}"
|
|
33
33
|
name="{{ params.name }}"
|
|
34
|
-
{% if
|
|
35
|
-
{% if radio.other
|
|
36
|
-
{% if radio.attributes
|
|
34
|
+
{% if radio.checked or (params.value is defined and params.value == radio.value) %} checked {% endif %}
|
|
35
|
+
{% if radio.other and not radio.other.open %} aria-controls="{{ radio.id }}-other-wrap" aria-haspopup="true"{% endif %}
|
|
36
|
+
{% if radio.attributes %}{% for attribute, value in (radio.attributes.items() if radio.attributes is mapping and radio.attributes.items else radio.attributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
|
|
37
37
|
>
|
|
38
38
|
{{ onsLabel({
|
|
39
39
|
"id": radio.id + "-label",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"classes": "ons-radio__label " + radio.label.classes | default(''),
|
|
44
44
|
"description": radio.label.description
|
|
45
45
|
}) }}
|
|
46
|
-
{% if radio.other
|
|
46
|
+
{% if radio.other %}
|
|
47
47
|
{% set otherType = radio.other.otherType | default('input') %}
|
|
48
48
|
<span class="ons-radio__other{{ " " + 'ons-radio__other--open' if radio.other.open else "" }}" id="{{ radio.id }}-other-wrap">
|
|
49
49
|
{% if otherType == "input" %}
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
{% endif %}
|
|
125
125
|
{% endfor %}
|
|
126
126
|
</div>
|
|
127
|
-
{% if params.clearRadios
|
|
127
|
+
{% if params.clearRadios %}
|
|
128
128
|
{{ onsButton({
|
|
129
129
|
"text": params.clearRadios.text,
|
|
130
130
|
"name": params.clearRadios.name,
|
|
@@ -3,11 +3,15 @@ export default class CheckRadios {
|
|
|
3
3
|
this.radio = radio;
|
|
4
4
|
this.openOther = openOther;
|
|
5
5
|
this.input = this.openOther.querySelector('.ons-input');
|
|
6
|
+
this.input.tabIndex = -1;
|
|
6
7
|
|
|
7
8
|
this.setInputBlurAttributes();
|
|
8
9
|
this.input.addEventListener('focus', this.checkRadio.bind(this));
|
|
9
10
|
this.radio.addEventListener('change', this.setInputFocusAttributes.bind(this));
|
|
10
|
-
this.radio.addEventListener('
|
|
11
|
+
this.radio.addEventListener('focus', this.setInputFocusAttributes.bind(this));
|
|
12
|
+
if (this.radio.type == 'radio') {
|
|
13
|
+
this.input.addEventListener('blur', this.setInputBlurAttributes.bind(this));
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
checkRadio() {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{% macro onsRelatedContent(params) %}
|
|
2
2
|
|
|
3
|
-
{% if params
|
|
3
|
+
{% if params.classes %}
|
|
4
4
|
{% set classes = ' ' + params.classes %}
|
|
5
5
|
{% endif %}
|
|
6
6
|
|
|
7
7
|
<aside class="ons-related-content{{ classes }}" aria-label="{{ params.ariaLabel | default("Related content") }}">
|
|
8
8
|
|
|
9
9
|
<div class="ons-related-content__body">
|
|
10
|
-
{% if params.rows
|
|
10
|
+
{% if params.rows %}
|
|
11
11
|
{% for row in params.rows %}
|
|
12
12
|
{% from "components/related-content/_section-macro.njk" import onsRelatedContentSection %}
|
|
13
13
|
{% call onsRelatedContentSection(
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
{% macro onsRelationships(params) %}
|
|
4
4
|
<div
|
|
5
|
-
{% if params.id
|
|
6
|
-
class="ons-relationships ons-js-relationships{% if params.classes
|
|
5
|
+
{% if params.id %}id="{{ params.id }}"{% endif %}
|
|
6
|
+
class="ons-relationships ons-js-relationships{% if params.classes %} {{ params.classes }}{% endif %}"
|
|
7
7
|
>
|
|
8
8
|
{{ onsRadios({
|
|
9
9
|
"name": params.name,
|
|
10
10
|
"dontWrap": params.dontWrap,
|
|
11
11
|
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
12
|
-
"radios": params.radios
|
|
12
|
+
"radios": params.radios,
|
|
13
|
+
"error": params.error
|
|
13
14
|
}) }}
|
|
14
15
|
<p class="ons-relationships__playback ons-js-relationships-playback ons-u-d-no" aria-live="polite">{{ params.playback | safe }}</p>
|
|
15
16
|
</div>
|
|
@@ -5,15 +5,25 @@
|
|
|
5
5
|
|
|
6
6
|
<div class="ons-search-component">
|
|
7
7
|
{{ content | safe }}
|
|
8
|
+
|
|
9
|
+
{%- set buttonLabel -%}
|
|
10
|
+
{%- if params.searchButton.visuallyHideButtonText == true -%}
|
|
11
|
+
<span class="ons-u-vh">{{ params.searchButton.text }}</span>
|
|
12
|
+
{%- else -%}
|
|
13
|
+
{{ params.searchButton.text }}
|
|
14
|
+
{%- endif -%}
|
|
15
|
+
{%- endset -%}
|
|
16
|
+
|
|
8
17
|
{{
|
|
9
18
|
onsButton({
|
|
10
19
|
"type": params.searchButton.type,
|
|
11
|
-
"
|
|
20
|
+
"html": buttonLabel,
|
|
12
21
|
"id": params.searchButton.id,
|
|
13
22
|
"variants": 'small',
|
|
14
23
|
"classes": 'ons-search__btn ons-u-mt-xs@xxs@s' + (" " + params.searchButton.classes if params.searchButton.classes else ""),
|
|
15
24
|
"attributes": params.searchButton.attributes,
|
|
16
|
-
"iconType": params.searchButton.iconType
|
|
25
|
+
"iconType": params.searchButton.iconType,
|
|
26
|
+
"iconPosition": 'only' if params.searchButton.visuallyHideButtonText == true else 'before'
|
|
17
27
|
})
|
|
18
28
|
}}
|
|
19
29
|
</div>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as cheerio from 'cheerio';
|
|
4
4
|
|
|
5
|
-
import axe from '../../tests/helpers/axe';
|
|
6
5
|
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
7
6
|
|
|
8
7
|
const EXAMPLE_SEARCH = {
|
|
@@ -34,11 +33,37 @@ describe('macro: search', () => {
|
|
|
34
33
|
expect(buttonSpy.occurrences[0]).toEqual({
|
|
35
34
|
id: 'search-button-id',
|
|
36
35
|
type: 'button',
|
|
37
|
-
|
|
36
|
+
html: 'Search for address',
|
|
38
37
|
variants: 'small',
|
|
39
38
|
classes: 'ons-search__btn ons-u-mt-xs@xxs@s extra-search-button-class',
|
|
40
39
|
attributes: EXAMPLE_SEARCH.searchButton.attributes,
|
|
41
40
|
iconType: 'search',
|
|
41
|
+
iconPosition: 'before',
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('renders button component with a visibly hidden label when specified', () => {
|
|
46
|
+
const faker = templateFaker();
|
|
47
|
+
const buttonSpy = faker.spy('button');
|
|
48
|
+
|
|
49
|
+
faker.renderComponent('input', {
|
|
50
|
+
searchButton: {
|
|
51
|
+
id: 'search-button-id',
|
|
52
|
+
type: 'button',
|
|
53
|
+
text: 'Search for address',
|
|
54
|
+
iconType: 'search',
|
|
55
|
+
visuallyHideButtonText: true,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(buttonSpy.occurrences[0]).toEqual({
|
|
60
|
+
id: 'search-button-id',
|
|
61
|
+
type: 'button',
|
|
62
|
+
html: '<span class="ons-u-vh">Search for address</span>',
|
|
63
|
+
variants: 'small',
|
|
64
|
+
classes: 'ons-search__btn ons-u-mt-xs@xxs@s',
|
|
65
|
+
iconPosition: 'only',
|
|
66
|
+
iconType: 'search',
|
|
42
67
|
});
|
|
43
68
|
});
|
|
44
69
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{% macro onsSectionNavigation(params) %}
|
|
2
|
-
<nav class="ons-section-nav{% if params.variants
|
|
2
|
+
<nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %}" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Section menu") }}">
|
|
3
3
|
<ul class="ons-section-nav__list">
|
|
4
4
|
{% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
|
|
5
5
|
{% if (params.currentPath and (item.url == params.currentPath or item.url in params.currentPath)) or (params.tabQuery and params.tabQuery == item.title|lower) %}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{% endif %}
|
|
10
10
|
<li class="ons-section-nav__item{% if item.classes %} ' ' + {{ item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
|
|
11
11
|
<a class="ons-section-nav__link" href="{{ item.url }}"{% if isCurrent == true %} aria-current="location"{% endif %}>{{ item.title }}</a>
|
|
12
|
-
{% if item.anchors
|
|
12
|
+
{% if item.anchors %}
|
|
13
13
|
<ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
|
|
14
14
|
{% for anchor in item.anchors %}
|
|
15
15
|
<li class="ons-section-nav__item ons-list__item">
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"legendClasses": params.legendClasses,
|
|
9
9
|
"dontWrap": params.dontWrap,
|
|
10
10
|
"error": params.error,
|
|
11
|
-
"inline": params.label.inline if params.label
|
|
11
|
+
"inline": params.label.inline if params.label else ''
|
|
12
12
|
}) %}
|
|
13
13
|
{{
|
|
14
14
|
onsLabel({
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
<select
|
|
22
22
|
id="{{ params.id }}"
|
|
23
23
|
name="{{ params.name }}"
|
|
24
|
-
class="ons-input ons-input--select{% if params.classes %} {{ params.classes }}{% endif %}{% if params.error
|
|
25
|
-
{% if params.value
|
|
26
|
-
{% if params.attributes
|
|
24
|
+
class="ons-input ons-input--select{% if params.classes %} {{ params.classes }}{% endif %}{% if params.error %} ons-input--error{% endif %}"
|
|
25
|
+
{% if params.value %}value="{{ params.value}}" {% endif %}
|
|
26
|
+
{% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
|
|
27
27
|
>
|
|
28
28
|
{% for option in params.options %}
|
|
29
29
|
<option value="{{ option.value | default(option.text) }}"
|
|
30
|
-
{% if option.id
|
|
31
|
-
{% if option.selected
|
|
32
|
-
{% if option.disabled
|
|
33
|
-
{% if params.attributes
|
|
30
|
+
{% if option.id %}id="{{ option.id }}" {% endif %}
|
|
31
|
+
{% if option.selected %}selected {% endif %}
|
|
32
|
+
{% if option.disabled %}disabled {% endif %}
|
|
33
|
+
{% if params.attributes %}{% for attribute, value in option.attributes %}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
|
|
34
34
|
>
|
|
35
35
|
{{- option.text -}}
|
|
36
36
|
</option>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
{% endif %}
|
|
8
8
|
|
|
9
9
|
{% set list = [] %}
|
|
10
|
-
{% if params.facebook
|
|
10
|
+
{% if params.facebook and params.facebook == true %}
|
|
11
11
|
{% set facebook =
|
|
12
12
|
{
|
|
13
13
|
"url": 'https://www.facebook.com/sharer/sharer.php?u=' ~ params.pageURL|urlencode,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
{% set list = (list.push(facebook), list) %}
|
|
22
22
|
{% endif %}
|
|
23
|
-
{% if params.twitter
|
|
23
|
+
{% if params.twitter and params.twitter == true %}
|
|
24
24
|
{% set twitter =
|
|
25
25
|
{
|
|
26
26
|
"url": 'https://twitter.com/intent/tweet?original_referer&text=' ~ params.pageTitle|urlencode ~ '&url=' ~ params.pageURL|urlencode,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{% macro onsStatus(params) %}
|
|
2
|
-
{% if params.type
|
|
2
|
+
{% if params.type %}
|
|
3
3
|
{% set typeClass = ' ons-status--' + params.type %}
|
|
4
4
|
{% else %}
|
|
5
5
|
{% set typeClass = ' ons-status--info' %}
|
|
6
6
|
{% endif %}
|
|
7
7
|
|
|
8
|
-
{% if params.size
|
|
8
|
+
{% if params.size == 'small' %}
|
|
9
9
|
{% set sizeClass = ' ons-status--small' %}
|
|
10
10
|
{% endif %}
|
|
11
11
|
|