@ons/design-system 67.0.6 → 67.2.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/date-field-input/_macro.njk +86 -0
- package/components/date-input/_macro.njk +79 -115
- package/components/{metadata/_metadata.scss → description-list/_description-list.scss} +2 -2
- package/components/description-list/_macro.njk +14 -0
- package/components/{metadata → description-list}/_macro.spec.js +26 -26
- package/components/{metadata/example-metadata.njk → description-list/example-description-list.njk} +3 -3
- package/components/document-list/document-list.scss +1 -1
- package/components/download-resources/_download-resources.scss +1 -1
- package/components/duration/_macro.njk +60 -85
- package/components/header/_header.scss +8 -0
- package/components/header/_macro.njk +59 -35
- package/components/header/_macro.spec.js +115 -0
- package/components/header/example-header-multiple-logos.njk +110 -0
- package/components/hero/_macro.njk +1 -3
- package/components/hero/_macro.spec.js +4 -12
- package/components/metadata/_macro.njk +12 -12
- package/components/summary/_macro.njk +14 -9
- package/components/summary/_macro.spec.js +23 -3
- package/components/summary/_summary.scss +34 -2
- package/components/summary/example-summary-card-grouped.njk +352 -0
- package/components/summary/example-summary-hub.njk +1 -1
- package/css/main.css +1 -1
- package/css/print.css +1 -1
- package/layout/_template.njk +1 -1
- package/package.json +2 -5
- package/scss/main.scss +1 -1
- package/scss/utilities/_margin.scss +1 -0
- package/scss/vars/_colors.scss +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{% from "components/mutually-exclusive/_macro.njk" import onsMutuallyExclusive %}
|
|
2
|
+
{% from "components/fieldset/_macro.njk" import onsFieldset %}
|
|
3
|
+
{% from "components/input/_macro.njk" import onsInput %}
|
|
4
|
+
{% from "components/error/_macro.njk" import onsError %}
|
|
5
|
+
|
|
6
|
+
{% macro onsDateFieldInput(params) %}
|
|
7
|
+
{% set fields %}
|
|
8
|
+
{% for field in params.fields %}
|
|
9
|
+
{{
|
|
10
|
+
onsInput({
|
|
11
|
+
"id": field.id,
|
|
12
|
+
"classes": field.classes,
|
|
13
|
+
"width": field.width,
|
|
14
|
+
"type": "number",
|
|
15
|
+
"name": field.name,
|
|
16
|
+
"value": field.value,
|
|
17
|
+
"min": field.min,
|
|
18
|
+
"max": field.max,
|
|
19
|
+
"maxLength": field.maxLength,
|
|
20
|
+
"suffix": field.suffix,
|
|
21
|
+
"label": field.label,
|
|
22
|
+
"attributes": field.attributes,
|
|
23
|
+
"error": field.error,
|
|
24
|
+
"fieldId": field.fieldId
|
|
25
|
+
})
|
|
26
|
+
}}
|
|
27
|
+
{% endfor %}
|
|
28
|
+
{% endset %}
|
|
29
|
+
|
|
30
|
+
{% if numberOfFields > 1 %}
|
|
31
|
+
{% set fields %}
|
|
32
|
+
<div class="ons-field-group">
|
|
33
|
+
{{ fields | safe }}
|
|
34
|
+
</div>
|
|
35
|
+
{% endset %}
|
|
36
|
+
{% endif %}
|
|
37
|
+
|
|
38
|
+
{% if params.mutuallyExclusive %}
|
|
39
|
+
{% set mutuallyExclusive = params.mutuallyExclusive | setAttributes({
|
|
40
|
+
"id": params.id,
|
|
41
|
+
"legend": params.legendOrLabel,
|
|
42
|
+
"legendClasses": params.legendClasses,
|
|
43
|
+
"description": params.description,
|
|
44
|
+
"error": params.error,
|
|
45
|
+
"classes": params.classes,
|
|
46
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
47
|
+
"dontWrap": params.dontWrap,
|
|
48
|
+
"exclusiveOptions": params.mutuallyExclusive.exclusiveOptions,
|
|
49
|
+
"or": params.mutuallyExclusive.or,
|
|
50
|
+
"deselectMessage": params.mutuallyExclusive.deselectMessage,
|
|
51
|
+
"deselectGroupAdjective": params.mutuallyExclusive.deselectGroupAdjective,
|
|
52
|
+
"deselectExclusiveOptionAdjective": params.mutuallyExclusive.deselectExclusiveOptionAdjective
|
|
53
|
+
}) %}
|
|
54
|
+
|
|
55
|
+
{% call onsMutuallyExclusive(mutuallyExclusive) %}
|
|
56
|
+
<div class="ons-field-group">
|
|
57
|
+
{{ fields | safe }}
|
|
58
|
+
</div>
|
|
59
|
+
{% endcall %}
|
|
60
|
+
{% elif params.numberOfFields > 1 %}
|
|
61
|
+
{% call onsFieldset({
|
|
62
|
+
"id": params.id,
|
|
63
|
+
"legend": params.legendOrLabel,
|
|
64
|
+
"classes": params.classes,
|
|
65
|
+
"description": params.description,
|
|
66
|
+
"legendClasses": params.legendClasses,
|
|
67
|
+
"error": params.error,
|
|
68
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
69
|
+
"dontWrap": params.dontWrap
|
|
70
|
+
}) %}
|
|
71
|
+
<div class="ons-field-group">
|
|
72
|
+
{{ fields | safe }}
|
|
73
|
+
</div>
|
|
74
|
+
{% endcall %}
|
|
75
|
+
{% elif params.numberOfFields == 1 %}
|
|
76
|
+
{% if params.error %}
|
|
77
|
+
{% call onsError(params.error) %}
|
|
78
|
+
{{ fields | safe }}
|
|
79
|
+
{% endcall %}
|
|
80
|
+
{% else %}
|
|
81
|
+
{{ fields | safe }}
|
|
82
|
+
{% endif %}
|
|
83
|
+
{% else %}
|
|
84
|
+
{{ fields | safe }}
|
|
85
|
+
{% endif %}
|
|
86
|
+
{% endmacro %}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
{%
|
|
2
|
-
{% from "components/fieldset/_macro.njk" import onsFieldset %}
|
|
3
|
-
{% from "components/mutually-exclusive/_macro.njk" import onsMutuallyExclusive %}
|
|
4
|
-
{% from "components/input/_macro.njk" import onsInput %}
|
|
5
|
-
{% from "components/error/_macro.njk" import onsError %}
|
|
1
|
+
{% from "components/date-field-input/_macro.njk" import onsDateFieldInput %}
|
|
6
2
|
|
|
3
|
+
{% macro onsDateInput(params) %}
|
|
7
4
|
{% set exclusiveClass = " ons-js-exclusive-group-item" if params.mutuallyExclusive else "" %}
|
|
8
|
-
|
|
9
|
-
{%- set numberOfFields = 0 -%}
|
|
5
|
+
{%- set numberOfFields = 0 -%}
|
|
10
6
|
|
|
11
7
|
{%- if params.day -%}
|
|
12
8
|
{%- set numberOfFields = numberOfFields + 1 -%}
|
|
@@ -20,114 +16,82 @@
|
|
|
20
16
|
{%- set numberOfFields = numberOfFields + 1 -%}
|
|
21
17
|
{%- endif -%}
|
|
22
18
|
|
|
23
|
-
{% set fields %}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{% endif %}
|
|
43
|
-
|
|
44
|
-
{% if params.month %}
|
|
45
|
-
{{ onsInput({
|
|
46
|
-
"id": params.id + "-month",
|
|
47
|
-
"type": "number",
|
|
48
|
-
"name": params.month.name,
|
|
49
|
-
"classes": (" ons-input--error" if (params.error and params.month.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default(""),
|
|
50
|
-
"width": "2",
|
|
51
|
-
"min": 1,
|
|
52
|
-
"max": 12,
|
|
53
|
-
"maxLength": 2,
|
|
54
|
-
"attributes": params.month.attributes,
|
|
55
|
-
"label": {
|
|
56
|
-
"text": params.month.label.text if numberOfFields > 1 else params.legendOrLabel,
|
|
57
|
-
"description": params.month.label.description if numberOfFields > 1 else params.description,
|
|
58
|
-
"id": params.id + "-month-label"
|
|
59
|
-
},
|
|
60
|
-
"value": params.month.value
|
|
61
|
-
}) }}
|
|
62
|
-
{% endif %}
|
|
63
|
-
|
|
64
|
-
{% if params.year %}
|
|
65
|
-
{{ onsInput({
|
|
66
|
-
"id": params.id + "-year",
|
|
67
|
-
"type": "number",
|
|
68
|
-
"name": params.year.name,
|
|
69
|
-
"classes": (" ons-input--error" if (params.error and params.year.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default(""),
|
|
70
|
-
"width": "4",
|
|
71
|
-
"min": 1000,
|
|
72
|
-
"max": 3000,
|
|
73
|
-
"maxLength": 4,
|
|
74
|
-
"attributes": params.year.attributes,
|
|
75
|
-
"label": {
|
|
76
|
-
"text": params.year.label.text if numberOfFields > 1 else params.legendOrLabel,
|
|
77
|
-
"description": params.year.label.description if numberOfFields > 1 else params.description,
|
|
78
|
-
"id": params.id + "-year-label"
|
|
79
|
-
},
|
|
80
|
-
"value": params.year.value
|
|
81
|
-
}) }}
|
|
82
|
-
{% endif %}
|
|
83
|
-
{% endset %}
|
|
84
|
-
|
|
85
|
-
{% if numberOfFields > 1 %}
|
|
86
|
-
{% set fields %}
|
|
87
|
-
<div class="ons-field-group">
|
|
88
|
-
{{ fields | safe }}
|
|
89
|
-
</div>
|
|
90
|
-
{% endset %}
|
|
19
|
+
{% set fields = [] %}
|
|
20
|
+
{% if params.day %}
|
|
21
|
+
{% set dayField = {
|
|
22
|
+
"id": params.id + "-day",
|
|
23
|
+
"label": {
|
|
24
|
+
"text": params.day.label.text if numberOfFields > 1 else params.legendOrLabel,
|
|
25
|
+
"description": params.day.label.description if numberOfFields > 1 else params.description,
|
|
26
|
+
"id": params.id + "-day-label"
|
|
27
|
+
},
|
|
28
|
+
"name": params.day.name,
|
|
29
|
+
"width": "2",
|
|
30
|
+
"min": 1,
|
|
31
|
+
"max": 31,
|
|
32
|
+
"maxLength": 2,
|
|
33
|
+
"attributes": params.day.attributes,
|
|
34
|
+
"value": params.day.value,
|
|
35
|
+
"classes": (" ons-input--error" if (params.error and params.day.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
|
|
36
|
+
} %}
|
|
37
|
+
{% set fields = (fields.push(dayField), fields) %}
|
|
91
38
|
{% endif %}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
{% endcall %}
|
|
111
|
-
{% elif numberOfFields == 1 %}
|
|
112
|
-
{% if params.error %}
|
|
113
|
-
{% call onsError(params.error) %}
|
|
114
|
-
{{ fields | safe }}
|
|
115
|
-
{% endcall %}
|
|
116
|
-
{% else %}
|
|
117
|
-
{{ fields | safe }}
|
|
118
|
-
{% endif %}
|
|
119
|
-
{% else %}
|
|
120
|
-
{% call onsFieldset({
|
|
121
|
-
"id": params.id,
|
|
122
|
-
"legend": params.legendOrLabel,
|
|
123
|
-
"legendClasses": params.legendClasses,
|
|
124
|
-
"description": params.description,
|
|
125
|
-
"classes": params.classes,
|
|
126
|
-
"dontWrap": params.dontWrap,
|
|
127
|
-
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
128
|
-
"error": params.error
|
|
129
|
-
}) %}
|
|
130
|
-
{{ fields | safe }}
|
|
131
|
-
{% endcall %}
|
|
39
|
+
{% if params.month %}
|
|
40
|
+
{% set monthField = {
|
|
41
|
+
"id": params.id + "-month",
|
|
42
|
+
"label": {
|
|
43
|
+
"text": params.month.label.text if numberOfFields > 1 else params.legendOrLabel,
|
|
44
|
+
"description": params.month.label.description if numberOfFields > 1 else params.description,
|
|
45
|
+
"id": params.id + "-month-label"
|
|
46
|
+
},
|
|
47
|
+
"name": params.month.name,
|
|
48
|
+
"width": "2",
|
|
49
|
+
"min": 1,
|
|
50
|
+
"max": 12,
|
|
51
|
+
"maxLength": 2,
|
|
52
|
+
"attributes": params.month.attributes,
|
|
53
|
+
"value": params.month.value,
|
|
54
|
+
"classes": (" ons-input--error" if (params.error and params.month.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
|
|
55
|
+
} %}
|
|
56
|
+
{% set fields = (fields.push(monthField), fields) %}
|
|
132
57
|
{% endif %}
|
|
58
|
+
{% if params.year %}
|
|
59
|
+
{% set yearField = {
|
|
60
|
+
"id": params.id + "-year",
|
|
61
|
+
"label": {
|
|
62
|
+
"text": params.year.label.text if numberOfFields > 1 else params.legendOrLabel,
|
|
63
|
+
"description": params.year.label.description if numberOfFields > 1 else params.description,
|
|
64
|
+
"id": params.id + "-year-label"
|
|
65
|
+
},
|
|
66
|
+
"name": params.year.name,
|
|
67
|
+
"width": "4",
|
|
68
|
+
"min": 1000,
|
|
69
|
+
"max": 3000,
|
|
70
|
+
"maxLength": 4,
|
|
71
|
+
"attributes": params.year.attributes,
|
|
72
|
+
"value": params.year.value,
|
|
73
|
+
"classes": (" ons-input--error" if (params.error and params.year.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
|
|
74
|
+
} %}
|
|
75
|
+
{% set fields = (fields.push(yearField), fields) %}
|
|
76
|
+
{% endif %}
|
|
77
|
+
|
|
78
|
+
{{ onsDateFieldInput({
|
|
79
|
+
"id": params.id,
|
|
80
|
+
"legendOrLabel": params.legendOrLabel,
|
|
81
|
+
"description": params.description,
|
|
82
|
+
"mutuallyExclusive": params.mutuallyExclusive,
|
|
83
|
+
"fields": fields,
|
|
84
|
+
"numberOfFields": numberOfFields,
|
|
85
|
+
"error": params.error,
|
|
86
|
+
"legend": params.legendOrLabel,
|
|
87
|
+
"dontWrap": params.dontWrap,
|
|
88
|
+
"legendClasses": params.legendClasses,
|
|
89
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
90
|
+
"classes": params.classes,
|
|
91
|
+
"exclusiveOptions": params.mutuallyExclusive.exclusiveOptions,
|
|
92
|
+
"or": params.mutuallyExclusive.or,
|
|
93
|
+
"deselectMessage": params.mutuallyExclusive.deselectMessage,
|
|
94
|
+
"deselectGroupAdjective": params.mutuallyExclusive.deselectGroupAdjective,
|
|
95
|
+
"deselectExclusiveOptionAdjective": params.mutuallyExclusive.deselectExclusiveOptionAdjective
|
|
96
|
+
}) }}
|
|
133
97
|
{% endmacro %}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{% macro onsDescriptionList(params) %}
|
|
2
|
+
<dl class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless ons-u-cf{{ (' ' + params.classes) if params.classes }}"{% if params.id %} id="{{ params.id }}" {% endif %}{% if params.descriptionListLabel %} title="{{ params.descriptionListLabel }}" aria-label="{{ params.descriptionListLabel }}"{% endif %}>
|
|
3
|
+
{% for item in params.itemsList %}
|
|
4
|
+
{% if item.term | length %}
|
|
5
|
+
<dt class="ons-description-list__term ons-grid__col ons-col-{{ params.termCol }}@m">{{ item.term }}</dt>
|
|
6
|
+
{% endif %}
|
|
7
|
+
{% for descriptionItem in item.descriptions %}
|
|
8
|
+
{% if descriptionItem.description | length %}
|
|
9
|
+
<dd {% if descriptionItem.id %}id="{{ descriptionItem.id }}" {% endif %}class="ons-description-list__value ons-grid__col ons-col-{{ params.descriptionCol }}@m">{{ descriptionItem.description }}</dd>
|
|
10
|
+
{% endif %}
|
|
11
|
+
{% endfor %}
|
|
12
|
+
{% endfor %}
|
|
13
|
+
</dl>
|
|
14
|
+
{% endmacro %}
|
|
@@ -5,10 +5,10 @@ import * as cheerio from 'cheerio';
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const EXAMPLE_DESCRIPTION_LIST_FULL = {
|
|
9
9
|
id: 'example-id',
|
|
10
10
|
classes: 'ons-u-mb-no',
|
|
11
|
-
|
|
11
|
+
descriptionListLabel: 'This is an example of the description list component',
|
|
12
12
|
termCol: 2,
|
|
13
13
|
descriptionCol: 10,
|
|
14
14
|
itemsList: [
|
|
@@ -37,7 +37,7 @@ const EXAMPLE_METADATA_FULL = {
|
|
|
37
37
|
],
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const EXAMPLE_DESCRIPTION_LIST_MINIMAL = {
|
|
41
41
|
itemsList: [
|
|
42
42
|
{
|
|
43
43
|
term: 'Survey:',
|
|
@@ -61,16 +61,16 @@ const EXAMPLE_METADATA_MINIMAL = {
|
|
|
61
61
|
],
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
describe('macro:
|
|
64
|
+
describe('macro: description-list', () => {
|
|
65
65
|
it('passes jest-axe checks when all parameters are provided', async () => {
|
|
66
|
-
const $ = cheerio.load(renderComponent('
|
|
66
|
+
const $ = cheerio.load(renderComponent('description-list', EXAMPLE_DESCRIPTION_LIST_FULL));
|
|
67
67
|
|
|
68
68
|
const results = await axe($.html());
|
|
69
69
|
expect(results).toHaveNoViolations();
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
it('passes jest-axe checks when minimal parameters are provided', async () => {
|
|
73
|
-
const $ = cheerio.load(renderComponent('
|
|
73
|
+
const $ = cheerio.load(renderComponent('description-list', EXAMPLE_DESCRIPTION_LIST_MINIMAL));
|
|
74
74
|
|
|
75
75
|
const results = await axe($.html());
|
|
76
76
|
expect(results).toHaveNoViolations();
|
|
@@ -78,8 +78,8 @@ describe('macro: metadata', () => {
|
|
|
78
78
|
|
|
79
79
|
it('has the provided `id` attribute', () => {
|
|
80
80
|
const $ = cheerio.load(
|
|
81
|
-
renderComponent('
|
|
82
|
-
...
|
|
81
|
+
renderComponent('description-list', {
|
|
82
|
+
...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
|
|
83
83
|
id: 'example-id',
|
|
84
84
|
}),
|
|
85
85
|
);
|
|
@@ -89,32 +89,32 @@ describe('macro: metadata', () => {
|
|
|
89
89
|
|
|
90
90
|
it('has additionally provided style classes', () => {
|
|
91
91
|
const $ = cheerio.load(
|
|
92
|
-
renderComponent('
|
|
93
|
-
...
|
|
92
|
+
renderComponent('description-list', {
|
|
93
|
+
...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
|
|
94
94
|
classes: 'extra-class another-extra-class',
|
|
95
95
|
}),
|
|
96
96
|
);
|
|
97
97
|
|
|
98
|
-
expect($('.ons-
|
|
99
|
-
expect($('.ons-
|
|
98
|
+
expect($('.ons-description-list').hasClass('extra-class')).toBe(true);
|
|
99
|
+
expect($('.ons-description-list').hasClass('another-extra-class')).toBe(true);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
it('outputs `title` and `aria-label` attributes when `
|
|
102
|
+
it('outputs `title` and `aria-label` attributes when `descriptionListLabel` is provided', () => {
|
|
103
103
|
const $ = cheerio.load(
|
|
104
|
-
renderComponent('
|
|
105
|
-
...
|
|
106
|
-
|
|
104
|
+
renderComponent('description-list', {
|
|
105
|
+
...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
|
|
106
|
+
descriptionListLabel: 'This is an example of the description list component',
|
|
107
107
|
}),
|
|
108
108
|
);
|
|
109
109
|
|
|
110
|
-
expect($('.ons-
|
|
111
|
-
expect($('.ons-
|
|
110
|
+
expect($('.ons-description-list').attr('title')).toBe('This is an example of the description list component');
|
|
111
|
+
expect($('.ons-description-list').attr('aria-label')).toBe('This is an example of the description list component');
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
it('outputs list items as expected', () => {
|
|
115
|
-
const $ = cheerio.load(renderComponent('
|
|
115
|
+
const $ = cheerio.load(renderComponent('description-list', EXAMPLE_DESCRIPTION_LIST_FULL));
|
|
116
116
|
|
|
117
|
-
const $listElements = $('.ons-
|
|
117
|
+
const $listElements = $('.ons-description-list__term, .ons-description-list__value');
|
|
118
118
|
|
|
119
119
|
expect($listElements[0].tagName).toBe('dt');
|
|
120
120
|
expect($($listElements[0]).text()).toBe('Survey:');
|
|
@@ -140,13 +140,13 @@ describe('macro: metadata', () => {
|
|
|
140
140
|
[4, 'ons-col-4\\@m'],
|
|
141
141
|
])('applies class for the provided `termCol` (%i -> %s)', (termCol, expectedClass) => {
|
|
142
142
|
const $ = cheerio.load(
|
|
143
|
-
renderComponent('
|
|
144
|
-
...
|
|
143
|
+
renderComponent('description-list', {
|
|
144
|
+
...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
|
|
145
145
|
termCol,
|
|
146
146
|
}),
|
|
147
147
|
);
|
|
148
148
|
|
|
149
|
-
const $termElements = $(`.ons-
|
|
149
|
+
const $termElements = $(`.ons-description-list__term.${expectedClass}`);
|
|
150
150
|
expect($termElements.length).toBe(2);
|
|
151
151
|
});
|
|
152
152
|
|
|
@@ -155,13 +155,13 @@ describe('macro: metadata', () => {
|
|
|
155
155
|
[4, 'ons-col-4\\@m'],
|
|
156
156
|
])('applies class for the provided `descriptionCol` (%i -> %s)', (descriptionCol, expectedClass) => {
|
|
157
157
|
const $ = cheerio.load(
|
|
158
|
-
renderComponent('
|
|
159
|
-
...
|
|
158
|
+
renderComponent('description-list', {
|
|
159
|
+
...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
|
|
160
160
|
descriptionCol,
|
|
161
161
|
}),
|
|
162
162
|
);
|
|
163
163
|
|
|
164
|
-
const $valueElements = $(`.ons-
|
|
164
|
+
const $valueElements = $(`.ons-description-list__value.${expectedClass}`);
|
|
165
165
|
expect($valueElements.length).toBe(3);
|
|
166
166
|
});
|
|
167
167
|
});
|
package/components/{metadata/example-metadata.njk → description-list/example-description-list.njk}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{% from "components/
|
|
1
|
+
{% from "components/description-list/_macro.njk" import onsDescriptionList %}
|
|
2
2
|
{{
|
|
3
|
-
|
|
3
|
+
onsDescriptionList({
|
|
4
4
|
"classes": "ons-u-mb-no",
|
|
5
|
-
"
|
|
5
|
+
"descriptionListLabel": "Information about this business and its survey requirements",
|
|
6
6
|
"termCol": "2",
|
|
7
7
|
"descriptionCol": "10",
|
|
8
8
|
"itemsList": [
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
{% from "components/mutually-exclusive/_macro.njk" import onsMutuallyExclusive %}
|
|
3
|
-
{% from "components/fieldset/_macro.njk" import onsFieldset %}
|
|
4
|
-
{% from "components/field/_macro.njk" import onsField %}
|
|
5
|
-
{% from "components/input/_macro.njk" import onsInput %}
|
|
1
|
+
{% from "components/date-field-input/_macro.njk" import onsDateFieldInput %}
|
|
6
2
|
|
|
7
3
|
{% macro onsDuration(params) %}
|
|
8
4
|
{% set numberOfFields = 0 %}
|
|
9
|
-
|
|
10
5
|
{% if params.field1 %}
|
|
11
6
|
{% set numberOfFields = numberOfFields + 1 %}
|
|
12
7
|
{% endif %}
|
|
@@ -15,85 +10,65 @@
|
|
|
15
10
|
{% set numberOfFields = numberOfFields + 1 %}
|
|
16
11
|
{% endif %}
|
|
17
12
|
|
|
18
|
-
{% set fields %}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{% if params.field2 %}
|
|
43
|
-
{{ onsInput({
|
|
44
|
-
"id": params.field2.id,
|
|
45
|
-
"classes": (" ons-input--error" if (params.error and params.field2.error) or (numberOfFields > 1 and params.error and not params.field1.error and not params.field2.error) else "") + (" ons-js-exclusive-group-item" if params.mutuallyExclusive else ""),
|
|
46
|
-
"width": "2",
|
|
47
|
-
"type": "number",
|
|
48
|
-
"name": params.field2.name,
|
|
49
|
-
"value": params.field2.value,
|
|
50
|
-
"suffix": {
|
|
51
|
-
"text": params.field2.suffix.text,
|
|
52
|
-
"title": params.field2.suffix.title,
|
|
53
|
-
"id": params.field2.suffix.id
|
|
54
|
-
},
|
|
55
|
-
"label": {
|
|
56
|
-
"text": params.legendOrLabel if numberOfFields < 2,
|
|
57
|
-
"description": params.description if numberOfFields < 2
|
|
58
|
-
},
|
|
59
|
-
"attributes": params.field2.attributes,
|
|
60
|
-
"fieldId": params.id if numberOfFields < 2,
|
|
61
|
-
"error": params.error if numberOfFields < 2
|
|
62
|
-
}) }}
|
|
63
|
-
{% endif %}
|
|
64
|
-
{% endset %}
|
|
65
|
-
|
|
66
|
-
{% if params.mutuallyExclusive %}
|
|
67
|
-
{% set mutuallyExclusive = params.mutuallyExclusive | setAttributes({
|
|
68
|
-
"id": params.id,
|
|
69
|
-
"legend": params.legendOrLabel,
|
|
70
|
-
"legendClasses": params.legendClasses,
|
|
71
|
-
"description": params.description,
|
|
72
|
-
"error": params.error,
|
|
73
|
-
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
74
|
-
"dontWrap": params.dontWrap
|
|
75
|
-
}) %}
|
|
13
|
+
{% set fields = [] %}
|
|
14
|
+
{% if params.field1 %}
|
|
15
|
+
{% set field1 = {
|
|
16
|
+
"id": params.field1.id,
|
|
17
|
+
"name": params.field1.name,
|
|
18
|
+
"attributes": params.field1.attributes,
|
|
19
|
+
"label": {
|
|
20
|
+
"text": params.legendOrLabel if numberOfFields < 2,
|
|
21
|
+
"description": params.description if numberOfFields < 2
|
|
22
|
+
},
|
|
23
|
+
"suffix": {
|
|
24
|
+
"text": params.field1.suffix.text,
|
|
25
|
+
"title": params.field1.suffix.title,
|
|
26
|
+
"id": params.field1.suffix.id
|
|
27
|
+
},
|
|
28
|
+
"width": "2",
|
|
29
|
+
"fieldId": params.id if numberOfFields < 2,
|
|
30
|
+
"value": params.field1.value,
|
|
31
|
+
"error": params.error if numberOfFields < 2,
|
|
32
|
+
"classes": (" ons-input--error" if (params.error and params.field1.error) or (params.error and not params.field1.error and not params.field2.error) else "") + (" ons-js-exclusive-group-item" if params.mutuallyExclusive else "")
|
|
33
|
+
} %}
|
|
34
|
+
{% set fields = (fields.push(field1), fields) %}
|
|
35
|
+
{% endif %}
|
|
76
36
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
{
|
|
37
|
+
{% if params.field2 %}
|
|
38
|
+
{% set field2 = {
|
|
39
|
+
"id": params.field2.id,
|
|
40
|
+
"name": params.field2.name,
|
|
41
|
+
"attributes": params.field2.attributes,
|
|
42
|
+
"width": "2",
|
|
43
|
+
"label": {
|
|
44
|
+
"text": params.legendOrLabel if numberOfFields < 2,
|
|
45
|
+
"description": params.description if numberOfFields < 2
|
|
46
|
+
},
|
|
47
|
+
"suffix": {
|
|
48
|
+
"text": params.field2.suffix.text,
|
|
49
|
+
"title": params.field2.suffix.title,
|
|
50
|
+
"id": params.field2.suffix.id
|
|
51
|
+
},
|
|
52
|
+
"value": params.field2.value,
|
|
53
|
+
"error": params.error if numberOfFields < 2,
|
|
54
|
+
"fieldId": params.id if numberOfFields < 2,
|
|
55
|
+
"classes": (" ons-input--error" if (params.error and params.field2.error) or (params.error and not params.field1.error and not params.field2.error) else "") + (" ons-js-exclusive-group-item" if params.mutuallyExclusive else "")
|
|
56
|
+
} %}
|
|
57
|
+
{% set fields = (fields.push(field2), fields) %}
|
|
98
58
|
{% endif %}
|
|
59
|
+
|
|
60
|
+
{{ onsDateFieldInput({
|
|
61
|
+
"id": params.id,
|
|
62
|
+
"legendOrLabel": params.legendOrLabel,
|
|
63
|
+
"description": params.description,
|
|
64
|
+
"mutuallyExclusive": params.mutuallyExclusive,
|
|
65
|
+
"numberOfFields": numberOfFields,
|
|
66
|
+
"fields": fields,
|
|
67
|
+
"error": params.error,
|
|
68
|
+
"legend": params.legendOrLabel,
|
|
69
|
+
"dontWrap": params.dontWrap,
|
|
70
|
+
"classes": params.classes,
|
|
71
|
+
"legendClasses": params.legendClasses,
|
|
72
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle
|
|
73
|
+
}) }}
|
|
99
74
|
{% endmacro %}
|