desy-html 8.10.2 → 8.12.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.
Files changed (35) hide show
  1. package/docs/index.html +15 -0
  2. package/package.json +1 -1
  3. package/src/css/styles.css +2 -0
  4. package/src/js/aria/accordion.js +66 -34
  5. package/src/js/aria/notification.js +47 -23
  6. package/src/js/aria/toggle.js +46 -31
  7. package/src/js/aria/tree.js +2 -3
  8. package/src/js/aria/treeitem.js +54 -0
  9. package/src/js/desy-html.js +6 -3
  10. package/src/templates/components/accordion/_examples.accordion.njk +29 -0
  11. package/src/templates/components/accordion/_template.accordion.njk +1 -1
  12. package/src/templates/components/accordion/params.accordion.yaml +5 -1
  13. package/src/templates/components/accordion-history/_examples.accordion-history.njk +29 -0
  14. package/src/templates/components/accordion-history/_template.accordion-history.njk +1 -1
  15. package/src/templates/components/accordion-history/params.accordion-history.yaml +5 -1
  16. package/src/templates/components/footer/_examples.footer.njk +73 -7
  17. package/src/templates/components/footer/_styles.footer.css +37 -0
  18. package/src/templates/components/footer/_template.footer.njk +25 -5
  19. package/src/templates/components/footer/params.footer.yaml +27 -3
  20. package/src/templates/components/header-advanced/_template.header-advanced.njk +2 -2
  21. package/src/templates/components/header-mini/_template.header-mini.njk +2 -2
  22. package/src/templates/components/menu-navigation/params.menu-navigation.yaml +4 -0
  23. package/src/templates/components/menubar/_template.menubar.njk +2 -2
  24. package/src/templates/components/notification/_examples.notification.njk +11 -0
  25. package/src/templates/components/pagination/_template.pagination.njk +1 -1
  26. package/src/templates/components/pagination/params.pagination.yaml +2 -2
  27. package/src/templates/components/table-advanced/_template.table-advanced.njk +1 -1
  28. package/src/templates/components/table-advanced/params.table-advanced.yaml +0 -4
  29. package/src/templates/components/toggle/_examples.toggle.njk +53 -0
  30. package/src/templates/components/toggle/_styles.toggle.css +31 -0
  31. package/src/templates/components/toggle/_template.toggle.njk +1 -0
  32. package/src/templates/components/toggle/params.toggle.yaml +4 -0
  33. package/src/templates/components/tree/_examples.tree.njk +447 -0
  34. package/src/templates/components/tree/_template.tree.njk +1 -1
  35. package/src/templates/components/tree/params.tree.yaml +5 -1
package/docs/index.html CHANGED
@@ -38,6 +38,21 @@
38
38
 
39
39
  <h2>Changelog (English)</h2>
40
40
  <p>What's new in the latest version of desy-html</p>
41
+ <h3>v.8.12.0</h3>
42
+ <ul class="text-sm">
43
+ <li>Added new logos and parameters in Footer.</li>
44
+ <li>Added global function to open/close Tree items.</li>
45
+ <li>Added global funcion to Notification to close it.</li>
46
+ <li>Accesibility fixes.</li>
47
+ <li>Improvements in docs.</li>
48
+ </ul>
49
+ <h3>v.8.11.0</h3>
50
+ <ul class="text-sm">
51
+ <li>Added global funcion to Accordion and Accordion history to open/close all items.</li>
52
+ <li>Added global function to check/uncheck Toggle.</li>
53
+ <li>Bug fixes.</li>
54
+ <li>Improvements in docs.</li>
55
+ </ul>
41
56
  <h3>v.8.10.2</h3>
42
57
  <ul class="text-sm">
43
58
  <li>Updated Tailwind CSS form and typography plugins.</li>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "desy-html",
3
- "version": "8.10.2",
3
+ "version": "8.12.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)",
@@ -23,6 +23,7 @@
23
23
  @import "../templates/components/collapsible/_styles.collapsible.css";
24
24
  @import "../templates/components/dialog/_styles.dialog.css";
25
25
  @import "../templates/components/dropdown/_styles.dropdown.css";
