desy-html 6.3.2 → 6.4.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 (39) hide show
  1. package/config/tailwind.config.js +2 -0
  2. package/docs/_macro.example-render.njk +1 -1
  3. package/docs/ds/_ds.example.description-list.njk +138 -1
  4. package/docs/ds/_ds.example.header-advanced.njk +146 -0
  5. package/docs/ds/_ds.example.header.njk +1 -25
  6. package/docs/ds/_ds.example.menu-navigation.njk +4 -4
  7. package/docs/ds/_ds.example.pagination.njk +63 -0
  8. package/docs/ds/_ds.section.navigation.njk +6 -1
  9. package/docs/ds/_ds.section.typography.njk +3 -3
  10. package/docs/index.html +17 -0
  11. package/package.json +1 -1
  12. package/src/js/aria/accordion.js +51 -22
  13. package/src/js/aria/collapsible.js +8 -1
  14. package/src/js/aria/dialog.js +13 -1
  15. package/src/js/aria/notification.js +29 -0
  16. package/src/js/aria/tabs.js +2 -0
  17. package/src/js/aria/toggle.js +24 -6
  18. package/src/js/desy-html.js +4 -0
  19. package/src/js/index.js +3 -1
  20. package/src/templates/components/accordion/_examples.accordion.njk +22 -0
  21. package/src/templates/components/accordion/_template.accordion.njk +7 -9
  22. package/src/templates/components/accordion-history/_examples.accordion-history.njk +23 -0
  23. package/src/templates/components/accordion-history/_template.accordion-history.njk +8 -9
  24. package/src/templates/components/collapsible/_template.collapsible.njk +1 -1
  25. package/src/templates/components/dialog/_examples.dialog.njk +2 -4
  26. package/src/templates/components/dialog/_styles.dialog.css +1 -1
  27. package/src/templates/components/header/_examples.header-2.njk +19 -0
  28. package/src/templates/components/header/_examples.header.njk +20 -26
  29. package/src/templates/components/header/_template.header.header__offcanvas.njk +2 -2
  30. package/src/templates/components/header/_template.header.njk +10 -1
  31. package/src/templates/components/header/params.header.yaml +20 -0
  32. package/src/templates/components/input-group/_examples.input-group.njk +36 -7
  33. package/src/templates/components/menu-navigation/_examples.menu-navigation.njk +4 -4
  34. package/src/templates/components/modal/_template.modal.njk +2 -2
  35. package/src/templates/components/notification/_template.notification.njk +3 -3
  36. package/src/templates/components/pagination/_examples.pagination.njk +4 -0
  37. package/src/templates/components/tabs/_examples.tabs.njk +1 -1
  38. package/src/templates/components/toggle/_examples.toggle.njk +19 -0
  39. package/src/templates/components/toggle/_template.toggle.njk +9 -7
@@ -16,64 +16,93 @@ 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('.c-accordion-trigger'));
20
- var panels = Array.prototype.slice.call(accordion.querySelectorAll('.c-accordion-panel'));
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);
25
24
  var target = event.target;
26
25
 
