@madgex/design-system 1.60.7 → 1.60.8
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/__tests__/unit/src/components/accordion.spec.js +16 -12
- package/coverage/cobertura-coverage.xml +58 -173
- package/coverage/components/accordion/accordion.js.html +63 -42
- package/coverage/components/accordion/index.html +15 -15
- 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 +1 -1
- package/coverage/components/inputs/combobox/vue-components/ListBoxOption.vue.html +1 -1
- package/coverage/components/inputs/combobox/vue-components/index.html +1 -1
- 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 +17 -47
- 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 +3 -6
- 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.json +1 -1
- package/dist/css/index.css +1 -1
- package/dist/js/index.js +5 -5
- package/package.json +1 -1
- package/src/components/{macro-index.njk → _macro-index.njk} +0 -1
- package/src/components/accordion/README.md +18 -7
- package/src/components/accordion/_template.njk +46 -52
- package/src/components/accordion/accordion.config.js +8 -8
- package/src/components/accordion/accordion.js +39 -32
- package/src/components/accordion/accordion.njk +2 -1
- package/src/components/accordion/accordion.scss +15 -15
- package/src/components/inputs/_form-elements.scss +54 -19
- package/src/components/inputs/checkbox/README.md +3 -1
- package/src/components/inputs/checkbox/_template.njk +80 -17
- package/src/components/inputs/checkbox/checkbox.config.js +110 -1
- package/src/components/inputs/checkbox/checkbox.njk +3 -1
- package/src/components/inputs/label/_template.njk +38 -29
- package/src/components/popover/popover.scss +1 -0
- package/src/js/index-vue.js +1 -2
- package/src/layout/forms/forms.config.js +20 -20
- package/src/layout/forms/forms.njk +11 -12
- package/src/scss/components/__index.scss +0 -1
- package/tasks/createMacroIndex.js +1 -1
- package/__tests__/unit/src/components/multiselect.spec.js +0 -91
- package/coverage/components/inputs/multi-select/index.html +0 -110
- package/coverage/components/inputs/multi-select/multi-select.js.html +0 -175
- package/coverage/components/inputs/multi-select/vue-components/MultiSelect.vue.html +0 -229
- package/coverage/components/inputs/multi-select/vue-components/MultiSelectCheckbox.vue.html +0 -349
- package/coverage/components/inputs/multi-select/vue-components/MultiSelectCheckboxGroup.vue.html +0 -274
- package/coverage/components/inputs/multi-select/vue-components/index.html +0 -140
- package/cypress/integration/components/multi-select.spec.js +0 -9
- package/src/components/inputs/multi-select/README.md +0 -18
- package/src/components/inputs/multi-select/_macro.njk +0 -3
- package/src/components/inputs/multi-select/_template.njk +0 -57
- package/src/components/inputs/multi-select/multi-select.config.js +0 -178
- package/src/components/inputs/multi-select/multi-select.js +0 -32
- package/src/components/inputs/multi-select/multi-select.njk +0 -16
- package/src/components/inputs/multi-select/multi-select.scss +0 -39
- package/src/components/inputs/multi-select/vue-components/MultiSelect.vue +0 -50
- package/src/components/inputs/multi-select/vue-components/MultiSelectCheckbox.vue +0 -90
- package/src/components/inputs/multi-select/vue-components/MultiSelectCheckboxGroup.vue +0 -65
package/package.json
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
{% from 'src/components/inputs/file-upload/_macro.njk' import MdsFileUpload %}
|
|
11
11
|
{% from 'src/components/inputs/input/_macro.njk' import MdsInput %}
|
|
12
12
|
{% from 'src/components/inputs/label/_macro.njk' import MdsInputLabel %}
|
|
13
|
-
{% from 'src/components/inputs/multi-select/_macro.njk' import MdsMultiSelect %}
|
|
14
13
|
{% from 'src/components/inputs/radio/_macro.njk' import MdsRadio %}
|
|
15
14
|
{% from 'src/components/inputs/select/_macro.njk' import MdsSelect %}
|
|
16
15
|
{% from 'src/components/inputs/textarea/_macro.njk' import MdsTextarea %}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
## Parameters
|
|
2
2
|
|
|
3
|
-
- `
|
|
4
|
-
- `triggerLabel`: label of the trigger button
|
|
3
|
+
- `id`: it will be used to create the id on the trigger and the content **required**
|
|
4
|
+
- `triggerLabel`: label of the trigger button. Be as descriptive as you can as it will help for a11y. **required**
|
|
5
5
|
- `triggerLabelActive`: label of the trigger button when accordion is expanded
|
|
6
6
|
- `triggerNoJsHidden`: trigger button to show/hide when js is disabled
|
|
7
|
-
- `
|
|
8
|
-
|
|
7
|
+
- `triggerHtmlTag`: trigger is `p` tag by default, you can pass an html tag if needed (`h2`, `h3`, `div`)
|
|
8
|
+
Note: Don't use `span` as it creates a bug with VoiceOver where you can't access the expanded content when the trigger is within an inline, inline block or floated element.
|
|
9
|
+
- `triggerClasses`: class will be added to the trigger (useful to change the font size)
|
|
9
10
|
- `breakpoint`: if a value (in px, em, rem) is passed, the accordion will be enabled only when screen size is smaller than the breakpoint
|
|
10
|
-
- `content`: this can also be a custom component or html
|
|
11
|
+
- `content`: this can also be a custom component or html **required**
|
|
11
12
|
- `expandIcon`: This allows you to override the iconography for the expand icon (default: chevron-down) - See design usage guidelines
|
|
12
13
|
- `collapseIcon`: This allows you to override the iconography for the collapse icon (default: chevron-up) - See design usage guidelines
|
|
13
14
|
- `leftAligned`: This will determine if the icon should sit on the left or the right of the label (default: false) - See design usage guidelines
|
|
@@ -15,7 +16,8 @@
|
|
|
15
16
|
|
|
16
17
|
## Accessibility
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
When javascript is enabled, accordion will contains `aria-label` and `aria-expanded` for screen readers.
|
|
20
|
+
Use a descriptive label for the trigger.
|
|
19
21
|
|
|
20
22
|
## Design usage guidelines
|
|
21
23
|
Where possible, the defaults should remain as they are to ensure we remain consistent across the platform, though there are a few areas where you may need to step
|
|
@@ -23,4 +25,13 @@ outside these guidelines, this offers an insight into the design decisions to be
|
|
|
23
25
|
|
|
24
26
|
- `expandIcon`: Where possible, we should ensure that this remains unchanged as the chevrons are a universal indicator of expandable content. However, there are scenarios where this may not work for you. In these scenarios, it is suggested you use one of the following icons: `plus-small` (Plus is a little too big to align nicely with the content of the label)
|
|
25
27
|
- `collapseIcon`: Where possible, we should ensure that this remains unchanged as the chevrons are a universal indicator of collapsable content. However, there are scenarios where this may not work for you. In these scenarios, it is suggested you use one of the following icons: `minus`
|
|
26
|
-
- `leftAligned`: Usage for this parameter depends largely on the content surrounding it. There are some cases where we have a list where some items are expandable while others are not so to avoid a misalignment due to the presence of icons or not, we've decided that when in a list the accordions would have the icons on the right. When used as a single component on the page, the icon is on the left instead.
|
|
28
|
+
- `leftAligned`: Usage for this parameter depends largely on the content surrounding it. There are some cases where we have a list where some items are expandable while others are not so to avoid a misalignment due to the presence of icons or not, we've decided that when in a list the accordions would have the icons on the right. When used as a single component on the page, the icon is on the left instead.
|
|
29
|
+
|
|
30
|
+
## Notes
|
|
31
|
+
|
|
32
|
+
- 02/11/20 - `aria-controls` attribute has been removed from the accordion as it is poorly supported and doesn't work as expected.
|
|
33
|
+
|
|
34
|
+
References:
|
|
35
|
+
|
|
36
|
+
- https://heydonworks.com/article/aria-controls-is-poop/ (that article's title says it all)
|
|
37
|
+
- https://a11ysupport.io/tech/aria/aria-controls_attribute
|
|
@@ -1,56 +1,50 @@
|
|
|
1
1
|
{% from "../icons/_macro.njk" import MdsIcon %}
|
|
2
2
|
|
|
3
3
|
{% if params.content %}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{%
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{{- MdsIcon({ iconName: expandIcon, classes: 'mds-icon--after mds-accordion__icon-expand'}) -}}
|
|
51
|
-
{% endif %}
|
|
52
|
-
</span>
|
|
53
|
-
</{{headerTag}}>
|
|
54
|
-
<div id="accordion-content-{{accordionId}}" class="mds-accordion__content" {%if not params.triggerNoJsHidden %}aria-labelledby="accordion-trigger-{{accordionId}}" {% endif %}data-test="accordion-content">{{params.content | safe}}</div>
|
|
55
|
-
</div>
|
|
4
|
+
{%- set triggerHtmlTag %}
|
|
5
|
+
{%- if params.triggerHtmlTag -%}
|
|
6
|
+
{{params.triggerHtmlTag}}
|
|
7
|
+
{%- else -%}
|
|
8
|
+
p
|
|
9
|
+
{%- endif -%}
|
|
10
|
+
{% endset -%}
|
|
11
|
+
{%- set collapseIcon -%}
|
|
12
|
+
{%- if params.collapseIcon -%}
|
|
13
|
+
{{params.collapseIcon}}
|
|
14
|
+
{%- else -%}
|
|
15
|
+
chevron-up
|
|
16
|
+
{%- endif -%}
|
|
17
|
+
{% endset -%}
|
|
18
|
+
{%- set expandIcon %}
|
|
19
|
+
{%- if params.expandIcon -%}
|
|
20
|
+
{{params.expandIcon}}
|
|
21
|
+
{%- else -%}
|
|
22
|
+
chevron-down
|
|
23
|
+
{% endif -%}
|
|
24
|
+
{% endset -%}
|
|
25
|
+
<{{triggerHtmlTag}} id="accordion-trigger-{{params.id}}" class="mds-accordion-trigger{%if params.triggerNoJsHidden %} mds-display-none{% endif %}" {% if params.breakpoint %}data-bp="{{params.breakpoint}}"{% endif %} data-test="accordion-trigger">
|
|
26
|
+
<span {% if params.triggerClasses %}class="{{params.triggerClasses}}"{% endif %}>
|
|
27
|
+
{% if params.leftAligned %}
|
|
28
|
+
{{- MdsIcon({ iconName: collapseIcon, classes: 'mds-icon--before mds-accordion-trigger__icon-collapse'}) -}}
|
|
29
|
+
{{- MdsIcon({ iconName: expandIcon, classes: 'mds-icon--before mds-accordion-trigger__icon-expand'}) -}}
|
|
30
|
+
{% endif %}
|
|
31
|
+
<span class="mds-accordion-trigger__label{% if params.hideTriggerLabel %} mds-visually-hidden{% endif %}" {%- if params.triggerLabelActive %} data-labelinverse="{{params.triggerLabelActive}}"{% endif %}>
|
|
32
|
+
{{- params.triggerLabel | safe -}}
|
|
33
|
+
</span>
|
|
34
|
+
{% if not params.leftAligned %}
|
|
35
|
+
{{- MdsIcon({ iconName: collapseIcon, classes: 'mds-icon--after mds-accordion-trigger__icon-collapse'}) -}}
|
|
36
|
+
{{- MdsIcon({ iconName: expandIcon, classes: 'mds-icon--after mds-accordion-trigger__icon-expand'}) -}}
|
|
37
|
+
{% endif %}
|
|
38
|
+
</span>
|
|
39
|
+
</{{triggerHtmlTag}}>
|
|
40
|
+
{% if params.useFieldset %}
|
|
41
|
+
{# used in nested checkboxes #}
|
|
42
|
+
<fieldset class="mds-accordion-content" data-test="accordion-content">
|
|
43
|
+
<legend class="mds-visually-hidden">{{params.triggerLabel}}</legend>
|
|
44
|
+
{{params.content | safe}}
|
|
45
|
+
</fieldset>
|
|
46
|
+
{% else %}
|
|
47
|
+
{# using aria-label instead of aria-labelledby to avoid getting `triggerLabelActive` as label for the content #}
|
|
48
|
+
<div class="mds-accordion-content" {% if not params.triggerNoJsHidden %}aria-label="{{ params.triggerLabel }}" {% endif %}data-test="accordion-content">{{params.content | safe}}</div>
|
|
49
|
+
{% endif %}
|
|
56
50
|
{% endif %}
|
|
@@ -8,8 +8,8 @@ module.exports = {
|
|
|
8
8
|
name: 'Taxonomy',
|
|
9
9
|
context: {
|
|
10
10
|
name: 'Taxonomy',
|
|
11
|
-
triggerLabel: 'View more',
|
|
12
|
-
triggerLabelActive: 'View less',
|
|
11
|
+
triggerLabel: 'View more categories',
|
|
12
|
+
triggerLabelActive: 'View less categories',
|
|
13
13
|
triggerNoJsHidden: true,
|
|
14
14
|
content:
|
|
15
15
|
'<dl class="mds-list mds-list--definition mds-list--border"><dt class="mds-list__key">Hours</dt><dd class="mds-list__value">Full time</dd><dt class="mds-list__key">Contract</dt><dd class="mds-list__value">Permanent</dd><dt class="mds-list__key">Industry</dt><dd class="mds-list__value">Accountant, Manager</dd></dl>',
|
|
@@ -19,14 +19,14 @@ module.exports = {
|
|
|
19
19
|
name: 'Alternative icons',
|
|
20
20
|
context: {
|
|
21
21
|
name: 'Alt Icons',
|
|
22
|
-
triggerLabel: 'View more',
|
|
23
|
-
triggerLabelActive: 'View less',
|
|
22
|
+
triggerLabel: 'View more options',
|
|
23
|
+
triggerLabelActive: 'View less options',
|
|
24
24
|
triggerNoJsHidden: true,
|
|
25
25
|
collapseIcon: 'minus',
|
|
26
26
|
expandIcon: 'plus-small',
|
|
27
27
|
leftAligned: true,
|
|
28
28
|
content:
|
|
29
|
-
'<
|
|
29
|
+
'<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ligula erat, dignissim non sollicitudin ut, sagittis a sapien. Quisque eget arcu sed nulla tincidunt eleifend. Maecenas sit amet velit elit. Maecenas elementum venenatis sapien sit amet elementum. Pellentesque id mauris quis tortor suscipit posuere. Donec eu consectetur tortor. Mauris id scelerisque quam. Sed scelerisque ut est quis sollicitudin. Etiam semper tempor erat, sed rhoncus ex malesuada non. Donec eu pellentesque odio. Vestibulum et suscipit risus, luctus semper nunc. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam eu est ac libero blandit egestas ac id tellus. Suspendisse pulvinar viverra ex, a varius ligula commodo at. Vivamus dignissim neque vitae est ultrices lobortis. Cras vel pulvinar erat.</p>',
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
{
|
|
@@ -36,7 +36,7 @@ module.exports = {
|
|
|
36
36
|
triggerLabel: 'Lorem ipsum',
|
|
37
37
|
triggerNoJsHidden: false,
|
|
38
38
|
triggerIsHeader: 'h3',
|
|
39
|
-
|
|
39
|
+
triggerClasses: 'mds-font-great-primer',
|
|
40
40
|
content:
|
|
41
41
|
'<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ligula erat, dignissim non sollicitudin ut, sagittis a sapien. Quisque eget arcu sed nulla tincidunt eleifend. Maecenas sit amet velit elit. Maecenas elementum venenatis sapien sit amet elementum. Pellentesque id mauris quis tortor suscipit posuere. Donec eu consectetur tortor. Mauris id scelerisque quam. Sed scelerisque ut est quis sollicitudin. Etiam semper tempor erat, sed rhoncus ex malesuada non. Donec eu pellentesque odio. Vestibulum et suscipit risus, luctus semper nunc. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam eu est ac libero blandit egestas ac id tellus. Suspendisse pulvinar viverra ex, a varius ligula commodo at. Vivamus dignissim neque vitae est ultrices lobortis. Cras vel pulvinar erat.</p>',
|
|
42
42
|
},
|
|
@@ -45,8 +45,8 @@ module.exports = {
|
|
|
45
45
|
name: 'Mobile Only',
|
|
46
46
|
context: {
|
|
47
47
|
name: 'Mobile Only',
|
|
48
|
-
triggerLabel: 'View more',
|
|
49
|
-
triggerLabelActive: 'View less',
|
|
48
|
+
triggerLabel: 'View more categories',
|
|
49
|
+
triggerLabelActive: 'View less categories',
|
|
50
50
|
triggerNoJsHidden: true,
|
|
51
51
|
breakpoint: tokens.size.breakpoint.md.original.value,
|
|
52
52
|
content:
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
const accordionTriggerClass = 'mds-accordion-trigger';
|
|
2
|
+
const accordionTriggerButtonClass = 'mds-accordion-trigger__button';
|
|
3
|
+
const accordionTriggerLabelClass = 'mds-accordion-trigger__label';
|
|
4
|
+
const accordionTriggerExpandedClass = 'mds-accordion-trigger--expanded';
|
|
5
|
+
const accordionContentExpandedClass = 'mds-accordion-content--expanded';
|
|
6
6
|
const accordionLabelInverseData = 'data-labelinverse';
|
|
7
|
-
const accordionTriggerLabelClass = 'mds-accordion__trigger-label';
|
|
8
7
|
|
|
9
8
|
const accordion = {
|
|
10
9
|
init: () => {
|
|
11
|
-
const
|
|
10
|
+
const accordionTriggerList = Array.from(document.querySelectorAll(`.${accordionTriggerClass}`));
|
|
12
11
|
const screenWidth = window.innerWidth;
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
const
|
|
13
|
+
accordionTriggerList.forEach((trigger) => {
|
|
14
|
+
const accordionContent = trigger.nextElementSibling;
|
|
15
|
+
const isAccordion = accordion.checkBreakpoint(trigger, screenWidth);
|
|
16
16
|
if (isAccordion) {
|
|
17
|
-
accordion.setAccordion(
|
|
17
|
+
accordion.setAccordion(trigger, accordionContent);
|
|
18
18
|
} else {
|
|
19
|
-
|
|
19
|
+
trigger.classList.add(accordionTriggerExpandedClass);
|
|
20
|
+
accordionContent.classList.add(accordionContentExpandedClass);
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
},
|
|
@@ -55,29 +56,34 @@ const accordion = {
|
|
|
55
56
|
}
|
|
56
57
|
return true;
|
|
57
58
|
},
|
|
58
|
-
setAccordion: (
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
setAccordion: (accordionTrigger, accordionContent) => {
|
|
60
|
+
const triggerContainer = accordionTrigger;
|
|
61
|
+
const accordionTriggerId = triggerContainer.id;
|
|
62
|
+
const label = triggerContainer.querySelector('.mds-accordion-trigger__label');
|
|
63
|
+
const labelText = label.innerText;
|
|
64
|
+
const triggerButton = accordion.createButton(accordionTriggerId, triggerContainer);
|
|
65
|
+
triggerContainer.classList.remove('mds-display-none');
|
|
66
|
+
if (accordionContent.nodeName.toLowerCase() !== 'fieldset') {
|
|
67
|
+
accordionContent.setAttribute('aria-label', labelText);
|
|
68
|
+
}
|
|
69
|
+
triggerContainer.innerHTML = '';
|
|
70
|
+
triggerContainer.appendChild(triggerButton);
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
triggerButton.addEventListener('click', (elem) => {
|
|
69
73
|
elem.preventDefault();
|
|
70
|
-
accordion.toggleExpand(
|
|
74
|
+
accordion.toggleExpand(triggerButton, triggerContainer, accordionContent);
|
|
71
75
|
});
|
|
72
76
|
},
|
|
73
|
-
createButton: (
|
|
77
|
+
createButton: (accordionTriggerId, element) => {
|
|
74
78
|
const accordionTriggerSpan = element.querySelector(`.${accordionTriggerClass} > span`);
|
|
75
79
|
const accordionTriggerButton = document.createElement('button');
|
|
76
80
|
accordionTriggerButton.className = accordionTriggerButtonClass;
|
|
77
|
-
|
|
78
|
-
accordionTriggerButton.
|
|
81
|
+
// can't use multiple arguments in classList.add() due to IE
|
|
82
|
+
accordionTriggerButton.classList.add('mds-button');
|
|
83
|
+
accordionTriggerButton.classList.add('mds-button--plain');
|
|
84
|
+
accordionTriggerButton.classList.add('mds-padding-b0');
|
|
85
|
+
accordionTriggerButton.setAttribute('id', accordionTriggerId);
|
|
79
86
|
accordionTriggerButton.setAttribute('aria-expanded', false);
|
|
80
|
-
accordionTriggerButton.setAttribute('aria-controls', `accordion-content-${accordionId}`);
|
|
81
87
|
if (accordionTriggerSpan) {
|
|
82
88
|
accordionTriggerButton.appendChild(accordionTriggerSpan);
|
|
83
89
|
}
|
|
@@ -94,17 +100,18 @@ const accordion = {
|
|
|
94
100
|
}
|
|
95
101
|
return element;
|
|
96
102
|
},
|
|
97
|
-
toggleExpand: (
|
|
98
|
-
const accordionTriggerButton =
|
|
99
|
-
const accordionTriggerButtonLabel =
|
|
100
|
-
const accordionParent = accordionTriggerButton.closest(`.${accordionClass}`);
|
|
103
|
+
toggleExpand: (triggerButton, triggerContainer, accordionContent) => {
|
|
104
|
+
const accordionTriggerButton = triggerButton;
|
|
105
|
+
const accordionTriggerButtonLabel = triggerButton.querySelector(`.${accordionTriggerLabelClass}`);
|
|
101
106
|
|
|
102
107
|
if (accordionTriggerButton.getAttribute('aria-expanded') === 'false') {
|
|
103
108
|
accordionTriggerButton.setAttribute('aria-expanded', true);
|
|
104
|
-
|
|
109
|
+
triggerContainer.classList.add(accordionTriggerExpandedClass);
|
|
110
|
+
accordionContent.classList.add(accordionContentExpandedClass);
|
|
105
111
|
} else {
|
|
106
112
|
accordionTriggerButton.setAttribute('aria-expanded', false);
|
|
107
|
-
|
|
113
|
+
triggerContainer.classList.remove(accordionTriggerExpandedClass);
|
|
114
|
+
accordionContent.classList.remove(accordionContentExpandedClass);
|
|
108
115
|
}
|
|
109
116
|
accordion.switchLabel(accordionTriggerButtonLabel);
|
|
110
117
|
},
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
triggerLabelActive: triggerLabelActive,
|
|
9
9
|
triggerNoJsHidden: triggerNoJsHidden,
|
|
10
10
|
triggerIsHeader: triggerIsHeader,
|
|
11
|
-
|
|
11
|
+
triggerClasses: triggerClasses,
|
|
12
|
+
hideTriggerLabel: hideTriggerLabel,
|
|
12
13
|
breakpoint: breakpoint,
|
|
13
14
|
content: content,
|
|
14
15
|
leftAligned: leftAligned,
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
.js .mds-accordion
|
|
1
|
+
.js .mds-accordion-content {
|
|
2
2
|
display: none;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
.js .mds-accordion
|
|
5
|
+
.js .mds-accordion-content--expanded {
|
|
6
6
|
display: block;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.mds-accordion {
|
|
10
|
-
& .mds-icon.mds-
|
|
9
|
+
.mds-accordion-trigger {
|
|
10
|
+
& .mds-icon.mds-accordion-trigger__icon {
|
|
11
11
|
&-expand {
|
|
12
12
|
display: inline-block;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
}
|
|
14
|
+
&-collapse {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
17
|
}
|
|
18
18
|
&--expanded {
|
|
19
|
-
& .mds-icon.mds-
|
|
19
|
+
& .mds-icon.mds-accordion-trigger__icon {
|
|
20
20
|
&-expand {
|
|
21
21
|
display: none;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
}
|
|
23
|
+
&-collapse {
|
|
24
|
+
display: inline-block;
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
html:not(.js) .mds-accordion .mds-
|
|
30
|
+
html:not(.js) .mds-accordion .mds-accordion-trigger .mds-icon {
|
|
31
31
|
display: none;
|
|
32
|
-
}
|
|
32
|
+
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
@mixin inputFocusStyle($focusColour: $mds-color-input-focus) {
|
|
2
|
+
border-color: $focusColour;
|
|
3
|
+
outline-color: $focusColour;
|
|
4
|
+
box-shadow: 0 0 3px 2px $focusColour;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
.mds-form-field {
|
|
2
8
|
margin-bottom: $mds-size-baseline * 7;
|
|
3
9
|
}
|
|
4
10
|
.mds-form-label {
|
|
5
11
|
display: flex;
|
|
6
12
|
margin-bottom: $mds-size-baseline * 3;
|
|
13
|
+
|
|
14
|
+
&--legend-with-tooltip {
|
|
15
|
+
// display: inline/inline-block doesn't work on <legend>
|
|
16
|
+
float: left;
|
|
17
|
+
}
|
|
7
18
|
}
|
|
8
19
|
.mds-form-label__label {
|
|
9
20
|
font-weight: bold;
|
|
10
|
-
flex: 1;
|
|
21
|
+
flex: 0 1 auto;
|
|
11
22
|
}
|
|
12
23
|
.mds-form-label__optional {
|
|
13
24
|
@extend .mds-font-brevier;
|
|
@@ -65,9 +76,7 @@
|
|
|
65
76
|
@extend .mds-font-body-copy;
|
|
66
77
|
|
|
67
78
|
&:focus {
|
|
68
|
-
|
|
69
|
-
outline-color: $mds-color-input-focus;
|
|
70
|
-
box-shadow: 0 0 4px 2px $mds-color-input-focus;
|
|
79
|
+
@include inputFocusStyle();
|
|
71
80
|
}
|
|
72
81
|
|
|
73
82
|
.mds-form-element--error & {
|
|
@@ -76,22 +85,12 @@
|
|
|
76
85
|
border-left-width: $mds-size-baseline;
|
|
77
86
|
padding-left: $mds-size-baseline * 2;
|
|
78
87
|
&:focus {
|
|
79
|
-
|
|
80
|
-
box-shadow: 0 0 4px 2px $mds-color-status-error-dark;
|
|
81
|
-
border-color: $mds-color-status-error-dark;
|
|
88
|
+
@include inputFocusStyle($mds-color-status-error-dark);
|
|
82
89
|
border-left-width: $mds-size-baseline;
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
92
|
}
|
|
86
93
|
|
|
87
|
-
.mds-form-check {
|
|
88
|
-
margin-bottom: $mds-size-baseline * 2;
|
|
89
|
-
|
|
90
|
-
&:last-child {
|
|
91
|
-
margin-bottom: 0;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
94
|
.mds-form-element--inline {
|
|
96
95
|
& .mds-form-check {
|
|
97
96
|
display: inline-block;
|
|
@@ -104,13 +103,44 @@
|
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
|
|
106
|
+
.mds-form-check-container--border {
|
|
107
|
+
border-radius: $mds-size-border-radius;
|
|
108
|
+
border: $mds-size-border-width solid $mds-color-input-border;
|
|
109
|
+
max-height: 200px;
|
|
110
|
+
min-height: 200px;
|
|
111
|
+
overflow-y: auto;
|
|
112
|
+
padding: $mds-size-baseline * 2;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.mds-form-check {
|
|
116
|
+
margin-bottom: $mds-size-baseline * 2;
|
|
117
|
+
|
|
118
|
+
&:last-child {
|
|
119
|
+
margin-bottom: 0;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.js .mds-form-check-container--border .mds-form-check {
|
|
124
|
+
display: flex;
|
|
125
|
+
flex-wrap: wrap;
|
|
126
|
+
align-items: center;
|
|
127
|
+
|
|
128
|
+
& .mds-accordion-trigger__button {
|
|
129
|
+
border: none; // helps with vertical alignment
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
& .mds-accordion-content {
|
|
133
|
+
width: 100%;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
107
137
|
.mds-form-check__input {
|
|
108
138
|
display: inline-block;
|
|
109
139
|
position: relative;
|
|
110
|
-
vertical-align: text-
|
|
140
|
+
vertical-align: text-top;
|
|
111
141
|
appearance: none;
|
|
112
|
-
height: $mds-size-baseline *
|
|
113
|
-
width: $mds-size-baseline *
|
|
142
|
+
height: $mds-size-baseline * 4;
|
|
143
|
+
width: $mds-size-baseline * 4;
|
|
114
144
|
padding: $mds-size-baseline;
|
|
115
145
|
border: $mds-size-border-width solid $mds-color-input-border;
|
|
116
146
|
background-color: $mds-color-neutral-white;
|
|
@@ -120,7 +150,7 @@
|
|
|
120
150
|
|
|
121
151
|
&:hover,
|
|
122
152
|
&:focus {
|
|
123
|
-
|
|
153
|
+
@include inputFocusStyle();
|
|
124
154
|
}
|
|
125
155
|
|
|
126
156
|
&:disabled {
|
|
@@ -161,6 +191,11 @@
|
|
|
161
191
|
}
|
|
162
192
|
}
|
|
163
193
|
|
|
194
|
+
.mds-form-check__nested-container {
|
|
195
|
+
margin-top: $mds-size-baseline * 2;
|
|
196
|
+
padding-left: $mds-size-baseline * 5;
|
|
197
|
+
}
|
|
198
|
+
|
|
164
199
|
.js .mds-form-element__fallback {
|
|
165
200
|
display: none;
|
|
166
201
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Parameters
|
|
2
2
|
|
|
3
|
-
- `labelText`: The label for the input **required**,
|
|
3
|
+
- `labelText`: The label for the input **required**, unless there is only one checkbox,
|
|
4
4
|
- `name`: The name of the input field, uses ID unless specified **optional**,
|
|
5
5
|
- `id`: The id attribute of the field, **required**
|
|
6
6
|
- `disabled`: Should the input be disabled **optional**,
|
|
@@ -11,6 +11,8 @@
|
|
|
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`, `selected`
|
|
13
13
|
|
|
14
|
+
**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
|
+
|
|
14
16
|
See an example option below
|
|
15
17
|
```
|
|
16
18
|
options: [
|