26
+ @import "../templates/components/footer/_styles.footer.css";
26
27
  @import "../templates/components/header/_styles.header.css";
27
28
  @import "../templates/components/input/_styles.input.css";
28
29
  @import "../templates/components/listbox/_styles.listbox.css";
@@ -37,6 +38,7 @@
37
38
  @import "../templates/components/skip-link/_styles.skip-link.css";
38
39
  @import "../templates/components/table-advanced/_styles.table-advanced.css";
39
40
  @import "../templates/components/tabs/_styles.tabs.css";
41
+ @import "../templates/components/toggle/_styles.toggle.css";
40
42
  @import "../templates/components/tree/_styles.tree.css";
41
43
  @import "./component.form-group.css";
42
44
  @import "./component.tippy-box.css";
@@ -24,39 +24,7 @@ export function accordion(aria) {
24
24
  var target = event.target;
25
25
 
26
26
  if(target.classList.contains('c-accordion__toggle-all')) {
27
- const getAllElementsShow = target.parentElement.parentElement.querySelectorAll('.c-accordion__show')
28
- const getAllElementsHide = target.parentElement.parentElement.querySelectorAll('.c-accordion__hide')
29
- const getAllPanels = target.parentElement.parentElement.querySelectorAll('.c-accordion__panel')
30
- const getAllTriggers = target.parentElement.parentElement.querySelectorAll('.c-accordion__trigger')
31
- if(target.textContent.includes('Mostrar todo')) {
32
- getAllElementsShow.forEach(element => {
33
- element.classList.add('hidden')
34
- })
35
- getAllElementsHide.forEach(element => {
36
- element.classList.remove('hidden')
37
- })
38
- getAllPanels.forEach(element => {
39
- element.removeAttribute('hidden')
40
- })
41
- getAllTriggers.forEach(element => {
42
- element.setAttribute('aria-expanded', 'true');
43
- })
44
- target.textContent = 'Ocultar todo'
45
- } else {
46
- getAllElementsShow.forEach(element => {
47
- element.classList.remove('hidden')
48
- })
49
- getAllElementsHide.forEach(element => {
50
- element.classList.add('hidden')
51
- })
52
- getAllPanels.forEach(element => {
53
- element.setAttribute('hidden', "")
54
- })
55
- getAllTriggers.forEach(element => {
56
- element.setAttribute('aria-expanded', 'false');
57
- })
58
- target.textContent = 'Mostrar todo'
59
- }
27
+ toggleAllAccordion(target)
60
28
  }
61
29
 
62
30
  if (target.classList.contains('c-accordion__trigger')) {
@@ -109,6 +77,10 @@ export function accordion(aria) {
109
77
 
110
78
  event.preventDefault();
111
79
  }
80
+
81
+ if(accordion.querySelector('.c-accordion__toggle-all') && !target.classList.contains('c-accordion__toggle-all')) {
82
+ checkIfAllPanelAreOpenOrClosed()
83
+ }
112
84
  });
113
85
 
114
86
  // Bind keyboard behaviors on the main accordion container
@@ -182,6 +154,55 @@ export function accordion(aria) {
182
154
  }
183
155
  }
184
156
 
