@ons/design-system 64.0.0 → 65.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/components/access-code/_macro.njk +2 -2
  2. package/components/access-code/_macro.spec.js +2 -2
  3. package/components/access-code/access-code.dom.js +11 -0
  4. package/components/access-code/{uac.js → access-code.js} +1 -1
  5. package/components/access-code/{uac.scss → access-code.scss} +1 -1
  6. package/components/access-code/example-access-code-error.njk +6 -6
  7. package/components/access-code/example-access-code.njk +4 -4
  8. package/components/accordion/_macro.njk +2 -2
  9. package/components/accordion/_macro.spec.js +3 -3
  10. package/components/accordion/accordion.dom.js +1 -1
  11. package/components/accordion/accordion.js +1 -1
  12. package/components/address-input/autosuggest.address.error.js +1 -1
  13. package/components/address-input/autosuggest.address.js +2 -2
  14. package/components/address-input/autosuggest.address.spec.js +5 -5
  15. package/components/autosuggest/_autosuggest.scss +11 -6
  16. package/components/autosuggest/_macro.njk +32 -31
  17. package/components/autosuggest/_macro.spec.js +18 -18
  18. package/components/autosuggest/autosuggest.spec.js +31 -31
  19. package/components/autosuggest/autosuggest.ui.js +8 -9
  20. package/components/breadcrumbs/_breadcrumbs.scss +6 -6
  21. package/components/breadcrumbs/_macro.njk +4 -4
  22. package/components/breadcrumbs/_macro.spec.js +13 -13
  23. package/components/button/_button.scss +27 -27
  24. package/components/button/_macro.spec.js +2 -2
  25. package/components/call-to-action/_macro.njk +1 -1
  26. package/components/card/_card.scss +14 -0
  27. package/components/card/_macro.njk +7 -8
  28. package/components/checkboxes/example-checkboxes-with-revealed-checkboxes-expanded.njk +88 -0
  29. package/components/checkboxes/example-checkboxes-with-revealed-radios-expanded.njk +70 -0
  30. package/components/checkboxes/example-checkboxes-with-revealed-select-expanded.njk +72 -0
  31. package/components/checkboxes/example-checkboxes-with-revealed-text-input-expanded.njk +60 -0
  32. package/components/content-pagination/_content-pagination.scss +1 -1
  33. package/components/date-input/_macro.njk +3 -3
  34. package/components/date-input/_macro.spec.js +118 -0
  35. package/components/date-input/example-date-input-error-for-single-field.njk +63 -0
  36. package/components/details/_details.scss +1 -1
  37. package/components/document-list/_macro.njk +5 -7
  38. package/components/document-list/_macro.spec.js +2 -2
  39. package/components/document-list/example-document-list-search-result-featured.njk +1 -1
  40. package/components/document-list/example-document-list-search-results.njk +3 -3
  41. package/components/external-link/_external-link.scss +3 -3
  42. package/components/external-link/_macro.njk +1 -1
  43. package/components/fieldset/_fieldset.scss +1 -1
  44. package/components/footer/_footer.scss +2 -2
  45. package/components/footer/example-footer-with-alternative-organisation.njk +5 -5
  46. package/components/header/_header.scss +8 -8
  47. package/components/header/_macro.njk +4 -4
  48. package/components/header/example-header-external-with-navigation.njk +5 -5
  49. package/components/header/example-header-external-with-service-links.njk +3 -3
  50. package/components/header/example-header-external-with-sub-navigation.njk +10 -10
  51. package/components/header/example-header-internal.njk +2 -2
  52. package/components/header/example-header-neutral-for-multicoloured-logo.njk +6 -6
  53. package/components/icon/_icon.scss +1 -1
  54. package/components/icon/_macro.njk +35 -35
  55. package/components/icon/_macro.spec.js +1 -1
  56. package/components/image/_image.scss +2 -2
  57. package/components/image/_macro.njk +4 -6
  58. package/components/image/_macro.spec.js +10 -10
  59. package/components/list/_list.scss +5 -2
  60. package/components/list/_macro.njk +22 -10
  61. package/components/list/_macro.spec.js +42 -0
  62. package/components/mutually-exclusive/_macro.njk +4 -3
  63. package/components/navigation/_macro.njk +6 -6
  64. package/components/navigation/_macro.spec.js +4 -4
  65. package/components/pagination/_macro.njk +17 -2
  66. package/components/pagination/_pagination.scss +14 -0
  67. package/components/pagination/example-pagination-first.njk +0 -2
  68. package/components/pagination/example-pagination-last.njk +0 -2
  69. package/components/pagination/example-pagination-with-no-range-indicator.njk +0 -2
  70. package/components/pagination/example-pagination.njk +0 -2
  71. package/components/panel/_macro.njk +1 -1
  72. package/components/panel/_panel.scss +7 -7
  73. package/components/password/_macro.njk +1 -1
  74. package/components/password/example-password.njk +1 -2
  75. package/components/question/example-question-interviewer-note.njk +1 -1
  76. package/components/quote/_quote.scss +1 -1
  77. package/components/radios/_macro.njk +1 -1
  78. package/components/radios/example-radios-with-clear-button-expanded.njk +98 -0
  79. package/components/radios/example-radios-with-revealed-checkboxes-expanded.njk +70 -0
  80. package/components/radios/example-radios-with-revealed-radios-expanded.njk +69 -0
  81. package/components/radios/example-radios-with-revealed-select-expanded.njk +70 -0
  82. package/components/radios/example-radios-with-revealed-text-input-expanded.njk +81 -0
  83. package/components/relationships/_macro.spec.js +9 -11
  84. package/components/relationships/example-relationships-error.njk +28 -28
  85. package/components/relationships/example-relationships-you.njk +29 -29
  86. package/components/relationships/example-relationships.njk +28 -28
  87. package/components/relationships/relationships.spec.js +13 -13
  88. package/components/reply/_macro.njk +5 -2
  89. package/components/reply/_macro.spec.js +7 -1
  90. package/components/section-navigation/_macro.njk +2 -1
  91. package/components/section-navigation/_macro.spec.js +2 -13
  92. package/components/skip-to-content/_macro.njk +2 -1
  93. package/components/skip-to-content/_macro.spec.js +17 -3
  94. package/components/skip-to-content/_skip.scss +1 -1
  95. package/components/skip-to-content/skip-to-content.dom.js +1 -1
  96. package/components/skip-to-content/skip-to-content.spec.js +3 -3
  97. package/components/summary/_summary.scss +1 -1
  98. package/components/table/_table.scss +6 -6
  99. package/components/table/sortable-table.js +1 -1
  100. package/components/tabs/_macro.njk +5 -5
  101. package/components/tabs/_macro.spec.js +1 -1
  102. package/components/tabs/example-tabs-details.njk +3 -0
  103. package/components/tabs/example-tabs.njk +0 -1
  104. package/components/textarea/example-textarea-error.njk +4 -4
  105. package/components/timeline/_macro.njk +18 -22
  106. package/components/timeline/_macro.spec.js +18 -0
  107. package/components/video/example-video.njk +1 -1
  108. package/components/video/video.js +10 -1
  109. package/components/video/video.spec.js +33 -0
  110. package/css/main.css +3 -3
  111. package/css/print.css +1 -1
  112. package/js/cookies-settings.js +1 -1
  113. package/js/main.js +1 -1
  114. package/package.json +19 -21
  115. package/scripts/main.es5.js +1 -1
  116. package/scripts/main.js +1 -1
  117. package/scss/base/_global.scss +1 -1
  118. package/scss/main.scss +1 -1
  119. package/scss/objects/_spacing.scss +3 -3
  120. package/scss/overrides/hcm.scss +10 -10
  121. package/scss/overrides/rtl.scss +2 -2
  122. package/scss/print.scss +2 -2
  123. package/components/access-code/uac.dom.js +0 -11
  124. /package/components/access-code/{uac.spec.js → access-code.spec.js} +0 -0
