desy-html 6.2.1 → 6.3.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/README.md +2 -2
- package/docs/_global.head.njk +1 -2
- package/docs/_macro.example-render.njk +11 -9
- package/docs/ds/_ds.macro.code-snippet.njk +6 -4
- package/docs/index.html +11 -3
- package/package.json +1 -1
- package/src/js/aria/accordion.js +24 -17
- package/src/js/aria/collapsible.js +35 -0
- package/src/js/aria/disclosureMenu.js +1 -2
- package/src/js/aria/tabs.js +43 -1
- package/src/js/aria/toggle.js +25 -0
- package/src/js/aria/treeitem.js +11 -20
- package/src/js/desy-html.js +10 -1
- package/src/js/index.js +12 -0
- package/src/templates/components/accordion/_examples.accordion.njk +1 -1
- package/src/templates/components/accordion/_template.accordion.njk +6 -34
- package/src/templates/components/accordion-history/_template.accordion-history.njk +2 -30
- package/src/templates/components/checkboxes/_template.checkboxes.njk +4 -8
- package/src/templates/components/collapsible/_template.collapsible.njk +7 -13
- package/src/templates/components/header-advanced/_examples.header-advanced-2.njk +103 -43
- package/src/templates/components/header-advanced/_examples.header-advanced.njk +163 -13
- package/src/templates/components/header-advanced/_template.header-advanced.njk +34 -14
- package/src/templates/components/header-advanced/params.header-advanced.yaml +61 -1
- package/src/templates/components/header-mini/_template.header-mini.njk +1 -1
- package/src/templates/components/menu-navigation/_template.menu-navigation.njk +1 -1
- package/src/templates/components/menu-navigation/params.menu-navigation.yaml +0 -5
- package/src/templates/components/notification/_template.notification.njk +3 -11
- package/src/templates/components/radios/_template.radios.njk +4 -8
- package/src/templates/components/table-advanced/_template.table-advanced.njk +3 -3
- package/src/templates/components/tabs/_examples.tabs.njk +35 -1
- package/src/templates/components/tabs/_styles.tabs.css +0 -17
- package/src/templates/components/tabs/_template.tabs.njk +4 -4
- package/src/templates/components/tabs/params.tabs.yaml +5 -1
- package/src/templates/components/toggle/_template.toggle.njk +7 -28
- package/src/templates/components/tree/_template.tree.njk +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# README #
|
|
2
2
|
|
|
3
|
-
desy-html is the NPM library you need to start building a user interface for Gobierno de Aragón webapps. It uses Gulp, Postcss, Tailwindcss
|
|
3
|
+
desy-html is the NPM library you need to start building a user interface for Gobierno de Aragón webapps. It uses Gulp, Postcss, Tailwindcss and Nunjucks to render html+css+js components. It's useful to create lightweight webapps or html mockups.
|
|
4
4
|
|
|
5
5
|
If you need a more powerful library based on this, use it's Angular port instead: [desy-angular](https://bitbucket.org/sdaragon/desy-angular)
|
|
6
6
|
|
|
@@ -33,4 +33,4 @@ Unless stated otherwise, the codebase is released under the [https://joinup.ec.e
|
|
|
33
33
|
This project started initially forked from: [https://github.com/saadeghi/tailwindcss-postcss-browsersync-boilerplate](https://github.com/saadeghi/tailwindcss-postcss-browsersync-boilerplate)
|
|
34
34
|
|
|
35
35
|
This project is built upon the GOV.UK Frontend project: [https://github.com/alphagov/govuk-frontend](https://github.com/alphagov/govuk-frontend)
|
|
36
|
-
We would like to thank the Government Digital Service team for their fabulous work and for making it opensource for the community.
|
|
36
|
+
We would like to thank the Government Digital Service team for their fabulous work and for making it opensource for the community.
|
package/docs/_global.head.njk
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<link rel="icon" type="image/x-icon" href="https://aplicaciones.aragon.es/favicon.ico">
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap" rel="stylesheet">
|
|
10
10
|
<link rel="stylesheet" href="css/styles.css">
|
|
11
|
-
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script>
|
|
12
11
|
<style>
|
|
13
12
|
/* PrismJS 1.15.0
|
|
14
13
|
https://prismjs.com/download.html#themes=prism-coy&languages=markup+css+clike+javascript+java+kotlin+markdown+swift&plugins=toolbar+show-language+copy-to-clipboard */
|
|
@@ -342,4 +341,4 @@
|
|
|
342
341
|
display: none; }
|
|
343
342
|
|
|
344
343
|
</style>
|
|
345
|
-
</head>
|
|
344
|
+
</head>
|
|
@@ -108,10 +108,12 @@ import componentTree %}
|
|
|
108
108
|
{% set exampleComponent = data.data.exampleComponent %}
|
|
109
109
|
{% set examples = data.data.examples %}
|
|
110
110
|
{% set exampleParams = data.data.params %}
|
|
111
|
-
<div
|
|
111
|
+
<div>
|
|
112
112
|
<h1 class="c-h1 inline-block">{{ exampleComponent | capitalize }} examples</h1>
|
|
113
|
-
<
|
|
114
|
-
|
|
113
|
+
<button class="inline-block ml-sm text-sm text-primary-base font-normal hover:text-primary-dark underline cursor-pointer c-code-snippet__button mt-xl py-base">
|
|
114
|
+
<span class="c-code-snippet__show pointer-events-none">Mostrar</span><span class="c-code-snippet__hide pointer-events-none hidden">Ocultar</span> params
|
|
115
|
+
</button>
|
|
116
|
+
<div class="c-markup hidden">
|
|
115
117
|
<div class="py-base">
|
|
116
118
|
<h4 class="mb-sm font-bold">Params</h4>
|
|
117
119
|
{% from "_macro.load-component-params.njk" import loadComponentParams %}
|
|
@@ -125,7 +127,7 @@ import componentTree %}
|
|
|
125
127
|
<a href="#example-{{ exampleComponent }}-{{ loop.index }}" class="hover:text-primary-base" title="permalink">{{ example.name }}</a>
|
|
126
128
|
</h4>
|
|
127
129
|
<p class="mb-base text-sm text-neutral-dark">{{ example.description }}</p>
|
|
128
|
-
<div
|
|
130
|
+
<div class="mt-xl py-lg border-b border-neutral-base">
|
|
129
131
|
{% if exampleComponent == "accordion" %}
|
|
130
132
|
{{ componentAccordion(example.data) }}
|
|
131
133
|
{% elseif exampleComponent == "accordion-history" %}
|
|
@@ -231,10 +233,10 @@ import componentTree %}
|
|
|
231
233
|
{% elseif exampleComponent == "tree" %}
|
|
232
234
|
{{ componentTree(example.data) }}
|
|
233
235
|
{% endif %}
|
|
234
|
-
<
|
|
235
|
-
<span
|
|
236
|
-
</
|
|
237
|
-
<div
|
|
236
|
+
<button class="inline-block text-base text-primary-base font-normal hover:text-primary-dark underline cursor-pointer c-code-snippet__button mt-xl py-base">
|
|
237
|
+
<span class="c-code-snippet__show pointer-events-none">Mostrar</span><span class="c-code-snippet__hide pointer-events-none hidden">Ocultar</span> código
|
|
238
|
+
</button>
|
|
239
|
+
<div class="c-markup hidden">
|
|
238
240
|
<div class="py-base">
|
|
239
241
|
<h4 class="mb-sm font-bold">Macro</h4>
|
|
240
242
|
{% if example.data.caller %}
|
|
@@ -258,4 +260,4 @@ import componentTree %}
|
|
|
258
260
|
</div>
|
|
259
261
|
</div>
|
|
260
262
|
{% endfor %}
|
|
261
|
-
{% endmacro %}
|
|
263
|
+
{% endmacro %}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{% macro DSCodeSnippet(urlSnippet, params={}) %}
|
|
2
2
|
{% set codeSnippetVariable %}{% include urlSnippet %}{% endset %}
|
|
3
|
-
<div
|
|
4
|
-
<
|
|
5
|
-
|
|
3
|
+
<div class="c-code-snippet">
|
|
4
|
+
<button class="inline-block ml-sm text-base text-primary-base font-normal hover:text-primary-dark underline cursor-pointer c-code-snippet__button">
|
|
5
|
+
<span class="c-code-snippet__show">Mostrar</span><span class="c-code-snippet__hide hidden">Ocultar</span> código
|
|
6
|
+
</button>
|
|
7
|
+
<div class="c-markup hidden">
|
|
6
8
|
<div class="py-base">
|
|
7
9
|
<pre><code class="language-html">{{ codeSnippetVariable|escape }}</code></pre>
|
|
8
10
|
</div>
|
|
9
11
|
</div>
|
|
10
12
|
</div>
|
|
11
|
-
{% endmacro %}
|
|
13
|
+
{% endmacro %}
|
package/docs/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<div class="prose pb-xl">
|
|
7
7
|
<div class="pb-lg"></div>
|
|
8
8
|
<h1>desy-html</h1>
|
|
9
|
-
<p>desy-html es una librería NPM que sirve para construir la interfaz de usuario de las aplicaciones web del Gobierno de Aragón. Utiliza <a href="https://gulpjs.com/">Gulp</a>, <a href="https://postcss.org/">PostCSS</a>, <a href="https://tailwindcss.com/">Tailwind CSS</a
|
|
9
|
+
<p>desy-html es una librería NPM que sirve para construir la interfaz de usuario de las aplicaciones web del Gobierno de Aragón. Utiliza <a href="https://gulpjs.com/">Gulp</a>, <a href="https://postcss.org/">PostCSS</a>, <a href="https://tailwindcss.com/">Tailwind CSS</a> y <a href="https://mozilla.github.io/nunjucks/">Nunjucks</a> para renderizar componentes HTML+CSS+JS. Es útil para crear aplicaciones web ligeras o maquetas html.</p>
|
|
10
10
|
<p>Si necesitas una librería con más potencia para construir tu aplicación web, te recomendamos mejor, que uses su versión traducida a Angular: <a href="https://bitbucket.org/sdaragon/desy-angular">desy-angular librería NPM</a>, <a href="https://desy.aragon.es/desy-angular">Ejemplos de desy-angular</a></p>
|
|
11
11
|
<p>Mira ejemplos de componentes de desy-html en la documentación: <a href="https://desy.aragon.es/">https://desy.aragon.es/</a></p>
|
|
12
12
|
<p>Mira ejemplos de templates de página usando los componentes de desy-html: <a href="https://desy.aragon.es/pages/desy-html-templates">https://desy.aragon.es/pages/desy-html-templates</a></p>
|
|
@@ -38,7 +38,15 @@
|
|
|
38
38
|
|
|
39
39
|
<h2>Changelog (English)</h2>
|
|
40
40
|
<p>What's new in the latest version of desy-html</p>
|
|
41
|
-
|
|
41
|
+
<h3>v.6.3.0</h3>
|
|
42
|
+
<ul class="text-sm">
|
|
43
|
+
<li>Added parameters and changes in Header advanced.</li>
|
|
44
|
+
<li>Added active parameter in Tabs.</li>
|
|
45
|
+
<li>Removed alpine.js and added new collapsible.js file.</li>
|
|
46
|
+
<li>Fixed keyboard navigation in Tree.</li>
|
|
47
|
+
<li>Minor fixes.</li>
|
|
48
|
+
</ul>
|
|
49
|
+
<h3>v.6.2.1</h3>
|
|
42
50
|
<ul class="text-sm">
|
|
43
51
|
<li>Fixed bad vertical spacing in c-form-group that affected forms in desy-angular.</li>
|
|
44
52
|
<li>Minor fixes in listbox, dropdown and menubar for header modifier.</li>
|
|
@@ -353,4 +361,4 @@
|
|
|
353
361
|
<p>Este proyecto fue inicialmente forkeado de: <a href="https://github.com/saadeghi/tailwindcss-postcss-browsersync-boilerplate">https://github.com/saadeghi/tailwindcss-postcss-browsersync-boilerplate</a></p>
|
|
354
362
|
<p>Este proyecto se ha construido sobre el código fuente del proyecto GOV.UK Frontend: <a href="https://github.com/alphagov/govuk-frontend">https://github.com/alphagov/govuk-frontend</a>. Agradecemos al equipo de <a href="https://www.gov.uk/government/organisations/government-digital-service">GDS Government Digital Service</a> por su fabuloso trabajo y por hacerlo opensource para la comunidad.</p>
|
|
355
363
|
</div>
|
|
356
|
-
{% endblock %}
|
|
364
|
+
{% endblock %}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desy-html",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "desy-html contains the code you need to start building a user interface for Gobierno de Aragón government webapps.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Desy (SDA Servicios Digitales de Aragón)",
|
package/src/js/aria/accordion.js
CHANGED
|
@@ -8,7 +8,7 @@ export function accordion(aria) {
|
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
|
-
Array.prototype.slice.call(document.querySelectorAll('.
|
|
11
|
+
Array.prototype.slice.call(document.querySelectorAll('.c-accordion')).forEach(function (accordion) {
|
|
12
12
|
|
|
13
13
|
// Allow for multiple accordion sections to be expanded at the same time
|
|
14
14
|
var allowMultiple = accordion.hasAttribute('data-allow-multiple');
|
|
@@ -16,57 +16,64 @@ export function accordion(aria) {
|
|
|
16
16
|
var allowToggle = (allowMultiple) ? allowMultiple : accordion.hasAttribute('data-allow-toggle');
|
|
17
17
|
|
|
18
18
|
// Create the array of toggle elements for the accordion group
|
|
19
|
-
var triggers = Array.prototype.slice.call(accordion.querySelectorAll('.
|
|
20
|
-
var panels = Array.prototype.slice.call(accordion.querySelectorAll('.
|
|
19
|
+
var triggers = Array.prototype.slice.call(accordion.querySelectorAll('.c-accordion-trigger'));
|
|
20
|
+
var panels = Array.prototype.slice.call(accordion.querySelectorAll('.c-accordion-panel'));
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
accordion.addEventListener('click', function (event) {
|
|
24
|
+
console.log("event", event);
|
|
24
25
|
var target = event.target;
|
|
25
26
|
|
|
26
|
-
if (target.classList.contains('
|
|
27
|
+
if (target.classList.contains('c-accordion-trigger')) {
|
|
27
28
|
// Check if the current toggle is expanded.
|
|
28
29
|
var isExpanded = target.getAttribute('aria-expanded') == 'true';
|
|
29
30
|
var active = accordion.querySelector('[aria-expanded="true"]');
|
|
30
31
|
|
|
31
32
|
// without allowMultiple, close the open accordion
|
|
32
33
|
if (!allowMultiple && active && active !== target) {
|
|
34
|
+
console.log("!allowMultiple && active && active !== target");
|
|
33
35
|
// Set the expanded state on the triggering element
|
|
34
36
|
active.setAttribute('aria-expanded', 'false');
|
|
35
37
|
//active.querySelector('span').innerText = 'Mostrar';
|
|
36
|
-
active.querySelector('.
|
|
37
|
-
active.querySelector('.
|
|
38
|
+
active.querySelector('.c-accordion-show').classList.remove('hidden');
|
|
39
|
+
active.querySelector('.c-accordion-hide').classList.add('hidden');
|
|
38
40
|
// Hide the accordion sections, using aria-controls to specify the desired section
|
|
39
41
|
document.getElementById(active.getAttribute('aria-controls')).setAttribute('hidden', '');
|
|
40
42
|
|
|
41
43
|
// When toggling is not allowed, clean up disabled state
|
|
42
44
|
if (!allowToggle) {
|
|
45
|
+
console.log("allowToggle");
|
|
43
46
|
active.removeAttribute('aria-disabled');
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
if (!isExpanded) {
|
|
51
|
+
console.log("isExpanded");
|
|
48
52
|
// Set the expanded state on the triggering element
|
|
53
|
+
console.log("target", target);
|
|
49
54
|
target.setAttribute('aria-expanded', 'true');
|
|
50
55
|
//target.querySelector('span').innerText = 'Ocultar';
|
|
51
|
-
target.querySelector('.
|
|
52
|
-
target.querySelector('.
|
|
56
|
+
target.querySelector('.c-accordion-show').classList.toggle('hidden');
|
|
57
|
+
target.querySelector('.c-accordion-hide').classList.toggle('hidden');
|
|
53
58
|
// Hide the accordion sections, using aria-controls to specify the desired section
|
|
54
59
|
document.getElementById(target.getAttribute('aria-controls')).removeAttribute('hidden');
|
|
55
60
|
|
|
56
61
|
// If toggling is not allowed, set disabled state on trigger
|
|
57
62
|
if (!allowToggle) {
|
|
63
|
+
console.log("if");
|
|
58
64
|
target.setAttribute('aria-disabled', 'true');
|
|
59
65
|
//target.querySelector('span').innerText = '';
|
|
60
|
-
target.querySelector('.
|
|
61
|
-
target.querySelector('.
|
|
66
|
+
target.querySelector('.c-accordion-show').classList.add('hidden');
|
|
67
|
+
target.querySelector('.c-accordion-hide').classList.add('hidden');
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
else if (allowToggle && isExpanded) {
|
|
71
|
+
console.log("else if");
|
|
65
72
|
// Set the expanded state on the triggering element
|
|
66
73
|
target.setAttribute('aria-expanded', 'false');
|
|
67
74
|
// target.querySelector('span').innerText = 'Mostrar';
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
target.querySelector('.c-accordion-show').classList.toggle('hidden');
|
|
76
|
+
target.querySelector('.c-accordion-hide').classList.toggle('hidden');
|
|
70
77
|
|
|
71
78
|
// Hide the accordion sections, using aria-controls to specify the desired section
|
|
72
79
|
document.getElementById(target.getAttribute('aria-controls')).setAttribute('hidden', '');
|
|
@@ -88,7 +95,7 @@ export function accordion(aria) {
|
|
|
88
95
|
var ctrlModifier = (event.ctrlKey && key.match(/33|34/));
|
|
89
96
|
|
|
90
97
|
// Is this coming from an accordion header?
|
|
91
|
-
if (target.classList.contains('
|
|
98
|
+
if (target.classList.contains('c-accordion-trigger')) {
|
|
92
99
|
// Up/ Down arrow and Control + Page Up/ Page Down keyboard operations
|
|
93
100
|
// 38 = Up, 40 = Down
|
|
94
101
|
if (key.match(/38|40/) || ctrlModifier) {
|
|
@@ -121,7 +128,7 @@ export function accordion(aria) {
|
|
|
121
128
|
});
|
|
122
129
|
|
|
123
130
|
// These are used to style the accordion when one of the buttons has focus
|
|
124
|
-
accordion.querySelectorAll('.
|
|
131
|
+
accordion.querySelectorAll('.c-accordion-trigger').forEach(function (trigger) {
|
|
125
132
|
|
|
126
133
|
trigger.addEventListener('focus', function (event) {
|
|
127
134
|
accordion.classList.add('focus');
|
|
@@ -143,10 +150,10 @@ export function accordion(aria) {
|
|
|
143
150
|
if (expanded) {
|
|
144
151
|
expanded.setAttribute('aria-disabled', 'true');
|
|
145
152
|
//expanded.querySelector('span').innerText = '';
|
|
146
|
-
expanded.querySelector('.
|
|
147
|
-
expanded.querySelector('.
|
|
153
|
+
expanded.querySelector('.c-accordion-show').classList.add('hidden');
|
|
154
|
+
expanded.querySelector('.c-accordion-hide').classList.add('hidden');
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
|
|
151
158
|
});
|
|
152
|
-
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function Collapsible(aria) {
|
|
2
|
+
|
|
3
|
+
class Collapsible {
|
|
4
|
+
constructor(domNode) {
|
|
5
|
+
this.rootEl = domNode;
|
|
6
|
+
this.buttonEl = this.rootEl.querySelector('button[aria-expanded]');
|
|
7
|
+
this.buttonEl.addEventListener('click', this.toggle.bind(this));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
toggle(event) {
|
|
11
|
+
const { target } = event
|
|
12
|
+
const elementCollapsibleShow = target.querySelector('.c-collapsible__show')
|
|
13
|
+
const elementCollapsibleHide = target.querySelector('.c-collapsible__hide')
|
|
14
|
+
const elementCollapsibleContent = target.nextElementSibling
|
|
15
|
+
|
|
16
|
+
elementCollapsibleShow.classList.toggle('hidden')
|
|
17
|
+
elementCollapsibleHide.classList.toggle('hidden')
|
|
18
|
+
elementCollapsibleContent.classList.toggle('hidden')
|
|
19
|
+
|
|
20
|
+
if(elementCollapsibleShow.classList.contains('hidden')) {
|
|
21
|
+
elementCollapsibleShow.setAttribute('aria-hidden', 'false')
|
|
22
|
+
elementCollapsibleHide.setAttribute('aria-hidden', 'true')
|
|
23
|
+
} else {
|
|
24
|
+
elementCollapsibleShow.setAttribute('aria-hidden', 'true')
|
|
25
|
+
elementCollapsibleHide.setAttribute('aria-hidden', 'false')
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const collapsible = document.querySelectorAll('.c-collapsible');
|
|
31
|
+
collapsible.forEach((collapsibleElement) => {
|
|
32
|
+
new Collapsible(collapsibleElement);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
}
|
|
@@ -118,7 +118,6 @@ export function DisclosureNav(aria) {
|
|
|
118
118
|
|
|
119
119
|
aria.DisclosureNav.prototype.handleButtonClick = function (event) {
|
|
120
120
|
var button = event.target;
|
|
121
|
-
console.log(button);
|
|
122
121
|
var buttonIndex = this.triggerNodes.indexOf(button);
|
|
123
122
|
var buttonExpanded = button.getAttribute('aria-expanded') === 'true';
|
|
124
123
|
this.toggleExpand(buttonIndex, !buttonExpanded);
|
|
@@ -150,4 +149,4 @@ export function DisclosureNav(aria) {
|
|
|
150
149
|
};
|
|
151
150
|
|
|
152
151
|
|
|
153
|
-
}
|
|
152
|
+
}
|
package/src/js/aria/tabs.js
CHANGED
|
@@ -15,6 +15,32 @@ export function tabs(aria) {
|
|
|
15
15
|
panels = elem.querySelectorAll('[role="tabpanel"]');
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
/*
|
|
19
|
+
* Buscamos si las tabs se han inizializado con
|
|
20
|
+
* la clase c-tabs__link--is-active. En ese caso
|
|
21
|
+
* añadimos las clases al button y al span
|
|
22
|
+
* Si ninguna tab contiene la clase c-tabs__link--is-active
|
|
23
|
+
* activamos la primera tab.
|
|
24
|
+
*/
|
|
25
|
+
function checkIfTabIsActive() {
|
|
26
|
+
const getClassFromTabs = Array.from(tabs)
|
|
27
|
+
if(getClassFromTabs.some(tab => tab.classList.contains('c-tabs__link--is-active'))) {
|
|
28
|
+
tabs.forEach((tab) => {
|
|
29
|
+
if(tab.classList.contains('c-tabs__link--is-active')) {
|
|
30
|
+
addActiveClass(tab)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
} else {
|
|
34
|
+
tabs.forEach((tab, index) => {
|
|
35
|
+
if(index === 0) {
|
|
36
|
+
addActiveClass(tab)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
checkIfTabIsActive()
|
|
43
|
+
|
|
18
44
|
// For easy reference
|
|
19
45
|
var keys = {
|
|
20
46
|
end: 35,
|
|
@@ -158,6 +184,9 @@ export function tabs(aria) {
|
|
|
158
184
|
// Set the tab as selected
|
|
159
185
|
tab.setAttribute('aria-selected', 'true');
|
|
160
186
|
|
|
187
|
+
//Add active class to current tab
|
|
188
|
+
addActiveClass(tab)
|
|
189
|
+
|
|
161
190
|
// Get the value of aria-controls (which is an ID)
|
|
162
191
|
var controls = tab.getAttribute('aria-controls');
|
|
163
192
|
|
|
@@ -175,6 +204,7 @@ export function tabs(aria) {
|
|
|
175
204
|
for (var t = 0; t < tabs.length; t++) {
|
|
176
205
|
tabs[t].setAttribute('tabindex', '-1');
|
|
177
206
|
tabs[t].setAttribute('aria-selected', 'false');
|
|
207
|
+
removeActiveClass(tabs[t])
|
|
178
208
|
};
|
|
179
209
|
|
|
180
210
|
for (var p = 0; p < panels.length; p++) {
|
|
@@ -241,5 +271,17 @@ export function tabs(aria) {
|
|
|
241
271
|
|
|
242
272
|
return delay;
|
|
243
273
|
};
|
|
274
|
+
|
|
275
|
+
function addActiveClass(element) {
|
|
276
|
+
//Add active class to current tab
|
|
277
|
+
element.classList.add("lg:bg-white", "lg:border-neutral-base", "lg:border-b-0", "lg:rounded-t", "no-underline");
|
|
278
|
+
|
|
279
|
+
element.firstElementChild.classList.add("text-black");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function removeActiveClass(element) {
|
|
283
|
+
element.classList.remove("lg:bg-white", "lg:border-neutral-base", "lg:border-b-0", "lg:rounded-t", "no-underline");
|
|
284
|
+
element.firstElementChild.classList.remove("text-black");
|
|
285
|
+
}
|
|
244
286
|
}
|
|
245
|
-
}
|
|
287
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function Toggle(aria) {
|
|
2
|
+
|
|
3
|
+
class Toggle {
|
|
4
|
+
constructor(domNode) {
|
|
5
|
+
this.rootEl = domNode;
|
|
6
|
+
this.buttonEl = this.rootEl.querySelector('button[aria-expanded]');
|
|
7
|
+
|
|
8
|
+
this.buttonEl.addEventListener('click', this.toggle.bind(this));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
toggle(event) {
|
|
12
|
+
const { target } = event
|
|
13
|
+
this.buttonEl.classList.toggle('c-button--has-selection')
|
|
14
|
+
target.querySelector('.c-button-is-not_pressed').classList.toggle('hidden')
|
|
15
|
+
target.querySelector('.c-button-is_pressed').classList.toggle('hidden')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const toggles = document.querySelectorAll('.c-toggle');
|
|
21
|
+
toggles.forEach((toggleElement) => {
|
|
22
|
+
new Toggle(toggleElement);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
}
|
package/src/js/aria/treeitem.js
CHANGED
|
@@ -104,10 +104,11 @@ export function Treeitem(aria) {
|
|
|
104
104
|
|
|
105
105
|
aria.Treeitem.prototype.handleKeydown = function (event) {
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
const targetElement = event.currentTarget;
|
|
108
|
+
let flag = false;
|
|
109
|
+
let char = event.key;
|
|
110
|
+
const getCurrentCheckbox = targetElement.querySelector('input');
|
|
111
|
+
const getAllChildrenOfTree = targetElement.parentElement.querySelectorAll('input');
|
|
111
112
|
|
|
112
113
|
function isPrintableCharacter (str) {
|
|
113
114
|
return str.length === 1 && str.match(/\S/);
|
|
@@ -139,23 +140,13 @@ export function Treeitem(aria) {
|
|
|
139
140
|
switch (event.keyCode) {
|
|
140
141
|
case this.keyCode.SPACE:
|
|
141
142
|
case this.keyCode.RETURN:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
'view': window,
|
|
147
|
-
'bubbles': true,
|
|
148
|
-
'cancelable': true
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
catch (err) {
|
|
152
|
-
if (document.createEvent) {
|
|
153
|
-
// DOM Level 3 for IE 9+
|
|
154
|
-
clickEvent = document.createEvent('MouseEvents');
|
|
155
|
-
clickEvent.initEvent('click', true, true);
|
|
143
|
+
const typeOfInput = getCurrentCheckbox.type
|
|
144
|
+
if(typeOfInput === 'radio') {
|
|
145
|
+
for (let item of getAllChildrenOfTree) {
|
|
146
|
+
item.checked = false
|
|
156
147
|
}
|
|
157
148
|
}
|
|
158
|
-
|
|
149
|
+
getCurrentCheckbox.checked = getCurrentCheckbox.checked === true ? false : true
|
|
159
150
|
flag = true;
|
|
160
151
|
break;
|
|
161
152
|
|
|
@@ -257,4 +248,4 @@ export function Treeitem(aria) {
|
|
|
257
248
|
aria.Treeitem.prototype.handleMouseOut = function (event) {
|
|
258
249
|
event.currentTarget.classList.remove('c-tree__item--hover');
|
|
259
250
|
};
|
|
260
|
-
}
|
|
251
|
+
}
|
package/src/js/desy-html.js
CHANGED
|
@@ -12,6 +12,8 @@ import { listbox } from './aria/listbox.js';
|
|
|
12
12
|
import { alert } from './aria/alert.js';
|
|
13
13
|
import { Treeitem } from './aria/treeitem.js';
|
|
14
14
|
import { Tree } from './aria/tree.js';
|
|
15
|
+
import { Toggle } from './aria/toggle.js';
|
|
16
|
+
import { Collapsible } from './aria/collapsible.js';
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
export function accordionComponent(aria) {
|
|
@@ -22,6 +24,14 @@ export function alertComponent(aria) {
|
|
|
22
24
|
alert(aria);
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
export function toggleComponent(aria) {
|
|
28
|
+
Toggle(aria);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function collapsibleComponent(aria) {
|
|
32
|
+
Collapsible(aria);
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
export function dialogComponent(aria) {
|
|
26
36
|
utils(aria);
|
|
27
37
|
dialog(aria);
|
|
@@ -223,7 +233,6 @@ export function menuNavigationComponent(aria) {
|
|
|
223
233
|
const moduleValue = modules[item].getAttribute('data-module');
|
|
224
234
|
|
|
225
235
|
if (moduleValue == 'c-menu-navigation'){
|
|
226
|
-
console.log(modules[item]);
|
|
227
236
|
const menuNavigation = new aria.DisclosureNav(modules[item]);
|
|
228
237
|
menuNavigation.init();
|
|
229
238
|
}
|
package/src/js/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import {
|
|
7
7
|
accordionComponent,
|
|
8
8
|
alertComponent,
|
|
9
|
+
collapsibleComponent,
|
|
9
10
|
dialogComponent,
|
|
10
11
|
dropdownComponent,
|
|
11
12
|
listboxComponent,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
tableAdvancedComponent,
|
|
15
16
|
tabsComponent,
|
|
16
17
|
tooltipComponent,
|
|
18
|
+
toggleComponent,
|
|
17
19
|
treeComponent
|
|
18
20
|
} from './desy-html.js';
|
|
19
21
|
|
|
@@ -21,6 +23,7 @@ var aria = aria || {};
|
|
|
21
23
|
|
|
22
24
|
accordionComponent(aria);
|
|
23
25
|
alertComponent(aria);
|
|
26
|
+
collapsibleComponent(aria);
|
|
24
27
|
dialogComponent(aria);
|
|
25
28
|
dropdownComponent(aria);
|
|
26
29
|
listboxComponent(aria);
|
|
@@ -29,4 +32,13 @@ menuNavigationComponent(aria);
|
|
|
29
32
|
tableAdvancedComponent(aria);
|
|
30
33
|
tabsComponent(aria);
|
|
31
34
|
tooltipComponent(aria);
|
|
35
|
+
toggleComponent(aria);
|
|
32
36
|
treeComponent(aria);
|
|
37
|
+
|
|
38
|
+
document.querySelectorAll('.c-code-snippet__button').forEach(button => {
|
|
39
|
+
button.addEventListener('click', (event) => {
|
|
40
|
+
event.target.querySelector('.c-code-snippet__show').classList.toggle('hidden')
|
|
41
|
+
event.target.querySelector('.c-code-snippet__hide').classList.toggle('hidden')
|
|
42
|
+
event.target.nextElementSibling.classList.toggle('hidden')
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -24,31 +24,6 @@
|
|
|
24
24
|
-#}
|
|
25
25
|
<!-- accordion -->
|
|
26
26
|
<div
|
|
27
|
-
x-ref="accordion"
|
|
28
|
-
x-data="{
|
|
29
|
-
showAll: true,
|
|
30
|
-
buttonText: 'Mostrar todo',
|
|
31
|
-
toggleShow: function(){
|
|
32
|
-
var buttons = this.$refs.accordion.querySelectorAll('.Accordion-trigger');
|
|
33
|
-
buttons.forEach((button) => {
|
|
34
|
-
if(this.showAll == true){
|
|
35
|
-
if(button.getAttribute('aria-expanded') == 'false'){
|
|
36
|
-
button.click();
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
39
|
-
if(button.getAttribute('aria-expanded') == 'true'){
|
|
40
|
-
button.click();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
this.showAll = !this.showAll;
|
|
45
|
-
if(this.showAll) {
|
|
46
|
-
this.buttonText = 'Mostrar todo';
|
|
47
|
-
} else {
|
|
48
|
-
this.buttonText = 'Ocultar todo';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}"
|
|
52
27
|
{%- if params.classes %} class="{{ params.classes }}"{% endif %}
|
|
53
28
|
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
|
|
54
29
|
<div class="flex justify-between">
|
|
@@ -71,15 +46,12 @@ x-data="{
|
|
|
71
46
|
{% endif %}
|
|
72
47
|
{% if params.showControl %}
|
|
73
48
|
<button
|
|
74
|
-
x-ref="button"
|
|
75
|
-
@click="toggleShow"
|
|
76
|
-
x-text="buttonText"
|
|
77
49
|
class="ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus">
|
|
78
50
|
Mostrar todo
|
|
79
51
|
</button>
|
|
80
52
|
{% endif %}
|
|
81
53
|
</div>
|
|
82
|
-
<div class="
|
|
54
|
+
<div class="c-accordion" {%- if params.allowToggle == true %} data-allow-toggle{% endif %} {%- if params.allowMultiple == true %} data-allow-multiple{% endif %}>
|
|
83
55
|
{% for item in params.items %}
|
|
84
56
|
{% if item %}
|
|
85
57
|
{%- if item.id -%}
|
|
@@ -97,7 +69,7 @@ x-data="{
|
|
|
97
69
|
{% set insideContent %}
|
|
98
70
|
<button
|
|
99
71
|
id="{{ id }}-title"
|
|
100
|
-
class="
|
|
72
|
+
class="c-accordion-trigger group relative w-full py-sm font-semibold text-left cursor-pointer focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black {%- if item.disabled %} cursor-not-allowed{% endif %}"
|
|
101
73
|
aria-controls="{{ id }}"
|
|
102
74
|
{% if item.open %}
|
|
103
75
|
aria-expanded = "true"
|
|
@@ -109,14 +81,14 @@ x-data="{
|
|
|
109
81
|
{{ item.headerHtml | safe if item.headerHtml else item.headerText }}
|
|
110
82
|
<span
|
|
111
83
|
class="absolute inset-y-0 right-0 py-sm font-normal text-sm text-neutral-dark underline group-focus:text-black pointer-events-none {%- if item.disabled %} hidden{% endif %}" aria-hidden="true">
|
|
112
|
-
<span class="
|
|
84
|
+
<span class="c-accordion-show {%- if item.open %} hidden{%else%}{%endif%} {%- if item.show.classes %} {{ item.show.classes }}{%endif%}">
|
|
113
85
|
{% if item.show %}
|
|
114
86
|
{{ item.show.html | safe if item.show.html else item.show.text }}
|
|
115
87
|
{% else %}
|
|
116
88
|
Mostrar
|
|
117
89
|
{% endif %}
|
|
118
90
|
</span>
|
|
119
|
-
<span class="
|
|
91
|
+
<span class="c-accordion-hide {%- if item.open %}{%else%} hidden{%endif%} {%- if item.hide.classes %} {{ item.hide.classes }}{%endif%}">
|
|
120
92
|
{% if item.hide %}
|
|
121
93
|
{{ item.hide.html | safe if item.hide.html else item.hide.text }}
|
|
122
94
|
{% else %}
|
|
@@ -147,7 +119,7 @@ x-data="{
|
|
|
147
119
|
{%- if id %}
|
|
148
120
|
id="{{ id }}"
|
|
149
121
|
{% endif %}
|
|
150
|
-
class="
|
|
122
|
+
class="c-accordion-panel {%- if item.classes %} {{ item.classes }}{% endif %}"
|
|
151
123
|
{%- for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>
|
|
152
124
|
{{ item.html | safe if item.html else item.text }}
|
|
153
125
|
</div>
|
|
@@ -156,4 +128,4 @@ x-data="{
|
|
|
156
128
|
{% endfor %}
|
|
157
129
|
</div>
|
|
158
130
|
</div>
|
|
159
|
-
<!-- /accordion -->
|
|
131
|
+
<!-- /accordion -->
|