mypgs 1.3.4 → 1.3.7

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 (92) hide show
  1. package/{AI_GUIDELINES.md → AGENTS.md} +18 -16
  2. package/README.md +8 -172
  3. package/assets/javascript/patterns/_header.js +77 -79
  4. package/assets/scss/base/_body.scss +2 -0
  5. package/assets/scss/base/_color.scss +2 -0
  6. package/assets/scss/base/_general.scss +2 -0
  7. package/assets/scss/base/_heading.scss +2 -0
  8. package/assets/scss/base/_variables.scss +2 -0
  9. package/assets/scss/components/_accordion.scss +2 -0
  10. package/assets/scss/components/_button.scss +2 -0
  11. package/assets/scss/components/_form.scss +2 -0
  12. package/assets/scss/components/_logo.scss +2 -0
  13. package/assets/scss/components/_menu.scss +2 -0
  14. package/assets/scss/components/_modals.scss +2 -0
  15. package/assets/scss/components/_notification.scss +2 -0
  16. package/assets/scss/components/_searchbar.scss +2 -0
  17. package/assets/scss/components/_slides.scss +2 -0
  18. package/assets/scss/components/_stepTabs.scss +2 -0
  19. package/assets/scss/components/_steps.scss +2 -0
  20. package/assets/scss/index.scss +32 -32
  21. package/assets/scss/layout/_flex.scss +2 -0
  22. package/assets/scss/layout/_grid.scss +2 -0
  23. package/assets/scss/layout/_layout.scss +2 -0
  24. package/assets/scss/layout/_pageShell.scss +2 -0
  25. package/assets/scss/mixin/_mx-base.scss +5 -2
  26. package/assets/scss/mixin/_mx-card.scss +5 -1
  27. package/assets/scss/mixin/_mx-form-addon.scss +4 -1
  28. package/assets/scss/mixin/_mx-form.scss +6 -3
  29. package/assets/scss/mixin/_mx-responsive.scss +14 -11
  30. package/assets/scss/mixin/_settings.scss +31 -0
  31. package/assets/scss/mixin/mixin.scss +11 -35
  32. package/assets/scss/patterns/_cookieConsent.scss +3 -1
  33. package/assets/scss/patterns/_footer.scss +2 -0
  34. package/assets/scss/patterns/_header.scss +12 -4
  35. package/dist/css/index.css +75 -25
  36. package/dist/css/index.css.map +1 -1
  37. package/dist/css/index.min.css +1 -1
  38. package/dist/javascript/index.js +77 -78
  39. package/dist/javascript/index.js.map +1 -1
  40. package/dist/javascript/index.min.js +1 -1
  41. package/package.json +1 -1
  42. package/templates/{components → html/components}/searchbar.html +1 -1
  43. package/templates/{patterns → html/patterns}/header.html +2 -2
  44. package/templates/react/components/accordion.jsx +27 -0
  45. package/templates/react/components/breadcumbs.jsx +27 -0
  46. package/templates/react/components/button.jsx +33 -0
  47. package/templates/react/components/card.jsx +27 -0
  48. package/templates/react/components/dropdown.jsx +29 -0
  49. package/templates/react/components/form.jsx +30 -0
  50. package/templates/react/components/logo.jsx +14 -0
  51. package/templates/react/components/menu.jsx +37 -0
  52. package/templates/react/components/modal.jsx +84 -0
  53. package/templates/react/components/notification.jsx +31 -0
  54. package/templates/react/components/searchbar.jsx +34 -0
  55. package/templates/react/components/slides.jsx +25 -0
  56. package/templates/react/components/stepTabs.jsx +40 -0
  57. package/templates/react/components/steps.jsx +21 -0
  58. package/templates/react/components/table.jsx +28 -0
  59. package/templates/react/components/tooltip.jsx +12 -0
  60. package/templates/react/layout/body.jsx +7 -0
  61. package/templates/react/layout/flex.jsx +36 -0
  62. package/templates/react/layout/grid.jsx +36 -0
  63. package/templates/react/layout/pageShell.jsx +48 -0
  64. package/templates/react/layout/section.jsx +44 -0
  65. package/templates/react/patterns/cookieConsent.jsx +62 -0
  66. package/templates/react/patterns/footer.jsx +40 -0
  67. package/templates/react/patterns/header.jsx +62 -0
  68. /package/templates/{components → html/components}/accordion.html +0 -0
  69. /package/templates/{components → html/components}/breadcumbs.html +0 -0
  70. /package/templates/{components → html/components}/button.html +0 -0
  71. /package/templates/{components → html/components}/card.html +0 -0
  72. /package/templates/{components → html/components}/dropdown.html +0 -0
  73. /package/templates/{components → html/components}/form.html +0 -0
  74. /package/templates/{components → html/components}/logo.html +0 -0
  75. /package/templates/{components → html/components}/menu.html +0 -0
  76. /package/templates/{components → html/components}/modal.html +0 -0
  77. /package/templates/{components → html/components}/notification.html +0 -0
  78. /package/templates/{components → html/components}/slides.html +0 -0
  79. /package/templates/{components → html/components}/stepTabs.html +0 -0
  80. /package/templates/{components → html/components}/steps.html +0 -0
  81. /package/templates/{components → html/components}/table.html +0 -0
  82. /package/templates/{components → html/components}/tooltip.html +0 -0
  83. /package/templates/{demo.css → html/demo.css} +0 -0
  84. /package/templates/{demo.html → html/demo.html} +0 -0
  85. /package/templates/{demo.js → html/demo.js} +0 -0
  86. /package/templates/{layout → html/layout}/body.html +0 -0
  87. /package/templates/{layout → html/layout}/flex.html +0 -0
  88. /package/templates/{layout → html/layout}/grid.html +0 -0
  89. /package/templates/{layout → html/layout}/pageShell.html +0 -0
  90. /package/templates/{layout → html/layout}/section.html +0 -0
  91. /package/templates/{patterns → html/patterns}/cookieConsent.html +0 -0
  92. /package/templates/{patterns → html/patterns}/footer.html +0 -0
