desy-html 8.3.1 → 8.4.1

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 (74) hide show
  1. package/docs/_include.template-header.njk +140 -66
  2. package/docs/catalogo.html +1 -1
  3. package/docs/componentes.html +1 -1
  4. package/docs/estilos.html +1 -1
  5. package/docs/examples-accordion-history.html +3 -1
  6. package/docs/examples-accordion.html +3 -1
  7. package/docs/examples-alert.html +3 -1
  8. package/docs/examples-breadcrumbs.html +3 -1
  9. package/docs/examples-button-loader.html +3 -1
  10. package/docs/examples-button.html +3 -1
  11. package/docs/examples-card.html +3 -1
  12. package/docs/examples-character-count.html +3 -1
  13. package/docs/examples-checkboxes.html +3 -1
  14. package/docs/examples-collapsible.html +3 -1
  15. package/docs/examples-date-input.html +3 -1
  16. package/docs/examples-description-list.html +3 -1
  17. package/docs/examples-details.html +3 -1
  18. package/docs/examples-dialog.html +3 -1
  19. package/docs/examples-dropdown.html +3 -1
  20. package/docs/examples-error-message.html +3 -1
  21. package/docs/examples-error-summary.html +3 -1
  22. package/docs/examples-fieldset.html +3 -1
  23. package/docs/examples-file-upload.html +3 -1
  24. package/docs/examples-footer.html +3 -1
  25. package/docs/examples-header-advanced.html +3 -1
  26. package/docs/examples-header-mini.html +3 -1
  27. package/docs/examples-header.html +3 -1
  28. package/docs/examples-hint.html +3 -1
  29. package/docs/examples-input-group.html +3 -1
  30. package/docs/examples-input.html +3 -1
  31. package/docs/examples-item.html +3 -1
  32. package/docs/examples-label.html +3 -1
  33. package/docs/examples-links-list.html +3 -1
  34. package/docs/examples-listbox.html +3 -1
  35. package/docs/examples-media-object.html +3 -1
  36. package/docs/examples-menu-horizontal.html +3 -1
  37. package/docs/examples-menu-navigation.html +3 -1
  38. package/docs/examples-menu-vertical.html +3 -1
  39. package/docs/examples-menubar.html +3 -1
  40. package/docs/examples-modal.html +3 -1
  41. package/docs/examples-nav.html +3 -1
  42. package/docs/examples-notification.html +3 -1
  43. package/docs/examples-pagination.html +3 -1
  44. package/docs/examples-pill.html +3 -1
  45. package/docs/examples-radios.html +3 -1
  46. package/docs/examples-searchbar.html +3 -1
  47. package/docs/examples-select.html +3 -1
  48. package/docs/examples-skip-link.html +3 -1
  49. package/docs/examples-spinner.html +3 -1
  50. package/docs/examples-status-item.html +3 -1
  51. package/docs/examples-status.html +3 -1
  52. package/docs/examples-table-advanced.html +3 -1
  53. package/docs/examples-table.html +3 -1
  54. package/docs/examples-tabs.html +3 -1
  55. package/docs/examples-textarea.html +3 -1
  56. package/docs/examples-toggle.html +3 -1
  57. package/docs/examples-tooltip.html +3 -1
  58. package/docs/examples-tree.html +3 -1
  59. package/docs/index.html +11 -1
  60. package/docs/plantillas.html +1 -1
  61. package/package.json +1 -1
  62. package/src/js/aria/MenuVertical.js +2 -2
  63. package/src/js/aria/Nav.js +55 -0
  64. package/src/js/desy-html.js +37 -51
  65. package/src/js/index.js +3 -1
  66. package/src/templates/components/header/_examples.header.njk +1 -1
  67. package/src/templates/components/header-advanced/_examples.header-advanced.njk +1 -1
  68. package/src/templates/components/links-list/_template.links-list.njk +2 -2
  69. package/src/templates/components/menu-horizontal/_styles.menu-horizontal.css +15 -0
  70. package/src/templates/components/menu-horizontal/_template.menu-horizontal.njk +4 -3
  71. package/src/templates/components/menu-navigation/_template.menu-navigation.njk +3 -3
  72. package/src/templates/components/menu-vertical/_template.menu-vertical.njk +4 -4
  73. package/src/templates/components/nav/_examples.nav.njk +3 -1
  74. package/src/templates/components/nav/_template.nav.njk +7 -9
