@madgex/design-system 3.4.2 → 3.6.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 (106) hide show
  1. package/coverage/cobertura-coverage.xml +108 -102
  2. package/coverage/components/accordion/accordion.js.html +1 -1
  3. package/coverage/components/accordion/index.html +1 -1
  4. package/coverage/components/button/button.js.html +1 -1
  5. package/coverage/components/button/index.html +1 -1
  6. package/coverage/components/inputs/combobox/combobox.js.html +1 -1
  7. package/coverage/components/inputs/combobox/index.html +1 -1
  8. package/coverage/components/inputs/combobox/vue-components/Combobox.vue.html +58 -19
  9. package/coverage/components/inputs/combobox/vue-components/ListBoxOption.vue.html +1 -1
  10. package/coverage/components/inputs/combobox/vue-components/index.html +16 -16
  11. package/coverage/components/inputs/file-upload/file-upload.js.html +1 -1
  12. package/coverage/components/inputs/file-upload/index.html +1 -1
  13. package/coverage/components/inputs/textarea/character-count.js.html +1 -1
  14. package/coverage/components/inputs/textarea/index.html +1 -1
  15. package/coverage/components/modal/index.html +1 -1
  16. package/coverage/components/modal/modal.js.html +1 -1
  17. package/coverage/components/notification/index.html +1 -1
  18. package/coverage/components/notification/notification.js.html +1 -1
  19. package/coverage/components/popover/index.html +1 -1
  20. package/coverage/components/popover/popover.js.html +1 -1
  21. package/coverage/components/switch-state/index.html +1 -1
  22. package/coverage/components/switch-state/switch-state.js.html +1 -1
  23. package/coverage/components/tabs/index.html +1 -1
  24. package/coverage/components/tabs/tabs.js.html +1 -1
  25. package/coverage/index.html +18 -18
  26. package/coverage/js/common.js.html +1 -1
  27. package/coverage/js/fractal-scripts/combobox.js.html +1 -1
  28. package/coverage/js/fractal-scripts/index.html +1 -1
  29. package/coverage/js/fractal-scripts/notification.js.html +1 -1
  30. package/coverage/js/fractal-scripts/switch-state.js.html +1 -1
  31. package/coverage/js/index-fractal.js.html +1 -1
  32. package/coverage/js/index-polyfills.js.html +1 -1
  33. package/coverage/js/index-vue.js.html +1 -1
  34. package/coverage/js/index.html +1 -1
  35. package/coverage/js/index.js.html +1 -1
  36. package/coverage/js/polyfills/arrayPrototypeFind.js.html +1 -1
  37. package/coverage/js/polyfills/closest.js.html +1 -1
  38. package/coverage/js/polyfills/index.html +1 -1
  39. package/coverage/js/polyfills/objectAssign.js.html +1 -1
  40. package/coverage/js/polyfills/remove.js.html +1 -1
  41. package/coverage/tokens/_config.js.html +1 -1
  42. package/coverage/tokens/index.html +1 -1
  43. package/dist/_tokens/css/_tokens.css +1 -1
  44. package/dist/_tokens/js/_tokens-module.js +1 -1
  45. package/dist/_tokens/scss/_tokens.scss +1 -1
  46. package/dist/assets/icons-inline.svg +1 -0
  47. package/dist/assets/icons.svg +1 -6
  48. package/dist/js/index.js +1 -1
  49. package/docs/tokens/icons.njk +1 -1
  50. package/package.json +2 -2
  51. package/src/components/icons/README.md +10 -6
  52. package/src/components/icons/_template.njk +1 -8
  53. package/src/components/inputs/_checkbox-elem/_template.njk +1 -1
  54. package/src/components/inputs/checkbox-list/README.md +7 -0
  55. package/src/components/inputs/checkbox-list/_template.njk +10 -8
  56. package/src/components/inputs/checkbox-list/checkbox-list.config.js +3 -0
  57. package/src/components/inputs/checkbox-list/checkbox-list.njk +2 -1
  58. package/src/components/inputs/combobox/README.md +12 -0
  59. package/src/components/inputs/combobox/_template.njk +4 -2
  60. package/src/components/inputs/combobox/combobox.config.js +8 -1
  61. package/src/components/inputs/combobox/combobox.njk +2 -1
  62. package/src/components/inputs/combobox/vue-components/Combobox.vue +20 -7
  63. package/src/components/inputs/combobox/vue-components/ListBox.vue +3 -3
  64. package/src/components/inputs/file-upload/README.md +15 -5
  65. package/src/components/inputs/file-upload/_template.njk +5 -11
  66. package/src/components/inputs/file-upload/file-upload.config.js +3 -5
  67. package/src/components/inputs/file-upload/file-upload.njk +1 -4
  68. package/src/components/inputs/input/README.md +6 -0
  69. package/src/components/inputs/input/_template.njk +2 -1
  70. package/src/components/inputs/input/input.config.js +0 -1
  71. package/src/components/inputs/label/README.md +6 -0
  72. package/src/components/inputs/label/_template.njk +2 -2
  73. package/src/components/inputs/label/label.config.js +0 -1
  74. package/src/components/inputs/radio/README.md +6 -0
  75. package/src/components/inputs/radio/_template.njk +2 -1
  76. package/src/components/inputs/radio/radio.config.js +0 -1
  77. package/src/components/inputs/select/README.md +8 -2
  78. package/src/components/inputs/select/_template.njk +4 -10
  79. package/src/components/inputs/select/select.config.js +4 -3
  80. package/src/components/inputs/select/select.njk +3 -3
  81. package/src/components/inputs/single-checkbox/README.md +10 -2
  82. package/src/components/inputs/single-checkbox/_template.njk +9 -6
  83. package/src/components/inputs/single-checkbox/single-checkbox.config.js +5 -7
  84. package/src/components/inputs/single-checkbox/single-checkbox.njk +2 -1
  85. package/src/components/inputs/textarea/README.md +7 -0
  86. package/src/components/inputs/textarea/_template.njk +3 -2
  87. package/src/components/inputs/textarea/textarea.config.js +0 -1
  88. package/src/components/inputs/textarea/textarea.njk +2 -1
  89. package/src/components/modal/README.md +6 -1
  90. package/src/components/modal/_template.njk +2 -8
  91. package/src/components/modal/modal.njk +4 -3
  92. package/src/components/pagination/README.md +18 -7
  93. package/src/components/pagination/_template.njk +18 -10
  94. package/src/components/pagination/pagination.config.js +36 -27
  95. package/src/components/pagination/pagination.njk +2 -6
  96. package/src/components/pagination-numbers/README.md +17 -7
  97. package/src/components/pagination-numbers/_pagination-numbers-number-macro.njk +5 -2
  98. package/src/components/pagination-numbers/_template.njk +20 -17
  99. package/src/components/pagination-numbers/pagination-numbers.config.js +18 -8
  100. package/src/components/pagination-numbers/pagination-numbers.njk +2 -10
  101. package/src/components/skip-link/README.md +1 -1
  102. package/src/components/skip-link/_template.njk +1 -1
  103. package/src/components/skip-link/skip-link.njk +3 -1
  104. package/src/icons/check.svg +1 -1
  105. package/src/icons/question-mark.svg +1 -1
  106. package/tasks/svgsprite.js +20 -14