@@ -62,16 +62,16 @@ Files analyzed:
62
62
  - `assets/scss/components/*`
63
63
  - `assets/scss/patterns/*`
64
64
  - `assets/scss/mixin/*`
65
- - `templates/components/*`
66
- - `templates/layout/*`
67
- - `templates/patterns/*`
65
+ - `templates/html/components/*`
66
+ - `templates/html/layout/*`
67
+ - `templates/html/patterns/*`
68
68
 
69
69
  Patterns found:
70
70
 
71
71
  - `pgs` is the main attribute: tokens are separated by spaces, for example `pgs="button modal-button"`.
72
72
  - `assets/scss/index.scss` imports base, layout, components, and patterns; layouts/components/patterns are almost all scoped under `[pgs~=initP]`.
73
- - The main markup must enable the library with `htmlBase initP`, and the body with base body tokens. Use `templates/demo.html` and `templates/layout/body.html` as the canonical references.
74
- - Components use a root token and child tokens with a consistent prefix. Use `templates/components/` as the canonical markup source.
73
+ - The main markup must enable the library with `htmlBase initP`, and the body with base body tokens. Use `templates/demo.html` and `templates/html/layout/body.html` as the canonical references.
74
+ - Components use a root token and child tokens with a consistent prefix. Use `templates/html/components/` as the canonical markup source.
75
75
 
76
76
  - Runtime states use `pgs-state`, for example `open`, `is-active`, `is-completed`, `is-locked`, `success`, `error`, `warning`, and `info`.
77
77
  - Configurable options use `pgs-option`, with simple tokens or values inside square brackets. Prefer copying the current option syntax from the relevant template rather than duplicating examples in this guide.
@@ -84,14 +84,15 @@ Patterns found:
84
84
  Recommended imports in a project that consumes the library:
85
85
 
86
86
  ```scss
87
- @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
88
- @import "../../node_modules/mypgs/assets/scss/index.scss";
87
+ @use "sass:meta";
88
+ @use "../../node_modules/mypgs/assets/scss/mixin/mixin.scss" as * ;
89
+ @include meta.load-css("../../node_modules/mypgs/assets/scss/index.scss");
89
90
  ```
90
91
 
91
92
  If you only need the mixins:
92
93
 
93
94
  ```scss
94
- @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
95
+ @use "../../node_modules/mypgs/assets/scss/mixin/mixin.scss" as * ;
95
96
  ```
96
97
 
97
98
  Direct usage of the compiled CSS:
@@ -222,9 +223,9 @@ Use the templates as the single source of truth for component and layout markup.
222
223
 
223
224
  Canonical template references:
224
225
 
225
- - Layouts: `templates/layout/body.html`, `templates/layout/flex.html`, `templates/layout/grid.html`, `templates/layout/pageShell.html`, `templates/layout/section.html`
226
- - Components: `templates/components/accordion.html`, `templates/components/breadcumbs.html`, `templates/components/button.html`, `templates/components/card.html`, `templates/components/dropdown.html`, `templates/components/form.html`, `templates/components/logo.html`, `templates/components/menu.html`, `templates/components/modal.html`, `templates/components/notification.html`, `templates/components/searchbar.html`, `templates/components/slides.html`, `templates/components/stepTabs.html`, `templates/components/steps.html`, `templates/components/table.html`, `templates/components/tooltip.html`
227
- - Patterns: `templates/patterns/cookieConsent.html`, `templates/patterns/footer.html`, `templates/patterns/header.html`
226
+ - Layouts: `templates/html/layout/body.html`, `templates/html/layout/flex.html`, `templates/html/layout/grid.html`, `templates/html/layout/pageShell.html`, `templates/html/layout/section.html`
227
+ - Components: `templates/html/components/accordion.html`, `templates/html/components/breadcumbs.html`, `templates/html/components/button.html`, `templates/html/components/card.html`, `templates/html/components/dropdown.html`, `templates/html/components/form.html`, `templates/html/components/logo.html`, `templates/html/components/menu.html`, `templates/html/components/modal.html`, `templates/html/components/notification.html`, `templates/html/components/searchbar.html`, `templates/html/components/slides.html`, `templates/html/components/stepTabs.html`, `templates/html/components/steps.html`, `templates/html/components/table.html`, `templates/html/components/tooltip.html`
228
+ - Patterns: `templates/html/patterns/cookieConsent.html`, `templates/html/patterns/footer.html`, `templates/html/patterns/header.html`
228
229
  - Complete demo assembly. DO NOT use this for inspiration. It is only used to show all the modules: `templates/demo.html`
229
230
 
230
231
  Before creating markup, open the relevant template and reuse its current structure, tokens, ARIA attributes, and `pgs-option` syntax.
@@ -257,11 +258,12 @@ import "mypgs/style.css";
257
258
  Source SCSS import:
258
259
 
259
260
  ```scss
260
- @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
261
- @import "../../node_modules/mypgs/assets/scss/index.scss";
261
+ @use "sass:meta";
262
+ @use "../../node_modules/mypgs/assets/scss/mixin/mixin.scss" as * ;
263
+ @include meta.load-css("../../node_modules/mypgs/assets/scss/index.scss");
262
264
  ```
263
265
 
264
- Recommended: use PGS layout tokens from `templates/layout/`.
266
+ Recommended: use PGS layout tokens from `templates/html/layout/`.
265
267
 
266
268
  Avoid: equivalent custom layout with ad hoc classes when a PGS layout token already exists.
267
269
 
@@ -281,7 +283,7 @@ Avoid: rewriting the whole button.
281
283
  display: inline-flex;
282
284
  gap: 12px;
283
285
  padding: 14px 22px;
284
- border-radius: 999px;
286
+ border-radius: 99px;
285
287
  background: #ff6161;
286
288
  }
287
289
  ```
@@ -326,7 +328,7 @@ For a new reusable component:
326
328
  - create JS in `assets/javascript/components/` or `assets/javascript/patterns/` only if behavior is needed;
327
329
  - export an object with `init` and/or `api` when the module needs a public API;
328
330
  - register it in `assets/javascript/_imports.js` with `pgs.registerModules` if it must be available as `pgs.moduleName`;
329
- - add a template in `templates/components/` or `templates/layout/`;
331
+ - add a template in `templates/html/components/` or `templates/html/layout/`;
330
332
  - update `README.md` and this guide if the usage changes.
331
333
 
332
334
  Example for a new module:
package/README.md CHANGED
@@ -56,14 +56,15 @@ Markup minimo consigliato:
56
56
  Se il progetto vuole compilare un CSS unico, importa gli SCSS sorgenti:
57
57
 
58
58
  ```scss