27
- if (target.classList.contains('c-accordion-trigger')) {
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
+ }
60
+ }
61
+
62
+ if (target.classList.contains('c-accordion__trigger')) {
28
63
  // Check if the current toggle is expanded.
29
64
  var isExpanded = target.getAttribute('aria-expanded') == 'true';
30
65
  var active = accordion.querySelector('[aria-expanded="true"]');
31
66
 
32
67
  // without allowMultiple, close the open accordion
33
68
  if (!allowMultiple && active && active !== target) {
34
- console.log("!allowMultiple && active && active !== target");
35
69
  // Set the expanded state on the triggering element
36
70
  active.setAttribute('aria-expanded', 'false');
37
71
  //active.querySelector('span').innerText = 'Mostrar';
38
- active.querySelector('.c-accordion-show').classList.remove('hidden');
39
- active.querySelector('.c-accordion-hide').classList.add('hidden');
72
+ active.querySelector('.c-accordion__show').classList.remove('hidden');
73
+ active.querySelector('.c-accordion__hide').classList.add('hidden');
40
74
  // Hide the accordion sections, using aria-controls to specify the desired section
41
75
  document.getElementById(active.getAttribute('aria-controls')).setAttribute('hidden', '');
42
76
 
43
77
  // When toggling is not allowed, clean up disabled state
44
78
  if (!allowToggle) {
45
- console.log("allowToggle");
46
79
  active.removeAttribute('aria-disabled');
47
80
  }
48
81
  }
49
82
 
50
83
  if (!isExpanded) {
51
- console.log("isExpanded");
52
84
  // Set the expanded state on the triggering element
53
- console.log("target", target);
54
85
  target.setAttribute('aria-expanded', 'true');
55
86
  //target.querySelector('span').innerText = 'Ocultar';
56
- target.querySelector('.c-accordion-show').classList.toggle('hidden');
57
- target.querySelector('.c-accordion-hide').classList.toggle('hidden');
87
+ target.querySelector('.c-accordion__show').classList.toggle('hidden');
88
+ target.querySelector('.c-accordion__hide').classList.toggle('hidden');
58
89
  // Hide the accordion sections, using aria-controls to specify the desired section
59
90
  document.getElementById(target.getAttribute('aria-controls')).removeAttribute('hidden');
60
91
 
61
92
  // If toggling is not allowed, set disabled state on trigger
62
93
  if (!allowToggle) {
63
- console.log("if");
64
94
  target.setAttribute('aria-disabled', 'true');
65
95
  //target.querySelector('span').innerText = '';
66
- target.querySelector('.c-accordion-show').classList.add('hidden');
67
- target.querySelector('.c-accordion-hide').classList.add('hidden');
96
+ target.querySelector('.c-accordion__show').classList.add('hidden');
97
+ target.querySelector('.c-accordion__hide').classList.add('hidden');
68
98
  }
69
99
  }
70
100
  else if (allowToggle && isExpanded) {
71
- console.log("else if");
72
101
  // Set the expanded state on the triggering element
73
102
  target.setAttribute('aria-expanded', 'false');
74
103
  // target.querySelector('span').innerText = 'Mostrar';
75
- target.querySelector('.c-accordion-show').classList.toggle('hidden');
76
- target.querySelector('.c-accordion-hide').classList.toggle('hidden');
104
+ target.querySelector('.c-accordion__show').classList.toggle('hidden');
105
+ target.querySelector('.c-accordion__hide').classList.toggle('hidden');
77
106
 
78
107
  // Hide the accordion sections, using aria-controls to specify the desired section
79
108
  document.getElementById(target.getAttribute('aria-controls')).setAttribute('hidden', '');
@@ -95,7 +124,7 @@ export function accordion(aria) {
95
124
  var ctrlModifier = (event.ctrlKey && key.match(/33|34/));
96
125
 
97
126
  // Is this coming from an accordion header?
98
- if (target.classList.contains('c-accordion-trigger')) {
127
+ if (target.classList.contains('c-accordion__trigger')) {
99
128
  // Up/ Down arrow and Control + Page Up/ Page Down keyboard operations
100
129
  // 38 = Up, 40 = Down
101
130
  if (key.match(/38|40/) || ctrlModifier) {
@@ -128,7 +157,7 @@ export function accordion(aria) {
128
157
  });
129
158
 
130
159
  // These are used to style the accordion when one of the buttons has focus
131
- accordion.querySelectorAll('.c-accordion-trigger').forEach(function (trigger) {
160
+ accordion.querySelectorAll('.c-accordion__trigger').forEach(function (trigger) {
132
161
 
133
162
  trigger.addEventListener('focus', function (event) {
134
163
  accordion.classList.add('focus');
@@ -150,8 +179,8 @@ export function accordion(aria) {
150
179
  if (expanded) {
151
180
  expanded.setAttribute('aria-disabled', 'true');
152
181
  //expanded.querySelector('span').innerText = '';
153
- expanded.querySelector('.c-accordion-show').classList.add('hidden');
154
- expanded.querySelector('.c-accordion-hide').classList.add('hidden');
182
+ expanded.querySelector('.c-accordion__show').classList.add('hidden');
183
+ expanded.querySelector('.c-accordion__hide').classList.add('hidden');
155
184
  }
156
185
  }
157
186
 
@@ -5,6 +5,9 @@ export function Collapsible(aria) {
5
5
  this.rootEl = domNode;
6
6
  this.buttonEl = this.rootEl.querySelector('button[aria-expanded]');
7
7
  this.buttonEl.addEventListener('click', this.toggle.bind(this));
8
+ if(domNode.dataset.expanded){
9
+ this.buttonEl.click()
10
+ }
8
11
  }
9
12
 
10
13
  toggle(event) {
@@ -18,16 +21,20 @@ export function Collapsible(aria) {
18
21
  elementCollapsibleContent.classList.toggle('hidden')
19
22
 
20
23
  if(elementCollapsibleShow.classList.contains('hidden')) {
24
+ this.buttonEl.setAttribute('aria-expanded', 'true')
21
25
  elementCollapsibleShow.setAttribute('aria-hidden', 'false')
22
26
  elementCollapsibleHide.setAttribute('aria-hidden', 'true')
27
+ elementCollapsibleContent.setAttribute('aria-hidden', 'false')
23
28
  } else {
29
+ this.buttonEl.setAttribute('aria-expanded', 'false')
24
30
  elementCollapsibleShow.setAttribute('aria-hidden', 'true')
25
31
  elementCollapsibleHide.setAttribute('aria-hidden', 'false')
32
+ elementCollapsibleContent.setAttribute('aria-hidden', 'true')
26
33
  }
27
34
  }
28
35
  }
29
36
 
30
- const collapsible = document.querySelectorAll('.c-collapsible');
37
+ const collapsible = document.querySelectorAll('[data-module="c-collapsible"]');
31
38
  collapsible.forEach((collapsibleElement) => {
32
39
  new Collapsible(collapsibleElement);
33
40
  });
@@ -276,12 +276,24 @@ export function dialog(aria) {
276
276
 
277
277
  aria.Dialog.prototype.addListeners = function () {
278
278
  document.addEventListener('focus', this.trapFocus, true);
279
+ document.addEventListener('click', this.clickOutSide, true)
279
280
  }; // end addListeners
280
281
 
281
282
  aria.Dialog.prototype.removeListeners = function () {
282
283
  document.removeEventListener('focus', this.trapFocus, true);
284
+ document.removeEventListener('click', this.clickOutSide, true);
283
285
  }; // end removeListeners
284
286
 
287
+ aria.Dialog.prototype.clickOutSide = function (event) {
288
+ var currentDialog = aria.getCurrentDialog();
289
+ var getDialogElement = currentDialog.dialogNode;
290
+ const isClickInside = getDialogElement.contains(event.target)
291
+
292
+ if (!isClickInside) {
293
+ currentDialog.close();
294
+ }
295
+ };
296
+
285
297
  aria.Dialog.prototype.trapFocus = function (event) {
286
298
  if (aria.Utils.IgnoreUtilFocusChanges) {
287
299
  return;
@@ -319,4 +331,4 @@ export function dialog(aria) {
319
331
  }; // end replaceDialog
320
332
 
321
333
  }());
322
- }
334
+ }
@@ -0,0 +1,29 @@
1
+ export function notification() {
2
+
3
+ class Notification {
4
+ constructor(domNode) {
5
+ this.rootEl = domNode;
6
+ /*No todas las notificaciones tienen botón de cerrar
7
+ así que comprobamos que el componente contiene el botón.*/
8
+ if(this.rootEl.querySelector('.c-notification-button__close')) {
9
+ this.buttonClose = this.rootEl.querySelector('.c-notification-button__close');
10
+ this.buttonClose.addEventListener('click', this._closeNotification.bind(this));
11
+ }
12
+ }
13
+
14
+ _closeNotification() {
15
+ //Replicamos la transición de alpine con tailwind al cerrar.
16
+ this.rootEl.classList.add('transition-opacity', 'duration-150', 'ease-in-out', 'opacity-0');
17
+ //Añadimos display: none para que el componente "desaparezca del DOM"
18
+ setTimeout(() =>{
19
+ this.rootEl.classList.add('hidden');
20
+ },300)
21
+ }
22
+ }
23
+
24
+ const notifications = document.querySelectorAll('[data-module="c-notification"]');
25
+ notifications.forEach((notificationElement) => {
26
+ new Notification(notificationElement);
27
+ });
28
+
29
+ }
@@ -27,12 +27,14 @@ export function tabs(aria) {
27
27
  if(getClassFromTabs.some(tab => tab.classList.contains('c-tabs__link--is-active'))) {
28
28
  tabs.forEach((tab) => {
29
29
  if(tab.classList.contains('c-tabs__link--is-active')) {
30
+ activateTab(tab, false)
30
31
  addActiveClass(tab)
31
32
  }
32
33
  })
33
34
  } else {
34
35
  tabs.forEach((tab, index) => {
35
36
  if(index === 0) {
37
+ activateTab(tab, false)
36
38
  addActiveClass(tab)
37
39
  }
38
40
  })
@@ -3,21 +3,39 @@ export function Toggle(aria) {
3
3
  class Toggle {
4
4
  constructor(domNode) {
5
5
  this.rootEl = domNode;
6
- this.buttonEl = this.rootEl.querySelector('button[aria-expanded]');
7
-
6
+ this.buttonEl = this.rootEl.querySelector('.c-toggle__button');
8
7
  this.buttonEl.addEventListener('click', this.toggle.bind(this));
9
8
  }
10
9
 
11
10
  toggle(event) {
12
11
  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')
12
+ this.buttonEl.classList.toggle('c-toggle--is-opened')
13
+ target.querySelector('.c-button--is-not-pressed').classList.toggle('hidden')
14
+ target.querySelector('.c-button--is-pressed').classList.toggle('hidden')
15
+
16
+ this.ariaAttribute(target)
17
+ }
18
+
19
+ ariaAttribute(target) {
20
+ if(target.getAttribute('aria-checked')) {
21
+ const toggleIsOpened = target.classList.contains('c-toggle--is-opened') ? true : false
22
+ this.buttonEl.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
+ this.buttonEl.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
+ this.buttonEl.setAttribute('aria-expanded', toggleIsOpened);
33
+ }
16
34
  }
17
35
 
18
36
  }
19
37
 
20
- const toggles = document.querySelectorAll('.c-toggle');
38
+ const toggles = document.querySelectorAll('[data-module="c-toggle"]');
21
39
  toggles.forEach((toggleElement) => {
22
40
  new Toggle(toggleElement);
23
41
  });
@@ -14,6 +14,7 @@ import { Treeitem } from './aria/treeitem.js';
14
14
  import { Tree } from './aria/tree.js';
15
15
  import { Toggle } from './aria/toggle.js';
16
16
  import { Collapsible } from './aria/collapsible.js';
17
+ import { notification } from './aria/notification.js';
17
18
 
18
19
 
19
20
  export function accordionComponent(aria) {
@@ -363,3 +364,6 @@ export function treeComponent(aria) {
363
364
  }
364
365
  }
365
366
 
367
+ export function notificationComponent(aria) {
368
+ notification(aria);
369
+ }
package/src/js/index.js CHANGED
@@ -16,7 +16,8 @@ import {
16
16
  tabsComponent,
17
17
  tooltipComponent,
18
18
  toggleComponent,
19
- treeComponent
19
+ treeComponent,
20
+ notificationComponent
20
21
  } from './desy-html.js';
21
22
 
22
23
  var aria = aria || {};
@@ -34,6 +35,7 @@ tabsComponent(aria);
34
35
  tooltipComponent(aria);
35
36
  toggleComponent(aria);
36
37
  treeComponent(aria);
38
+ notificationComponent(aria);
37
39
 
38
40
  document.querySelectorAll('.c-code-snippet__button').forEach(button => {
39
41
  button.addEventListener('click', (event) => {
@@ -259,6 +259,28 @@
259
259
  ]
260
260
  }
261
261
  },
262
+ {
263
+ "name": "with html in headers",
264
+ "description": "To avoid event problems, use pointer-events-none class in subelements",
265
+ "data": {
266
+ "idPrefix": "accordion-example-pointer-events-none",
267
+ "headingLevel": 3,
268
+ "items": [
269
+ {
270
+ "headerHtml": '<span class="block pointer-events-none">Accordion Item 1</span><span class="block pointer-events-none font-normal">Subelement also receives events</span>',
271
+ "html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>"
272
+ },
273
+ {
274
+ "headerHtml": '<span class="block pointer-events-none">Accordion Item 2</span><span class="block pointer-events-none font-normal">Subelement also receives events</span>',
275
+ "html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>"
276
+ },
277
+ {
278
+ "headerHtml": '<span class="block pointer-events-none">Accordion Item 3</span><span class="block pointer-events-none font-normal">Subelement also receives events</span>',
279
+ "html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>"
280
+ }
281
+ ]
282
+ }
283
+ },
262
284
  {
263
285
  "name": "With classes applied",
264
286
  "description": "Show code to display the classes applied in html",
@@ -23,9 +23,7 @@
23
23
  2. If there are one item opened at init and allowToggle=true, the button text ('Mostrar/Ocultar') only shows 'Ocultar' without changing to 'Mostrar'. It should change to 'Mostrar' when closed.
24
24
  -#}
25
25
  <!-- accordion -->
26
- <div
27
- {%- if params.classes %} class="{{ params.classes }}"{% endif %}
28
- {%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
26
+ <div class="c-accordion {%- if params.classes %} {{ params.classes }}{% endif %}" {%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %} {%- if params.allowToggle == true %} data-allow-toggle{% endif %} {%- if params.allowMultiple == true %} data-allow-multiple{% endif %}>
29
27
  <div class="flex justify-between">
30
28
  {% if params.heading.html or params.heading.text %}
31
29
  {% set headingAttributes %}class="{% if params.heading.classes %}{{ params.heading.classes }}{% else %}c-h2 mb-base{% endif %}"{% endset %}
@@ -46,12 +44,12 @@
46
44
  {% endif %}
47
45
  {% if params.showControl %}
48
46
  <button
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">
47
+ 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">
50
48
  Mostrar todo
51
49
  </button>
52
50
  {% endif %}
53
51
  </div>
54
- <div class="c-accordion" {%- if params.allowToggle == true %} data-allow-toggle{% endif %} {%- if params.allowMultiple == true %} data-allow-multiple{% endif %}>
52
+ <div>
55
53
  {% for item in params.items %}
56
54
  {% if item %}
57
55
  {%- if item.id -%}
@@ -69,7 +67,7 @@
69
67
  {% set insideContent %}
70
68
  <button
71
69
  id="{{ id }}-title"
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 %}"
70
+ 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 %}"
73
71
  aria-controls="{{ id }}"
74
72
  {% if item.open %}
75
73
  aria-expanded = "true"
@@ -81,14 +79,14 @@
81
79
  {{ item.headerHtml | safe if item.headerHtml else item.headerText }}
82
80
  <span
83
81
  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">
84
- <span class="c-accordion-show {%- if item.open %} hidden{%else%}{%endif%} {%- if item.show.classes %} {{ item.show.classes }}{%endif%}">
82
+ <span class="c-accordion__show {%- if item.open %} hidden{%else%}{%endif%} {%- if item.show.classes %} {{ item.show.classes }}{%endif%}">
85
83
  {% if item.show %}
86
84
  {{ item.show.html | safe if item.show.html else item.show.text }}
87
85
  {% else %}
88
86
  Mostrar
89
87
  {% endif %}
90
88
  </span>
91
- <span class="c-accordion-hide {%- if item.open %}{%else%} hidden{%endif%} {%- if item.hide.classes %} {{ item.hide.classes }}{%endif%}">
89
+ <span class="c-accordion__hide {%- if item.open %}{%else%} hidden{%endif%} {%- if item.hide.classes %} {{ item.hide.classes }}{%endif%}">
92
90
  {% if item.hide %}
93
91
  {{ item.hide.html | safe if item.hide.html else item.hide.text }}
94
92
  {% else %}
@@ -119,7 +117,7 @@
119
117
  {%- if id %}
120
118
  id="{{ id }}"
121
119
  {% endif %}
122
- class="c-accordion-panel {%- if item.classes %} {{ item.classes }}{% endif %}"
120
+ class="c-accordion__panel {%- if item.classes %} {{ item.classes }}{% endif %}"
123
121
  {%- for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>
124
122
  {{ item.html | safe if item.html else item.text }}
125
123
  </div>
@@ -87,6 +87,7 @@
87
87
  "idPrefix": "allowtoggle-example",
88
88
  "headingLevel": 3,
89
89
  "allowToggle": true,
90
+ "showControl": false,
90
91
  "items": [
91
92
  {
92
93
  "headerText": "Accordion Item 1",
@@ -294,6 +295,28 @@
294
295
  ]
295
296
  }
296
297
  },
298
+ {
299
+ "name": "with html in headers",
300
+ "description": "To avoid event problems, use pointer-events-none class in subelements",
301
+ "data": {
302
+ "idPrefix": "accordion-example-pointer-events-none",
303
+ "headingLevel": 3,
304
+ "items": [
305
+ {
306
+ "headerHtml": '<span class="block pointer-events-none">Accordion Item 1</span><span class="block pointer-events-none font-normal">Subelement also receives events</span>',
307
+ "html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>"
308
+ },
309
+ {
310
+ "headerHtml": '<span class="block pointer-events-none">Accordion Item 2</span><span class="block pointer-events-none font-normal">Subelement also receives events</span>',
311
+ "html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>"
312
+ },
313
+ {
314
+ "headerHtml": '<span class="block pointer-events-none">Accordion Item 3</span><span class="block pointer-events-none font-normal">Subelement also receives events</span>',
315
+ "html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>"
316
+ }
317
+ ]
318
+ }
319
+ },
297
320
  {
298
321
  "name": "With classes applied",
299
322
  "description": "Show code to display the classes applied in html",
@@ -23,9 +23,8 @@
23
23
  2. If there are one item opened at init and allowToggle=true, the button text ('Mostrar/Ocultar') only shows 'Ocultar' without changing to 'Mostrar'. It should change to 'Mostrar' when closed.
24
24
  -#}
25
25
  <!-- accordion-history -->
26
- <div
27
- {%- if params.classes %} class="{{ params.classes }}"{% endif %}
28
- {%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
26
+ <div class="c-accordion {%- if params.classes %} {{ params.classes }} {% endif %}"
27
+ {%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %} {%- if params.allowToggle == true %} data-allow-toggle{% endif %} {%- if params.allowMultiple == true %} data-allow-multiple{% endif %}>
29
28
  <div class="flex justify-between">
30
29
  {% if params.heading.html or params.heading.text %}
31
30
  {% set headingAttributes %}class="{% if params.heading.classes %}{{ params.heading.classes }}{% else %}c-h2 mb-base{% endif %}"{% endset %}
@@ -46,12 +45,12 @@
46
45
  {% endif %}
47
46
  {% if params.showControl %}
48
47
  <button
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">
48
+ 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">
50
49
  Mostrar todo
51
50
  </button>
52
51
  {% endif %}
53
52
  </div>
54
- <div class="Accordion pl-lg" {%- if params.allowToggle == true %} data-allow-toggle{% endif %} {%- if params.allowMultiple == true %} data-allow-multiple{% endif %}>
53
+ <div class="pl-lg">
55
54
  {% for item in params.items %}
56
55
  {% if item %}
57
56
  {%- if item.id -%}
@@ -69,7 +68,7 @@
69
68
  {% set insideContent %}
70
69
  <button
71
70
  id="{{ id }}-title"
72
- class="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 %}"
71
+ 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 %}"
73
72
  aria-controls="{{ id }}"
74
73
  {% if item.open %}
75
74
  aria-expanded = "true"
@@ -92,14 +91,14 @@
92
91
  {% endif %}
93
92
  <span
94
93
  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">
95
- <span class="Accordion-show {%- if item.open %} hidden{%else%}{%endif%} {%- if item.show.classes %} {{ item.show.classes }}{%endif%}">
94
+ <span class="c-accordion__show {%- if item.open %} hidden{%else%}{%endif%} {%- if item.show.classes %} {{ item.show.classes }}{%endif%}">
96
95
  {% if item.show %}
97
96
  {{ item.show.html | safe if item.show.html else item.show.text }}
98
97
  {% else %}
99
98
  Mostrar
100
99
  {% endif %}
101
100
  </span>
102
- <span class="Accordion-hide {%- if item.open %}{%else%} hidden{%endif%} {%- if item.hide.classes %} {{ item.hide.classes }}{%endif%}">
101
+ <span class="c-accordion__hide {%- if item.open %}{%else%} hidden{%endif%} {%- if item.hide.classes %} {{ item.hide.classes }}{%endif%}">
103
102
  {% if item.hide %}
104
103
  {{ item.hide.html | safe if item.hide.html else item.hide.text }}
105
104
  {% else %}
@@ -167,7 +166,7 @@
167
166
  {%- if id %}
168
167
  id="{{ id }}"
169
168
  {% endif %}
170
- class="Accordion-panel relative {%- if item.classes %} {{ item.classes }}{% endif %}"
169
+ class="c-accordion__panel relative {%- if item.classes %} {{ item.classes }}{% endif %}"
171
170
  {%- for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>
172
171
  {% if not loop.last %}
173
172
  {% if item.status == 'current' %}
@@ -1,5 +1,5 @@
1
1
  <!-- collapsible -->
2
- <div class="{%- if params.classes %} {{ params.classes }}{% else -%} -my-px py-sm border-t border-b border-neutral-base{% endif %} c-collapsible" {%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
2
+ <div class="{%- if params.classes %} {{ params.classes }}{% else -%} -my-px py-sm border-t border-b border-neutral-base{% endif %} c-collapsible" {%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %} {% if params.open %} data-expanded="true" {% endif %} data-module="c-collapsible">
3
3
  <button aria-expanded="false" {%- if params.id %} id="{{params.id}}-title"{% endif %} class="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 params.id %} aria-controls="{{params.id}}"{% endif %}>{{ params.headerHtml | safe if params.headerHtml else params.headerText }}
4
4
  <span class="c-collapsible__show absolute inset-y-0 right-0 py-sm font-normal text-sm text-neutral-dark underline group-focus:text-black pointer-events-none " aria-hidden="false">Mostrar</span>
5
5
  <span class="c-collapsible__hide absolute inset-y-0 right-0 py-sm font-normal text-sm text-neutral-dark underline group-focus:text-black pointer-events-none hidden" aria-hidden="true">Ocultar</span>
@@ -18,8 +18,7 @@
18
18
  }
19
19
  }
20
20
  ],
21
- "isDismissible": true,
22
- "classes": "mt-2xl"
21
+ "isDismissible": true
23
22
  }) }}
24
23
  {% endset %}
25
24
 
@@ -46,8 +45,7 @@
46
45
  }
47
46
  }
48
47
  ],
49
- "isDismissible": true,
50
- "classes": "mt-2xl"
48
+ "isDismissible": true
51
49
  }) }}
52
50
  {% endset %}
53
51
 
@@ -13,7 +13,7 @@
13
13
  @apply hidden fixed overflow-y-auto inset-0 bg-black bg-opacity-50 z-50;
14
14
 
15
15
  &.active {
16
- @apply flex justify-center content-center;
16
+ @apply grid h-screen place-items-center;
17
17
  }
18
18
  }
19
19
  }
@@ -369,6 +369,25 @@
369
369
  "caller": exampleOffcanvas
370
370
  }
371
371
  },
372
+ {
373
+ "name": "con offcanvas y mobileTitle",
374
+ "description": "Menu mobile que sólo se muestra en anchuras pequeñas y que permite insertar dentro cualquier contenido con Nunjuks caller y título que sólo se muestra en mobile",
375
+ "data": {
376
+ "homepageUrl": "/",
377
+ "mobileTitle": {
378
+ "text": "Carpeta del gestor"
379
+ },
380
+ "subnav": {
381
+ "text": "Carpeta del gestor"
382
+ },
383
+ "offcanvas": {
384
+ "text": "Menú",
385
+ "textClose": "Cerrar menu",
386
+ "labelledId": "offcanvas-title"
387
+ },
388
+ "caller": exampleOffcanvas
389
+ }
390
+ },
372
391
  {
373
392
  "name": "con subnav text",
374
393
  "description": "Utilizar para mostrar el nombre de la app actual. Si no se proporcionan items en subnav, el texto será simple sin un dropdown.",