@@ -9,7 +9,7 @@ All icons available in MDS
9
9
  {% macro Icon(params) %}
10
10
  <div class="icon">
11
11
  <svg class="mds-icon mds-icon--{{ params.name }}{% if class %} {{ class }}{% endif %}">
12
- <use href="{{ '/assets/icons.svg' | path }}#{{ params.name }}" />
12
+ <use href="{{ '/assets/icons.svg' | path }}#icon-{{ params.name }}" />
13
13
  </svg>
14
14
  <span class="icon__label"><code>mds-icon--{{ params.name }}</code></span>
15
15
  </div>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@madgex/design-system",
3
3
  "author": "Madgex",
4
4
  "license": "UNLICENSED",
5
- "version": "3.4.2",
5
+ "version": "3.6.0",
6
6
  "scripts": {
7
7
  "clean": "rimraf dist public tokens/build",
8
8
  "commit": "commit",
@@ -97,7 +97,7 @@
97
97
  "sass": "^1.35.2",
98
98
  "semantic-release": "^15.13.24",
99
99
  "svg-sprite-loader": "^6.0.9",
100
- "svgo": "^2.3.1",
100
+ "svgo": "^2.8.0",
101
101
  "svgo-loader": "^3.0.0",
102
102
  "svgstore": "^3.0.0-2",
103
103
  "vue-jest": "^3.0.7",
@@ -1,17 +1,21 @@
1
+ ## Setup
2
+
3
+ **Default path of the icons file**:
4
+
5
+ You need to set `defaultIconPath` as a Nunjucks global if you want to use an external file (for example, `/assets/icons/svg`).
6
+ https://mozilla.github.io/nunjucks/api.html#addglobal
7
+
8
+ If you prefer using inline svgs, don't set the path and include the file `icons-inline.svg` in your template instead.
9
+
1
10
  ## Parameters
2
11
 
3
12
  - `iconName`: the name of the icon you want to use
4
13
  - `classes`: add extra CSS classes to the icon
5
- - `path`: if you need to use a different path than the default (*/assets/icons.svg*)
14
+ - `path`: if you need to use a different path than your default
6
15
  - `visuallyHiddenLabel`: add a visually hidden label (see Accessibility notes below)
7
16
  - `hasContainer`: `true/false` - used to add a container arount the icon *optional*
8
17
  - `containerClasses`: classes for the container (see Container notes below)
9
18
 
10
- **Note regarding the default path of the icons file**:
11
- If you would like to change the default path, you can use the `defaultIconPath` variable in Nunjucks. You can set it as global variable like this:
12
-
13
- `env.addGlobal('defaultIconPath', value)`
14
-
15
19
  ## Accessibility
16
20
 
17
21
  The SVGs are hidden from screen readers by default (with the use of `aria-hidden=true` and `focusable=false`). When the icons are used without a visible label, a **visually hidden label needs to be added** instead.
@@ -1,15 +1,8 @@
1
- {%- set iconPath -%}
2
- {%- if defaultIconPath -%}
3
- {{- defaultIconPath -}}
4
- {%- else -%}
5
- '/assets/icons.svg'
6
- {%- endif -%}
7
- {%- endset -%}
8
1
  {%- if params.hasContainer -%}
9
2
  <span class="mds-icon-container {{ params.containerClasses }}">
10
3
  {%- endif -%}
11
4
  <svg aria-hidden="true" focusable="false" class="mds-icon mds-icon--{{ params.iconName }}{% if params.classes %} {{ params.classes }}{% endif %}">
12
- <use href="{{ params.path | default(iconPath) }}#{{ params.iconName }}" />
5
+ <use href="{{ params.path | default(defaultIconPath) }}#icon-{{ params.iconName }}" />
13
6
  </svg>
14
7
  {%- if params.visuallyHiddenLabel %}
15
8
  <span class="mds-visually-hidden">{{ params.visuallyHiddenLabel }}</span>
@@ -15,7 +15,7 @@
15
15
  {{- MdsIcon({
16
16
  iconName: 'asterisk',
17
17
  classes: 'mds-form-label__required',
18
- visuallyHiddenLabel: 'required'
18
+ visuallyHiddenLabel: params.i18n.requiredIcon | default('required')
19
19
  }) -}}
20
20
  {%- endif -%}{#
21
21
  #}</label>
@@ -12,6 +12,13 @@
12
12
  - `describedBy`: adding aria-describeby to the fieldset (if multiple checkboxes) or the input field if only one checkbox - **optional**
13
13
  - `options`: This is an array of objects containing the parameters for each option: `labelText`, `value`, `id`, `classes`
14
14
  - `selectedOptions`: Preselected checkboxes - Array or comma-separated string **optional**
15
+ - `i18n`: Text to translate/customise (object) **optional**
16
+ ```
17
+ i18n: {
18
+ requiredIcon: 'required', // visually hidden text for the required icon (label)
19
+ accordionTrigger: 'Select options under {label}' // text to improve a11y on nested checkboxes - please note the use of `{label}` to get the name of the option
20
+ }
21
+ ```
15
22
 
16
23
  **Note:** `id` in `options` is optional. If you don't specify one, an id will be created for you using the name/id of the field and the value of the option.
17
24
 
@@ -51,15 +51,15 @@
51
51
  optional: true
52
52
  }) }}