59
- @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
60
- @import "../../node_modules/mypgs/assets/scss/index.scss";
59
+ @use "sass:meta";
60
+ @use "../../node_modules/mypgs/assets/scss/mixin/mixin.scss" as * ;
61
+ @include meta.load-css("../../node_modules/mypgs/assets/scss/index.scss");
61
62
  ```
62
63
 
63
64
  Se servono solo i mixin:
64
65
 
65
66
  ```scss
66
- @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
67
+ @use "../../node_modules/mypgs/assets/scss/mixin/mixin.scss" as * ;
67
68
  ```
68
69
 
69
70
  La libreria espone molte custom properties da preferire agli hardcode, per esempio:
@@ -228,173 +229,7 @@ pgs.modal.api(modalEl)?.open();
228
229
 
229
230
  ## Componenti e markup
230
231
 
231
- I template completi sono in `templates/components/` e `templates/layout/`. Usa quei file come sorgente di riferimento prima di creare markup nuovo.
232
-
233
- ### Layout
234
-
235
- ```html
236
- <main pgs="main">
237
- <section pgs="section flexColumnElements">
238
- <div pgs="flexColumnTexts">
239
- <h2>Titolo</h2>
240
- <p>Contenuto.</p>
241
- </div>
242
- </section>
243
- </main>
244
- ```
245
-
246
- ```html
247
- <section pgs="sectionFull flexColumnElements">
248
- <div pgs="grid-3">
249
- <article pgs="card flexColumnTexts">
250
- <h3>Colonna uno</h3>
251
- <p>Contenuto.</p>
252
- </article>
253
- </div>
254
- </section>
255
- ```
256
-
257
- ### Bottoni
258
-
259
- ```html
260
- <button pgs="button" type="button">Base</button>
261
- <button pgs="buttonStrong" type="button">Primario</button>
262
- <button pgs="buttonIcon" type="button" aria-label="Impostazioni">
263
- <i class="fa-solid fa-gear" aria-hidden="true"></i>
264
- </button>
265
- ```
266
-
267
- ### Accordion
268
-
269
- ```html
270
- <div pgs="accordion">
271
- <button pgs="accordion-button" type="button">Domanda</button>
272
- <div pgs="accordion-content">Risposta</div>
273
- </div>
274
- ```
275
-
276
- ### Dropdown
277
-
278
- ```html
279
- <span pgs="dropdown">
280
- <button pgs="dropdown-button button" type="button">Apri menu</button>
281
- <div pgs="dropdown-content">
282
- <nav aria-label="Menu dropdown"></nav>
283
- </div>
284
- </span>
285
- ```
286
-
287
- ### Modal
288
-
289
- ```html
290
- <div pgs="modal" pgs-option="containerID[modal-container]">
291
- <button pgs="modal-button button" type="button">Apri modale</button>
292
- <dialog>
293
- <div pgs="modal-dialog-content">
294
- <div pgs="modal-dialog-content-header">
295
- <h3>Modale</h3>
296
- </div>
297
- <div pgs="modal-dialog-content-scroll">
298
- <p>Contenuto della modale.</p>
299
- </div>
300
- </div>
301
- </dialog>
302
- </div>
303
- <div id="modal-container"></div>
304
- ```
305
-
306
- ### Slides
307
-
308
- ```html
309
- <div pgs="slides" pgs-option="singleScroll shadowDesktop">
310
- <ul pgs="slides-container">
311
- <li>
312
- <article pgs="card flexColumn">
313
- <img pgs="card-img imgCover" src="image.jpg" alt="">
314
- <div pgs="flexColumnTexts">
315
- <h3>Slide uno</h3>
316
- </div>
317
- </article>
318
- </li>
319
- </ul>
320
- </div>
321
- ```
322
-
323
- ### Step tabs
324
-
325
- ```html
326
- <div pgs="stepTabs flexColumnElements">
327
- <div pgs="stepTabs-dots" aria-label="Avanzamento"></div>
328
- <div pgs="stepTabs-container">
329
- <section pgs="tab flexColumnTexts" tabindex="-1" pgs-option="tabIcon[fa-user]"></section>
330
- </div>
331
- <div pgs="flexRow">
332
- <button pgs="stepTabs-prev button" type="button">Indietro</button>
333
- <button pgs="stepTabs-next button" pgs-option="buttonReverse" type="button">Avanti</button>
334
- </div>
335
- </div>
336
- ```
337
-
338
- ### Form
339
-
340
- ```html
341
- <form pgs="form" action="#" method="post">
342
- <label pgs="label" for="form-email">Email</label>
343
- <input id="form-email" pgs="input" type="email" name="email" required data-form-field-message="Inserisci una email valida">
344
- <button pgs="buttonStrong" type="submit">Invia</button>
345
- </form>
346
- ```
347
-
348
- Validazione programmatica:
349
-
350
- ```js
351
- const form = document.querySelector("form");
352
- const validator = new pgs.formValidate({ form });
353
-
354
- if (validator.validate()) {
355
- pgs.notification.toast.success("Inviato con successo");
356
- }
357
- ```
358
-
359
- ### Notifiche
360
-
361
- ```html
362
- <div pgs="notification" aria-live="polite"></div>
363
- <div pgs="toast" aria-live="polite"></div>
364
- ```
365
-
366
- ```js
367
- pgs.notification.toast.success("Salvato");
368
- pgs.notification.alert.error("Errore", null, 0);
369
- ```
370
-
371
- Trigger da markup:
372
-
373
- ```html
374
- <div pgs="hidden notificationTrigger" data-notification='{
375
- "title":"Titolo",
376
- "message":"Messaggio",
377
- "element":"notification",
378
- "type":"info",
379
- "duration":"-1"
380
- }'></div>
381
- ```
382
-
383
- ### Menu
384
-
385
- ```html
386
- <nav pgs="menuHorizontal" aria-label="Menu principale">
387
- <ul>
388
- <li class="menu-item"><a href="/">Home</a></li>
389
- <li class="menu-item menu-item-has-children">
390
- <a href="/servizi">Servizi</a>
391
- <ul class="sub-menu">
392
- <li class="menu-item"><a href="/servizi/uno">Servizio uno</a></li>
393
- </ul>
394
- </li>
395
- </ul>
396
- </nav>
397
- ```
232
+ I template completi sono in `templates/html/components/`, `templates/html/patterns/` e `templates/html/layout/`. Usa quei file come sorgente di riferimento prima di creare markup nuovo.
398
233
 
399
234
  ## Componenti disponibili
400
235
 
@@ -484,8 +319,9 @@ import "mypgs/style.css";
484
319
  Uso sorgente SCSS:
485
320
 
486
321
  ```scss
