@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.
Files changed (81) hide show
  1. package/components/access-code/_macro.njk +3 -3
  2. package/components/accordion/_macro.njk +1 -1
  3. package/components/address-input/_macro.njk +7 -7
  4. package/components/address-output/_macro.njk +7 -7
  5. package/components/autosuggest/_macro.njk +19 -19
  6. package/components/breadcrumbs/_macro.njk +3 -3
  7. package/components/button/_button.scss +49 -51
  8. package/components/button/_macro.njk +61 -35
  9. package/components/button/_macro.spec.js +24 -24
  10. package/components/button/button.spec.js +11 -11
  11. package/components/call-to-action/_macro.njk +1 -1
  12. package/components/card/_macro.njk +10 -10
  13. package/components/checkboxes/_checkbox-macro.njk +9 -9
  14. package/components/checkboxes/_macro.njk +10 -10
  15. package/components/checkboxes/checkbox-with-fieldset.js +6 -5
  16. package/components/checkboxes/checkboxes.dom.js +6 -9
  17. package/components/code-highlight/_macro.njk +1 -1
  18. package/components/collapsible/_macro.njk +7 -7
  19. package/components/date-input/_macro.njk +5 -5
  20. package/components/document-list/_macro.njk +29 -29
  21. package/components/duration/_macro.njk +9 -9
  22. package/components/duration/_macro.spec.js +0 -3
  23. package/components/error/_macro.njk +1 -1
  24. package/components/external-link/_macro.njk +1 -1
  25. package/components/feedback/_macro.njk +2 -2
  26. package/components/field/_macro.njk +5 -5
  27. package/components/fieldset/_fieldset.scss +5 -0
  28. package/components/fieldset/_macro.njk +8 -8
  29. package/components/footer/_macro.njk +19 -23
  30. package/components/footer/_macro.spec.js +0 -6
  31. package/components/header/_macro.njk +39 -41
  32. package/components/header/_macro.spec.js +4 -8
  33. package/components/hero/_macro.njk +15 -15
  34. package/components/icons/_macro.njk +2 -2
  35. package/components/images/_macro.njk +3 -3
  36. package/components/input/_input-type.scss +4 -0
  37. package/components/input/_macro.njk +41 -34
  38. package/components/input/_macro.spec.js +66 -59
  39. package/components/label/_macro.njk +1 -1
  40. package/components/language-selector/_macro.njk +1 -1
  41. package/components/lists/_macro.njk +22 -22
  42. package/components/message/_macro.njk +6 -6
  43. package/components/message-list/_macro.njk +1 -1
  44. package/components/metadata/_macro.njk +2 -2
  45. package/components/modal/_macro.njk +4 -4
  46. package/components/mutually-exclusive/_macro.njk +1 -1
  47. package/components/mutually-exclusive/mutually-exclusive.js +3 -1
  48. package/components/navigation/_macro.njk +11 -10
  49. package/components/navigation/_macro.spec.js +3 -2
  50. package/components/pagination/_macro.njk +3 -3
  51. package/components/panel/_macro.njk +37 -39
  52. package/components/panel/_macro.spec.js +1 -13
  53. package/components/promotional-banner/_macro.njk +2 -2
  54. package/components/question/_macro.njk +20 -20
  55. package/components/question/_macro.spec.js +2 -2
  56. package/components/question/_question.scss +1 -1
  57. package/components/quote/_macro.njk +2 -2
  58. package/components/radios/_macro.njk +8 -8
  59. package/components/radios/check-radios.js +5 -1
  60. package/components/related-content/_macro.njk +2 -2
  61. package/components/relationships/_macro.njk +4 -3
  62. package/components/search/_macro.njk +12 -2
  63. package/components/search/_macro.spec.js +27 -2
  64. package/components/section-navigation/_macro.njk +2 -2
  65. package/components/select/_macro.njk +8 -8
  66. package/components/share-page/_macro.njk +2 -2
  67. package/components/status/_macro.njk +2 -2
  68. package/components/summary/_macro.njk +25 -25
  69. package/components/table/_macro.njk +10 -10
  70. package/components/table-of-contents/_macro.njk +4 -4
  71. package/components/textarea/_macro.njk +8 -8
  72. package/components/timeline/_macro.njk +1 -1
  73. package/components/video/_macro.njk +1 -1
  74. package/css/census.css +1 -1
  75. package/css/ids.css +1 -1
  76. package/css/main.css +1 -1
  77. package/layout/_template.njk +35 -35
  78. package/package.json +1 -1
  79. package/scripts/main.es5.js +1 -1
  80. package/scripts/main.js +1 -1
  81. package/scss/patternlib.scss +2 -2
@@ -1,6 +1,6 @@
1
1
  {% macro onsPanel(params) %}
2
2
 
3
- {% if params is defined and params and params.classes is defined and params.classes %}
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 is defined and params and params.type is defined and params.type %}
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 is defined and params.type == "warn-branded" %}
17
+ {% if params.type == "warn-branded" %}
18
18
  {% set containerClass = 'ons-branded-warning' %}
19
19
  {% endif %}
20
20
 
21
- {% if params is defined and params.type == "announcement" %}
21
+ {% if params.type == "announcement" %}
22
22
  {% set containerClass = 'ons-announcement' %}
23
23
  {% endif %}
24
24
 
25
- {% if params is defined and params and params.spacious is defined and params.spacious %}
25
+ {% if params.spacious %}
26
26
  {% set spaciousClass = ' ons-panel--spacious' %}
27
27
  {% endif %}
28
28
 