157
+ function toggleAllAccordion(target, show = null) {
158
+ const getAllElementsShow = target.parentElement.parentElement.querySelectorAll('.c-accordion__show')
159
+ const getAllElementsHide = target.parentElement.parentElement.querySelectorAll('.c-accordion__hide')
160
+ const getAllPanels = target.parentElement.parentElement.querySelectorAll('.c-accordion__panel')
161
+ const getAllTriggers = target.parentElement.parentElement.querySelectorAll('.c-accordion__trigger')
162
+ if(target.textContent.includes('Mostrar todo') || show === true) {
163
+ getAllElementsShow.forEach(element => {
164
+ element.classList.add('hidden')
165
+ })
166
+ getAllElementsHide.forEach(element => {
167
+ element.classList.remove('hidden')
168
+ })
169
+ getAllPanels.forEach(element => {
170
+ element.removeAttribute('hidden')
171
+ })
172
+ getAllTriggers.forEach(element => {
173
+ element.setAttribute('aria-expanded', 'true');
174
+ })
175
+ target.textContent = 'Ocultar todo'
176
+ } else {
177
+ getAllElementsShow.forEach(element => {
178
+ element.classList.remove('hidden')
179
+ })
180
+ getAllElementsHide.forEach(element => {
181
+ element.classList.add('hidden')
182
+ })
183
+ getAllPanels.forEach(element => {
184
+ element.setAttribute('hidden', "")
185
+ })
186
+ getAllTriggers.forEach(element => {
187
+ element.setAttribute('aria-expanded', 'false');
188
+ })
189
+ target.textContent = 'Mostrar todo'
190
+ }
191
+ }
192
+
193
+ function checkIfAllPanelAreOpenOrClosed() {
194
+ const getAccordionTrigger = accordion.querySelectorAll('.c-accordion__trigger');
195
+ let arrayAccordionTrigger = [...getAccordionTrigger].map(element => element.getAttribute('aria-expanded'));
196
+
197
+ if(arrayAccordionTrigger.every(element => element === 'true')) {
198
+ accordion.querySelector('.c-accordion__toggle-all').textContent = 'Ocultar todo';
199
+ }
200
+
201
+ if(arrayAccordionTrigger.every(element => element === 'false')) {
202
+ accordion.querySelector('.c-accordion__toggle-all').textContent = 'Mostrar todo';
203
+ }
204
+ }
205
+
185
206
  window.activateItemAccordion = function (menuId, activeItemId) {
186
207
  const menu = document.getElementById(menuId);
187
208
  if (menu) {
@@ -194,7 +215,18 @@ export function accordion(aria) {
194
215
  return null;
195
216
  }
196
217
  } else {
197
- console.log('There is no menu with this id in the document.');
218
+ console.log('There is no accordion with this id in the document.');
219
+ return null;
220
+ }
221
+ };
222
+
223
+ window.activateAllAccordion = function (element, show) {
224
+ const button = document.getElementById(element);
225
+ if (button) {
226
+ toggleAllAccordion(button, show);
227
+ return [button, show]
228
+ } else {
229
+ console.log('There is no element with this id in the menu.');
198
230
  return null;
199
231
  }
200
232
  };