@@ -200,7 +200,7 @@ describe('macro: button', () => {
200
200
  }),
201
201
  );
202
202
 
203
- expect($('.ons-svg-icon + .ons-btn__text').text()).toBe('Click me!');
203
+ expect($('.ons-icon + .ons-btn__text').text()).toBe('Click me!');
204
204
  });
205
205
 
206
206
  it('has custom icon after button text', () => {
@@ -213,7 +213,7 @@ describe('macro: button', () => {
213
213
  );
214
214
 
215
215
  expect(
216
- $('.ons-btn__text + .ons-svg-icon')
216
+ $('.ons-btn__text + .ons-icon')
217
217
  .prev()
218
218
  .text(),
219
219
  ).toBe('Click me!');
@@ -14,7 +14,7 @@
14
14
  "text": params.button.text,
15
15
  "url": params.button.url,
16
16
  "variants": "small"
17
- })}}
17
+ }) }}
18
18
  </div>
19
19
  </div>
20
20
  </div>
@@ -1,6 +1,20 @@
1
1
  .ons-card {
2
2
  margin: 0 0 2rem;
3
3
  width: 100%;
4
+
5
+ &__link {
6
+ display: flex;
7
+ flex-direction: column;
8
+ }
9
+
10
+ &__image--reorder {
11
+ order: 1;
12
+ }
13
+
14
+ &__title--reorder {
15
+ order: 2;
16
+ }
17
+
4
18
  &__link:hover {
5
19
  text-decoration-thickness: 3px;
6
20
  }
@@ -4,21 +4,20 @@
4
4
 
5
5
  {% set titleSize = params.titleSize | default('2') %}
6
6
 
7
- <div class="ons-card" aria-describedBy="{{ params.textId }}">
7
+ <div class="ons-card">
8
8
 
9
9
  {%- if params.image -%}
10
10
  {%- if params.url -%}
11
- <a href="{{ params.url }}" class="ons-card__link ons-u-db">
11
+ <a href="{{ params.url }}" class="ons-card__link">
12
12
  {%- endif -%}
13
+ <h{{ titleSize }} class="ons-card__title ons-card__title--reorder {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
14
+ {{ params.title }}
15
+ </h{{ titleSize }}>
13
16
  {% if params.image.smallSrc %}
14
- <img class="ons-card__image ons-u-mb-s" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
17
+ <img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
15
18
  {% elif params.image == true or params.image.placeholderURL %}
16
- <img class="ons-card__image ons-u-mb-s" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
19
+ <img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
17
20
  {% endif %}
18
-
19
- <h{{ titleSize }} class="ons-card__title {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
20
- {{ params.title }}
21
- </h{{ titleSize }}>
22
21
  {%- if params.url -%}
23
22
  </a>
24
23
  {%- endif -%}
@@ -0,0 +1,88 @@
1
+ {% from "components/checkboxes/_macro.njk" import onsCheckboxes %}
2
+
3
+ {{
4
+ onsCheckboxes({
5
+ "legend": "Content type",
6
+ "checkboxesLabel": "Show only:",
7
+ "borderless": true,
8
+ "name": "dietary",
9
+ "checkboxes": [
10
+ {
11
+ "id": "data",
12
+ "label": {
13
+ "text": "Data (309)"
14
+ },
15
+ "value": "data",
16
+ "checked": true,
17
+ "other": {
18
+ "otherType": "checkboxes",
19
+ "selectAllChildren": true,
20
+ "legend": "Data type",
21
+ "legendClasses": "ons-u-vh",
22
+ "name": "name",
23
+ "checkboxes": [
24
+ {
25
+ "id": "datasets",
26
+ "label": {
27
+ "text": "Datasets (100)"
28
+ },
29
+ "value": "datasets"
30
+ },
31
+ {
32
+ "id": "timeseries",
33
+ "label": {
34
+ "text": "Timeseries (20)"
35
+ },
36
+ "value": "timeseries"
37
+ },
38
+ {
39
+ "id": "requested",
40
+ "label": {
41
+ "text": "User requested data (17)"
42
+ },
43
+ "value": "requested"
44
+ }
45
+ ]
46
+ }
47
+ },
48
+ {
49
+ "id": "publications",
50
+ "label": {
51
+ "text": "Publications (137)"
52
+ },
53
+ "value": "publications",
54
+ "checked": true,
55
+ "other": {
56
+ "otherType": "checkboxes",
57
+ "selectAllChildren": true,
58
+ "legend": "Publication type",
59
+ "legendClasses": "ons-u-vh",
60
+ "name": "name",
61
+ "checkboxes": [
62
+ {
63
+ "id": "press-release",
64
+ "label": {
65
+ "text": "Press release (100)"
66
+ },
67
+ "value": "pressrelease"
68
+ },
69
+ {
70
+ "id": "bulletin",
71
+ "label": {
72
+ "text": "Bulletin (20)"
73
+ },
74
+ "value": "bulletin"
75
+ }
76
+ ]
77
+ }
78
+ },
79
+ {
80
+ "id": "areas",
81
+ "label": {
82
+ "text": "Areas (0)"
83
+ },
84
+ "value": "areas"
85
+ }
86
+ ]
87
+ })
88
+ }}
@@ -0,0 +1,70 @@
1
+ {% from "components/checkboxes/_macro.njk" import onsCheckboxes %}
2
+
3
+ {{
4
+ onsCheckboxes({
5
+ "checkboxesLabel": "Select all that apply",
6
+ "legend": "How would you like us to contact you?",
7
+ "name": "contact",
8
+ "borderless": true,
9
+ "checkboxes": [
10
+ {
11
+ "id": "post",
12
+ "label": {
13
+ "text": "By post"
14
+ },
15
+ "value": "post"
16
+ },
17
+ {
18
+ "id": "email",
19
+ "label": {
20
+ "text": "By email"
21
+ },
22
+ "value": "email"
23
+ },
24
+ {
25
+ "id": "phone",
26
+ "label": {
27
+ "text": "By phone"
28
+ },
29
+ "value": "phone",
30
+ "checked": true,
31
+ "other": {
32
+ "otherType": "radios",
33
+ "id": "phone-time",
34
+ "name": "phone-time",
35
+ "legend": "Choose preferred time of day",
36
+ "radios": [
37
+ {
38
+ "value": "anytime",
39
+ "id": "anytime",
40
+ "label": {
41
+ "text": "Any time of day"
42
+ }
43
+ },
44
+ {
45
+ "value": "morning",
46
+ "id": "morning",
47
+ "label": {
48
+ "text": "Morning"
49
+ }
50
+ },
51
+ {
52
+ "value": "afternoon",
53
+ "id": "afternoon",
54
+ "label": {
55
+ "text": "Afternoon"
56
+ }
57
+ },
58
+ {
59
+ "value": "evening",
60
+ "id": "evening",
61
+ "label": {
62
+ "text": "Evening"
63
+ }
64
+ }
65
+ ]
66
+ }
67
+ }
68
+ ]
69
+ })
70
+ }}
@@ -0,0 +1,72 @@
1
+ {% from "components/question/_macro.njk" import onsQuestion %}
2
+ {% from "components/checkboxes/_macro.njk" import onsCheckboxes %}
3
+
4
+ {% call onsQuestion({
5
+ "title": "How would you like us to contact you?",
6
+ "legendIsQuestionTitle": true,
7
+ "classes": "ons-u-mt-no"
8
+ }) %}
9
+ {{
10
+ onsCheckboxes({
11
+ "checkboxesLabel": "Select all that apply",
12
+ "dontWrap": true,
13
+ "name": "contact",
14
+ "checkboxes": [
15
+ {
16
+ "id": "post",
17
+ "label": {
18
+ "text": "By post"
19
+ },
20
+ "value": "post"
21
+ },
22
+ {
23
+ "id": "email",
24
+ "label": {
25
+ "text": "By email"
26
+ },
27
+ "value": "email"
28
+ },
29
+ {
30
+ "id": "phone",
31
+ "label": {
32
+ "text": "By phone"
33
+ },
34
+ "value": "phone",
35
+ "checked": true,
36
+ "other": {
37
+ "otherType": "select",
38
+ "id": "phone-time",
39
+ "name": "phone-time",
40
+ "label": {
41
+ "text": "Choose preferred time of day"
42
+ },
43
+ "options": [
44
+ {
45
+ "value": "",
46
+ "text": "Select an option",
47
+ "disabled": true,
48
+ "selected": true
49
+ },
50
+ {
51
+ "value": "anytime",
52
+ "text": "Anytime of day"
53
+ },
54
+ {
55
+ "value": "morning",
56
+ "text": "Morning"
57
+ },
58
+ {
59
+ "value": "afternoon",
60
+ "text": "Afternoon"
61
+ },
62
+ {
63
+ "value": "evening",
64
+ "text": "Evening"
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ ]
70
+ })
71
+ }}
72
+ {% endcall %}
@@ -0,0 +1,60 @@
1
+ {% from "components/question/_macro.njk" import onsQuestion %}
2
+ {% from "components/checkboxes/_macro.njk" import onsCheckboxes %}
3
+
4
+ {% call onsQuestion({
5
+ "title": "Do you have any dietary requirements?",
6
+ "legendIsQuestionTitle": true,
7
+ "classes": "ons-u-mt-no"
8
+ }) %}
9
+ {{
10
+ onsCheckboxes({
11
+ "checkboxesLabel": "Select all that apply",
12
+ "dontWrap": true,
13
+ "checkboxes": [
14
+ {
15
+ "id": "gluten-free",
16
+ "label": {
17
+ "text": "Gluten free"
18
+ },
19
+ "value": "gluten-free"
20
+ },
21
+ {
22
+ "id": "lactose-intolerant",
23
+ "label": {
24
+ "text": "Lactose intolerant"
25
+ },
26
+ "value": "lactose-intolerant"
27
+ },
28
+ {
29
+ "id": "vegan",
30
+ "label": {
31
+ "text": "Vegan"
32
+ },
33
+ "value": "vegan"
34
+ },
35
+ {
36
+ "id": "vegetarian",
37
+ "label": {
38
+ "text": "Vegetarian"
39
+ },
40
+ "value": "vegetarian"
41
+ },
42
+ {
43
+ "id": "other-checkbox",
44
+ "label": {
45
+ "text": "Other"
46
+ },
47
+ "value": "other",
48
+ "checked": true,
49
+ "other": {
50
+ "id": "other-textbox",
51
+ "name": "other-answer",
52
+ "label": {
53
+ "text": "Enter dietary requirements"
54
+ }
55
+ }
56
+ }
57
+ ]
58
+ })
59
+ }}
60
+ {% endcall %}
@@ -37,7 +37,7 @@
37
37
  }
38
38
 
39
39
  &__link-text {
40
- @extend .ons-u-fs-m;
40
+ @extend .ons-u-fs-r--b;
41
41
 
42
42
  margin: 0 0 0 0.5rem;
43
43
  vertical-align: middle;
@@ -26,7 +26,7 @@
26
26
  "id": params.id + "-day",
27
27
  "type": "number",
28
28
  "name": params.day.name,
29
- "classes": (" ons-input--error" if params.error else "") + exclusiveClass | default(""),
29
+ "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(""),
30
30
  "width": "2",
31
31
  "min": 1,
32
32
  "max": 31,
@@ -46,7 +46,7 @@
46
46
  "id": params.id + "-month",
47
47
  "type": "number",
48
48
  "name": params.month.name,
49
- "classes": (" ons-input--error" if params.error else "") + exclusiveClass | default(""),
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
50
  "width": "2",
51
51
  "min": 1,
52
52
  "max": 12,
@@ -66,7 +66,7 @@
66
66
  "id": params.id + "-year",
67
67
  "type": "number",
68
68
  "name": params.year.name,
69
- "classes": (" ons-input--error" if params.error else "") + exclusiveClass | default(""),
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
70
  "width": "4",
71
71
  "min": 1000,
72
72
  "max": 3000,
@@ -11,6 +11,15 @@ const EXAMPLE_DATE_INPUT_BASE = {
11
11
  description: 'For example, 31 3 1980',
12
12
  };
13
13
 
14
+ const EXAMPLE_DATE_INPUT_BASE_WITH_ERROR = {
15
+ id: 'date',
16
+ legendOrLabel: 'Date of birth',
17
+ description: 'For example, 31 3 1980',
18
+ error: {
19
+ text: 'Enter a date that is after 1 January 2019',
20
+ },
21
+ };
22
+
14
23
  const EXAMPLE_DAY_FIELD = {
15
24
  day: {
16
25
  label: {
@@ -53,6 +62,66 @@ const EXAMPLE_YEAR_FIELD = {
53
62
  },
54
63
  };
55
64
 
65
+ const EXAMPLE_DAY_FIELD_WITH_ERROR = {
66
+ day: {
67
+ label: {
68
+ text: 'Day',
69
+ description: 'The day',
70
+ },
71
+ value: 'Day',
72
+ error: true,
73
+ name: 'day',
74
+ attributes: {
75
+ autocomplete: 'bday-day',
76
+ },
77
+ },
78
+ };
79
+
80
+ const EXAMPLE_MONTH_FIELD_WITH_ERROR = {
81
+ month: {
82
+ label: {
83
+ text: 'Month',
84
+ description: 'The month',
85
+ },
86
+ value: 'Month',
87
+ error: true,
88
+ name: 'month',
89
+ attributes: {
90
+ autocomplete: 'bday-month',
91
+ },
92
+ },
93
+ };
94
+
95
+ const EXAMPLE_YEAR_FIELD_WITH_ERROR = {
96
+ year: {
97
+ label: {
98
+ text: 'Year',
99
+ description: 'The year',
100
+ },
101
+ value: 'Year',
102
+ error: true,
103
+ name: 'year',
104
+ attributes: {
105
+ autocomplete: 'bday-year',
106
+ },
107
+ },
108
+ };
109
+
110
+ const EXAMPLE_YEAR_FIELD_WITH_NO_ERROR = {
111
+ year: {
112
+ label: {
113
+ text: 'Year',
114
+ description: 'The year',
115
+ },
116
+ value: 'Year',
117
+ name: 'year',
118
+ error: false,
119
+ attributes: {
120
+ autocomplete: 'bday-year',
121
+ },
122
+ },
123
+ };
124
+
56
125
  const EXAMPLE_DATE_SINGLE_FIELD = {
57
126
  ...EXAMPLE_DATE_INPUT_BASE,
58
127
  ...EXAMPLE_YEAR_FIELD,
@@ -65,6 +134,25 @@ const EXAMPLE_DATE_MULTIPLE_FIELDS = {
65
134
  ...EXAMPLE_YEAR_FIELD,
66
135
  };
67
136
 
137
+ const EXAMPLE_DATE_MULTIPLE_FIELDS_WITH_SINGLE_ERROR = {
138
+ ...EXAMPLE_DATE_INPUT_BASE_WITH_ERROR,
139
+ ...EXAMPLE_DAY_FIELD,
140
+ ...EXAMPLE_MONTH_FIELD,
141
+ ...EXAMPLE_YEAR_FIELD_WITH_ERROR,
142
+ };
143
+
144
+ const EXAMPLE_DATE_MULTIPLE_FIELDS_WITH_ERROR = {
145
+ ...EXAMPLE_DATE_INPUT_BASE_WITH_ERROR,
146
+ ...EXAMPLE_DAY_FIELD_WITH_ERROR,
147
+ ...EXAMPLE_MONTH_FIELD_WITH_ERROR,
148
+ ...EXAMPLE_YEAR_FIELD_WITH_ERROR,
149
+ };
150
+
151
+ const EXAMPLE_DATE_MULTIPLE_FIELDS_WITH_NO_ERROR = {
152
+ ...EXAMPLE_DATE_INPUT_BASE,
153
+ ...EXAMPLE_YEAR_FIELD_WITH_NO_ERROR,
154
+ };
155
+
68
156
  describe('macro: date input', () => {
69
157
  describe('mode: multiple fields', () => {
70
158
  it('passes jest-axe checks', async () => {
@@ -282,4 +370,34 @@ describe('macro: date input', () => {
282
370
  });
283
371
  });
284
372
  });
373
+
374
+ describe('mode: multiple fields with single field error', () => {
375
+ it('passes jest-axe checks', async () => {
376
+ const $ = cheerio.load(renderComponent('date-input', EXAMPLE_DATE_MULTIPLE_FIELDS_WITH_SINGLE_ERROR));
377
+
378
+ const results = await axe($.html());
379
+ expect(results).toHaveNoViolations();
380
+ });
381
+
382
+ it('has the provided error class on one input', async () => {
383
+ const $ = cheerio.load(renderComponent('date-input', EXAMPLE_DATE_MULTIPLE_FIELDS_WITH_SINGLE_ERROR));
384
+ const $errorContent = $('.ons-input--error');
385
+
386
+ expect($errorContent.length).toBe(1);
387
+ });
388
+
389
+ it('has the provided error class on multiple inputs', async () => {
390
+ const $ = cheerio.load(renderComponent('date-input', EXAMPLE_DATE_MULTIPLE_FIELDS_WITH_ERROR));
391
+ const $errorContent = $('.ons-input--error');
392
+
393
+ expect($errorContent.length).toBe(3);
394
+ });
395
+
396
+ it('does not provide error class when error parameter set to false', async () => {
397
+ const $ = cheerio.load(renderComponent('date-input', EXAMPLE_DATE_MULTIPLE_FIELDS_WITH_NO_ERROR));
398
+ const $errorContent = $('.ons-input--error');
399
+
400
+ expect($errorContent.length).toBe(0);
401
+ });
402
+ });
285
403
  });
@@ -0,0 +1,63 @@
1
+
2
+ {% from "components/date-input/_macro.njk" import onsDateInput %}
3
+ {{
4
+ onsDateInput({
5
+ "id": "period-from-date",
6
+ "legendOrLabel": "Period from:",
7
+ "description": "For example, 31 3 2019",
8
+ "day": {
9
+ "label": {
10
+ "text": "Day"
11
+ },
12
+ "name": "day",
13
+ "value": "1"
14
+ },
15
+ "month": {
16
+ "label": {
17
+ "text": "Month"
18
+ },
19
+ "name": "month",
20
+ "value": "1"
21
+ },
22
+ "year": {
23
+ "label": {
24
+ "text": "Year"
25
+ },
26
+ "name": "year",
27
+ "value": "2019"
28
+ }
29
+ })
30
+ }}
31
+
32
+ {{
33
+ onsDateInput({
34
+ "id": "period-to-date",
35
+ "legendOrLabel": "Period to:",
36
+ "description": "For example, 31 3 2020",
37
+ "day": {
38
+ "label": {
39
+ "text": "Day"
40
+ },
41
+ "name": "day",
42
+ "value": "31"
43
+ },
44
+ "month": {
45
+ "label": {
46
+ "text": "Month"
47
+ },
48
+ "name": "month",
49
+ "value": "12"
50
+ },
51
+ "year": {
52
+ "label": {
53
+ "text": "Year"
54
+ },
55
+ "name": "year",
56
+ "value": "2018",
57
+ "error": true
58
+ },
59
+ "error": {
60
+ "text": "Enter a date that is after 1 January 2019"
61
+ }
62
+ })
63
+ }}
@@ -22,7 +22,7 @@ $details-caret-width: 1.5rem;
22
22
  margin-left: -$details-caret-width;
23
23
  padding-left: $details-caret-width;
24
24
  }
25
- .ons-details__icon .ons-svg-icon {
25
+ .ons-details__icon .ons-icon {
26
26
  fill: var(--ons-color-text-link-focus);
27
27
  }
28
28
  }
@@ -2,9 +2,9 @@
2
2
  <ul{% if params.id %} id="{{ params.id }}"{% endif %} class="ons-document-list{{ ' ' + params.classes if params.classes else '' }}"{% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}>
3
3
  {% for document in params.documents %}
4
4
 
5
- <li class="ons-document-list__item{{ ' ons-document-list__item--featured' if document.featured }}{{ ' ons-document-list__item--full-width' if document.fullWidth == true }}{{ ' ' + document.classes if document.classes else '' }}"{% if document.attributes %}{% for attribute, value in (document.attributes.items() if document.attributes is mapping and document.attributes.items else document.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}>
5
+ <li class="ons-document-list__item{{ ' ons-document-list__item--featured' if document.featured }}{{ ' ons-document-list__item--full-width' if document.featured and document.fullWidth == true }}{{ ' ' + document.classes if document.classes else '' }}"{% if document.attributes %}{% for attribute, value in (document.attributes.items() if document.attributes is mapping and document.attributes.items else document.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}>
6
6
 
7
- {% if document.fullWidth == true %}
7
+ {% if document.featured and document.fullWidth == true %}
8
8
 
9
9
  <div class="ons-container{{ ' ons-container--wide' if document.wide == true }}">
10
10
 
@@ -50,10 +50,8 @@
50
50
 
51
51
  {%- if document.metadata.date %}
52
52
  <li class="ons-document-list__item-attribute">
53
- {% if document.metadata.date -%}
54
- {% set prefixClasses = "ons-u-fw-b" if document.metadata.date.showPrefix == true else "ons-u-vh" %}
55
- <span class="{{ prefixClasses }}">{{ document.metadata.date.prefix | default("Published") }}: </span>
56
- {%- endif -%}
53
+ {% set prefixClasses = "ons-u-fw-b" if document.metadata.date.showPrefix == true else "ons-u-vh" %}
54
+ <span class="{{ prefixClasses }}">{{ document.metadata.date.prefix | default("Published") }}: </span>
57
55
  {% if document.metadata.date.iso -%}
58
56
  <time datetime="{{ document.metadata.date.iso }}">{{ document.metadata.date.short }}</time>
59
57
  {%- endif %}
@@ -99,7 +97,7 @@
99
97
 
100
98
  </div>
101
99
 
102
- {% if document.fullWidth == true %}
100
+ {% if document.featured and document.fullWidth == true %}
103
101
 
104
102
  </div>
105
103