@gemeentenijmegen/web-components 0.0.2-alpha.64 → 0.0.2-alpha.66
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.
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
function styleInject(css, ref) {
|
|
5
|
+
if ( ref === void 0 ) ref = {};
|
|
6
|
+
var insertAt = ref.insertAt;
|
|
7
|
+
|
|
8
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
9
|
+
|
|
10
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
11
|
+
var style = document.createElement('style');
|
|
12
|
+
style.type = 'text/css';
|
|
13
|
+
|
|
14
|
+
if (insertAt === 'top') {
|
|
15
|
+
if (head.firstChild) {
|
|
16
|
+
head.insertBefore(style, head.firstChild);
|
|
17
|
+
} else {
|
|
18
|
+
head.appendChild(style);
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
head.appendChild(style);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (style.styleSheet) {
|
|
25
|
+
style.styleSheet.cssText = css;
|
|
26
|
+
} else {
|
|
27
|
+
style.appendChild(document.createTextNode(css));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var css_248z = "/* Nijmegen overrides */\n.utrecht-accordion__button {\n align-items: flex-start; /* Nijmegen override */\n}\n.utrecht-accordion__button .utrecht-accordion__button-icon {\n position: relative;\n top: 1px; /* stylelint-disable-line property-disallowed-list */ /* Nijmegen override */\n}";
|
|
32
|
+
styleInject(css_248z);
|
|
33
|
+
|
|
34
|
+
var html = "<div class=\"utrecht-accordion\">\n <slot></slot>\n</div>\n";
|
|
35
|
+
|
|
36
|
+
class NijmegenAccordion extends HTMLElement {
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
const template = document.createElement('template');
|
|
40
|
+
template.innerHTML = html;
|
|
41
|
+
|
|
42
|
+
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
43
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
44
|
+
|
|
45
|
+
const stylesheet = new CSSStyleSheet();
|
|
46
|
+
stylesheet.replaceSync(css_248z);
|
|
47
|
+
shadowRoot.adoptedStyleSheets = [stylesheet];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
connectedCallback() {
|
|
51
|
+
Array.from(this.children).forEach((child) => {
|
|
52
|
+
const expandableElements = child.querySelectorAll('[aria-expanded]');
|
|
53
|
+
expandableElements.forEach((element) => {
|
|
54
|
+
element.addEventListener('click', (event) => {
|
|
55
|
+
// Find the closest element with aria-expanded attribute
|
|
56
|
+
let target = event.target.closest('[aria-expanded]');
|
|
57
|
+
this.handleClick(target, expandableElements);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
handleClick(target, expandableElements) {
|
|
64
|
+
expandableElements.forEach((element) => {
|
|
65
|
+
if (element === target) {
|
|
66
|
+
const section = target.closest('.utrecht-accordion__section');
|
|
67
|
+
const panel = section ? section.querySelector('.utrecht-accordion__panel') : null;
|
|
68
|
+
|
|
69
|
+
if (panel) {
|
|
70
|
+
element.ariaExpanded = element.ariaExpanded === 'true' ? 'false' : 'true';
|
|
71
|
+
panel.ariaHidden = element.ariaExpanded === 'false' ? 'true' : 'false';
|
|
72
|
+
|
|
73
|
+
if (panel.ariaHidden === 'false') {
|
|
74
|
+
panel.removeAttribute('hidden');
|
|
75
|
+
} else {
|
|
76
|
+
panel.setAttribute('hidden', '');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!customElements.get('nijmegen-accordion')) {
|
|
85
|
+
customElements.define('nijmegen-accordion', NijmegenAccordion);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.2-alpha.
|
|
2
|
+
"version": "0.0.2-alpha.66",
|
|
3
3
|
"author": "gemeente Nijmegen",
|
|
4
4
|
"description": "Web components for the gemeente Nijmegen design system",
|
|
5
5
|
"license": "EUPL-1.2",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"clean": "rimraf dist"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gemeentenijmegen/components-css": "0.0.1-alpha.
|
|
29
|
+
"@gemeentenijmegen/components-css": "0.0.1-alpha.89",
|
|
30
30
|
"postcss-discard-duplicates": "7.0.1",
|
|
31
31
|
"rollup": "4.12.1",
|
|
32
32
|
"rollup-plugin-html": "0.2.1",
|
|
33
33
|
"rollup-plugin-node-resolve": "5.2.0",
|
|
34
34
|
"rollup-plugin-postcss": "4.0.2"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "2919b0c1782fa193b64b3dcd804459a9e434598a"
|
|
37
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import style from '@gemeentenijmegen/components-css/accordion/index.scss?inline';
|
|
1
2
|
import html from './template.html?raw';
|
|
2
3
|
|
|
3
4
|
class NijmegenAccordion extends HTMLElement {
|
|
@@ -8,6 +9,10 @@ class NijmegenAccordion extends HTMLElement {
|
|
|
8
9
|
|
|
9
10
|
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
10
11
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
+
|
|
13
|
+
const stylesheet = new CSSStyleSheet();
|
|
14
|
+
stylesheet.replaceSync(style);
|
|
15
|
+
shadowRoot.adoptedStyleSheets = [stylesheet];
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
connectedCallback() {
|