53
53
  {% if option.options and option.options.length %}
54
- {%- set triggerLabel %}Select options under {{ option.labelText | safe }}{% endset -%}
54
+ {%- set triggerLabel %}{{ checkboxParams.i18n.accordionTrigger | default('Select options under {label}') | replace('{label}', option.labelText) | safe }}{% endset -%}
55
55
  {%- set accordionContent %}
56
56
  <div class="mds-form-check__nested-container">
57
57
  {{ createCheckboxes({
58
- options: option.options,
59
- selectedOptions: checkboxParams.selectedOptions,
60
- name: checkboxParams.name,
61
- disabled: checkboxParams.disabled
62
- }) }}
58
+ options: option.options,
59
+ selectedOptions: checkboxParams.selectedOptions,
60
+ name: checkboxParams.name,
61
+ disabled: checkboxParams.disabled
62
+ }) }}
63
63
  </div>
64
64
  {% endset -%}
65
65
  {{ MdsAccordion({
@@ -102,7 +102,8 @@
102
102
  hideLabel: params.hideLabel,
103
103
  inputId: params.id,
104
104
  optional: params.optional,
105
- tooltipMessage: params.tooltipMessage
105
+ tooltipMessage: params.tooltipMessage,
106
+ i18n: params.i18n
106
107
  }) }}
