@madgex/design-system 11.0.0 → 12.0.1

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.
@@ -1 +1 @@
1
- (()=>{"use strict";const e=e=>{e.classList.remove("mds-switch-state--default"),e.classList.add("mds-switch-state--inverse")},t=e=>{e.classList.remove("mds-switch-state--inverse"),e.classList.add("mds-switch-state--default")},o=()=>{Array.from(document.querySelectorAll(".js-mds-switch-state")).forEach(o=>{o.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation();const s=o.currentTarget;s.classList.contains("mds-switch-state--default")?e(s):(s.classList.contains("mds-switch-state--inverse"),t(s))})})},s="mds-notification",n={init:(e,t,o=3e3)=>{const{body:c}=document;n.hide(c);const a=document.createElement("div");a.setAttribute("role","alert"),a.classList.add(s,"mds-message",`mds-message--${t}`),a.innerText=e,n.show(c,a),setTimeout(n.hide,o,c)},show:(e,t)=>{e.appendChild(t)},hide:e=>{Array.from(e.querySelectorAll(`.${s}`)).forEach(e=>{e.parentNode.removeChild(e)})}},c=n,a=()=>{Array.from(document.querySelectorAll(".js-notification-example")).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation();const t=e.currentTarget,o=t.innerText,{messageType:s}=t.dataset;c.init(o,s)})})},i="mds-combobox",l=()=>{!function(){const e=document.querySelector('[data-combobox-id="distance-selection"]');if(e){const t=e.querySelector("select"),o=Array.from(t.querySelectorAll("option"));e.querySelector(i).options=o.slice(1).map(e=>({value:e.value,label:e.textContent}))}}(),function(){const e=document.querySelector('[data-combobox-id="salary-selection"]');if(e){const t=e.querySelector("select"),o=Array.from(t.querySelectorAll("option"));e.querySelector(i).options=o.slice(1).map(e=>({value:e.value,label:e.textContent}))}}(),function(){const e=document.querySelector('[data-combobox-id="salary-selection"] mds-combobox'),t=document.querySelector("#salary-selection-hidden-input");e&&t&&e.addEventListener("select-option",()=>{console.log("Setting #salary-selection-hidden-input.."),t.value="flip"===t.value?"flop":"flip"})}(),function(){const e=document.querySelector('[data-combobox-id="salary-selection"] mds-combobox'),t=document.querySelector("#salary-selection-hidden-input");e&&t&&e.addEventListener("clear-all",()=>{console.log("Clearing #salary-selection-hidden-input.."),t.value=""})}(),function(){const e=document.querySelector('[data-combobox-id="keywords-lookup"]');if(e){const t=e.querySelector(i);t.filterOptions=!1,t.addEventListener("search",e=>{const[o]=e.detail;o&&o.length>2?fetch(`https://api.datamuse.com/sug?s=${o}`).then(e=>e.json()).then(e=>{const o=e.map(({word:e})=>({value:e,label:e}));return t.options=o,o}).catch(console.log):t.options=[]})}}()};document.addEventListener("DOMContentLoaded",()=>{o(),a(),setTimeout(()=>{l()},1e3)})})();
1
+ (()=>{"use strict";const e=e=>{e.classList.remove("mds-switch-state--default"),e.classList.add("mds-switch-state--inverse")},t=e=>{e.classList.remove("mds-switch-state--inverse"),e.classList.add("mds-switch-state--default")},s=()=>{Array.from(document.querySelectorAll(".js-mds-switch-state")).forEach(s=>{s.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation();const a=s.currentTarget;a.classList.contains("mds-switch-state--default")?e(a):(a.classList.contains("mds-switch-state--inverse"),t(a))})})},a="mds-notification",i={init:(e,t,s=3e3)=>{const{body:r}=document;i.hide(r);const n=document.createElement("div");n.setAttribute("role","alert"),n.classList.add(a,"mds-message",`mds-message--${t}`),n.innerText=e,i.show(r,n),setTimeout(i.hide,s,r)},show:(e,t)=>{e.appendChild(t)},hide:e=>{Array.from(e.querySelectorAll(`.${a}`)).forEach(e=>{e.parentNode.removeChild(e)})}},r=i,n=()=>{Array.from(document.querySelectorAll(".js-notification-example")).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation();const t=e.currentTarget,s=t.innerText,{messageType:a}=t.dataset;r.init(s,a)})})};document.addEventListener("DOMContentLoaded",()=>{s(),n()})})();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@madgex/design-system",
3
3
  "author": "Madgex",