@@ -1,5 +1,7 @@
1
1
  {% set title = "Header mini. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Header mini" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/header-mini/_examples.header-mini.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Header. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Header" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/header/_examples.header.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Hint. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Hint" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/hint/_examples.hint.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Input group. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Input group" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/input-group/_examples.input-group.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Input. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Input" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/input/_examples.input.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Item. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Item" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/item/_examples.item.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Label. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Label" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/label/_examples.label.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Links list. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Links list" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/links-list/_examples.links-list.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Listbox. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Listbox" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/listbox/_examples.listbox.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Media object. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Media object" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/media-object/_examples.media-object.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Menu horizontal. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Menu horizontal" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/menu-horizontal/_examples.menu-horizontal.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Menu navigation. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Menu navigation" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/menu-navigation/_examples.menu-navigation.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Menu vertical. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Menu vertical" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/menu-vertical/_examples.menu-vertical.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Menubar. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Menubar" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/menubar/_examples.menubar.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Modal. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Modal" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/modal/_examples.modal.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Nav. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Nav" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/nav/_examples.nav.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Notification. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Notification" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/notification/_examples.notification.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Pagination. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Pagination" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/pagination/_examples.pagination.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Pill. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Pill" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/pill/_examples.pill.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Radios. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Radios" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/radios/_examples.radios.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Searchbar. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Searchbar" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/searchbar/_examples.searchbar.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Select. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Select" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/select/_examples.select.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Skip link. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Skip link" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/skip-link/_examples.skip-link.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Spinner. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Spinner" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/spinner/_examples.spinner.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Status item. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Status item" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/status-item/_examples.status-item.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Status. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Status" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/status/_examples.status.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Table advanced. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Table advanced" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/table-advanced/_examples.table-advanced.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Table. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Table" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/table/_examples.table.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Tabs. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Tabs" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/tabs/_examples.tabs.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Textarea. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Textarea" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/textarea/_examples.textarea.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Toggle. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Toggle" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/toggle/_examples.toggle.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Tooltip. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Tooltip" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/tooltip/_examples.tooltip.njk" as exampleData %}
@@ -1,5 +1,7 @@
1
1
  {% set title = "Tree. Componente, parámetros y ejemplos. Documentación de desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-4" %}
2
+
3
+ {% set activePage = "page-componentes" %}
4
+ {% set activeComponent = "Tree" %}
3
5
  {% extends "_template.examples.njk" %}
4
6
  {% block contentBlock %}
5
7
  {% import "components/tree/_examples.tree.njk" as exampleData %}
package/docs/index.html CHANGED
@@ -1,6 +1,6 @@
1
1
  {% set title = "Desy. Sistema de diseño para aplicaciones web. Gobierno de Aragón" %}
2
2
  {% set description = "Documentación y librería desy-html para implementarlo en HTML, CSS y Javascript con un paquete NPM." %}
3
- {% set activeSection = "header-nav-item-1" %}
3
+ {% set activePage = "page-inicio" %}
4
4
  {% extends "_template.default.njk" %}
5
5
  {% block contentBlock %}
6
6
 
@@ -38,6 +38,16 @@
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.4.1</h3>
42
+ <ul class="text-sm">
43
+ <li>Active items are font-bold now in all components.</li>
44
+ <li>Minor improvements.</li>
45
+ </ul>
46
+ <h3>v.8.4.0</h3>
47
+ <ul class="text-sm">
48
+ <li>Added global function to select an item in Nav.</li>
49
+ <li>Docs now show the active section in offcanvas menus.</li>
50
+ </ul>
41
51
  <h3>v.8.3.1</h3>
42
52
  <ul class="text-sm">
43
53
  <li>Minor fixes.</li>
@@ -1,5 +1,5 @@
1
1
  {% set title = "Plantillas para desy-html. Gobierno de Aragón" %}
2
- {% set activeSection = "header-nav-item-5" %}
2
+ {% set activePage = "page-plantillas" %}
3
3
  {% extends "_template.default.njk" %}
4
4
 
5
5
  {% block contentBlock %}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "desy-html",
3
- "version": "8.3.1",
3
+ "version": "8.4.1",
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)",
@@ -25,8 +25,8 @@ export function MenuVertical(aria) {
25
25
  };
