@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.
- package/coverage/cobertura-coverage.xml +108 -102
- package/coverage/components/accordion/accordion.js.html +1 -1
- package/coverage/components/accordion/index.html +1 -1
- package/coverage/components/button/button.js.html +1 -1
- package/coverage/components/button/index.html +1 -1
- package/coverage/components/inputs/combobox/combobox.js.html +1 -1
- package/coverage/components/inputs/combobox/index.html +1 -1
- package/coverage/components/inputs/combobox/vue-components/Combobox.vue.html +58 -19
- package/coverage/components/inputs/combobox/vue-components/ListBoxOption.vue.html +1 -1
- package/coverage/components/inputs/combobox/vue-components/index.html +16 -16
- package/coverage/components/inputs/file-upload/file-upload.js.html +1 -1
- package/coverage/components/inputs/file-upload/index.html +1 -1
- package/coverage/components/inputs/textarea/character-count.js.html +1 -1
- package/coverage/components/inputs/textarea/index.html +1 -1
- package/coverage/components/modal/index.html +1 -1
- package/coverage/components/modal/modal.js.html +1 -1
- package/coverage/components/notification/index.html +1 -1
- package/coverage/components/notification/notification.js.html +1 -1
- package/coverage/components/popover/index.html +1 -1
- package/coverage/components/popover/popover.js.html +1 -1
- package/coverage/components/switch-state/index.html +1 -1
- package/coverage/components/switch-state/switch-state.js.html +1 -1
- package/coverage/components/tabs/index.html +1 -1
- package/coverage/components/tabs/tabs.js.html +1 -1
- package/coverage/index.html +18 -18
- package/coverage/js/common.js.html +1 -1
- package/coverage/js/fractal-scripts/combobox.js.html +1 -1
- package/coverage/js/fractal-scripts/index.html +1 -1
- package/coverage/js/fractal-scripts/notification.js.html +1 -1
- package/coverage/js/fractal-scripts/switch-state.js.html +1 -1
- package/coverage/js/index-fractal.js.html +1 -1
- package/coverage/js/index-polyfills.js.html +1 -1
- package/coverage/js/index-vue.js.html +1 -1
- package/coverage/js/index.html +1 -1
- package/coverage/js/index.js.html +1 -1
- package/coverage/js/polyfills/arrayPrototypeFind.js.html +1 -1
- package/coverage/js/polyfills/closest.js.html +1 -1
- package/coverage/js/polyfills/index.html +1 -1
- package/coverage/js/polyfills/objectAssign.js.html +1 -1
- package/coverage/js/polyfills/remove.js.html +1 -1
- package/coverage/tokens/_config.js.html +1 -1
- package/coverage/tokens/index.html +1 -1
- package/dist/_tokens/css/_tokens.css +1 -1
- package/dist/_tokens/js/_tokens-module.js +1 -1
- package/dist/_tokens/scss/_tokens.scss +1 -1
- package/dist/assets/icons-inline.svg +1 -0
- package/dist/assets/icons.svg +1 -6
- package/dist/js/index.js +1 -1
- package/docs/tokens/icons.njk +1 -1
- package/package.json +2 -2
- package/src/components/icons/README.md +10 -6
- package/src/components/icons/_template.njk +1 -8
- package/src/components/inputs/_checkbox-elem/_template.njk +1 -1
- package/src/components/inputs/checkbox-list/README.md +7 -0
- package/src/components/inputs/checkbox-list/_template.njk +10 -8
- package/src/components/inputs/checkbox-list/checkbox-list.config.js +3 -0
- package/src/components/inputs/checkbox-list/checkbox-list.njk +2 -1
- package/src/components/inputs/combobox/README.md +12 -0
- package/src/components/inputs/combobox/_template.njk +4 -2
- package/src/components/inputs/combobox/combobox.config.js +8 -1
- package/src/components/inputs/combobox/combobox.njk +2 -1
- package/src/components/inputs/combobox/vue-components/Combobox.vue +20 -7
- package/src/components/inputs/combobox/vue-components/ListBox.vue +3 -3
- package/src/components/inputs/file-upload/README.md +15 -5
- package/src/components/inputs/file-upload/_template.njk +5 -11
- package/src/components/inputs/file-upload/file-upload.config.js +3 -5
- package/src/components/inputs/file-upload/file-upload.njk +1 -4
- package/src/components/inputs/input/README.md +6 -0
- package/src/components/inputs/input/_template.njk +2 -1
- package/src/components/inputs/input/input.config.js +0 -1
- package/src/components/inputs/label/README.md +6 -0
- package/src/components/inputs/label/_template.njk +2 -2
- package/src/components/inputs/label/label.config.js +0 -1
- package/src/components/inputs/radio/README.md +6 -0
- package/src/components/inputs/radio/_template.njk +2 -1
- package/src/components/inputs/radio/radio.config.js +0 -1
- package/src/components/inputs/select/README.md +8 -2
- package/src/components/inputs/select/_template.njk +4 -10
- package/src/components/inputs/select/select.config.js +4 -3
- package/src/components/inputs/select/select.njk +3 -3
- package/src/components/inputs/single-checkbox/README.md +10 -2
- package/src/components/inputs/single-checkbox/_template.njk +9 -6
- package/src/components/inputs/single-checkbox/single-checkbox.config.js +5 -7
- package/src/components/inputs/single-checkbox/single-checkbox.njk +2 -1
- package/src/components/inputs/textarea/README.md +7 -0
- package/src/components/inputs/textarea/_template.njk +3 -2
- package/src/components/inputs/textarea/textarea.config.js +0 -1
- package/src/components/inputs/textarea/textarea.njk +2 -1
- package/src/components/modal/README.md +6 -1
- package/src/components/modal/_template.njk +2 -8
- package/src/components/modal/modal.njk +4 -3
- package/src/components/pagination/README.md +18 -7
- package/src/components/pagination/_template.njk +18 -10
- package/src/components/pagination/pagination.config.js +36 -27
- package/src/components/pagination/pagination.njk +2 -6
- package/src/components/pagination-numbers/README.md +17 -7
- package/src/components/pagination-numbers/_pagination-numbers-number-macro.njk +5 -2
- package/src/components/pagination-numbers/_template.njk +20 -17
- package/src/components/pagination-numbers/pagination-numbers.config.js +18 -8
- package/src/components/pagination-numbers/pagination-numbers.njk +2 -10
- package/src/components/skip-link/README.md +1 -1
- package/src/components/skip-link/_template.njk +1 -1
- package/src/components/skip-link/skip-link.njk +3 -1
- package/src/icons/check.svg +1 -1
- package/src/icons/question-mark.svg +1 -1
- package/tasks/svgsprite.js +20 -14
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
- `classes`: add extra classes to the fieldgroup - **optional**
|
|
10
10
|
- `describedBy`: adding aria-describeby to the input field - **optional**
|
|
11
11
|
- `selectedOptions`: Preselected checkboxes - Array or comma-separed string
|
|
12
|
-
- `options`:
|
|
12
|
+
- `options`: options for the checkbox inside. Can be an array or a single object. **required**: `labelText`, `value`, `id`, `classes`
|
|
13
|
+
- `i18n`: Text to translate/customise (object) **optional**
|
|
14
|
+
```
|
|
15
|
+
i18n: {
|
|
16
|
+
requiredIcon: 'required', // visually hidden text for the required icon (label)
|
|
17
|
+
}
|
|
18
|
+
```
|
|
13
19
|
|
|
14
20
|
**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.
|
|
15
21
|
|
|
@@ -23,11 +29,13 @@ options: [
|
|
|
23
29
|
},
|
|
24
30
|
]
|
|
25
31
|
```
|
|
26
|
-
|
|
32
|
+
or
|
|
27
33
|
```
|
|
34
|
+
options: {
|
|
28
35
|
labelText: "Checkbox Input 1",
|
|
29
36
|
value: "2-1",
|
|
30
37
|
id: "checkbox-2-1",
|
|
38
|
+
}
|
|
31
39
|
```
|
|
32
40
|
|
|
33
41
|
## Accessibility
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{% from "../_message/_macro.njk" import MdsInputMessages %}
|
|
2
2
|
{% from "../_checkbox-elem/_macro.njk" import MdsCheckboxElem %}
|
|
3
3
|
|
|
4
|
+
{% set options = params.options[0] or params.options %}
|
|
5
|
+
|
|
4
6
|
{%- set name -%}
|
|
5
7
|
{%- if params.name -%}
|
|
6
8
|
{{- params.name -}}
|
|
@@ -10,14 +12,14 @@
|
|
|
10
12
|
{%- endset -%}
|
|
11
13
|
|
|
12
14
|
{%- set id -%}
|
|
13
|
-
{%- if
|
|
14
|
-
{{-
|
|
15
|
+
{%- if options.id -%}
|
|
16
|
+
{{- options.id -}}
|
|
15
17
|
{% else %}
|
|
16
|
-
{{- name -}}-{{-
|
|
18
|
+
{{- name -}}-{{- options.value -}}
|
|
17
19
|
{% endif -%}
|
|
18
20
|
{%- endset -%}
|
|
19
21
|
|
|
20
|
-
{%- if params.selectedOptions ==
|
|
22
|
+
{%- if params.selectedOptions == options.value -%}
|
|
21
23
|
{%- set isSelected = true -%}
|
|
22
24
|
{%- endif -%}
|
|
23
25
|
|
|
@@ -32,12 +34,13 @@
|
|
|
32
34
|
{{- MdsCheckboxElem({
|
|
33
35
|
disabled: params.disabled,
|
|
34
36
|
isSelected: isSelected,
|
|
35
|
-
labelText:
|
|
37
|
+
labelText: options.labelText,
|
|
36
38
|
describedBy: params.describedBy,
|
|
37
39
|
optional: params.optional,
|
|
38
40
|
name: name,
|
|
39
41
|
id: id,
|
|
40
|
-
value:
|
|
42
|
+
value: options.value,
|
|
43
|
+
i18n: params.i18n
|
|
41
44
|
}) -}}
|
|
42
45
|
</div>
|
|
43
46
|
</div>
|
|
@@ -18,13 +18,11 @@ module.exports = {
|
|
|
18
18
|
context: {
|
|
19
19
|
id: 'preselected',
|
|
20
20
|
optional: true,
|
|
21
|
-
options:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
],
|
|
21
|
+
options: {
|
|
22
|
+
labelText: 'I want to opt out of third party emails',
|
|
23
|
+
value: 'out-out',
|
|
24
|
+
id: 'out-out-checkbox',
|
|
25
|
+
},
|
|
28
26
|
selectedOptions: 'out-out',
|
|
29
27
|
},
|
|
30
28
|
},
|
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
- `placeholder`: add a placeholder to the textarea **optional**
|
|
16
16
|
**(please see accessibility notes below regarding the use of this parameter)**
|
|
17
17
|
- `maxlength`: specify the maximum length (in characters) allowed in the textarea. Adding this attribute will automatically add a "character counter" at the bottom right of the textarea (see notes below) - **optional**
|
|
18
|
+
- `i18n`: Text to translate/customise (object) **optional**
|
|
19
|
+
```
|
|
20
|
+
i18n: {
|
|
21
|
+
requiredIcon: 'required', // visually hidden text for the required icon (label)
|
|
22
|
+
characterCountText: '<span class="js-character-count-number">[maxlength]</span> characters remaining' (use with the maxlength parameter)
|
|
23
|
+
}
|
|
24
|
+
```
|
|
18
25
|
|
|
19
26
|
|
|
20
27
|
## Accessibility
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
hideLabel: params.hideLabel,
|
|
15
15
|
inputId: params.id,
|
|
16
16
|
optional: params.optional,
|
|
17
|
-
tooltipMessage: params.tooltipMessage
|
|
17
|
+
tooltipMessage: params.tooltipMessage,
|
|
18
|
+
i18n: params.i18n
|
|
18
19
|
}) }}
|
|
19
20
|
{{ MdsInputMessages({
|
|
20
21
|
id: params.id,
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
containerClasses: 'mds-icon-container--circle mds-icon-container--error mds-icon-container--before'
|
|
50
51
|
})
|
|
51
52
|
-}}
|
|
52
|
-
<span
|
|
53
|
+
<span>{{ params.i18n.characterCountText | default('<span class="js-character-count-number">'+ params.maxlength +'</span> characters remaining') | safe }}</span>
|
|
53
54
|
</div>
|
|
54
55
|
{% endif %}
|
|
55
56
|
</div>
|
|
@@ -11,7 +11,12 @@ The modal will have to be positionned outsite the site container so we can hide
|
|
|
11
11
|
- `ariaLabelledby`: id of the element inside the content, which will provide a label for the modal - **required**,
|
|
12
12
|
- `ariaDescribedby`: id of the element inside the content, which will provide a description for the content of the modal - *optional*,
|
|
13
13
|
- `siteContainerId`: id of the container to target so we can hide the rest of the page to all users when the modal is active - **required**
|
|
14
|
-
- `
|
|
14
|
+
- `i18n`: Text to translate/customise (object) **optional**
|
|
15
|
+
```
|
|
16
|
+
i18n: {
|
|
17
|
+
closeText: 'Close' // "close" button on the top right
|
|
18
|
+
}
|
|
19
|
+
```
|
|
15
20
|
|
|
16
21
|
## Accessibility
|
|
17
22
|
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
{% from "../icons/_macro.njk" import MdsIcon %}
|
|
2
2
|
{% from "../button/_macro.njk" import MdsButton %}
|
|
3
3
|
|
|
4
|
-
{%- set
|
|
5
|
-
{%- if params.closeTranslation -%}
|
|
6
|
-
{{params.closeTranslation}}
|
|
7
|
-
{%- else -%}
|
|
8
|
-
Close
|
|
9
|
-
{%- endif -%}
|
|
10
|
-
{%- endset -%}
|
|
4
|
+
{%- set closeText = params.i18n.closeText | default('Close') -%}
|
|
11
5
|
|
|
12
6
|
<div class="mds-modal" role="dialog" id="{{ params.id }}"{% if params.ariaLabelledby %} aria-labelledby="{{ params.ariaLabelledby }}"{% endif %}{% if params.ariaDescribedby %} aria-describedby="{{ params.ariaDescribedby }}"{% endif %} data-site-container="{{ params.siteContainerId }}">
|
|
13
7
|
<div class="mds-modal__wrapper">
|
|
14
8
|
<div class="mds-modal__inner">
|
|
15
9
|
|
|
16
10
|
{{- MdsButton({
|
|
17
|
-
html:
|
|
11
|
+
html: closeText + MdsIcon({
|
|
18
12
|
iconName: 'close',
|
|
19
13
|
classes: 'mds-icon--after'
|
|
20
14
|
}),
|
|
@@ -34,8 +34,7 @@
|
|
|
34
34
|
content: modalContent,
|
|
35
35
|
ariaLabelledby: 'modal-label',
|
|
36
36
|
ariaDescribedby: 'modal-description',
|
|
37
|
-
siteContainerId: 'site-container'
|
|
38
|
-
closeTranslation: 'Close'
|
|
37
|
+
siteContainerId: 'site-container'
|
|
39
38
|
}) }}
|
|
40
39
|
|
|
41
40
|
{{ MdsModal({
|
|
@@ -44,5 +43,7 @@
|
|
|
44
43
|
ariaLabelledby: 'modal-label',
|
|
45
44
|
ariaDescribedby: 'modal-description',
|
|
46
45
|
siteContainerId: 'site-container',
|
|
47
|
-
|
|
46
|
+
i18n: {
|
|
47
|
+
closeText: 'Close popup'
|
|
48
|
+
}
|
|
48
49
|
}) }}
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
## Parameters
|
|
2
2
|
|
|
3
|
-
- `name`: name of the component, used for accessibility purpose, should be descriptive (i.e. job details pagination)
|
|
4
3
|
- `classes`: add extra CSS classes to the component
|
|
5
4
|
- `hideIcons`: hide caret icons
|
|
6
|
-
- `prevLabel`: label of the previous link
|
|
7
5
|
- `prevUrl`: url of the previous link
|
|
8
|
-
- `prevVisHiddenLabel`: hidden label for accessibility purpose
|
|
9
6
|
- `prevExtraLabel`: extra label of the previous link (i.e. title of the page)
|
|
10
|
-
- `nextLabel`: label of the next link
|
|
11
7
|
- `nextUrl`: url of the next link
|
|
12
|
-
- `nextVisHiddenLabel`: hidden label for accessibility purpose
|
|
13
8
|
- `nextExtraLabel`: extra label of the next link (i.e. title of the page)
|
|
14
|
-
- `backToLabel`: label of the "back to" link
|
|
15
9
|
- `backToUrl`: url of the "back to" link
|
|
10
|
+
- `i18n`: Text to translate/customise (object) **optional**
|
|
11
|
+
```
|
|
12
|
+
i18n: {
|
|
13
|
+
navAriaLabel: 'Pagination', // aria-label for <nav> element - see a11y notes
|
|
14
|
+
backToLabel: 'Results', // label for the "back to" link
|
|
15
|
+
backToAriaLabel: 'Back to results', // aria-label for the "back to" link - see a11y notes
|
|
16
|
+
prevLabel: 'Previous', // label for the "previous" link
|
|
17
|
+
prevAriaLabel: 'Previous page', // aria-label for the "previous" link - see a11y notes
|
|
18
|
+
nextLabel: 'Next', // label for the "next" link
|
|
19
|
+
nextAriaLabel: 'Next page', // aria-label for the "next" link - see a11y notes
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
## Accessibility
|
|
18
25
|
|
|
19
|
-
use
|
|
26
|
+
We use aria labels to provide more context about the navigation element and the links.
|
|
27
|
+
|
|
28
|
+
Adding an aria label on the `<nav>` element (here `navAriaLabel`) allow an assistive technology user to be able to quickly understand the purpose of the landmark.
|
|
29
|
+
|
|
30
|
+
As for the links, since they can be read out of context of the page, it is important to provide descriptive text. Instead of just using "Next" which doesn't mean much out of context, please add "Next job/article/event..." for the aria label as it is clearer to the user what clicking on the link will do.
|
|
@@ -1,47 +1,55 @@
|
|
|
1
1
|
{% from "../icons/_macro.njk" import MdsIcon %}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
{%- set navAriaLabel = params.i18n.navAriaLabel | default('Pagination') -%}
|
|
4
|
+
{%- set backToLabel = params.i18n.backToLabel | default('Results') -%}
|
|
5
|
+
{%- set backToAriaLabel = params.i18n.backToAriaLabel | default('Back to results') -%}
|
|
6
|
+
{%- set prevLabel = params.i18n.prevLabel | default('Previous') -%}
|
|
7
|
+
{%- set prevAriaLabel = params.i18n.prevAriaLabel | default('Previous page') -%}
|
|
8
|
+
{%- set nextLabel = params.i18n.nextLabel | default('Next') -%}
|
|
9
|
+
{%- set nextAriaLabel = params.i18n.nextAriaLabel | default('Next page') -%}
|
|
10
|
+
|
|
11
|
+
<nav aria-label="{{ navAriaLabel }}" data-test="pagination{% if params.id %}-{{params.id}}{% endif %}">
|
|
4
12
|
<ul class="mds-pagination mds-text-align-right{% if params.classes %} {{params.classes}}{% endif %}">
|
|
5
|
-
{% if params.
|
|
13
|
+
{% if params.backToUrl and backToLabel -%}
|
|
6
14
|
<li class="mds-float-left">
|
|
7
|
-
<a href="{{ params.backToUrl }}" class="mds-pagination__link mds-pagination__link--back" aria-label="{{-
|
|
15
|
+
<a href="{{ params.backToUrl }}" class="mds-pagination__link mds-pagination__link--back" aria-label="{{- backToAriaLabel -}}">
|
|
8
16
|
{% if not params.hideIcons -%}
|
|
9
17
|
{{ MdsIcon({
|
|
10
18
|
iconName: 'chevron-left',
|
|
11
19
|
classes: 'mds-icon--before'
|
|
12
20
|
}) -}}
|
|
13
21
|
{%- endif %}
|
|
14
|
-
{{-
|
|
22
|
+
{{- backToLabel -}}
|
|
15
23
|
</a>
|
|
16
24
|
</li>
|
|
17
25
|
{%- endif %}
|
|
18
|
-
{% if params.
|
|
26
|
+
{% if params.prevUrl and prevLabel -%}
|
|
19
27
|
<li class="mds-float-left">
|
|
20
28
|
<a href="{{ params.prevUrl }}"
|
|
21
29
|
class="mds-pagination__link mds-pagination__link--background"
|
|
22
|
-
aria-label="{{
|
|
30
|
+
aria-label="{{ prevAriaLabel }}{% if params.prevExtraLabel %} - {{ params.prevExtraLabel }}{% endif %}">
|
|
23
31
|
{%- if not params.hideIcons -%}
|
|
24
32
|
{{ MdsIcon({
|
|
25
33
|
iconName: 'chevron-left',
|
|
26
34
|
classes: 'mds-icon--before'
|
|
27
35
|
}) }}
|
|
28
36
|
{%- endif -%}
|
|
29
|
-
<span>{{-
|
|
37
|
+
<span>{{- prevLabel -}}</span>
|
|
30
38
|
{%- if params.prevExtraLabel -%}
|
|
31
39
|
<strong class="mds-pagination__extra-label mds-display-none mds-display-lg-inline mds-padding-left-b3">{{ params.prevExtraLabel | truncate(40, false) }}</strong>
|
|
32
40
|
{%- endif %}
|
|
33
41
|
</a>
|
|
34
42
|
</li>
|
|
35
43
|
{%- endif %}
|
|
36
|
-
{% if params.
|
|
44
|
+
{% if params.nextUrl and nextLabel -%}
|
|
37
45
|
<li>
|
|
38
46
|
<a href="{{ params.nextUrl }}"
|
|
39
47
|
class="mds-pagination__link mds-pagination__link--background"
|
|
40
|
-
aria-label="{{
|
|
48
|
+
aria-label="{{ nextAriaLabel }}{% if params.nextExtraLabel %} - {{ params.nextExtraLabel }}{% endif %}">
|
|
41
49
|
{%- if params.nextExtraLabel -%}
|
|
42
50
|
<strong class="mds-pagination__extra-label mds-display-none mds-display-md-inline mds-margin-right-b3">{{ params.nextExtraLabel | truncate(40, false) }}</strong>
|
|
43
51
|
{%- endif -%}
|
|
44
|
-
<span>{{-
|
|
52
|
+
<span>{{- nextLabel -}}</span>
|
|
45
53
|
{% if not params.hideIcons -%}
|
|
46
54
|
{{ MdsIcon({
|
|
47
55
|
iconName: 'chevron-right',
|
|
@@ -2,68 +2,77 @@ module.exports = {
|
|
|
2
2
|
title: 'Pagination',
|
|
3
3
|
label: 'Pagination',
|
|
4
4
|
context: {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
prevUrl: '/prev-page',
|
|
6
|
+
nextUrl: '/next-page',
|
|
7
7
|
id: 'default',
|
|
8
|
+
i18n: {
|
|
9
|
+
prevAriaLabel: 'Previous job',
|
|
10
|
+
nextAriaLabel: 'Next job',
|
|
11
|
+
},
|
|
8
12
|
},
|
|
9
13
|
variants: [
|
|
10
14
|
{
|
|
11
|
-
name: '
|
|
15
|
+
name: 'With backTo link',
|
|
12
16
|
context: {
|
|
13
|
-
|
|
14
|
-
prevLabel: 'Previous',
|
|
15
|
-
prevVisHiddenLabel: 'Previous job',
|
|
17
|
+
backToUrl: '/results/',
|
|
16
18
|
prevUrl: '/prev-page',
|
|
17
|
-
nextLabel: 'Next',
|
|
18
|
-
nextVisHiddenLabel: 'Next job',
|
|
19
19
|
nextUrl: '/next-page',
|
|
20
20
|
id: 'pag-1',
|
|
21
|
+
i18n: {
|
|
22
|
+
navAriaLabel: 'Job pagination',
|
|
23
|
+
backToAriaLabel: 'Back to results',
|
|
24
|
+
prevAriaLabel: 'Previous job',
|
|
25
|
+
nextAriaLabel: 'Next job',
|
|
26
|
+
},
|
|
21
27
|
},
|
|
22
28
|
},
|
|
23
29
|
{
|
|
24
|
-
name: '
|
|
30
|
+
name: 'Next link',
|
|
25
31
|
context: {
|
|
26
|
-
name: 'Job details pagination 2',
|
|
27
32
|
classes: 'mds-font-long-primer',
|
|
28
|
-
nextLabel: 'Next',
|
|
29
33
|
nextUrl: '/next-page',
|
|
30
|
-
nextVisHiddenLabel: 'Next job',
|
|
31
34
|
nextExtraLabel: 'Customer Service, Special-Agent Assistant Part-Time',
|
|
32
|
-
backToLabel: 'Results',
|
|
33
35
|
backToUrl: '/results/',
|
|
34
36
|
id: 'pag-2',
|
|
37
|
+
i18n: {
|
|
38
|
+
backToAriaLabel: 'Back to results',
|
|
39
|
+
nextAriaLabel: 'Next job',
|
|
40
|
+
},
|
|
35
41
|
},
|
|
36
42
|
},
|
|
37
43
|
{
|
|
38
|
-
name: '
|
|
44
|
+
name: 'Previous link',
|
|
39
45
|
context: {
|
|
40
|
-
name: 'Job details pagination 3',
|
|
41
46
|
classes: 'mds-font-long-primer',
|
|
42
|
-
prevLabel: 'Previous',
|
|
43
47
|
prevUrl: '/prev-page',
|
|
44
|
-
prevVisHiddenLabel: 'Previous job',
|
|
45
48
|
prevExtraLabel: 'Part Time Sales Assistant',
|
|
46
|
-
backToLabel: 'Results',
|
|
47
49
|
backToUrl: '/results/',
|
|
48
50
|
id: 'pag-3',
|
|
51
|
+
i18n: {
|
|
52
|
+
backToAriaLabel: 'Back to results',
|
|
53
|
+
nextAriaLabel: 'Previous job',
|
|
54
|
+
},
|
|
49
55
|
},
|
|
50
56
|
},
|
|
51
57
|
{
|
|
52
|
-
name: '
|
|
58
|
+
name: 'Translated',
|
|
53
59
|
context: {
|
|
54
|
-
name: 'Job details pagination 4',
|
|
55
60
|
classes: 'mds-font-long-primer',
|
|
56
|
-
prevLabel: 'Previous',
|
|
57
61
|
prevUrl: '/prev-page',
|
|
58
|
-
|
|
59
|
-
prevExtraLabel: 'Part Time Sales Assistant',
|
|
60
|
-
nextLabel: 'Next',
|
|
62
|
+
prevExtraLabel: "Agent / Agente d'entretien de nettoyage industriel",
|
|
61
63
|
nextUrl: '/next-page',
|
|
62
|
-
|
|
63
|
-
nextExtraLabel: 'Customer Service, Special-Agent Assistant Part-Time',
|
|
64
|
-
backToLabel: 'Results',
|
|
64
|
+
nextExtraLabel: 'Conseiller/ère de vente (F/H)',
|
|
65
65
|
backToUrl: '/results/',
|
|
66
66
|
id: 'pag-4',
|
|
67
|
+
i18n: {
|
|
68
|
+
navAriaLabel: "Pagination de l'offre",
|
|
69
|
+
backToLabel: 'Recherche',
|
|
70
|
+
backToAriaLabel: 'Revenir à la page de recherche',
|
|
71
|
+
prevLabel: 'Précédent',
|
|
72
|
+
prevAriaLabel: 'Offre précédente',
|
|
73
|
+
nextLabel: 'Suivant',
|
|
74
|
+
nextAriaLabel: 'Offre suivante',
|
|
75
|
+
},
|
|
67
76
|
},
|
|
68
77
|
},
|
|
69
78
|
],
|
|
@@ -4,15 +4,11 @@
|
|
|
4
4
|
name: name,
|
|
5
5
|
classes: classes,
|
|
6
6
|
hideIcons: hideIcons,
|
|
7
|
-
prevLabel: prevLabel,
|
|
8
7
|
prevUrl: prevUrl,
|
|
9
|
-
prevVisHiddenLabel: prevVisHiddenLabel,
|
|
10
8
|
prevExtraLabel: prevExtraLabel,
|
|
11
|
-
nextLabel: nextLabel,
|
|
12
9
|
nextUrl: nextUrl,
|
|
13
|
-
nextVisHiddenLabel: nextVisHiddenLabel,
|
|
14
10
|
nextExtraLabel: nextExtraLabel,
|
|
15
|
-
backToLabel: backToLabel,
|
|
16
11
|
backToUrl: backToUrl,
|
|
17
|
-
id: id
|
|
12
|
+
id: id,
|
|
13
|
+
i18n: i18n
|
|
18
14
|
}) }}
|
|
@@ -7,17 +7,27 @@
|
|
|
7
7
|
- `pageNo`: (_required_) current page the list is on
|
|
8
8
|
- `pageSize`: (_required_) how many items per page
|
|
9
9
|
- `totalItemCount`: (_required_) total items count
|
|
10
|
-
- `prevLabel`: label of the previous link
|
|
11
|
-
- `prevVisHiddenLabel`: hidden label for accessibility purpose
|
|
12
|
-
- `nextLabel`: label of the next link
|
|
13
|
-
- `nextVisHiddenLabel`: hidden label for accessibility purpose
|
|
14
|
-
- `pageVisHiddenLabel`: (_required_) Label for each number link i.e. passing 'Page {pageNo}' will create 'Page 23'. {pageNo} is used as a placeholder for the page number.
|
|
15
|
-
- `pageVisHiddenCurrentPageLabel`: (_required_) Label for active number link i.e. passing 'Current page, page {pageNo}' will create 'Current page, page 2'.
|
|
16
10
|
- `alwaysShowLastPage`: (false by default) Always show the last page number,which may display ellipses if its far ahead of 'current page'
|
|
11
|
+
- `i18n`: Text to translate/customise (object) **optional**
|
|
12
|
+
```
|
|
13
|
+
i18n: {
|
|
14
|
+
navAriaLabel: 'Pagination', // aria-label for <nav> element - see a11y notes
|
|
15
|
+
prevLabel: 'Previous', // label for the "previous" link
|
|
16
|
+
prevAriaLabel: 'Previous page', // aria-label for the "previous" link - see a11y notes
|
|
17
|
+
nextLabel: 'Next', // label for the "next" link
|
|
18
|
+
nextAriaLabel: 'Next page', // aria-label for the "next" link - see a11y notes
|
|
19
|
+
pageNumberAriaLabel: 'Page {pageNo}', // aria-label for the page number - please note the use of `{pageNo}` to get the page number
|
|
20
|
+
currentPageAriaLabel: 'Current page, page {pageNo}', // aria-label for the current page - please note the use of `{pageNo}` to get the page number
|
|
21
|
+
}
|
|
22
|
+
```
|
|
17
23
|
|
|
18
24
|
## Accessibility
|
|
19
25
|
|
|
20
|
-
use
|
|
26
|
+
We use aria labels to provide more context about the navigation element and the links.
|
|
27
|
+
|
|
28
|
+
Adding an aria label on the `<nav>` element (here `navAriaLabel`) allow an assistive technology user to be able to quickly understand the purpose of the landmark.
|
|
29
|
+
|
|
30
|
+
It is important for the links to be as descriptive as possible as they can be read out of context when using assistive technology. For example, instead of just using "Next" which doesn't mean much out of context, please add "Next page" for the aria label as it is clearer to the user what clicking on the link will do.
|
|
21
31
|
|
|
22
32
|
## Quirks
|
|
23
33
|
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{% macro PaginationNumbersNumber(params) %}
|
|
2
2
|
{%- set isCurrentPage = params.pageNo === params.number -%}
|
|
3
3
|
|
|
4
|
+
{%- set pageNumberAriaLabel = params.i18n.pageNumberAriaLabel | default('Page {pageNo}') -%}
|
|
5
|
+
{%- set currentPageAriaLabel = params.i18n.currentPageAriaLabel | default('Current page, page {pageNo}') -%}
|
|
6
|
+
|
|
4
7
|
<a href="{{params.pageUrlTemplate | replace('{pageNo}', params.number)}}"
|
|
5
8
|
{%- if isCurrentPage -%}
|
|
6
9
|
aria-current="true"
|
|
7
|
-
aria-label="{{
|
|
10
|
+
aria-label="{{ currentPageAriaLabel | replace('{pageNo}', params.number) }}"
|
|
8
11
|
class="mds-pagination__link mds-pagination__link--background mds-pagination__link--active"
|
|
9
12
|
{%- else -%}
|
|
10
|
-
aria-label="{{
|
|
13
|
+
aria-label="{{ pageNumberAriaLabel | replace('{pageNo}', params.number) }}"
|
|
11
14
|
class="mds-pagination__link mds-pagination__link--background"
|
|
12
15
|
{%- endif -%}>
|
|
13
16
|
{%- if params.showLastEllipses -%}
|
|
@@ -56,23 +56,30 @@ Otherwise, show an extra page in front of the current page to make up the displa
|
|
|
56
56
|
{%- set disabledButtonNext = true -%}
|
|
57
57
|
{%- endif -%}
|
|
58
58
|
|
|
59
|
+
{# Labels #}
|
|
60
|
+
{%- set navAriaLabel = params.i18n.navAriaLabel | default('Pagination') -%}
|
|
61
|
+
{%- set prevLabel = params.i18n.prevLabel | default('Previous') -%}
|
|
62
|
+
{%- set prevAriaLabel = params.i18n.prevAriaLabel | default('Previous page') -%}
|
|
63
|
+
{%- set nextLabel = params.i18n.nextLabel | default('Next') -%}
|
|
64
|
+
{%- set nextAriaLabel = params.i18n.nextAriaLabel | default('Next page') -%}
|
|
65
|
+
|
|
59
66
|
{# VIEW #}
|
|
60
67
|
|
|
61
|
-
<nav aria-label="{{
|
|
68
|
+
<nav aria-label="{{ navAriaLabel }}" data-test="pagination-numbers{% if params.id %}-{{params.id}}{% endif %}">
|
|
62
69
|
<ul class="mds-pagination mds-pagination--numbers mds-text-align-center {% if params.classes %} {{params.classes}}{% endif %}">
|
|
63
|
-
{% if
|
|
70
|
+
{% if prevLabel -%}
|
|
64
71
|
<li class="mds-pagination__item">
|
|
65
72
|
{%- if disabledButtonPrev -%}
|
|
66
73
|
<div class="mds-pagination__link mds-pagination__link--disabled" aria-disabled="true">
|
|
67
74
|
{%- else -%}
|
|
68
75
|
<a href="{{params.pageUrlTemplate | replace('{pageNo}', pageNo - 1) }}"
|
|
69
76
|
class="mds-pagination__link mds-pagination__link--background"
|
|
70
|
-
|
|
77
|
+
aria-label="{{ prevAriaLabel }}">
|
|
71
78
|
{%- endif -%}
|
|
72
79
|
{% if not params.hideIcons -%}
|
|
73
80
|
{{ MdsIcon({iconName: 'chevron-left'}) }}
|
|
74
81
|
{%- endif -%}
|
|
75
|
-
<span class="mds-display-none mds-display-md-inline mds-margin-left-b2">{{-
|
|
82
|
+
<span class="mds-display-none mds-display-md-inline mds-margin-left-b2">{{- prevLabel -}}</span>
|
|
76
83
|
{%- if disabledButtonPrev -%}
|
|
77
84
|
</div>
|
|
78
85
|
{%- else -%}
|
|
@@ -85,21 +92,18 @@ Otherwise, show an extra page in front of the current page to make up the displa
|
|
|
85
92
|
pageNo: pageNo,
|
|
86
93
|
pageUrlTemplate: params.pageUrlTemplate,
|
|
87
94
|
number: 1,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
})
|
|
95
|
+
showFirstEllipses: showFirstEllipses,
|
|
96
|
+
i18n: params.i18n
|
|
97
|
+
})
|
|
92
98
|
}}
|
|
93
99
|
</li>
|
|
94
100
|
{%- for page in pages -%}
|
|
95
101
|
<li class="mds-pagination__item mds-border-left">
|
|
96
102
|
{{ PaginationNumbersNumber({
|
|
97
103
|
pageNo: pageNo,
|
|
98
|
-
|
|
99
104
|
pageUrlTemplate: params.pageUrlTemplate,
|
|
100
105
|
number: page,
|
|
101
|
-
|
|
102
|
-
pageVisHiddenLabel: params.pageVisHiddenLabel
|
|
106
|
+
i18n: params.i18n
|
|
103
107
|
})
|
|
104
108
|
}}
|
|
105
109
|
</li>
|
|
@@ -110,23 +114,22 @@ Otherwise, show an extra page in front of the current page to make up the displa
|
|
|
110
114
|
pageNo: pageNo,
|
|
111
115
|
pageUrlTemplate: params.pageUrlTemplate,
|
|
112
116
|
number: pageCount,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
showLastEllipses: showLastEllipses
|
|
117
|
+
showLastEllipses: showLastEllipses,
|
|
118
|
+
i18n: params.i18n
|
|
116
119
|
})
|
|
117
120
|
}}
|
|
118
121
|
</li>
|
|
119
122
|
{%- endif -%}
|
|
120
|
-
{%- if
|
|
123
|
+
{%- if nextLabel -%}
|
|
121
124
|
<li class="mds-pagination__item mds-border-left">
|
|
122
125
|
{%- if disabledButtonNext -%}
|
|
123
126
|
<div class="mds-pagination__link mds-pagination__link--disabled" aria-disabled="true">
|
|
124
127
|
{%- else -%}
|
|
125
128
|
<a href="{{params.pageUrlTemplate | replace('{pageNo}', pageNo + 1)}}"
|
|
126
129
|
class="mds-pagination__link mds-pagination__link--background"
|
|
127
|
-
|
|
130
|
+
aria-label="{{ nextAriaLabel }}">
|
|
128
131
|
{%- endif -%}
|
|
129
|
-
<span class="mds-display-none mds-display-md-inline mds-margin-right-b2">{{-
|
|
132
|
+
<span class="mds-display-none mds-display-md-inline mds-margin-right-b2">{{- nextLabel -}}</span>
|
|
130
133
|
{%- if not params.hideIcons -%}
|
|
131
134
|
{{ MdsIcon({iconName: 'chevron-right'}) }}
|
|
132
135
|
{%- endif -%}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
title: 'Pagination numbers',
|
|
3
3
|
label: 'Pagination numbers',
|
|
4
|
-
status: 'wip',
|
|
5
4
|
context: {
|
|
6
|
-
name: 'Pagination numbers',
|
|
7
|
-
nextLabel: 'Next',
|
|
8
|
-
prevLabel: 'Previous',
|
|
9
|
-
pageVisHiddenLabel: 'Page {pageNo}',
|
|
10
|
-
pageVisHiddenCurrentPageLabel: 'Current page, page {pageNo}',
|
|
11
5
|
pageUrlTemplate: '/article/{pageNo}/my-seo-things',
|
|
12
|
-
prevVisHiddenLabel: 'Previous article',
|
|
13
|
-
nextVisHiddenLabel: 'Next article',
|
|
14
6
|
id: 'default',
|
|
15
7
|
},
|
|
16
8
|
variants: [
|
|
@@ -87,5 +79,23 @@ module.exports = {
|
|
|
87
79
|
id: '1-render',
|
|
88
80
|
},
|
|
89
81
|
},
|
|
82
|
+
{
|
|
83
|
+
name: 'Translated',
|
|
84
|
+
context: {
|
|
85
|
+
pageNo: 2,
|
|
86
|
+
totalItemCount: 100,
|
|
87
|
+
pageSize: 10,
|
|
88
|
+
id: 'translated',
|
|
89
|
+
i18n: {
|
|
90
|
+
navAriaLabel: 'Pagination numérotée',
|
|
91
|
+
prevLabel: 'Précédent',
|
|
92
|
+
prevAriaLabel: 'Page précédente',
|
|
93
|
+
nextLabel: 'Suivant',
|
|
94
|
+
nextAriaLabel: 'Page suivante',
|
|
95
|
+
pageNumberAriaLabel: 'page {pageNo}',
|
|
96
|
+
currentPageAriaLabel: 'Page actuelle ({pageNo})',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
90
100
|
],
|
|
91
101
|
};
|