487
- @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
488
- @import "../../node_modules/mypgs/assets/scss/index.scss";
322
+ @use "sass:meta";
323
+ @use "../../node_modules/mypgs/assets/scss/mixin/mixin.scss" as * ;
324
+ @include meta.load-css("../../node_modules/mypgs/assets/scss/index.scss");
489
325
  ```
490
326
 
491
327
  ## Sviluppo
@@ -1,107 +1,111 @@
1
1
  //# HEADER
2
2
  const header = pgs(document).querySelector("header");
3
- const headerElements = pgs(header).querySelectorAll("header-element");
4
- headerElements.forEach(element => PGS_header(element));
5
3
 
6
4
  //= HEADER
7
- function PGS_header(selectHeader) {
5
+ function PGS_header(selectHeader = document) {
6
+
7
+ if (!header) return;
8
8
 
9
- //= INIT
10
- if (selectHeader.getAttribute("data-initialize") == "true") return;
11
- selectHeader.setAttribute("data-initialize", "true");
9
+ const headerElements = pgs(header).querySelectorAll("header-element");
10
+
11
+ if (!headerElements.length) return;
12
12
 
13
- //= ACTIVE MOBILE
14
- let menuAttivate = false;
15
- let childsWidthSAVE;
13
+ headerElements.forEach(selectHeader => {
16
14
 
17
- function mobileActive(headerElement) {
15
+ //== ACTIVE MOBILE
16
+ let menuAttivate = false;
17
+ let childsWidthSAVE;
18
18
 
19
- //=== header
20
- let style = window.getComputedStyle(headerElement);
21
- let padding = parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
22
- let gap = parseFloat(style.gap);
23
- let headerElementWidth = parseInt(headerElement.offsetWidth - padding);
24
- let childsWidth;
19
+ function mobileActive(headerElement) {
25
20
 
26
- if (menuAttivate) {
27
- childsWidth = childsWidthSAVE;
28
- } else {
29
- let childs = [];
30
-
31
- // Esclude l'area mobile dedicata e l'hamburger, poi misura i figli sempre visibili su desktop.
32
- Array.from(headerElement.children)
33
- .filter(el => !pgs(el).contains("header-element-onlyMobile"))
34
- .forEach(child => {
35
- if (pgs(child).contains("header-element-hamburger")) return;
36
- childs.push(...child.children);
37
- });
21
+ //=== header
22
+ let style = window.getComputedStyle(headerElement);
23
+ let padding = parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
24
+ let gap = parseFloat(style.gap);
25
+ let headerElementWidth = parseInt(headerElement.offsetWidth - padding);
26
+ let childsWidth;
38
27
 
39
- gap = Math.round(gap * (childs.length - 1));
40
- let childsReduce = childs.reduce((totalWidth, child) => totalWidth + child.offsetWidth, 0) - 2;
28
+ if (menuAttivate) {
29
+ childsWidth = childsWidthSAVE;
30
+ } else {
31
+ let childs = [];
41
32
 
42
- childsWidth = childsReduce + gap;
43
- }
33
+ // Esclude l'area mobile dedicata e l'hamburger, poi misura i figli sempre visibili su desktop.
34
+ Array.from(headerElement.children)
35
+ .filter(el => !pgs(el).contains("header-element-onlyMobile"))
36
+ .forEach(child => {
37
+ if (pgs(child).contains("header-element-hamburger")) return;
38
+ childs.push(...child.children);
39
+ });
44
40
 
45
- //===set data
46
- if (window.innerWidth < 600) {
47
- header.setAttribute("data-header-mobileActive", "true");
48
- selectHeader.setAttribute("data-header-mobileActive", "true");
49
- } else if (headerElementWidth < childsWidth) {
50
- header.setAttribute("data-header-mobileActive", "true");
51
- headerElement.setAttribute("data-header-mobileActive", "true");
52
- menuAttivate = true;
53
- childsWidthSAVE = childsWidth;
54
- } else {
55
- header.setAttribute("data-header-mobileActive", "false");
56
- headerElement.setAttribute("data-header-mobileActive", "false");
57
- }
58
- }
41
+ gap = Math.round(gap * (childs.length - 1));
42
+ let childsReduce = childs.reduce((totalWidth, child) => totalWidth + child.offsetWidth, 0) - 2;
59
43
 
60
- //== observer (throttled to avoid ResizeObserver loop warnings)
61
- let resizeRafId = 0;
62
- const scheduleMobileActive = () => {
63
- if (resizeRafId) return;
64
- resizeRafId = requestAnimationFrame(() => {
65
- resizeRafId = 0;
66
- mobileActive(selectHeader);
67
- });
68
- };
44
+ childsWidth = childsReduce + gap;
45
+ }
69
46
 
70
- let observer = new ResizeObserver(scheduleMobileActive);
71
- observer.observe(selectHeader);
72
- scheduleMobileActive();
47
+ //===set data
48
+ if (window.innerWidth < 600) {
49
+ pgs(header).state.add("mobileActive");
50
+ pgs(selectHeader).state.add("mobileActive");
51
+ } else if (headerElementWidth < childsWidth) {
52
+ pgs(header).state.add("mobileActive");
53
+ pgs(headerElement).state.add("mobileActive");
54
+ menuAttivate = true;
55
+ childsWidthSAVE = childsWidth;
56
+ } else {
57
+ pgs(header).state.remove("mobileActive");
58
+ pgs(headerElement).state.remove("mobileActive");
59
+ }
60
+ }
73
61
 
62
+ //== observer (throttled to avoid ResizeObserver loop warnings)
63
+ let resizeRafId = 0;
64
+ const scheduleMobileActive = () => {
65
+ if (resizeRafId) return;
66
+ resizeRafId = requestAnimationFrame(() => {
67
+ resizeRafId = 0;
68
+ mobileActive(selectHeader);
69
+ });
70
+ };
71
+
72
+ let observer = new ResizeObserver(scheduleMobileActive);
73
+ observer.observe(selectHeader);
74
+ scheduleMobileActive();
75
+ });
76
+
77
+ // Ripristina la posizione dell'header quando si esce dalla modalità mobile
78
+ window.addEventListener("resize", () => {
79
+ if (window.innerWidth > 768) header.style.transform = "translateY(0)";
80
+ });
74
81
  }
75
-
76
-
82
+ PGS_header();
77
83
 
78
84
 
79
85
  //= HEADER HEIGHT
80
- const body = document.querySelector("body");
81
86
  function headerHeight() {
82
- const headerElements = document.querySelectorAll("header > [data-initialize=true]");
87
+ if (!header) return;
83
88
  const wordPressBar = window.getComputedStyle(document.documentElement).marginTop ?? 0;
89
+ const headerHeight = header.offsetHeight
84
90
 
85
- const totalHeight = Array.from(headerElements)
86
- .map(el => el.offsetHeight)
87
- .reduce((sum, h) => sum + h);
88
-
89
- const height = totalHeight + parseInt(wordPressBar);
90
-
91
- body.style.setProperty('--heightOfHeader', `${height}px`);
91
+ const body = document.querySelector("body");
92
+ const height = headerHeight + parseInt(wordPressBar);
92
93
  const scrollHeight = document.querySelector("header").getAttribute("data-header-scroll") === "true" ? 0 : height;
94
+ body.style.setProperty('--heightOfHeader', `${height}px`);
93
95
  body.style.setProperty('--heightOfHeaderScroll', `${scrollHeight}px`);
94
-
95
96
  }
96
97
  headerHeight()
97
98
  window.addEventListener("resize", headerHeight);
98
99
  window.addEventListener("scroll", headerHeight);
99
100
 
100
101
 
102
+
103
+
101
104
  //= SCROLL
102
105
  // Nasconde l'header quando si scorre verso il basso e lo mostra quando si scorre verso l'alto su dispositivi con larghezza fino a 900px.
103
106
  let lastScrollY = window.scrollY;
104
107
  window.addEventListener("scroll", () => {
108
+ if (!header) return;
105
109
  let currentScrollY = window.scrollY;
106
110
 
107
111
  if (window.innerHeight <= 900) {
@@ -122,13 +126,7 @@ window.addEventListener("scroll", () => {
122
126
 
123
127
  });
124
128
 
125
- // Ripristina la posizione dell'header quando si esce dalla modalità mobile
126
- window.addEventListener("resize", () => {
127
- if (window.innerWidth > 768) header.style.transform = "translateY(0)";
128
- });
129
129
 
130
- // MOBILE ACTIVE
131
- if (window.innerWidth < 600) {
132
- document.querySelector("header").setAttribute("data-header-mobileActive", "true");
133
- document.querySelector("[pgs~=header-element]").setAttribute("data-header-mobileActive", "true");
134
- }
130
+
131
+
132
+
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //== BASE
2
4
  [pgs~="bodyBase"] {
3
5
  background-color: var(--color-background);
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //= COLOR
2
4
  //== LIGHTMODE & DARKMODE
3
5
  :root {
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //# GENERAL
2
4
  [pgs~=initP] {
3
5
 
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //# HEADING
2
4
  [pgs~=initP] {
3
5
  [pgs~=h1] {
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //+ MIXIN
2
4
  // = SETTINGS
3
5
  :root {
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //# ACCORDION
2
4
  [pgs~=accordion] {
3
5
  padding: 0 !important;
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //# BUTTON
2
4
  [pgs~=button] {
3
5
  @include button()
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //# FORM
2
4
  [pgs~=textarea] {
3
5
  @include textarea();
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //# LOGO
2
4
  [pgs~="logo"] {
3
5
  display: flex;
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //# MENU
2
4
  [pgs~=menu] {
3
5
  ul {
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  html:has(dialog[open]) {
2
4
  overflow: hidden;
3
5
  position: relative;
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //= NOTIFICATION GROUP / TRIGGER
2
4
  [pgs~="notificationTrigger"] {}
3
5
 
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  //= SEARCH BAR
2
4
  [pgs~="searchbar"] {
3
5
  position: relative;
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  [pgs~="slides"] {
2
4
  display: flex;
3
5
  flex-direction: column;
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  [pgs~=stepTabs] {
2
4
  [pgs~=stepTabs-container] {
3
5
  [pgs~=tab] {
@@ -1,3 +1,5 @@
1
+ @use "../mixin/mixin" as *;
2
+
1
3
  ol[pgs~="steps"] {
2
4
  color: var(--color-black);
3
5