107
108
  {{ MdsInputMessages({
108
109
  id: params.id,
@@ -114,7 +115,8 @@
114
115
  options: params.options,
115
116
  selectedOptions: params.selectedOptions,
116
117
  name: name,
117
- disabled: params.disabled
118
+ disabled: params.disabled,
119
+ i18n: params.i18n
118
120
  }) }}
119
121
  </div>
120
122
  </fieldset>
@@ -81,6 +81,9 @@ module.exports = {
81
81
  labelText: 'Industry',
82
82
  tooltipMessage: 'Select some options',
83
83
  selectedOptions: [101, 600104],
84
+ i18n: {
85
+ accordionTrigger: 'Please find more options under {label}',
86
+ },
84
87
  options: [
85
88
  {
86
89
  value: 101,
@@ -13,6 +13,7 @@
13
13
  tooltipMessage: tooltipMessage,
14
14
  optional: optional,
15
15
  state: state,
16
- validationError: validationError
16
+ validationError: validationError,
17
+ i18n: i18n
17
18
  }) }}
18
19
  </div>
@@ -13,6 +13,17 @@
13
13
  - `validationError`: The error message provided by validation _optional_,
14
14
  - `state`: The current state of the input, currently the only allowed value is `error` _optional_
15
15
  - `type`: name of the options api e.g "location-lookup"
16
+ - `i18n`: Text to translate/customise (object) **optional**
17
+ ```
18
+ i18n: {
19
+ requiredIcon: 'required', // visually hidden text for the required icon (label)
20
+ loadingText: 'Loading', // visually hidden text for the loading icon
21
+ describedByText:
22
+ 'When autocomplete results are available, use up and down arrows to review and enter to select.', // help text for screen readers users to explain how to use the combobox
23
+ resultsMessage: '{count} result available.', // announce number of results - note the use of `{count}` to get the number of results
24
+ resultsMessage_plural: '{count} results available.', // announce number of results (plural) - note the use of `{count}` to get the number of results
25
+ }
26
+ ```
16
27
 
17
28
  ## Props - Vue component
18
29
 
@@ -23,6 +34,7 @@
23
34
  - `value`: a default value for the combobox input. Populated automatically from Nunjucks parameters
24
35
  - `options`: an array of options, which should be objects with a `label` and a `value`. The array should be provided externally by selecting the custom `<mds-combobox>` element and setting it as an attribute
25
36
  - `filterOptions`: whether or not the Vue component should internally filter the options array according to the search input (defaults to true)
37
+ - `i18n`: Text to translate/customise. Populated automatically from Nunjucks parameters
26
38
 
27
39
  ## Accessibility
28
40
 
@@ -30,7 +30,8 @@
30
30
  inputId: comboboxId,
31
31
  id: labelId,
32
32
  optional: params.optional,
33
- tooltipMessage: params.tooltipMessage
33
+ tooltipMessage: params.tooltipMessage,
34
+ i18n: params.i18n
34
35
  }) }}