@@ -1,32 +1,56 @@
1
- export function notification() {
1
+ export function Notification(aria) {
2
2
 
3
- class Notification {
3
+ aria.notificationInit = function (domNode) {
4
+ this.rootEl = domNode;
5
+ /*No todas las notificaciones tienen botón de cerrar
6
+ así que comprobamos que el componente contiene el botón.*/
7
+ if(this.rootEl.querySelector('.c-notification-button__close')) {
8
+ window.addEventListener('click', this.closeNotification.bind(this));
9
+ }
10
+ };
4
11
 
5
- constructor(domNode) {
6
- this.rootEl = domNode;
7
- /*No todas las notificaciones tienen botón de cerrar
8
- así que comprobamos que el componente contiene el botón.*/
9
- if(this.rootEl.querySelector('.c-notification-button__close')) {
10
- window.addEventListener('click', this.closeNotification.bind(this));
11
- }
12
+ aria.closeNotification = function (event) {
13
+ const { target } = event;
14
+ const elementNotification = target ? target : event
15
+ if(target) {
16
+ aria.closeNotificationEvent(elementNotification)
12
17
  }
13
18
 
14
- closeNotification(event) {
15
- const { target } = event;
16
- if(target.classList.contains('c-notification-button__close')) {
17
- //Replicamos la transición de alpine con tailwind al cerrar.
18
- target.parentElement.parentElement.parentElement.classList.add('transition-opacity', 'duration-150', 'ease-in-out', 'opacity-0');
19
- //Añadimos display: none para que el componente "desaparezca del DOM"
20
- setTimeout(() =>{
21
- target.parentElement.parentElement.parentElement.classList.add('hidden');
22
- }, 300)
23
- }
19
+ if(!target) {
20
+ aria.closeNotificationWindow(elementNotification)
24
21
  }
22
+ }
25
23
 
24
+ aria.closeNotificationEvent = function (element) {
25
+ if(element.classList.contains('c-notification-button__close')) {
26
+ //Replicamos la transición de alpine con tailwind al cerrar.
27
+ element.parentElement.parentElement.parentElement.classList.add('transition-opacity', 'duration-150', 'ease-in-out', 'opacity-0');
28
+ //Añadimos display: none para que el componente "desaparezca del DOM"
29
+ setTimeout(() =>{
30
+ element.parentElement.parentElement.parentElement.classList.add('hidden');
31
+ }, 300)
32
+ }
26
33
  }
27
34
 
28
- const notifications = document.querySelectorAll('[data-module="c-notification"]');
29
- notifications.forEach((notificationElement) => {
30
- new Notification(notificationElement);
31
- });
35
+ aria.closeNotificationWindow = function (element) {
36
+ if(element.querySelector('.c-notification-button__close')) {
37
+ //Replicamos la transición de alpine con tailwind al cerrar.
38
+ element.classList.add('transition-opacity', 'duration-150', 'ease-in-out', 'opacity-0');
39
+ //Añadimos display: none para que el componente "desaparezca del DOM"
40
+ setTimeout(() =>{
41
+ element.classList.add('hidden');
42
+ }, 300)
43
+ }
44
+ }
45
+
46
+ window.closeItemNotification = function (element) {
47
+ const notification = document.getElementById(element);
48
+ if (notification) {
49
+ aria.closeNotification(notification)
50
+ return [notification];
51
+ } else {
52
+ console.log('There is no menu with this id in the document.');
53
+ return null;
54
+ }
55
+ };
32
56
  }
@@ -1,46 +1,61 @@
1
1
  export function Toggle(aria) {
2
2
 
3
- class Toggle {
4
- constructor(domNode) {
5
- this.rootEl = domNode;
6
- this.buttonEl = this.rootEl.querySelector('.c-toggle__button');
7
- this.buttonEl.addEventListener('click', this.toggle.bind(this));
8
- if(this.buttonEl.getAttribute('aria-pressed') === 'true' || this.buttonEl.getAttribute('aria-checked') === 'true') {
9
- this.buttonEl.click()
10
- }
3
+ aria.toggleInit = function (domNode) {
4
+ this.rootEl = domNode;
5
+ this.buttonEl = this.rootEl.querySelector('.c-toggle__button');
6
+ this.buttonEl.addEventListener('click', this.toggle.bind(this));
7
+ if(this.buttonEl.getAttribute('aria-pressed') === 'true' || this.buttonEl.getAttribute('aria-checked') === 'true') {
8
+ this.buttonEl.click()
11
9
  }
10
+ };
12
11
 
13
- toggle(event) {
14
- const { target } = event
15
- this.buttonEl.classList.toggle('c-toggle--is-opened')
16
- target.querySelector('.c-button--is-not-pressed').classList.toggle('hidden')
17
- target.querySelector('.c-button--is-pressed').classList.toggle('hidden')
12
+ aria.toggle = function (event) {
13
+ const { target } = event
14
+ target.classList.toggle('c-toggle--is-opened')
18
15
 
19
- this.ariaAttribute(target)
16
+ this.ariaAttribute(target)
17
+ }
18
+
19
+ aria.ariaAttribute = function (target) {
20
+ if(target.getAttribute('aria-checked')) {
21
+ const toggleIsOpened = target.classList.contains('c-toggle--is-opened') ? true : false
22
+ target.setAttribute('aria-checked', toggleIsOpened);
23
+ }
24
+
25
+ if(target.getAttribute('aria-pressed')) {
26
+ const toggleIsOpened = target.classList.contains('c-toggle--is-opened') ? true : false
27
+ target.setAttribute('aria-pressed', toggleIsOpened);
28
+ }
29
+
30
+ if(target.getAttribute('aria-expanded')) {
31
+ const toggleIsOpened = target.classList.contains('c-toggle--is-opened') ? true : false
32
+ target.setAttribute('aria-expanded', toggleIsOpened);
20
33
  }
34
+ }
21
35
 
22
- ariaAttribute(target) {
23
- if(target.getAttribute('aria-checked')) {
24
- const toggleIsOpened = target.classList.contains('c-toggle--is-opened') ? true : false
25
- this.buttonEl.setAttribute('aria-checked', toggleIsOpened);
26
- }
27
-
28
- if(target.getAttribute('aria-pressed')) {
29
- const toggleIsOpened = target.classList.contains('c-toggle--is-opened') ? true : false
30
- this.buttonEl.setAttribute('aria-pressed', toggleIsOpened);
31
- }
32
-
33
- if(target.getAttribute('aria-expanded')) {
34
- const toggleIsOpened = target.classList.contains('c-toggle--is-opened') ? true : false
35
- this.buttonEl.setAttribute('aria-expanded', toggleIsOpened);
36
- }
36
+ function handleToggle(element, toggle) {
37
+ if(toggle){
38
+ element.classList.add('c-toggle--is-opened')
39
+ } else {
40
+ element.classList.remove('c-toggle--is-opened')
37
41
  }
38
42
 
43
+ aria.ariaAttribute(element)
39
44
  }
40
45
 
46
+ window.activateItemToggle = function (element, toggle) {
47
+ const toggleElement = document.getElementById(element);
48
+ if (toggleElement) {
49
+ handleToggle(toggleElement, toggle)
50
+ return [toggleElement, toggle];
51
+ } else {
52
+ console.log('There is no toggle with this id in the document.');
53
+ return null;
54
+ }
55
+ };
56
+
41
57
  const toggles = document.querySelectorAll('[data-module="c-toggle"]');
42
58
  toggles.forEach((toggleElement) => {
43
- new Toggle(toggleElement);
59
+ aria.toggleInit(toggleElement);
44
60
  });
45
-
46
61
  }
@@ -168,8 +168,7 @@ export function Tree(aria) {
168
168
 
169
169
  if (currentItem.isExpanded()) {
170
170
  groupTreeitem = currentItem;
171
- }
172
- else {
171
+ } else {
173
172
  groupTreeitem = currentItem.groupTreeitem;
174
173
  }
175
174
 
@@ -242,4 +241,4 @@ export function Tree(aria) {
242
241
  };
243
242
 
244
243
  return aria;
245
- }
244
+ }
@@ -261,4 +261,58 @@ export function Treeitem(aria) {
261
261
  aria.Treeitem.prototype.handleMouseOut = function (event) {
262
262
  event.currentTarget.classList.remove('c-tree__item--hover');
263
263
  };
264
+
265
+ window.activateItemsTree = function (elementId, itemsIds, open = null) {
266
+ const element = document.getElementById(elementId);
267
+ if (element) {
268
+ arrayOrSingleElement(elementId, itemsIds, open);
269
+ return [elementId, itemsIds, open];
270
+ } else {
271
+ console.log('There is no menu with this id in the document.');
272
+ return null;
273
+ }
274
+ };
275
+
276
+ function arrayOrSingleElement(elementId, itemsIds, open) {
277
+ if(typeof itemsIds === 'object' && open !== null) {
278
+ itemsIds.forEach((item) => {
279
+ const selectItem = document.querySelector(`#${elementId} #${item}`)
280
+ activateElement(selectItem, open)
281
+ })
282
+ }
283
+
284
+ if(typeof itemsIds !== 'object' && open !== null) {
285
+ const selectItem = document.querySelector(`#${elementId} #${itemsIds}`)
286
+ activateElement(selectItem, open)
287
+ }
288
+
289
+ if(typeof itemsIds === 'object' && open === null) {
290
+ itemsIds.forEach((item) => {
291
+ const selectItem = document.querySelector(`#${elementId} #${item[0]}`)
292
+ activateElement(selectItem, item[1])
293
+ })
294
+ }
295
+ }
296
+
297
+ function activateElement(item, open) {
298
+ if(open === true) {
299
+ item.setAttribute('aria-expanded', 'true');
300
+ recursiveParent(item)
301
+ } else {
302
+ item.setAttribute('aria-expanded', 'false');
303
+ }
304
+ }
305
+
306
+ function recursiveParent(item) {
307
+ if(item.parentNode.tagName === "UL" && typeof item.parentNode.id === "string" && item.parentNode.id.length === 0) {
308
+ recursiveParent(item.parentNode)
309
+ } else if(item.parentNode.tagName === "LI" && item.parentNode.getAttribute('aria-expanded') === "true") {
310
+ recursiveParent(item.parentNode)
311
+ } else if(item.parentNode.getAttribute('aria-expanded') === "false") {
312
+ item.parentNode.setAttribute('aria-expanded', 'true');
313
+ if(item.parentNode.parentNode.parentNode.getAttribute('aria-expanded') === "false") {
314
+ recursiveParent(item.parentNode)
315
+ }
316
+ }
317
+ }
264
318
  }
@@ -13,7 +13,7 @@ import { Treeitem } from './aria/treeitem.js';
13
13
  import { Tree } from './aria/tree.js';
14
14
  import { Toggle } from './aria/toggle.js';
15
15
  import { Collapsible } from './aria/collapsible.js';
16
- import { notification } from './aria/notification.js';
16
+ import { Notification } from './aria/notification.js';
17
17
  import { RadioButton } from './aria/radioButton.js';
18
18
  import { CheckBox } from './aria/checkBoxes.js';
19
19
  import { MenuVertical } from './aria/MenuVertical.js';
@@ -22,7 +22,6 @@ import { MenuHorizontal } from './aria/MenuHorizontal.js';
22
22
  import { MenuNavigation } from './aria/MenuNavigation.js';
23
23
  import { Nav } from './aria/Nav.js';
24
24
 
25
-
26
25
  export function accordionComponent(aria) {
27
26
  accordion(aria);
28
27
  }
@@ -376,7 +375,11 @@ export function treeComponent(aria) {
376
375
  }
377
376
 
378
377
  export function notificationComponent(aria) {
379
- notification(aria);
378
+ Notification(aria);
379
+ const modules = document.querySelectorAll('[data-module="c-notification"]');
380
+ [...modules].forEach((module) => {
381
+ aria.notificationInit(module);
382
+ });
380
383
  }
381
384
 
382
385
  export function radioButtonComponent(aria) {
@@ -228,6 +228,35 @@
228
228
  ]
229
229
  }
230
230
  },
231
+ {
232
+ "name": "Mostrar todo u ocultar todo con JavaScript",
233
+ "description": 'Es necesario usar el parámetro <code>"showControl": true</code>. Puedes usar con javascript la función global <code>activateAllAccordion(element, show)</code>, para mostrar u ocultar todos los items, usando el id del botón, el parámetro <code>show</code> admite <code>true</code> o <code>false</code>, si le pasamos true se mostrarán todos los items expandidos, y si le pasamos false se mostrarán cerrados. Ej: Abre la consola del navegador y escribe <code>activateAllAccordion("show-all-accordion-button-js", true)</code> para mostrar todos los items expandidos.',
234
+ "data": {
235
+ "idPrefix": "show-all-accordion-example-js",
236
+ "id": "show-all-accordion-button-js",
237
+ "headingLevel": 3,
238
+ "heading": {
239
+ "text": "Encabezado de acordeón"
240
+ },
241
+ "showControl": true,
242
+ "allowMultiple": true,
243
+ "items": [
244
+ {
245
+ "headerText": "Item de acordeón 1",
246
+ "html": '<div class="w-48 p-2"><div class="border-4 border-dashed border-neutral-light rounded-lg h-40"></div></div>'
247
+ },
248
+ {
249
+ "headerText": "Item de acordeón 2",
250
+ "html": '<div class="w-48 p-2"><div class="border-4 border-dashed border-neutral-light rounded-lg h-40"></div></div>',
251
+ "open": true
252
+ },
253
+ {
254
+ "headerText": "Item de acordeón 3",
255
+ "html": '<div class="w-48 p-2"><div class="border-4 border-dashed border-neutral-light rounded-lg h-40"></div></div>'
256
+ }
257
+ ]
258
+ }
259
+ },
231
260
  {
232
261
  "name": "Con controles personalizados para mostrar/ocultar",
233
262
  "description": 'Usa los parámetros <code>"show"</code> y <code>"hide"</code> para personalizar los controles que permiten abrir cada item. El último item de este ejemplo no muestra ningún controlador visible.',
@@ -38,7 +38,7 @@
38
38
  {% endif %}
39
39
  {% endif %}
40
40
  {% if params.showControl %}
41
- <button class="c-accordion__toggle-all ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus text-right" type="button">
41
+ <button id="{{ params.id }}" class="c-accordion__toggle-all ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus text-right" type="button">
42
42
  Mostrar todo
43
43
  </button>
44
44
  {% endif %}
@@ -32,6 +32,10 @@ params:
32
32
  type: string
33
33
  required: false
34
34
  description: Classes to add to the heading.
35
+ - name: id
36
+ type: string
37
+ required: false
38
+ description: Id to add to the button to show or hide all elements. Not required, but recommended to improve the accessibility.
35
39
  - name: showControl
36
40
  type: boolean
37
41
  required: false
@@ -118,4 +122,4 @@ params:
118
122
  - name: attributes
119
123
  type: object
120
124
  required: false
121
- description: HTML attributes (for example data attributes) to add to the accordion container.
125
+ description: HTML attributes (for example data attributes) to add to the accordion container.
@@ -264,6 +264,35 @@
264
264
  ]
265
265
  }
266
266
  },
267
+ {
268
+ "name": "Mostrar todo u ocultar todo con JavaScript",
269
+ "description": 'Es necesario usar el parámetro <code>"showControl": true</code>. Puedes usar con javascript la función global <code>activateAllAccordion(element, show)</code>, para mostrar u ocultar todos los items, usando el id del botón, el parámetro <code>show</code> admite <code>true</code> o <code>false</code>, si le pasamos true se mostrarán todos los items expandidos, y si le pasamos false se mostrarán cerrados. Ej: Abre la consola del navegador y escribe <code>activateAllAccordion("show-all-accordion-history-button-js", true)</code> para mostrar todos los items expandidos.',
270
+ "data": {
271
+ "idPrefix": "show-all-accordion-example-history-js",
272
+ "id": "show-all-accordion-history-button-js",
273
+ "headingLevel": 3,
274
+ "heading": {
275
+ "text": "Encabezado de acordeón"
276
+ },
277
+ "showControl": true,
278
+ "allowMultiple": true,
279
+ "items": [
280
+ {
281
+ "headerText": "Item de acordeón 1",
282
+ "html": '<div class="w-48 p-2"><div class="border-4 border-dashed border-neutral-light rounded-lg h-40"></div></div>'
283
+ },
284
+ {
285
+ "headerText": "Item de acordeón 2",
286
+ "html": '<div class="w-48 p-2"><div class="border-4 border-dashed border-neutral-light rounded-lg h-40"></div></div>',
287
+ "open": true
288
+ },
289
+ {
290
+ "headerText": "Item de acordeón 3",
291
+ "html": '<div class="w-48 p-2"><div class="border-4 border-dashed border-neutral-light rounded-lg h-40"></div></div>'
292
+ }
293
+ ]
294
+ }
295
+ },
267
296
  {
268
297
  "name": "Con controles personalizados para mostrar/ocultar",
269
298
  "description": 'Usa los parámetros <code>"show"</code> y <code>"hide"</code> para personalizar los controles que permiten abrir cada item. El último item de este ejemplo no muestra ningún controlador visible.',
@@ -39,7 +39,7 @@
39
39
  {% endif %}
40
40
  {% endif %}
41
41
  {% if params.showControl %}
42
- <button class="c-accordion__toggle-all ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus text-right" type="button">
42
+ <button id="{{ params.id }}" class="c-accordion__toggle-all ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus text-right" type="button">
43
43
  Mostrar todo
44
44
  </button>
45
45
  {% endif %}
@@ -28,6 +28,10 @@ params:
28
28
  type: string
29
29
  required: true
30
30
  description: If `text` is set, this is not required. HTML to use within the heading. If `html` is provided, the `text` argument will be ignored.
31
+ - name: id
32
+ type: string
33
+ required: false
34
+ description: Id to add to the item. Not required, but recommended to improve the accessibility.
31
35
  - name: classes
32
36
  type: string
33
37
  required: false
@@ -122,4 +126,4 @@ params:
122
126
  - name: attributes
123
127
  type: object
124
128
  required: false
125
- description: HTML attributes (for example data attributes) to add to the accordion container.
129
+ description: HTML attributes (for example data attributes) to add to the accordion container.