gent_styleguide 7.0.5 → 7.0.6
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/build/css/main.css +1 -1
- package/build/styleguide/fonts/gent-icons-v7.eot +0 -0
- package/build/styleguide/fonts/gent-icons-v7.ttf +0 -0
- package/build/styleguide/fonts/gent-icons-v7.woff +0 -0
- package/build/styleguide/fonts/gent-icons-v7.woff2 +0 -0
- package/build/styleguide/js/breadcrumbs.functions-min.js +1 -1
- package/build/styleguide/js/breadcrumbs.functions.js +93 -48
- package/build/styleguide/sass/31-molecules/breadcrumbs/_breadcrumbs.scss +2 -1
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
((e,t)=>{"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.Breadcrumbs=t()})(window,function(){return function(
|
|
1
|
+
((e,t)=>{"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.Breadcrumbs=t()})(window,function(){return function(l,e){let o=l.querySelector("ol, ul");if(o){let n=null,r=()=>o.querySelectorAll("li"),d=()=>{n&&n.parentNode&&n.parentNode.removeChild(n),n=null},a=e=>{e&&"function"==typeof e.preventDefault&&e.preventDefault(),d(),l.setAttribute("aria-expanded","true"),o.focus()},i=e=>{var t=document.createElement("a");t.textContent="...",t.href="#",t.addEventListener("click",a),(n=document.createElement("li")).classList.add("expandable"),n.appendChild(t),o.insertBefore(n,o.children[e]),o.tabIndex=-1},e=e=>{var e=e.matches,t=r();d(),e&&5<t.length||!e&&2<t.length?(l.setAttribute("aria-expanded","false"),i(t.length-2)):l.removeAttribute("aria-expanded")};var t;t=window.matchMedia("(min-width: 768px)"),e(t),"function"==typeof t.addEventListener?t.addEventListener("change",e):"function"==typeof t.addListener&&t.addListener(e)}return{}}});
|
|
@@ -4,90 +4,135 @@
|
|
|
4
4
|
if (typeof define === 'function' && define.amd) {
|
|
5
5
|
define(factory);
|
|
6
6
|
}
|
|
7
|
+
else if (typeof exports === 'object') {
|
|
8
|
+
module.exports = factory();
|
|
9
|
+
}
|
|
7
10
|
else {
|
|
8
|
-
|
|
9
|
-
module.exports = factory();
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
root.Breadcrumbs = factory();
|
|
13
|
-
}
|
|
11
|
+
root.Breadcrumbs = factory();
|
|
14
12
|
}
|
|
15
13
|
}(this || window, function () {
|
|
16
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Breadcrumb constructor.
|
|
17
|
+
*
|
|
18
|
+
* @param {HTMLElement} elem
|
|
19
|
+
* The root .breadcrumb element.
|
|
20
|
+
* @param {Object} [options]
|
|
21
|
+
* Optional options object (currently unused).
|
|
22
|
+
*
|
|
23
|
+
* @return {Object}
|
|
24
|
+
* An object representing the Breadcrumbs instance. Currently empty, but
|
|
25
|
+
* reserved for future public API methods.
|
|
26
|
+
*/
|
|
17
27
|
return function (elem, options) {
|
|
18
28
|
let list = elem.querySelector('ol, ul');
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
if (!list) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let expandable = null;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the current list items for this breadcrumb.
|
|
37
|
+
*
|
|
38
|
+
* @return {NodeListOf<HTMLLIElement>}
|
|
39
|
+
* List items.
|
|
40
|
+
*/
|
|
41
|
+
const getItems = () => list.querySelectorAll('li');
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Remove the expandable for the current breadcrumb.
|
|
45
|
+
*/
|
|
46
|
+
const removeExpandable = () => {
|
|
47
|
+
if (expandable && expandable.parentNode) {
|
|
48
|
+
expandable.parentNode.removeChild(expandable);
|
|
49
|
+
}
|
|
50
|
+
expandable = null;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Expand the entire breadcrumb.
|
|
55
|
+
*
|
|
56
|
+
* @param {Event} e
|
|
57
|
+
* Event object.
|
|
58
|
+
*/
|
|
59
|
+
const expand = e => {
|
|
60
|
+
if (e && typeof e.preventDefault === 'function') {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
removeExpandable();
|
|
65
|
+
elem.setAttribute('aria-expanded', 'true');
|
|
66
|
+
list.focus();
|
|
67
|
+
};
|
|
21
68
|
|
|
22
69
|
/**
|
|
23
70
|
* Add an element to the DOM that makes it possible to expand the breadcrumb.
|
|
24
71
|
*
|
|
25
|
-
* @param {
|
|
72
|
+
* @param {number} position
|
|
26
73
|
* Index of the new element.
|
|
27
74
|
*/
|
|
28
75
|
const insertExpandable = position => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
76
|
+
const expandLink = document.createElement('a');
|
|
77
|
+
expandLink.textContent = '...';
|
|
78
|
+
expandLink.href = '#';
|
|
32
79
|
|
|
33
|
-
//
|
|
34
|
-
|
|
80
|
+
// Attach event listener on this instance only.
|
|
81
|
+
expandLink.addEventListener('click', expand);
|
|
35
82
|
|
|
36
|
-
// Add it to the DOM
|
|
37
83
|
expandable = document.createElement('li');
|
|
38
84
|
expandable.classList.add('expandable');
|
|
39
|
-
expandable.appendChild(
|
|
85
|
+
expandable.appendChild(expandLink);
|
|
86
|
+
|
|
87
|
+
// Insert before the requested position.
|
|
40
88
|
list.insertBefore(expandable, list.children[position]);
|
|
41
89
|
list.tabIndex = -1;
|
|
42
90
|
};
|
|
43
91
|
|
|
44
92
|
/**
|
|
45
|
-
*
|
|
93
|
+
* Collapse the breadcrumb for the given media query result.
|
|
46
94
|
*
|
|
47
|
-
* @param {MediaQueryList} query
|
|
48
|
-
* The
|
|
95
|
+
* @param {MediaQueryList|MediaQueryListEvent} query
|
|
96
|
+
* The matchMedia object or its event.
|
|
49
97
|
*/
|
|
50
98
|
const collapse = query => {
|
|
51
|
-
//
|
|
99
|
+
// In some browsers the callback receives a MediaQueryListEvent.
|
|
100
|
+
const matches = query.matches;
|
|
101
|
+
|
|
102
|
+
const items = getItems();
|
|
103
|
+
|
|
104
|
+
// Remove any old expandable for this breadcrumb.
|
|
52
105
|
removeExpandable();
|
|
53
106
|
|
|
54
107
|
// Collapse when more than 5 items on tablet+,
|
|
55
|
-
// or more than 2 items on mobile screens
|
|
56
|
-
if ((
|
|
57
|
-
|
|
58
|
-
elem.setAttribute('aria-expanded', false);
|
|
108
|
+
// or more than 2 items on mobile screens.
|
|
109
|
+
if ((matches && items.length > 5) || (!matches && items.length > 2)) {
|
|
110
|
+
elem.setAttribute('aria-expanded', 'false');
|
|
59
111
|
insertExpandable(items.length - 2);
|
|
60
112
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* Remove the expandable for the current breadcrumb.
|
|
65
|
-
*/
|
|
66
|
-
const removeExpandable = () => {
|
|
67
|
-
if (expandable) {
|
|
68
|
-
expandable.parentNode.removeChild(expandable);
|
|
113
|
+
else {
|
|
114
|
+
// When not collapsed, remove attribute for clarity.
|
|
115
|
+
elem.removeAttribute('aria-expanded');
|
|
69
116
|
}
|
|
70
117
|
};
|
|
71
118
|
|
|
72
119
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @param {Event} e
|
|
76
|
-
* Event object.
|
|
77
|
-
*/
|
|
78
|
-
const expand = e => {
|
|
79
|
-
removeExpandable();
|
|
80
|
-
elem.setAttribute('aria-expanded', true);
|
|
81
|
-
list.focus();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Initialize functionality.
|
|
120
|
+
* Initialize functionality for this breadcrumb instance.
|
|
86
121
|
*/
|
|
87
122
|
const init = () => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
123
|
+
const query = window.matchMedia('(min-width: 768px)');
|
|
124
|
+
|
|
125
|
+
// Execute once on page load.
|
|
126
|
+
collapse(query);
|
|
127
|
+
|
|
128
|
+
// Listen to changes in viewport width.
|
|
129
|
+
if (typeof query.addEventListener === 'function') {
|
|
130
|
+
query.addEventListener('change', collapse);
|
|
131
|
+
}
|
|
132
|
+
else if (typeof query.addListener === 'function') {
|
|
133
|
+
// Fallback for older browsers.
|
|
134
|
+
query.addListener(collapse);
|
|
135
|
+
}
|
|
91
136
|
};
|
|
92
137
|
|
|
93
138
|
init();
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
display: inline-flex;
|
|
20
20
|
align-items: center;
|
|
21
|
+
height: 38px;
|
|
21
22
|
margin-right: 8px;
|
|
22
23
|
margin-bottom: 0;
|
|
23
24
|
padding-left: 0;
|
|
@@ -99,7 +100,7 @@
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
&::after {
|
|
102
|
-
line-height:
|
|
103
|
+
line-height: 1.6rem;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
|