mypgs 1.3.6 → 1.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.
- package/{AI_GUIDELINES.md → AGENTS.md} +17 -15
- package/README.md +8 -172
- package/assets/javascript/_imports.js +2 -1
- package/assets/javascript/components/_summary.js +105 -0
- package/assets/javascript/index.js +2 -1
- package/assets/javascript/patterns/_header.js +5 -6
- package/assets/javascript/pgs.d.ts +1 -0
- package/assets/scss/base/_variables.scss +1 -1
- package/assets/scss/components/_badges.scss +93 -0
- package/assets/scss/components/_summary.scss +56 -0
- package/assets/scss/index.scss +2 -0
- package/assets/scss/layout/_pageShell.scss +66 -40
- package/assets/scss/mixin/_mx-responsive.scss +11 -10
- package/assets/scss/patterns/_header.scss +6 -2
- package/dist/css/index.css +217 -57
- package/dist/css/index.css.map +1 -1
- package/dist/css/index.min.css +1 -1
- package/dist/javascript/index.js +143 -17
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/index.min.js +1 -1
- package/package.json +1 -1
- package/templates/html/components/badges.html +37 -0
- package/templates/html/components/summary.html +14 -0
- package/templates/{demo.html → html/demo.html} +1 -1
- package/templates/{demo.js → html/demo.js} +11 -9
- package/templates/{layout → html/layout}/pageShell.html +22 -13
- package/templates/react/components/accordion.jsx +27 -0
- package/templates/react/components/breadcumbs.jsx +27 -0
- package/templates/react/components/button.jsx +33 -0
- package/templates/react/components/card.jsx +27 -0
- package/templates/react/components/dropdown.jsx +29 -0
- package/templates/react/components/form.jsx +30 -0
- package/templates/react/components/logo.jsx +14 -0
- package/templates/react/components/menu.jsx +37 -0
- package/templates/react/components/modal.jsx +84 -0
- package/templates/react/components/notification.jsx +31 -0
- package/templates/react/components/searchbar.jsx +34 -0
- package/templates/react/components/slides.jsx +25 -0
- package/templates/react/components/stepTabs.jsx +40 -0
- package/templates/react/components/steps.jsx +21 -0
- package/templates/react/components/summary.jsx +18 -0
- package/templates/react/components/table.jsx +28 -0
- package/templates/react/components/tooltip.jsx +12 -0
- package/templates/react/layout/body.jsx +7 -0
- package/templates/react/layout/flex.jsx +36 -0
- package/templates/react/layout/grid.jsx +36 -0
- package/templates/react/layout/pageShell.jsx +50 -0
- package/templates/react/layout/section.jsx +44 -0
- package/templates/react/patterns/cookieConsent.jsx +62 -0
- package/templates/react/patterns/footer.jsx +40 -0
- package/templates/react/patterns/header.jsx +62 -0
- /package/templates/{components → html/components}/accordion.html +0 -0
- /package/templates/{components → html/components}/breadcumbs.html +0 -0
- /package/templates/{components → html/components}/button.html +0 -0
- /package/templates/{components → html/components}/card.html +0 -0
- /package/templates/{components → html/components}/dropdown.html +0 -0
- /package/templates/{components → html/components}/form.html +0 -0
- /package/templates/{components → html/components}/logo.html +0 -0
- /package/templates/{components → html/components}/menu.html +0 -0
- /package/templates/{components → html/components}/modal.html +0 -0
- /package/templates/{components → html/components}/notification.html +0 -0
- /package/templates/{components → html/components}/searchbar.html +0 -0
- /package/templates/{components → html/components}/slides.html +0 -0
- /package/templates/{components → html/components}/stepTabs.html +0 -0
- /package/templates/{components → html/components}/steps.html +0 -0
- /package/templates/{components → html/components}/table.html +0 -0
- /package/templates/{components → html/components}/tooltip.html +0 -0
- /package/templates/{demo.css → html/demo.css} +0 -0
- /package/templates/{layout → html/layout}/body.html +0 -0
- /package/templates/{layout → html/layout}/flex.html +0 -0
- /package/templates/{layout → html/layout}/grid.html +0 -0
- /package/templates/{layout → html/layout}/section.html +0 -0
- /package/templates/{patterns → html/patterns}/cookieConsent.html +0 -0
- /package/templates/{patterns → html/patterns}/footer.html +0 -0
- /package/templates/{patterns → html/patterns}/header.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
|
-
@
|
|
88
|
-
@
|
|
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
|
-
@
|
|
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
|
-
@
|
|
261
|
-
@
|
|
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
|
|
|
@@ -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
|
-
@
|
|
60
|
-
@
|
|
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
|
-
@
|
|
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
|
-
@
|
|
488
|
-
@
|
|
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
|
|
@@ -8,6 +8,7 @@ import { PGS_notification } from "./components/_notifications.js";
|
|
|
8
8
|
import { PGS_slides } from "./components/_slides.js";
|
|
9
9
|
import { PGS_stepTabs } from "./components/_stepTabs.js";
|
|
10
10
|
import { PGS_steps } from "./components/_steps.js";
|
|
11
|
+
import { PGS_summary } from "./components/_summary.js";
|
|
11
12
|
import { PGS_formValidate } from "./functions/_formValidate.js";
|
|
12
13
|
import { PGS_scrollHorizontal } from "./functions/_scrollY.js";
|
|
13
14
|
|
|
@@ -20,7 +21,7 @@ pgs.registerModules({
|
|
|
20
21
|
slides: PGS_slides,
|
|
21
22
|
stepTabs: PGS_stepTabs,
|
|
22
23
|
steps: PGS_steps,
|
|
24
|
+
summary: PGS_summary,
|
|
23
25
|
formValidate: PGS_formValidate,
|
|
24
26
|
scrollHorizontal: PGS_scrollHorizontal,
|
|
25
27
|
});
|
|
26
|
-
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//= SUMMARY
|
|
2
|
+
const API = new WeakMap();
|
|
3
|
+
let summaryId = 0;
|
|
4
|
+
|
|
5
|
+
function nextSummaryId() {
|
|
6
|
+
summaryId += 1;
|
|
7
|
+
return summaryId;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getLineHeight(element) {
|
|
11
|
+
const style = window.getComputedStyle(element);
|
|
12
|
+
const lineHeight = parseFloat(style.lineHeight);
|
|
13
|
+
if (Number.isFinite(lineHeight)) return lineHeight;
|
|
14
|
+
|
|
15
|
+
const fontSize = parseFloat(style.fontSize);
|
|
16
|
+
return Number.isFinite(fontSize) ? fontSize * 1.2 : 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function directPgsChild(element, token) {
|
|
20
|
+
return Array.from(element.children).find(child => pgs(child).contains(token));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function PGS_summary_init(root = document) {
|
|
24
|
+
pgs(root).querySelectorAll("summary").forEach((summary) => {
|
|
25
|
+
if (API.has(summary)) return;
|
|
26
|
+
|
|
27
|
+
const content = directPgsChild(summary, "summary-content");
|
|
28
|
+
const button = directPgsChild(summary, "summary-button");
|
|
29
|
+
if (!content || !button) return;
|
|
30
|
+
|
|
31
|
+
const id = nextSummaryId();
|
|
32
|
+
const contentId = content.id || `summary-content-${id}`;
|
|
33
|
+
content.id = contentId;
|
|
34
|
+
|
|
35
|
+
button.type ||= "button";
|
|
36
|
+
button.setAttribute("aria-controls", content.id);
|
|
37
|
+
|
|
38
|
+
function isOpen() {
|
|
39
|
+
return pgs(summary).state.contains("open");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getCollapsedHeight() {
|
|
43
|
+
return getLineHeight(content) * 3;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isOverflowing() {
|
|
47
|
+
return content.scrollHeight > Math.ceil(getCollapsedHeight()) + 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function setExpanded(expanded) {
|
|
51
|
+
const overflow = isOverflowing();
|
|
52
|
+
|
|
53
|
+
pgs(summary).state.toggle("overflow", overflow);
|
|
54
|
+
pgs(summary).state.toggle("open", expanded && overflow);
|
|
55
|
+
|
|
56
|
+
button.hidden = !overflow;
|
|
57
|
+
button.setAttribute("aria-hidden", String(!overflow));
|
|
58
|
+
button.setAttribute("aria-expanded", String(expanded && overflow));
|
|
59
|
+
button.textContent = expanded && overflow ? "Mostra meno" : "Mostra di più";
|
|
60
|
+
|
|
61
|
+
const nextHeight = expanded && overflow ? content.scrollHeight : getCollapsedHeight();
|
|
62
|
+
content.style.setProperty("--summary-content-max-height", `${nextHeight}px`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function refresh() {
|
|
66
|
+
const wasOpen = isOpen();
|
|
67
|
+
content.style.setProperty("--summary-content-max-height", "none");
|
|
68
|
+
setExpanded(wasOpen);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function toggle() {
|
|
72
|
+
setExpanded(!isOpen());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
button.addEventListener("click", toggle);
|
|
76
|
+
window.addEventListener("resize", refresh, { passive: true });
|
|
77
|
+
|
|
78
|
+
refresh();
|
|
79
|
+
requestAnimationFrame(refresh);
|
|
80
|
+
|
|
81
|
+
API.set(summary, {
|
|
82
|
+
element: summary,
|
|
83
|
+
content,
|
|
84
|
+
button,
|
|
85
|
+
open: () => setExpanded(true),
|
|
86
|
+
close: () => setExpanded(false),
|
|
87
|
+
toggle,
|
|
88
|
+
refresh,
|
|
89
|
+
isOpen,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//# INIT
|
|
95
|
+
PGS_summary_init();
|
|
96
|
+
|
|
97
|
+
//# API
|
|
98
|
+
export function PGS_summary_api(selector) {
|
|
99
|
+
return API.get(selector);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const PGS_summary = {
|
|
103
|
+
init: PGS_summary_init,
|
|
104
|
+
api: PGS_summary_api
|
|
105
|
+
};
|
|
@@ -14,6 +14,7 @@ import "./components/_modals.js";
|
|
|
14
14
|
import "./components/_slides.js"
|
|
15
15
|
import "./components/_steps.js";
|
|
16
16
|
import "./components/_stepTabs.js";
|
|
17
|
+
import "./components/_summary.js";
|
|
17
18
|
import "./components/_notifications.js";
|
|
18
19
|
|
|
19
20
|
//= IMPORT REGISTRY
|
|
@@ -21,4 +22,4 @@ import "./_imports.js";
|
|
|
21
22
|
|
|
22
23
|
//= PATTERNS
|
|
23
24
|
import "./patterns/_header.js";
|
|
24
|
-
import "./patterns/_cookieConsent.js";
|
|
25
|
+
import "./patterns/_cookieConsent.js";
|
|
@@ -3,11 +3,11 @@ const header = pgs(document).querySelector("header");
|
|
|
3
3
|
|
|
4
4
|
//= HEADER
|
|
5
5
|
function PGS_header(selectHeader = document) {
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
if (!header) return;
|
|
8
8
|
|
|
9
9
|
const headerElements = pgs(header).querySelectorAll("header-element");
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
if (!headerElements.length) return;
|
|
12
12
|
|
|
13
13
|
headerElements.forEach(selectHeader => {
|
|
@@ -87,12 +87,11 @@ function headerHeight() {
|
|
|
87
87
|
if (!header) return;
|
|
88
88
|
const wordPressBar = window.getComputedStyle(document.documentElement).marginTop ?? 0;
|
|
89
89
|
const headerHeight = header.offsetHeight
|
|
90
|
-
|
|
91
|
-
const body = document.querySelector("body");
|
|
92
90
|
const height = headerHeight + parseInt(wordPressBar);
|
|
93
91
|
const scrollHeight = document.querySelector("header").getAttribute("data-header-scroll") === "true" ? 0 : height;
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
|
|
93
|
+
document.documentElement.style.setProperty("--heightOfHeader", `${height}px`);
|
|
94
|
+
document.documentElement.style.setProperty("--heightOfHeaderScroll", `${scrollHeight}px`);
|
|
96
95
|
}
|
|
97
96
|
headerHeight()
|
|
98
97
|
window.addEventListener("resize", headerHeight);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
--text-shadow: 0px 0px 50px #000000;
|
|
20
20
|
--backdrop: #0000003e;
|
|
21
21
|
--blur: blur(20px);
|
|
22
|
-
--page-top:
|
|
22
|
+
--page-top: calc(var(--heightOfHeaderScroll) + (var(--gap-elements)*2));
|
|
23
23
|
--page-width: 1280px;
|
|
24
24
|
--page-space: clamp(var(--padding-page), calc((100% - var(--section-width)) / 2 + var(--padding-page)), 100%);
|
|
25
25
|
--gap-texts: 1.0rem;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
@use "../mixin/mixin" as *;
|
|
2
|
+
|
|
3
|
+
@mixin _badge() {
|
|
4
|
+
--badge-background: var(--color-box);
|
|
5
|
+
--badge-color: var(--color-black);
|
|
6
|
+
--badge-size: 1.25rem;
|
|
7
|
+
--badge-icon-size: 1.4rem;
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
gap: calc(var(--badge-size) / 2);
|
|
12
|
+
width: max-content;
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
min-height: calc(var(--badge-size) * 2.2);
|
|
15
|
+
padding: calc(var(--badge-size) / 2) var(--badge-size);
|
|
16
|
+
border-radius: var(--border-radius-input);
|
|
17
|
+
background: var(--badge-background);
|
|
18
|
+
color: var(--badge-color);
|
|
19
|
+
font-size: var(--badge-size);
|
|
20
|
+
font-weight: 700;
|
|
21
|
+
line-height: 1;
|
|
22
|
+
text-decoration: none;
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
overflow-wrap: normal;
|
|
25
|
+
|
|
26
|
+
i {
|
|
27
|
+
color: var(--badge-color);
|
|
28
|
+
font-size: var(--badge-icon-size);
|
|
29
|
+
--fa-size: var(--badge-icon-size);
|
|
30
|
+
--fa-primary-color: var(--badge-color);
|
|
31
|
+
--fa-secondary-color: var(--badge-color);
|
|
32
|
+
--fa-secondary-opacity: 0.5;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[pgs~="badge"],
|
|
37
|
+
[pgs~="badgePrimary"],
|
|
38
|
+
[pgs~="badgeStrong"],
|
|
39
|
+
[pgs~="badgeSuccess"],
|
|
40
|
+
[pgs~="badgeWarning"],
|
|
41
|
+
[pgs~="badgeError"],
|
|
42
|
+
[pgs~="badgeInfo"],
|
|
43
|
+
[pgs~="badgeNeutral"],
|
|
44
|
+
[pgs~="badgeDot"] {
|
|
45
|
+
@include _badge();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[pgs~="badgePrimary"] {
|
|
49
|
+
--badge-background: var(--color-primary-soft);
|
|
50
|
+
--badge-color: var(--color-primary-strong);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[pgs~="badgeStrong"] {
|
|
54
|
+
--badge-background: var(--color-primary);
|
|
55
|
+
--badge-color: var(--color-whiteFixed);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[pgs~="badgeSuccess"] {
|
|
59
|
+
--badge-background: var(--color-success-background);
|
|
60
|
+
--badge-color: var(--color-success);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[pgs~="badgeWarning"] {
|
|
64
|
+
--badge-background: var(--color-warning-background);
|
|
65
|
+
--badge-color: var(--color-warning);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[pgs~="badgeError"] {
|
|
69
|
+
--badge-background: var(--color-error-background);
|
|
70
|
+
--badge-color: var(--color-error);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[pgs~="badgeInfo"] {
|
|
74
|
+
--badge-background: var(--color-linkBackgorud);
|
|
75
|
+
--badge-color: var(--color-link);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[pgs~="badgeNeutral"] {
|
|
79
|
+
--badge-background: var(--color-box-transparent);
|
|
80
|
+
--badge-color: var(--color-text);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[pgs~="badgeDot"] {
|
|
84
|
+
&::before {
|
|
85
|
+
content: "";
|
|
86
|
+
display: block;
|
|
87
|
+
inline-size: 0.65em;
|
|
88
|
+
block-size: 0.65em;
|
|
89
|
+
flex: 0 0 auto;
|
|
90
|
+
border-radius: 50%;
|
|
91
|
+
background: currentColor;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
@use "../mixin/mixin" as *;
|
|
2
|
+
|
|
3
|
+
[pgs~="summary"] {
|
|
4
|
+
--summary-fade-size: 4rem;
|
|
5
|
+
--summary-fade-background: var(--color-background);
|
|
6
|
+
--summary-content-max-height: 5.7rem;
|
|
7
|
+
position: relative;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: var(--gap-texts);
|
|
11
|
+
isolation: isolate;
|
|
12
|
+
|
|
13
|
+
[pgs~="summary-content"] {
|
|
14
|
+
max-height: var(--summary-content-max-height, none);
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
transition: max-height 300ms ease;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&[pgs-state~="overflow"]:not([pgs-state~="open"]) {
|
|
20
|
+
[pgs~="summary-content"] {
|
|
21
|
+
position: relative;
|
|
22
|
+
|
|
23
|
+
&::after {
|
|
24
|
+
content: "";
|
|
25
|
+
position: absolute;
|
|
26
|
+
inset: auto 0 0;
|
|
27
|
+
height: var(--summary-fade-size);
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
background: linear-gradient(to bottom, transparent, var(--summary-fade-background));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:has([pgs~="summary-button"][hidden]) {
|
|
35
|
+
[pgs~="summary-content"]{
|
|
36
|
+
max-height: unset;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[pgs~="summary-button"] {
|
|
41
|
+
padding: 5px;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
background-color: transparent;
|
|
44
|
+
border: unset;
|
|
45
|
+
margin-top: calc(var(--gap-texts) * -1);
|
|
46
|
+
z-index: 1;
|
|
47
|
+
color: var(--color-primary-strong);
|
|
48
|
+
font-family: var(--font);
|
|
49
|
+
font-weight: 600;
|
|
50
|
+
font-size: 1.6rem;
|
|
51
|
+
|
|
52
|
+
&[hidden] {
|
|
53
|
+
display: none !important;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
package/assets/scss/index.scss
CHANGED
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
@include meta.load-css("components/steps");
|
|
43
43
|
@include meta.load-css("components/table");
|
|
44
44
|
@include meta.load-css("components/stepTabs");
|
|
45
|
+
@include meta.load-css("components/summary");
|
|
46
|
+
@include meta.load-css("components/badges");
|
|
45
47
|
@include meta.load-css("components/notification");
|
|
46
48
|
@include meta.load-css("components/tooltip");
|
|
47
49
|
@include meta.load-css("components/searchbar");
|