4
4
  "license": "UNLICENSED",
5
- "version": "11.0.0",
5
+ "version": "12.0.1",
6
6
  "main": "dist/js/index.js",
7
7
  "exports": {
8
8
  ".": "./dist/js/index.js",
@@ -3,7 +3,11 @@
3
3
  - `id`: the id of your combobox
4
4
  - `name`: the name of the input for form submission. Uses ID unless specified - _optional_
5
5
  - `labelText`: the text used in the label
6
- - `options`: a json object of key, value pairs e.g { 45: 'Orange' }. To be used when falling back to a native select if Javascript is not available
6
+ - `options`: a JSON array, e.g `[{ label: 'Orange', value: 45 }]`. Populates both mds-combobox, and fallback select options
7
+ - `apiUrl`: when populated, `options` is ignored and data is fetching from an API URL instead
8
+ - `apiQueryKey`: the query paramter name added to `apiUrl` - _optional_ (defaults to 'searchText')
9
+ - `apiOptionsPath`: where to grab an array of options on api response, e.g. `data.options` would be an array of options. _optional_ . leave undefined to use root api response as array
10
+ - `optionLabelPath`: where to grab the visual label propertly from the option object e.g. 'label' or 'title' or 'nested.object.label' _optional_ (defaults to `label`)
7
11
  - `value`: a default selected value for the input - _optional_
8
12
  - `fallbackTo`: the form element to use as a fallback. Should be either 'select' or 'input'
9
13
  - `placeholder`: the placeholder for your input (defaults to 'Please select')
@@ -29,13 +33,31 @@ i18n: {
29
33
  }
30
34
  ```
31
35
 
32
- ## Events
36
+ ## Updating hidden input values
33
37
 
34
- The following events are emiited.
38
+ When a user selects an option, any inputs passed inside MdsCombobox with the data attribute `data-key` will be populated with values from that chosen option.
35
39
 
36
- - `select-option`
37
- - `search`
38
- - `clear-all`
40
+ ### Example 1
41
+
42
+ Populate the hidden input with the `value` property from the selected option `{label:"my label", value: 56}`.
43
+
44
+ ```njk
45
+ {\% call MdsCombobox({...}) \%}
46
+ <input type="hidden" data-key="value" /> <!-- value will be 56 -->
47
+ {\% endcall \%}
48
+ ```
49
+
50
+ ### Example 2
51
+
52
+ Populate the hidden input with the `nested.thing` property from the selected option `{label:"my label", nested: {thing: 989 }, lat: "56.202", lon: '0.142'}`.
53
+
54
+ ```njk
55
+ {\% call MdsCombobox({...}) \%}
56
+ <input type="hidden" data-key="nested.thing" /> <!-- value will be 989 -->
57
+ <input type="hidden" data-key="lat" /> <!-- value will be 56.202 -->
58
+ <input type="hidden" data-key="lon" /> <!-- value will be 0.142 -->
59
+ {\% endcall \%}
60
+ ```
39
61
 
40
62
  ## Accessibility
41
63
 
@@ -52,47 +52,58 @@
52
52
  validationErrorId: validationErrorId,
53
53
  validationError: params.validationError
54
54
  }) }}
55
- <div class="mds-form-element__fallback">
56
- {% if params.fallbackTo === 'select' and params.options %}
57
- <select
58
- class="mds-form-control"
59
- id="{{ comboboxId }}"
60
- name="{{ comboboxName }}"
61
- value="{{ params.defaultValue|default('') }}"
62
- {% if ariaDescribedBy %}aria-describedby="{{ariaDescribedBy}}"{% endif %}
63
- >
64
- <option>{{ placeholder }}</option>
65
- {%- if params.options -%}
66
- {%- for value, option in params.options -%}
67
- <option value="{{ value }}">{{ option }}</option>
68
- {%- endfor -%}
69
- {%- endif -%}
70
- </select>
71
- {% elseif params.fallbackTo === 'input' %}
72
- <input
73
- class="mds-form-control"
74
- type="text"
75
- name="{{ comboboxName }}"
76
- autocomplete="off"
77
- id="{{ comboboxId }}"
78
- value="{{ params.value|default('') }}"
79
- placeholder="{{ placeholder }}"
80
- {% if params.validationError %}aria-invalid="true"{% endif %}
81
- {% if ariaDescribedBy %}aria-describedby="{{ariaDescribedBy}}"{% endif %}
82
- />
83
- {% endif %}
84
- </div>
85
55
  {# Leave the custom element at the bottom so it has access to the above elements on render #}
86
56
  <mds-combobox
87
57
  comboboxid="{{ comboboxId }}"
88
58
  placeholder="{{ params.placeholder }}"
89
59
  iconpath="{{ defaultIconPath }}"
60
+ {% if params.options.length %}options="{{params.options | dump}}"{% endif %}
61
+ {% if params.apiUrl %}api-url="{{params.apiUrl}}"{% endif%}
62
+ {% if params.apiQueryKey %}api-query-key="{{params.apiQueryKey}}"{% endif%}
63
+ {% if params.apiOptionsPath %}api-options-path="{{params.apiOptionsPath}}"{% endif%}
64
+ {% if params.optionLabelPath %}option-label-path="{{params.optionLabelPath}}"{% endif%}
90
65
  i18n="{{ params.i18n | dump }}"
91
66
  data-aria-invalid="{{ params.validationError }}"
92
67
  {% if params.minSearchCharacters %}min-search-characters="{{ params.minSearchCharacters }}"{% endif %}
93
68
  {% if params.fallbackTo === 'input' %}name="{{ comboboxName }}"{% endif %}
94
69
  {% if params.value %}value="{{ params.value }}"{% endif %}
95
70
  {% if ariaDescribedBy %} describedby-id="{{ariaDescribedBy}}"{% endif -%}
96
- ></mds-combobox>
71
+ >
72
+ <div class="mds-form-element__fallback">
73
+ {% if params.fallbackTo === 'select' and params.options %}
74
+ <select
75
+ class="mds-form-control"
76
+ id="{{ comboboxId }}"
77
+ name="{{ comboboxName }}"
78
+ value="{{ params.defaultValue|default('') }}"
79
+ {% if ariaDescribedBy %}aria-describedby="{{ariaDescribedBy}}"{% endif %}
80
+ >
81
+ <option>{{ placeholder }}</option>
82
+ {%- if params.options -%}
83
+ {%- for option in params.options -%}
84
+ <option value="{{ option.value }}">{{ option.label }}</option>
85
+ {%- endfor -%}
86
+ {%- endif -%}
87
+ </select>
88
+ {% elseif params.fallbackTo === 'input' %}
89
+ <input
90
+ class="mds-form-control"
91
+ type="text"
92
+ name="{{ comboboxName }}"
93
+ autocomplete="off"
94
+ id="{{ comboboxId }}"
95
+ value="{{ params.value|default('') }}"
96
+ placeholder="{{ placeholder }}"
97
+ {% if params.validationError %}aria-invalid="true"{% endif %}
98
+ {% if ariaDescribedBy %}aria-describedby="{{ariaDescribedBy}}"{% endif %}
99
+ />
100
+ {% endif %}
101
+ </div>
102
+ {% if caller %}
103
+ <span slot="target-inputs">
104
+ {{- caller() -}}
105
+ </span>
106
+ {% endif %}
107
+ </mds-combobox>
97
108
  </div>
98
109
  {%- endif -%}
@@ -1,5 +1,9 @@
1
- const optionsSalary = { ...new Array(20).fill().map((_, index) => `Up to £${10 + index * 10}k`) };
2
- const optionsDistance = { ...new Array(20).fill().map((_, index) => `Within ${5 * (1 + index)} miles`) };
1
+ const optionsSalary = new Array(20)
2
+ .fill()
3
+ .map((_, index) => ({ label: `Up to £${10 + index * 10}k`, value: 10 + index * 10 }));
4
+ const optionsDistance = new Array(20)
5
+ .fill()
6
+ .map((_, index) => ({ label: `Within ${5 * (1 + index)} miles`, value: 5 * (1 + index) }));
3
7
 
4
8
  module.exports = {
5
9
  title: 'Combobox',
@@ -58,6 +62,10 @@ module.exports = {
58
62
  placeholder: 'eg. Web developer',
59
63
  fallbackTo: 'input',
60
64
  minSearchCharacters: 3,
65
+ apiUrl: 'https://api.datamuse.com/sug',
66
+ apiQueryKey: 's',
67
+ apiOptionsPath: undefined,
68
+ optionLabelPath: 'word',
61
69
  i18n: {
62
70
  requiredIcon: 'Required (test i18n)',
63
71
  loadingText: 'Loading (test i18n)',
@@ -82,6 +90,10 @@ module.exports = {
82
90
  vModel: 'Initial Value',
83
91
  fallbackTo: 'input',
84
92
  minSearchCharacters: 3,
93
+ apiUrl: 'https://api.datamuse.com/sug',
94
+ apiQueryKey: 's',
95
+ apiOptionsPath: undefined,
96
+ optionLabelPath: 'word',
85
97
  },
86
98
  },
87
99
  {
@@ -1,11 +1,11 @@
1
1
  {% from "./inputs/combobox/_macro.njk" import MdsCombobox %}
2
2
 
3
3
  {% if not multiple %}
4
-
5
4
  <div class="mds-grid-row">
6
5
  <div class="mds-grid-col-6">
7
6
  <h3>{{ variantTitle }}</h3>
8
- {{ MdsCombobox({
7
+
8
+ {% call MdsCombobox({
9
9
  id: id,
10
10
  name: name,
11
11
  labelText: labelText,
@@ -19,17 +19,27 @@
19
19
  validationError: validationError,
20
20
  helpText: helpText,
21
21
  i18n: i18n,
22
- minSearchCharacters: minSearchCharacters
23
- }) }}
24
- {#
25
- The below only applies to one combobox example.
26
- Demonstrates how the clear-all event (fired when combobox is cleared),
27
- can be used to clear hidden form fields.
28
- #}
22
+ minSearchCharacters: minSearchCharacters,
23
+ apiUrl: apiUrl,
24
+ apiQueryKey: apiQueryKey,
25
+ apiOptionsPath: apiOptionsPath,
26
+ optionLabelPath: optionLabelPath
27
+ }) %}
28
+ {#
29
+ The below demonstrates how a target input value can be set on option selection, or on clear of combobox
30
+ #}
31
+ {% if id === 'salary-selection' %}
32
+ <input disabled data-key="value" placeholder="normally hidden target" style="position:absolute; left: 100%; top: 0;" />
33
+ {% endif %}
34
+ {% if id === 'keywords-lookup' or id === 'keywords-lookup-prefilled' %}
35
+ <input disabled data-key="word" placeholder="normally hidden target" style="position:absolute; left: 100%; top: 0;" />
36
+ {% endif %}
37
+ {% endcall %}
38
+
29
39
  {% if id === 'salary-selection' %}
30
- <p class="mds-margin-top-b3">A hidden input is cleared when clear-all event fires. Check <em>#salary-selection-hidden-input</em> in dev tools.</p>
31
- <input type="hidden" id="salary-selection-hidden-input" />
40
+ <p class="mds-margin-top-b3">A hidden input is cleared when combobox is cleared.
32
41
  {% endif %}
42
+
33
43
  <br><br>
34
44
  </div>
35
45
  </div>
@@ -1,20 +1,19 @@
1
1
  ## Parameters
2
2
 
3
- - `name`: the name you want to use to differentiate the component
4
3
  - `classes`: add extra CSS classes to the component
5
- - `allHeadersTag`: the html tag to use for the panel header (h2 as default)
6
- - `allHeadersDisplay`: wheter the panel header should be always visible or not (default false)
7
- - `content`: is an array of objects containing [label, selected, id, content, headerText, linkCustomAttr] for each tab, the content for the panel can also be a custom component, headerText is
8
- text used for each panel header
4
+ - `content`: is an array of objects containing [label, selected, id, content, linkCustomAttr] for each tab, the content for the panel can also be a custom component
9
5
  - `content[{linkCustomAttr}]`: you can add extra attributes by passing an object to the parameter. Example: `attributes: { attribute-name: 'attribute-value' }`
10
6
 
11
7
  ## Variations
12
- Tabs have different style depending on the amount of items to display, if 2 tabs then it will always display tabs (except when js is disabled), if more than 2 then it will display a list of links for small devices and tabs for desktop
13
8
 
9
+ Tabs have different style depending on the amount of items to display, if 2 tabs then it will always display tabs (except when js is disabled), if more than 2 then it will display a list of links for small devices and tabs for desktop
14
10
 
15
11
  ## Accessibility
16
12
 
17
- the tabs contain aria-controls and aria-selected for screen readers.
18
- the panels contain aria-labelledby
13
+ The tabs contain aria-controls and aria-selected for screen readers.
14
+ The panels contain aria-labelledby
15
+
16
+ Switching tabs should also work if the hash in addressbar is changed
19
17
 
20
- switching tabs should also work if the hash in addressbar is changed
18
+ Include a heading at the beginning of each tab to improve navigation on smaller screen sizes and for screen reader users.
19
+ If needed, you can use the `mds-visually-hidden` class if you don't want to make it visible.
@@ -1,21 +1,17 @@
1
1
  {% from "./tab-id.njk" import TabId %}
2
2
  {% from "../../sub-components/attributes/macro.njk" import MdsAttributes %}
3
-
4
3
  {% if params.content %}
5
- {% set kebabName -%}
6
- {{- params.name | lower | trim | replace(' ', '-') -}}
7
- {%- endset %}
8
4
  {% set tabVariation -%}
9
- {%- if params.content.length > 2 -%}
10
- js-desktop-tabbed
11
- {%- else -%}
12
- mds-tabs--full-tabbed js-full-tabbed
13
- {%- endif -%}
5
+ {%- if params.content.length > 2 -%}
6
+ js-desktop-tabbed
7
+ {%- else -%}
8
+ mds-tabs--full-tabbed js-full-tabbed
9
+ {%- endif -%}
14
10
  {%- endset %}
15
- <div class="mds-tabs {{ tabVariation }}{%- if params.name %} mds-tabs--{{ kebabName }}{%- endif -%}{% if params.classes %} {{ params.classes }}{% endif %}">
11
+ <div class="mds-tabs {{ tabVariation }}{% if params.classes %} {{ params.classes }}{% endif %}">
16
12
  <ul class="mds-tabs__list">
17
13
  {%- for item in params.content -%}
18
- {%- set tabId = TabId(item, params, loop.index) -%}
14
+ {%- set tabId = TabId(item, loop.index) -%}
19
15
  <li class="mds-tabs__list-item">
20
16
  <a href="#{{ tabId }}" id="label-{{ tabId }}" class="mds-tabs__tab{%- if item.selected %} mds-tabs__tab--selected{%- endif %} js-tabs-item" {{ MdsAttributes(item.linkCustomAttr) }}>
21
17
  {{- item.label -}}
@@ -24,32 +20,13 @@
24
20
  {%- endfor -%}
25
21
  </ul>
26
22
  {%- for item in params.content -%}
27
- {%- set tabId = TabId(item, params, loop.index) %}
28
- {%- set allHeadersTag -%}
29
- {%- if params.allHeadersTag -%}
30
- {{- params.allHeadersTag -}}
31
- {%- else -%}
32
- h2
33
- {%- endif -%}
34
- {%- endset -%}
35
- {%- set allHeadersDisplay -%}
36
- {%- if params.allHeadersDisplay %} mds-tabs__panel-header--visible{%- endif -%}
37
- {%- endset -%}
38
- {%- set headerText -%}
39
- {%- if item.headerText -%}
40
- {{- item.headerText | safe -}}
41
- {%- else -%}
42
- {{- item.label -}}
43
- {%- endif -%}
44
- {%- endset -%}
45
-
23
+ {%- set tabId = TabId(item, loop.index) -%}
24
+ {# id is used in js to apply aria-labelledby, don't forget to update both if needed #}
46
25
  <section class="mds-tabs__panel{%- if not item.selected %} mds-tabs__panel--hidden {%- endif -%}{% if item.contentClasses %} {{ item.contentClasses }}{% endif %}" id="{{ tabId }}">
47
- {# id is used in js to apply aria-labelledby, don't forget to update both if needed #}
48
- <{{allHeadersTag}} class="mds-tabs__panel-header{{allHeadersDisplay}}">{{- headerText | safe -}}</{{allHeadersTag}}>
49
26
  <div class="mds-tabs__panel__content">
50
27
  {{ item.content | safe }}
51
28
  </div>
52
29
  </section>
53
30
  {%- endfor -%}
54
31
  </div>
55
- {% endif %}
32
+ {% endif %}
@@ -1,13 +1,12 @@
1
- {%- macro TabId(item, params, loopIndex) -%}
1
+ {%- macro TabId(item, loopIndex) -%}
2
2
  {%- if item.id -%}
3
3
  {{ item.id }}
4
4
  {%- else -%}
5
5
  {#
6
6
  if the id is missing it will be constructed using:
7
- [component name]-[item label]-[index]
7
+ [item label]-[index]
8
8
  e.g. period-next-week-2
9
9
  #}
10
- {%- if params.name -%}{{ kebabName }}-{%- endif -%}
11
- {{ item.label | lower | trim | replace(' ', '-') }}-{{loopIndex}}
10
+ {{- item.label | lower | trim | replace(' ', '-') }}-{{loopIndex}}
12
11
  {%- endif -%}
13
12
  {%- endmacro -%}
@@ -10,123 +10,98 @@ module.exports = {
10
10
  label: 'Today',
11
11
  selected: true,
12
12
  id: 'today',
13
- content:
14
- '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero. Donec commodo elementum ligula, vel posuere purus tempor sit amet.</p>',
13
+ content: `<h2>Today</h2>
14
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero. Donec commodo elementum ligula, vel posuere purus tempor sit amet.</p>`,
15
15
  },
16
16
  {
17
17
  label: 'Tomorrow',
18
18
  id: 'tomorrow',
19
- content:
20
- '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero.</p>',
19
+ content: `<h2>Tomorrow</h2>
20
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero.</p>`,
21
21
  },
22
22
  {
23
23
  label: 'Next week',
24
24
  id: 'next-week',
25
- content: '<ul><li>Lorem</li><li>ipsum</li><li>dolor</li><li>sit</li><li>amet</li></ul><p>next week</p>',
25
+ content: `<h2>Next week</h2>
26
+ <ul><li>Lorem</li><li>ipsum</li><li>dolor</li><li>sit</li><li>amet</li></ul>
27
+ <p>next week</p>`,
26
28
  contentClasses: 'mds-prose',
27
29
  },
28
30
  {
29
31
  label: 'Next month',
30
32
  id: 'next-month',
31
- content:
32
- '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero.</p>',
33
+ content: `<h2>Next month</h2>
34
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero.</p>`,
33
35
  },
34
36
  ],
35
37
  },
36
38
  variants: [
37
39
  {
38
- name: 'Two Items',
40
+ name: 'Two Items with visually hidden headers',
39
41
  context: {
40
- name: 'Two Items',
42
+ name: 'Two Items with visually hidden headers',
41
43
  classes: '',
42
44
  content: [
43
45
  {
44
46
  label: 'Item 1',
45
47
  selected: true,
46
- content: '<p>When there are only two tabs they remain inline at mobile.</p>',
48
+ content: `
49
+ <h2 class="mds-visually-hidden">Section 1</h2>
50
+ <p>When there are only two tabs they remain inline at mobile.</p>`,
47
51
  },
48
52
  {
49
53
  label: 'Item 2',
50
- content: '<p>When there are only two tabs they remain inline at mobile.</p>',
54
+ content: `<h2 class="mds-visually-hidden">Section 2</h2>
55
+ <p>When there are only two tabs they remain inline at mobile.</p>`,
51
56
  },
52
57
  ],
53
58
  },
54
59
  },
55
60
  {
56
- name: 'No Ids, visible headers, 3 items',
61
+ name: 'No Ids, 3 items',
57
62
  context: {
58
- name: 'No Ids, visible headers, 3 items',
63
+ name: 'No Ids, 3 items',
59
64
  classes: '',
60
- allHeadersTag: 'h3',
61
- allHeadersDisplay: true,
62
65
  content: [
63
66
  {
64
67
  label: 'Dogs',
65
- selected: true,
66
- headerText: 'Relevant News about Dogs',
67
- content:
68
- '<p><strong>No Ids, visible headers, 3 items</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero. Donec commodo elementum ligula, vel posuere purus tempor sit amet.</p>',
68
+ content: `<h2>Dogs</h2>
69
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero. Donec commodo elementum ligula, vel posuere purus tempor sit amet.</p>`,
69
70
  },
70
71
  {
71
72
  label: 'Cats',
72
- headerText: 'Latest Cats',
73
- content:
74
- '<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero.</p>',
73
+ selected: true,
74
+ content: `<h2>Cats</h2>
75
+ <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero.</p>`,
75
76
  },
76
77
  {
77
78
  label: 'Seagulls',
78
- headerText: 'Latest News about Seagulls',
79
- content: '<ul><li>Lorem</li><li>ipsum</li><li>dolor</li><li>sit</li><li>amet</li></ul><p>next week</p>',
79
+ content: `<h2>Seagulls</h2>
80
+ <ul><li>Lorem</li><li>ipsum</li><li>dolor</li><li>sit</li><li>amet</li></ul>
81
+ <p>next week</p>`,
80
82
  contentClasses: 'mds-prose',
81
83
  },
82
84
  ],
83
85
  },
84
86
  },
85
87
  {
86
- name: 'No Ids, visible header, 2 items',
88
+ name: 'No Ids, 2 items, custom attributes',
87
89
  context: {
88
- name: 'No Ids, visible header, 2 items',
90
+ name: 'No Ids, 2 items, custom attributes',
89
91
  classes: '',
90
- allHeadersTag: 'h3',
91
- allHeadersDisplay: true,
92
92
  content: [
93
93
  {
94
94
  label: 'Jobs',
95
95
  selected: true,
96
- headerText: 'Recruiter&#39;s Latest Jobs',
97
- content:
98
- '<p><strong>No Ids, visible headers, 2 items</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero. Donec commodo elementum ligula, vel posuere purus tempor sit amet.</p>',
96
+ linkCustomAttr: { 'data-metric': 'jobs' },
97
+ content: `<h2>Recruiter's Latest Jobs</h2>
98
+ <p><strong>No Ids, visible headers, 2 items</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero. Donec commodo elementum ligula, vel posuere purus tempor sit amet.</p>`,
99
99
  },
100
100
  {
101
101
  label: 'Articles',
102
- headerText: 'Recruiter&#39;s Articles',
103
- content:
104
- '<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero.</p>',
105
- },
106
- ],
107
- },
108
- },
109
- {
110
- name: 'Links in tabs have custom attributes',
111
- context: {
112
- name: 'Custom Link Attributes',
113
- classes: '',
114
- allHeadersTag: 'h3',
115
- content: [
116
- {
117
- label: 'Plane',
118
- selected: true,
119
- headerText: 'Flying craft',
120
- linkCustomAttr: { 'data-metric': 'wings' },
121
- content:
122
- '<p>Inspect the anchor tags inside each tab to see the custom attributes that are added. One use case of this is allowing us to add click metrics.</p>',
123
- },
124
- {
125
- label: 'Helicopter',
126
- headerText: 'Flying craft',
127
- linkCustomAttr: { 'data-metric': 'rotor-blades' },
128
- content:
129
- '<p>Inspect the anchor tags inside each tab to see the custom attributes that are added. One use case of this is allowing us to add click metrics.</p>',
102
+ linkCustomAttr: { 'data-metric': 'recruiters' },
103
+ content: `<h2>Recruiter's Articles</h2>
104
+ <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna ex, lobortis in luctus quis, viverra eu libero.</p>`,
130
105
  },
131
106
  ],
132
107
  },
@@ -4,10 +4,7 @@
4
4
 
5
5
  <div class="mds-surface mds-margin-bottom-b5">
6
6
  {{ MdsTabs({
7
- name: name,
8
7
  classes: classes,
9
- allHeadersTag: allHeadersTag,
10
- allHeadersDisplay: allHeadersDisplay,
11
8
  content: content
12
9
  }) }}
13
10
  </div>
@@ -14,16 +14,6 @@
14
14
  }
15
15
  }
16
16
 
17
- .mds-tabs__panel-header {
18
- @extend .mds-font-s2;
19
- @extend .mds-surface__inner;
20
- border-bottom: $regular-border;
21
- padding-top: $constant-size-baseline * 3;
22
- padding-bottom: $constant-size-baseline * 3;
23
- margin-bottom: 0;
24
- background: $constant-color-neutral-lightest;
25
- }
26
-
27
17
  .mds-tabs__list-item {
28
18
  @extend .mds-font-s2;
29
19
  }
@@ -48,17 +38,6 @@
48
38
  width: auto;
49
39
  }
50
40
 
51
- .mds-tabs__panel-header:not(.mds-tabs__panel-header--visible) {
52
- @include mds-visually-hidden;
53
- }
54
-
55
- .mds-tabs__panel-header--visible {
56
- background: transparent;
57
- border-bottom: 0;
58
- padding-top: $constant-size-baseline * 8;
59
- padding-bottom: 0;
60
- }
61
-
62
41
  .mds-tabs__panel--hidden {
63
42
  display: none;
64
43
  }
@@ -1,11 +1,7 @@
1
1
  import switchStateScript from './fractal-scripts/switch-state';
2
2
  import notificationScript from './fractal-scripts/notification';
3
- import comboboxScript from './fractal-scripts/combobox';
4
3
 
5
4
  document.addEventListener('DOMContentLoaded', () => {
6
5
  switchStateScript.init();
7
6
  notificationScript.init();
8
- setTimeout(() => {
9
- comboboxScript.init();
10
- }, 1000);
11
7
  });