29
- {% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
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 is defined and params and params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params is defined and params and params.attributes is mapping and params.attributes.items is defined and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params is defined and params and params.id is defined and params.id %} id="{{params.id}}"{% endif %}>
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 is defined and params and params.type == "warn" or params.type == "warn-branded" %}
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 is defined and params and params.type == "announcement" %}
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 is defined and params %}
54
- {% if params.title is defined and params.title %}
55
- {% if params is defined and params and params.type == 'error' %}
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
- {% if params.type is not defined or params.type == "branded" or params.type == "info" %}
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
- {% if params.iconType is defined and params.iconType %}
74
- {% from "components/icons/_macro.njk" import onsIcon %}
75
- <span class= "ons-panel__icon ons-u-fs-{{ params.iconSize | default('r') }}">
76
- {{
77
- onsIcon({
78
- "iconType": params.iconType,
79
- "iconSize": params.iconSize
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
- <div class="ons-panel__body{% if params is defined and params and params.iconSize is defined and params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}">{{ (params.body if params else "") | safe }}
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 is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
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 is defined %}
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 is defined and 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 is defined and params.readDescriptionFirst == true and params.description is defined and params.description %}
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 is defined and params.readDescriptionFirst == true %}
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 is defined and 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 is defined and 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 is defined and params.guidance.content %}
40
+ {% if params.guidance.content %}
41
41
  {{ params.guidance.content | safe }}
42
42
  {% endif %}
43
- {% if params.guidance.lists is defined and params.guidance.lists %}
43
+ {% if params.guidance.lists %}
44
44
  {%- for item in params.guidance.lists -%}
45
- {% if item.listHeading is defined and 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 is defined and 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 is defined and params.id %} id="{{ params.id }}"{% endif %}
65
- class="ons-question ons-u-mb-l{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
66
- {% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
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 is defined and params.legendIsQuestionTitle %}
68
+ {% if params.legendIsQuestionTitle %}
69
69
  {% from "components/fieldset/_macro.njk" import onsFieldset %}
70
70
 
71
- {# Resolves caller issue in jijna: https://github.com/pallets/jinja/issues/371 #}
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 is defined and params.description else '',
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 is defined and params.description %}
90
+ {% if params.description %}
91
91
  {{- descHtml | safe -}}
92
92
  {% endif %}
93
93
 
94
- {% if params.instruction is defined and params.instruction %}
94
+ {% if params.instruction %}
95
95
  {{- instHtml | safe -}}
96
96
  {% endif %}
97
97
 
98
- {% if params.definition is defined and params.definition %}
98
+ {% if params.definition %}
99
99
  {{- questionDefinition | safe -}}
100
100
  {% endif %}
101
101
 
102
- {% if params.guidance is defined and 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 is defined and 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
- "submitType": params.submitButton.submitType,
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
- submitType: 'button',
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('submitType', 'button');
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
 
7
7
  em,
8
8
  .ons-highlight {
9
- background-color: $color-highlight;
9
+ @extend .ons-highlight;
10
10
  }
11
11
  mark,
12
12
  .ons-instruction {
@@ -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 is defined and params.textFontSize else 'l' }}">{{ caller() if caller else params.text | safe }}</span>
10
- {% if params.ref is defined and params.ref %}<span class="ons-quote__ref">&mdash; {{ params.ref | safe }}</span>{% endif %}
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">&mdash; {{ 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 is defined and params.or and loop.revindex0 == 0 %}
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 is defined and radio.other and radio.other.selectAllChildren is defined and radio.other.selectAllChildren == true %}
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 and params.inputClasses is defined else '' }}{{ ' ' + radio.classes if radio.classes else '' }}{{ ' ons-js-other' if radio.other else '' }}{{ selectAllClass }}"
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 (radio.checked is defined and radio.checked) or (params.value is defined and params.value == radio.value) %} checked {% endif %}
35
- {% if radio.other is defined and radio.other and not radio.other.open %} aria-controls="{{ radio.id }}-other-wrap" aria-haspopup="true"{% endif %}
36
- {% if radio.attributes is defined and radio.attributes %}{% for attribute, value in (radio.attributes.items() if radio.attributes is mapping and radio.attributes.items else radio.attributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
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 is defined and 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 is defined and 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('blur', this.setInputBlurAttributes.bind(this));
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 is defined and params and params.classes is defined and params.classes %}
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 is defined and 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 is defined and params.id %}id="{{ params.id }}"{% endif %}
6
- class="ons-relationships ons-js-relationships{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
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
- "text": params.searchButton.text,
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
- text: 'Search for address',
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 is defined and params.variants == 'vertical' %} ons-section-nav--vertical{% endif %}" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Section menu") }}">
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 is defined and 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 is defined and params.label else ''
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 is defined and params.error %} ons-input--error{% endif %}"
25
- {% if params.value is defined and params.value %}value="{{ params.value}}" {% endif %}
26
- {% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
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 is defined and option.id %}id="{{ option.id }}" {% endif %}
31
- {% if option.selected is defined and option.selected %}selected {% endif %}
32
- {% if option.disabled is defined and option.disabled %}disabled {% endif %}
33
- {% if params.attributes is defined and params.attributes %}{% for attribute, value in option.attributes %}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
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 is defined and params.facebook and params.facebook == true %}
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 is defined and params.twitter and params.twitter == true %}
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 is defined and 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 is defined and params.size == 'small' %}
8
+ {% if params.size == 'small' %}
9
9
  {% set sizeClass = ' ons-status--small' %}
10
10
  {% endif %}
11
11