35
36
  {{ MdsInputMessages({
36
37
  id: comboboxId,
@@ -52,7 +53,8 @@
52
53
  {% endif %}
53
54
  </div>
54
55
  {# Leave the custom element at the bottom so it has access to the above elements on render #}
55
- <mds-combobox comboboxid="{{ comboboxId }}" placeholder="{{ params.placeholder }}" iconpath="{{ defaultIconPath }}" data-aria-invalid="{{ params.validationError }}"
56
+ <mds-combobox comboboxid="{{ comboboxId }}" placeholder="{{ params.placeholder }}" iconpath="{{ defaultIconPath }}"
57
+ i18n="{{ params.i18n | dump }}" data-aria-invalid="{{ params.validationError }}"
56
58
  {% if params.fallbackTo === 'input' %}name="{{ comboboxName }}"{% endif %}
57
59
  {% if params.value %}value="{{ params.value }}"{% endif %}
58
60
  ></mds-combobox>
@@ -1,7 +1,6 @@
1
1
  module.exports = {
2
2
  title: 'Combobox',
3
3
  label: 'Combobox',
4
- status: 'wip',
5
4
  variants: [
6
5
  {
7
6
  name: 'default',
@@ -25,6 +24,14 @@ module.exports = {
25
24
  labelText: 'Keywords:',
26
25
  placeholder: 'eg. Web developer',
27
26
  fallbackTo: 'input',
27
+ i18n: {
28
+ requiredIcon: 'Required (test i18n)',
29
+ loadingText: 'Loading (test i18n)',
30
+ describedByText:
31
+ 'When autocomplete results are available, use up and down arrows to review and enter to select. (test i18n)',
32
+ resultsMessage: '{count} result available (test i18n)',
33
+ resultsMessage_plural: '{count} results available (test i18n)',
34
+ },
28
35
  },
29
36
  },
30
37
  {
@@ -13,7 +13,8 @@
13
13
  fallbackTo: fallbackTo,
14
14
  classes: classes,
15
15
  placeholder: placeholder,
16
- type: type
16
+ type: type,
17
+ i18n: i18n
17
18
  }) }}
18
19
  <br><br>
19
20
  </div>
@@ -37,9 +37,7 @@
37
37
  </template>
38
38
  </ListBox>
39
39
  <div aria-live="polite" role="status" class="mds-visually-hidden">{{ resultCountMessage }}</div>
40
- <span :id="describedBy" style="display: none">
41
- When autocomplete results are available use up and down arrows to review and enter to select.
42
- </span>
40
+ <span :id="describedBy" style="display: none">{{ i18nText.describedByText }} </span>
43
41
  </div>
44
42
  </template>
45
43
 
@@ -88,6 +86,10 @@ export default {
88
86
  type: String,
89
87
  default: '',
90
88
  },
89
+ i18n: {
90
+ type: String,
91
+ default: '',
92
+ },
91
93
  },
92
94
  data() {
93
95
  return {
@@ -96,13 +98,12 @@ export default {
96
98
  chosen: null,
97
99
  searchValue: this.$props.value,
98
100
  resultCountMessage: null,
99
- resultMessage: 'result available',
100
- resultMessage_plural: 'results available',
101
101
  };
102
102
  },
103
103
  provide() {
104
104
  return {
105
105
  iconPath: this.iconpath,
106
+ loadingText: this.i18nText.loadingText,
106
107
  };
107
108
  },
108
109
  computed: {
@@ -184,6 +185,17 @@ export default {
184
185
  ariaInvalid() {
185
186
  return this.dataAriaInvalid ? 'true' : 'false';
186
187
  },
188
+ i18nText() {
189
+ return this.i18n
190
+ ? JSON.parse(this.i18n)
191
+ : {
192
+ loadingText: 'Loading',
193
+ describedByText:
194
+ 'When autocomplete results are available, use up and down arrows to review and enter to select.',
195
+ resultsMessage: '{count} result available',
196
+ resultsMessage_plural: '{count} results available',
197
+ };
198
+ },
187
199
  },
188
200
  methods: {
189
201
  makeActive() {
@@ -252,9 +264,10 @@ export default {
252
264
  updateCount() {
253
265
  this.clearCount();
254
266
  setTimeout(() => {
255
- const message = this.visibleOptions.length === 1 ? this.resultMessage : this.resultMessage_plural;
267
+ const message =
268
+ this.visibleOptions.length === 1 ? this.i18nText.resultsMessage : this.i18nText.resultsMessage_plural;
256
269
 
257
- this.resultCountMessage = `${this.visibleOptions.length} ${message}`;
270
+ this.resultCountMessage = message.replace('{count}', this.visibleOptions.length);
258
271
  }, 1400);
259
272
  },
260
273
  clearCount() {
@@ -4,9 +4,9 @@
4
4
  <!-- Ideally we would pass this in as a slot in the custom element with MdsIcon, but something is borked
5
5
  with passing slots in Chrome https://github.com/karol-f/vue-custom-element/issues/162 -->
6
6
  <svg aria-hidden="true" focusable="true" class="mds-icon mds-icon--spinner mds-icon--after">
7
- <use :href="`${iconPath}#spinner`" />
7
+ <use :href="`${iconPath}#icon-spinner`" />
8
8
  </svg>
9
- <span class="mds-visually-hidden">Loading...</span>
9
+ <span class="mds-visually-hidden">{{ loadingText }}</span>
10
10
  </li>
11
11
  <slot></slot>
12
12
  </ul>
@@ -29,6 +29,6 @@ export default {
29
29
  required: true,
30
30
  },
31
31
  },
32
- inject: ['iconPath'],
32
+ inject: ['iconPath', 'loadingText'],
33
33
  };
34
34
  </script>
@@ -1,9 +1,6 @@
1
1
  ## Parameters
2
2
 
3
3
  - `labelText`: The label for the input **required**,
4
- - `buttonText`: The text for the secondary label acting as the file upload button, uses labelText unless specified **optional**,
5
- - `defaultFileText`: The default text to show in place of a file name when a user has not selected a file yet **required**,
6
- - `removeButtonText`: The text to show on the button that clears the input when a file has been selected **required**,
7
4
  - `hideLabel`: true/false - Add this parameter if you need to visually hide the label **optional**
8
5
  **(please see accessibility notes below regarding the use of this parameter)**
9
6
  - `name`: The name of the input field, uses ID unless specified **optional**,
@@ -15,9 +12,22 @@
15
12
  - `state`: The current state of the input, currently the only allowed value is `error` **optional**,
16
13
  - `tooltipMessage`: Toggles a tooltip with this message to appear on the input **optional**
17
14
  - `classes`: add extra classes to the trigger **optional**
18
- - `fileTypes`: comma separated list of the different types of file you want to allow. It will add the `accept` attribute on the input - **optional ** (see notes on validation)
15
+ - `fileTypes`: comma separated list of the different types of file you want to allow. It will add the `accept` attribute on the input - **optional** (see notes on validation)
19
16
  - `value`: name of a file - we can't pre-fill a file input for security reasons but using `value` will allow you to indicate to the user that the system will use a pre-saved file. You will need to add logic behind the scenes to cater for that option. **optional**
20
- - `selectedFileText`: To be used in combination with `value`. Add text which explains that the system will use a pre-saved file. Useful when there is no javascript or for browsers that don't support the drag and drop. To ensure accessibility, the text "Use `[params.value]` or upload a different file" is added by default when `value` is used. Use `selectedFileText` to customise it. **optional**
17
+ - `i18n`: Text to translate/customise (object) **optional**
18
+ ```
19
+ i18n: {
20
+ defaultFileText: 'Drag and drop',
21
+ buttonText: 'Choose a file',
22
+ removeButtonText: 'Remove file',
23
+ selectedFileText: 'Selected file:', // hidden text when a file has been selected
24
+ fallbackSelectedFileText: 'Use `[value]` or upload a different file'
25
+ }
26
+ ```
27
+ + `defaultFileText`: The default text to show in place of a file name when a user has not selected a file yet
28
+ + `buttonText`: The text for the file upload button
29
+ + `removeButtonText`: The text to show on the button that clears the input when a file has been selected
30
+ + `fallbackSelectedFileText`: To be used in combination with `value`. Add text which explains that the system will use a pre-saved file. Useful when there is no javascript or for browsers that don't support the drag and drop. To ensure accessibility, the text "Use `[value]` or upload a different file" is added by default when `value` is used.
21
31
 
22
32
  ## Accessibility
23
33
 
@@ -9,14 +9,8 @@
9
9
  {% set name = params.id %}
10
10
  {% endif %}
11
11
 
12
- {% if params.buttonText %}
13
- {% set buttonText = params.buttonText %}
14
- {% else %}
15
- {% set buttonText = params.labelText %}
16
- {% endif %}
17
-
18
12
  {% set removeButtonText -%}
19
- {{- params.removeButtonText -}}
13
+ {{- params.i18n.removeButtonText | default('Remove file') -}}
20
14
  {{-
21
15
  MdsIcon({
22
16
  iconName: 'cross',
@@ -33,7 +27,7 @@
33
27
  optional: params.optional,
34
28
  tooltipMessage: params.tooltipMessage
35
29
  }) }}
36
- {% if params.value %}<p class="mds-file-upload__selected-file-fallback">{% if params.selectedFileText %}{{ params.selectedFileText }}{% else %}Use {{ params.value }} or upload a different file{% endif %}</p>{% endif %}
30
+ {% if params.value %}<p class="mds-file-upload__selected-file-fallback">{{ params.i18n.fallbackSelectedFileText | default('Use ' + params.value + ' or upload a different file') }}</p>{% endif %}
37
31
  {{ MdsInputMessages({
38
32
  id: params.id,
39
33
  helpText: params.helpText,
@@ -66,12 +60,12 @@
66
60
  })
67
61
  }}
68
62
  <span>
69
- {{ params.defaultFileText }}
63
+ {{ params.i18n.defaultFileText | default('Drag and drop') }}
70
64
  </span>
71
65
  </div>
72
66
  <div class="mds-file-upload__browse-button mds-text-align-center">
73
67
  <div class="mds-form-label">
74
- <label class="mds-form-label__label" for="{{params.id}}">{{ buttonText }}</label>
68
+ <label class="mds-form-label__label" for="{{params.id}}">{{ params.i18n.buttonText | default('Choose a file') }}</label>
75
69
  </div>
76
70
  </div>
77
71
  </div>
@@ -84,7 +78,7 @@
84
78
  containerClasses: 'mds-icon-container--circle mds-icon-container--success mds-icon-container--before'
85
79
  })
86
80
  -}}
87
- <span class="mds-visually-hidden">Selected file: </span>
81
+ <span class="mds-visually-hidden">{{ params.i18n.selectedFileText | default('Selected file:') }} </span>
88
82
  <span class="mds-file-upload__file-name">{% if params.value %}{{ params.value }}{% endif %}</span>
89
83
  </div>
90
84
  {{ MdsButton({
@@ -1,12 +1,8 @@
1
1
  module.exports = {
2
2
  title: 'File Upload',
3
- status: 'wip',
4
3
  context: {
5
4
  labelText: 'Upload a file',
6
5
  helpText: 'Your file must be a .doc, .pdf, .docx, or .rtf. No larger than 1MB',
7
- defaultFileText: 'Drag and drop',
8
- buttonText: 'Choose a file',
9
- removeButtonText: 'Remove file',
10
6
  name: 'file',
11
7
  id: 'file',
12
8
  fileTypes: '.doc,.docx,.pdf,.rtf',
@@ -18,7 +14,9 @@ module.exports = {
18
14
  value: 'myCV.doc',
19
15
  name: 'selected-file',
20
16
  id: 'selected-file',
21
- selectedFileText: 'Use my saved CV or upload a different one',
17
+ i18n: {
18
+ fallbackSelectedFileText: 'Use my saved CV or upload a different one',
19
+ },
22
20
  },
23
21
  },
24
22
  ],
@@ -5,9 +5,6 @@
5
5
  <div class="mds-form-field">
6
6
  {{ MdsFileUpload({
7
7
  labelText: labelText,
8
- buttonText: buttonText,
9
- defaultFileText: defaultFileText,
10
- removeButtonText: removeButtonText,
11
8
  hideLabel: hideLabel,
12
9
  name: name,
13
10
  id: id,
@@ -21,7 +18,7 @@
21
18
  classes: classes,
22
19
  tooltipMessage: tooltipMessage,
23
20
  fileTypes: fileTypes,
24
- selectedFileText: selectedFileText
21
+ i18n: i18n
25
22
  }) }}
26
23
  </div>
27
24
  </div>
@@ -16,6 +16,12 @@
16
16
  - `inputClasses`: add extra classes to the inner input element - **optional**
17
17
  - `placeholder`: add a placeholder to the input **optional**
18
18
  **(please see accessibility notes below regarding the use of this parameter)**
19
+ - `i18n`: Text to translate/customise (object) **optional**
20
+ ```
21
+ i18n: {
22
+ requiredIcon: 'required', // visually hidden text for the required icon (label)
23
+ }
24
+ ```
19
25
 
20
26
  ## Accessibility
21
27
 
@@ -13,7 +13,8 @@
13
13
  hideLabel: params.hideLabel,
14
14
  inputId: params.id,
15
15
  optional: params.optional,
16
- tooltipMessage: params.tooltipMessage
16
+ tooltipMessage: params.tooltipMessage,
17
+ i18n: params.i18n
17
18
  }) }}
18
19
  {{ MdsInputMessages({
19
20
  id: params.id,
@@ -1,6 +1,5 @@
1
1
  module.exports = {
2
2
  title: 'Input',
3
- status: 'wip',
4
3
  context: {
5
4
  labelText: 'Text input',
6
5
  name: 'Example input',
@@ -7,6 +7,12 @@
7
7
  - `element`: Which element type this label should be (legend/label | default: label) **optional**
8
8
  - `hideLabel`: true/false - Add this parameter if you need to visually hide the label. The text of the label will the used by default as a placeholder, unless overridden by the placeholder parameter **optional**
9
9
  **(please see accessibility notes below regarding the use of this parameter)**
10
+ - `i18n`: Text to translate/customise (object) **optional**
11
+ ```
12
+ i18n: {
13
+ requiredIcon: 'required', // visually hidden text for the required icon
14
+ }
15
+ ```
10
16
 
11
17
  ## Accessibility
12
18
  Avoid using `hideLabel` if you can. Only hide the label when there can be no mistake as to what the input is for, probably when there is only one input in the form.
@@ -18,7 +18,7 @@
18
18
  {{ MdsIcon({
19
19
  iconName: 'asterisk',
20
20
  classes: 'mds-form-label__required',
21
- visuallyHiddenLabel: 'required'
21
+ visuallyHiddenLabel: params.i18n.requiredIcon | default('required')
22
22
  }) }}
23
23
  {%- endif -%}
24
24
  {%- if params.element == 'legend' -%}
@@ -34,7 +34,7 @@
34
34
  text: MdsIcon({
35
35
  iconName: 'question-mark',
36
36
  classes: 'mds-icon--info',
37
- visuallyHiddenLabel: 'More info'
37
+ visuallyHiddenLabel: params.i18n.tooltipIcon | default('More info')
38
38
  }),
39
39
  placement: 'right',
40
40
  classes: 'mds-button mds-button--plain mds-form-label__tooltip',
@@ -1,6 +1,5 @@
1
1
  module.exports = {
2
2
  title: 'Label',
3
- status: 'wip',
4
3
  context: {
5
4
  labelText: 'This is a test label',
6
5
  },
@@ -11,6 +11,12 @@
11
11
  - `classes`: add extra classes to the fieldgroup - **optional**
12
12
  - `options`: This is an array of objects containing the parameters for each option: `labelText`, `value`, `id`, `classes`
13
13
  - `value`: Value to preselect
14
+ - `i18n`: Text to translate/customise (object) **optional**
15
+ ```
16
+ i18n: {
17
+ requiredIcon: 'required', // visually hidden text for the required icon (label)
18
+ }
19
+ ```
14
20
 
15
21
  **Note:** `id` in `options` is optional. If you don't specify one, an id will be created for you using the name/id of the field and the value of the option.
16
22
 
@@ -15,7 +15,8 @@
15
15
  hideLabel: params.hideLabel,
16
16
  inputId: params.id,
17
17
  optional: params.optional,
18
- tooltipMessage: params.tooltipMessage
18
+ tooltipMessage: params.tooltipMessage,
19
+ i18n: params.i18n
19
20
  }) }}
20
21
  {{ MdsInputMessages({
21
22
  id: params.id,
@@ -1,6 +1,5 @@
1
1
  module.exports = {
2
2
  title: 'Radio',
3
- status: 'wip',
4
3
  context: {
5
4
  id: 'radio-input',
6
5
  labelText: 'Standard Radio group',
@@ -12,10 +12,16 @@
12
12
  - `state`: The current state of the input, currently the only allowed value is `error` **optional**,
13
13
  - `tooltipMessage`: Toggles a tooltip with this message to appear on the input **optional**
14
14
  - `classes`: add extra classes to the trigger - **optional**
15
- - `defaultHide`: remove default disabled option - **optional**
16
- - `defaultLabel`: text for default option - **optional**
15
+ - `hideDefault`: remove default disabled option - **optional**
17
16
  - `value`: A default value to have selected as an option
18
17
  - `options`: This is an object of all options. The valid keys are `labelText` and `value`
18
+ - `i18n`: Text to translate/customise (object) **optional**
19
+ ```
20
+ i18n: {
21
+ requiredIcon: 'required', // visually hidden text for the required icon (label)
22
+ defaultOptionLabel: 'Please select', // text for default option - won't display if hideDefault parameter is set
23
+ }
24
+ ```
19
25
 
20
26
  ## Accessibility
21
27
 
@@ -19,7 +19,8 @@
19
19
  hideLabel: params.hideLabel,
20
20
  inputId: params.id,
21
21
  optional: params.optional,
22
- tooltipMessage: params.tooltipMessage
22
+ tooltipMessage: params.tooltipMessage,
23
+ i18n: params.i18n
23
24
  }) }}
24
25
  {{ MdsInputMessages({
25
26
  id: params.id,
@@ -34,16 +35,9 @@
34
35
  {% endif -%}
35
36
  class="mds-form-control"
36
37
  >
37
- {% if not params.defaultHide -%}
38
- {%- set defaultLabel -%}
39
- {%- if params.defaultLabel -%}
40
- {{params.defaultLabel}}
41
- {%- else -%}
42
- Please select
43
- {%- endif -%}
44
- {%- endset -%}
38
+ {% if not params.hideDefault -%}
45
39
  <option {%- if not params.value %} selected="selected"{% endif %} value="">
46
- {{ defaultLabel | safe }}
40
+ {{- params.i18n.defaultOptionLabel | default('Please select') | safe -}}
47
41
  </option>
48
42
  {%- endif %}
49
43
  {%- for option in params.options %}
@@ -1,6 +1,5 @@
1
1
  module.exports = {
2
2
  title: 'Select',
3
- status: 'wip',
4
3
  context: {
5
4
  labelText: 'Select input',
6
5
  name: 'Select input',
@@ -53,7 +52,7 @@ module.exports = {
53
52
  name: 'Default option hidden',
54
53
  id: 'default-option-hidden',
55
54
  optional: true,
56
- defaultHide: true,
55
+ hideDefault: true,
57
56
  options: [
58
57
  {
59
58
  labelText: 'Option 1',
@@ -77,7 +76,6 @@ module.exports = {
77
76
  name: 'Default option custom',
78
77
  id: 'default-option-custom',
79
78
  optional: true,
80
- defaultLabel: 'All',
81
79
  options: [
82
80
  {
83
81
  labelText: 'Option 1',
@@ -92,6 +90,9 @@ module.exports = {
92
90
  value: 'option-3',
93
91
  },
94
92
  ],
93
+ i18n: {
94
+ defaultOptionLabel: 'All',
95
+ },
95
96
  },
96
97
  },
97
98
  ],