26
26
 
27
27
  aria.MenuVertical.prototype.wrapActiveElement = function (elementActive) {
28
- elementActive.setAttribute('aria-current', 'true');
29
- elementActive.innerHTML = `<strong>${elementActive.textContent}</strong>`;
28
+ elementActive.setAttribute('aria-current', 'page');
29
+ elementActive.innerHTML = `<strong class="font-bold">${elementActive.textContent}</strong>`;
30
30
  };
31
31
 
32
32
  aria.MenuVertical.prototype.deactivateElement = function (elementDeactivated) {
@@ -0,0 +1,55 @@
1
+ export function Nav(aria) {
2
+ (function () {
3
+ aria.Nav = function (domNode) {
4
+ this.domNode = domNode;
5
+ };
6
+
7
+ aria.Nav.prototype.init = function () {
8
+ this.valueActive = this.domNode.dataset.menuActive;
9
+ if (this.valueActive) {
10
+ this.activateElement(this.valueActive);
11
+ }
12
+ };
13
+
14
+ aria.Nav.prototype.activateElement = function (elementActive) {
15
+ this.domNode.querySelectorAll('li').forEach((element) => {
16
+ const getLink = element.querySelector('a') || element.querySelector('span');
17
+ if (getLink) {
18
+ if (getLink.id === elementActive) {
19
+ this.wrapActiveElement(getLink);
20
+ } else {
21
+ this.deactivateElement(getLink);
22
+ }
23
+ }
24
+ });
25
+ };
26
+
27
+ aria.Nav.prototype.wrapActiveElement = function (elementActive) {
28
+ elementActive.setAttribute('aria-current', 'page');
29
+ elementActive.innerHTML = `<strong class="font-bold">${elementActive.textContent}</strong>`;
30
+ };
31
+
32
+ aria.Nav.prototype.deactivateElement = function (elementDeactivated) {
33
+ elementDeactivated.removeAttribute('aria-current');
34
+ elementDeactivated.innerHTML = elementDeactivated.textContent;
35
+ };
36
+
37
+ window.activateItemNav = function (menuId, activeItemId) {
38
+ const menu = document.getElementById(menuId);
39
+ if (menu) {
40
+ const activeItem = document.querySelector(`#${menuId} #${activeItemId}`);
41
+ if (activeItem) {
42
+ const menuInstance = new aria.Nav(menu);
43
+ menuInstance.activateElement(activeItemId);
44
+ return [menu, activeItem];
45
+ } else {
46
+ console.log('There is no element with this id in the menu.');
47
+ return null;
48
+ }
49
+ } else {
50
+ console.log('There is no menu with this id in the document.');
51
+ return null;
52
+ }
53
+ };
54
+ }());
55
+ }
@@ -19,6 +19,7 @@ import { RadioButton } from './aria/radioButton.js';
19
19
  import { CheckBox } from './aria/checkBoxes.js';
20
20
  import { MenuVertical } from './aria/MenuVertical.js';
21
21
  import { HeaderNavigation } from './aria/HeaderNavigation.js';
22
+ import { Nav } from './aria/Nav.js';
22
23
 
23
24
 
24
25
  export function accordionComponent(aria) {
@@ -220,53 +221,37 @@ export function menubarComponent(aria) {
220
221
  PopupMenuAction(aria);
221
222
  MenubarItemAction(aria);
222
223
  MenubarAction(aria);
223
- const modules = document.querySelectorAll('[data-module]');
224
- for (const item in modules) if (modules.hasOwnProperty(item)) {
225
- const moduleValue = modules[item].getAttribute('data-module');
226
-
227
- if (moduleValue == 'c-menubar'){
228
- const menubar = new aria.MenubarAction(modules[item]);
229
- menubar.init(null);
230
- }
231
- }
224
+ const modules = document.querySelectorAll('[data-module="c-menubar"]');
225
+ [...modules].forEach((module) => {
226
+ const menubar = new aria.MenubarAction(module);
227
+ menubar.init(null);
228
+ });
232
229
  }
233
230
 
234
231
  export function menuNavigationComponent(aria) {
235
232
  DisclosureNav(aria);
236
- const modules = document.querySelectorAll('[data-module]');
237
- for (const item in modules) if (modules.hasOwnProperty(item)) {
238
- const moduleValue = modules[item].getAttribute('data-module');
239
-
240
- if (moduleValue == 'c-menu-navigation'){
241
- const menuNavigation = new aria.DisclosureNav(modules[item]);
242
- menuNavigation.init();
243
- }
244
- }
233
+ const modules = document.querySelectorAll('[data-module="c-menu-navigation"]');
234
+ [...modules].forEach((module) => {
235
+ const menuNavigation = new aria.DisclosureNav(module);
236
+ menuNavigation.init();
237
+ });
245
238
  }
246
239
 
247
240
  export function tableAdvancedComponent(aria) {
248
241
  utils(aria);
249
242
  dataGrid(aria);
250
- const modules = document.querySelectorAll('[data-module]');
251
- for (const item in modules) if (modules.hasOwnProperty(item)) {
252
- const moduleValue = modules[item].getAttribute('data-module');
253
-
254
- if (moduleValue == 'c-table-advanced'){
255
- const grid = new aria.Grid(modules[item]);
256
- }
257
- }
243
+ const modules = document.querySelectorAll('[data-module="c-table-advanced"]');
244
+ [...modules].forEach((module) => {
245
+ const grid = new aria.Grid(module);
246
+ });
258
247
  }
259
248
 
260
249
  export function tabsComponent(aria) {
261
250
  tabs(aria);
262
- const modules = document.querySelectorAll('[data-module]');
263
- for (const item in modules) if (modules.hasOwnProperty(item)) {
264
- const moduleValue = modules[item].getAttribute('data-module');
265
-
266
- if (moduleValue == 'c-tabs'){
267
- aria.tabsInit(modules[item]);
268
- }
269
- }
251
+ const modules = document.querySelectorAll('[data-module="c-tabs"]');
252
+ [...modules].forEach((module) => {
253
+ aria.tabsInit(module);
254
+ });
270
255
  }
271
256
 
272
257
  export function tooltipComponent(aria) {
@@ -382,26 +367,27 @@ export function checkBoxComponent(aria) {
382
367
 
383
368
  export function MenuVerticalComponent(aria) {
384
369
  MenuVertical(aria);
385
- const modules = document.querySelectorAll('[data-module]');
386
- for (const item in modules) if (modules.hasOwnProperty(item)) {
387
- const moduleValue = modules[item].getAttribute('data-module');
388
-
389
- if (moduleValue == 'c-menu-vertical'){
390
- const menuVertical = new aria.MenuVertical(modules[item]);
391
- menuVertical.init(null);
392
- }
393
- }
370
+ const modules = document.querySelectorAll('[data-module="c-menu-vertical"]');
371
+ [...modules].forEach((module) => {
372
+ const menuVertical = new aria.MenuVertical(module);
373
+ menuVertical.init(null);
374
+ });
394
375
  }
395
376
 
396
377
  export function HeaderNavigationComponent(aria) {
397
378
  HeaderNavigation(aria);
398
- const modules = document.querySelectorAll('[data-module]');
399
- for (const item in modules) if (modules.hasOwnProperty(item)) {
400
- const moduleValue = modules[item].getAttribute('data-module');
379
+ const modules = document.querySelectorAll('[data-module="c-header-navigation"]');
380
+ [...modules].forEach((module) => {
381
+ const headerNavigation = new aria.HeaderNavigation(module);
382
+ headerNavigation.init(null);
383
+ });
384
+ }
401
385
 
402
- if (moduleValue == 'c-header-navigation'){
403
- const headerNavigation = new aria.HeaderNavigation(modules[item]);
404
- headerNavigation.init(null);
405
- }
406
- }
386
+ export function NavComponent(aria) {
387
+ Nav(aria);
388
+ const modules = document.querySelectorAll('[data-module="c-nav"]');
389
+ [...modules].forEach((module) => {
390
+ const nav = new aria.Nav(module);
391
+ nav.init(null);
392
+ });
407
393
  }
package/src/js/index.js CHANGED
@@ -21,7 +21,8 @@ import {
21
21
  radioButtonComponent,
22
22
  checkBoxComponent,
23
23
  MenuVerticalComponent,
24
- HeaderNavigationComponent
24
+ HeaderNavigationComponent,
25
+ NavComponent
25
26
  } from './desy-html.js';
26
27
 
27
28
  var aria = aria || {};
@@ -44,6 +45,7 @@ radioButtonComponent(aria);
44
45
  checkBoxComponent(aria);
45
46
  MenuVerticalComponent(aria);
46
47
  HeaderNavigationComponent(aria);
48
+ NavComponent(aria);
47
49
 
48
50
  //Using the browser API to copy code to the clipboard
49
51
  const copyButtons = document.querySelectorAll('[data-module = "c-button-copy"]');
@@ -200,7 +200,7 @@
200
200
  {% set examples = [
201
201
  {
202
202
  "name": "por defecto",
203
- "description": 'El menú por defecto de las aplicaciones de la administración digital tiene un logo que enlaza a la página de inicio y un menu principal de navegación. El menu de navegación se oculta en mobile si no se añaden clases a navigation. El logotipo es simple, sin letras, si la app está diseñada para funcionarios. Junto al logo hay un texto que da nombre a la app en la que estamos. Puedes usar con javascript la función global <code>activateItemHeaderNavigation(elementMenu, idItemSeleccionado)</code> para seleccionar un item de un menú, usando sus ids. Ej: Abre la consola del navegador y escribe <code>activateItemHeaderNavigation("header-nav-item", "header-nav-item-3")</code> para desactivar el item actual y activar el tercer item del header de la página.',
203
+ "description": 'El menú por defecto de las aplicaciones de la administración digital tiene un logo que enlaza a la página de inicio y un menu principal de navegación. El menu de navegación se oculta en mobile si no se añaden clases a navigation. El logotipo es simple, sin letras, si la app está diseñada para funcionarios. Junto al logo hay un texto que da nombre a la app en la que estamos. Puedes usar con javascript la función global <code>activateItemHeaderNavigation(elementMenu, idItemSeleccionado)</code> para seleccionar un item de un menú, usando sus ids. Ej: Abre la consola del navegador y escribe <code>activateItemHeaderNavigation("header-nav-item", "page-catalogo")</code> para desactivar el item actual y activar el tercer item del header de la página.',
204
204
  "data": {
205
205
  "homepageUrl": "/",
206
206
  "idPrefix": "mi-menu",
@@ -627,7 +627,7 @@
627
627
  {% set examples = [
628
628
  {
629
629
  "name": "por defecto",
630
- "description": 'Esta es la cabecera por defecto para sitios web de submarcas del Gobierno de Aragón. Tiene un título que enlaza a la página de inicio. Puedes usar con javascript la función global <code>activateItemHeaderNavigation(elementMenu, idItemSeleccionado)</code> para seleccionar un item de un menú, usando sus ids. Ej: Abre la consola del navegador y escribe <code>activateItemHeaderNavigation("header-nav-item", "header-nav-item-3")</code> para desactivar el item actual y activar el tercer item del header de la página.',
630
+ "description": 'Esta es la cabecera por defecto para sitios web de submarcas del Gobierno de Aragón. Tiene un título que enlaza a la página de inicio. Puedes usar con javascript la función global <code>activateItemHeaderNavigation(elementMenu, idItemSeleccionado)</code> para seleccionar un item de un menú, usando sus ids. Ej: Abre la consola del navegador y escribe <code>activateItemHeaderNavigation("header-nav-item", "page-catalogo")</code> para desactivar el item actual y activar el tercer item del header de la página.',
631
631
  "data": {
632
632
  "title": {
633
633
  "homepageUrl": "/",
@@ -31,7 +31,7 @@
31
31
  {% endif %}
32
32
  <div class="flex-1">
33
33
  {% if item.active %}
34
- <strong>{{ item.html | safe if item.html else item.text }}</strong>
34
+ <strong class="font-bold">{{ item.html | safe if item.html else item.text }}</strong>
35
35
  {% else %}
36
36
  {{ item.html | safe if item.html else item.text }}
37
37
  {% endif %}
@@ -51,7 +51,7 @@
51
51
  {% endif %}
52
52
  <div class="flex-1">
53
53
  {% if item.active %}
54
- <strong>{{ item.html | safe if item.html else item.text }}</strong>
54
+ <strong class="font-bold">{{ item.html | safe if item.html else item.text }}</strong>
55
55
  {% else %}
56
56
  {{ item.html | safe if item.html else item.text }}
57
57
  {% endif %}