mypgs 1.3.2 → 1.3.4
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 +353 -0
- package/README.md +483 -53
- package/assets/javascript/_imports.js +12 -11
- package/assets/javascript/_pgs.js +16 -1
- package/assets/javascript/components/_accordion.js +18 -9
- package/assets/javascript/components/_dropdown.js +176 -120
- package/assets/javascript/components/_menu.js +15 -116
- package/assets/javascript/components/_modals.js +0 -1
- package/assets/javascript/components/_notifications.js +2 -3
- package/assets/javascript/components/_slides.js +0 -1
- package/assets/javascript/components/_stepTabs.js +0 -1
- package/assets/javascript/components/_steps.js +0 -1
- package/assets/javascript/patterns/_cookieConsent.js +8 -2
- package/assets/javascript/pgs.d.ts +12 -1
- package/assets/scss/base/_html.scss +23 -1
- package/assets/scss/components/_dropdown.scss +24 -88
- package/assets/scss/components/_menu.scss +129 -15
- package/assets/scss/components/_modals.scss +15 -3
- package/assets/scss/components/_notification.scss +11 -14
- package/assets/scss/components/_tooltip.scss +2 -9
- package/assets/scss/index.scss +0 -1
- package/assets/scss/layout/_gap.scss +7 -1
- package/assets/scss/layout/_layout.scss +0 -12
- package/assets/scss/layout/_pageShell.scss +104 -105
- package/assets/scss/mixin/_mx-form.scss +16 -6
- package/assets/scss/mixin/_mx-responsive.scss +2 -2
- package/assets/scss/mixin/_mx-semantic.scss +0 -60
- package/assets/scss/mixin/mixin.scss +0 -1
- package/assets/scss/patterns/_footer.scss +1 -0
- package/assets/scss/patterns/_header.scss +20 -18
- package/dist/css/index.css +264 -1179
- package/dist/css/index.css.map +1 -1
- package/dist/css/index.min.css +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/javascript/index.js +264 -272
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/index.min.js +1 -1
- package/package.json +1 -1
- package/templates/components/{md-accordion.html → accordion.html} +2 -2
- package/templates/components/dropdown.html +91 -0
- package/templates/components/menu.html +41 -0
- package/templates/components/modal.html +78 -0
- package/templates/components/notification.html +35 -0
- package/templates/components/{md-slides.html → slides.html} +5 -5
- package/templates/components/{md-steps.html → steps.html} +7 -7
- package/templates/components/{md-tooltip.html → tooltip.html} +4 -2
- package/templates/demo.css +18 -0
- package/templates/demo.html +4 -5
- package/templates/demo.js +53 -52
- package/templates/layout/flex.html +89 -0
- package/templates/layout/grid.html +89 -0
- package/templates/layout/pageShell.html +59 -0
- package/templates/layout/section.html +40 -0
- package/templates/{layout/md-footer.html → patterns/footer.html} +1 -0
- package/templates/{layout/md-header.html → patterns/header.html} +6 -9
- package/assets/scss/base/_reset.scss +0 -15
- package/assets/scss/mixin/_mx-menu.scss +0 -154
- package/templates/components/md-dropdown.html +0 -16
- package/templates/components/md-menu.html +0 -40
- package/templates/components/md-modal.html +0 -19
- package/templates/components/md-notification.html +0 -13
- package/templates/layout/md-pageShell.html +0 -22
- package/templates/layout/md-section.html +0 -25
- /package/templates/components/{md-breadcumbs.html → breadcumbs.html} +0 -0
- /package/templates/components/{md-button.html → button.html} +0 -0
- /package/templates/components/{md-card.html → card.html} +0 -0
- /package/templates/components/{md-form.html → form.html} +0 -0
- /package/templates/components/{md-logo.html → logo.html} +0 -0
- /package/templates/components/{md-searchbar.html → searchbar.html} +0 -0
- /package/templates/components/{md-stepTabs.html → stepTabs.html} +0 -0
- /package/templates/components/{md-table.html → table.html} +0 -0
- /package/templates/layout/{md-body.html → body.html} +0 -0
- /package/templates/{layout/md-cookieConsent.html → patterns/cookieConsent.html} +0 -0
package/README.md
CHANGED
|
@@ -1,32 +1,148 @@
|
|
|
1
1
|
# MyPGS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`mypgs` e' una libreria frontend condivisa per costruire interfacce coerenti tramite attributi `pgs`, SCSS sorgenti, componenti UI e comportamenti JavaScript riutilizzabili.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
La libreria nasce come base di design system: layout, spacing, colori, bottoni, form, menu, modali, dropdown, slides, notifiche e pattern ricorrenti vengono definiti una volta sola e riusati nei progetti.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Cosa contiene
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- `assets/scss/`: SCSS sorgenti divisi in base, layout, componenti, pattern e mixin.
|
|
10
|
+
- `assets/javascript/`: helper `pgs`, componenti JS, funzioni e pattern.
|
|
11
|
+
- `templates/`: esempi HTML pronti per componenti e layout.
|
|
12
|
+
- `dist/css/`: CSS compilato.
|
|
13
|
+
- `dist/javascript/`: bundle JavaScript compilato.
|
|
14
|
+
- `dist/index.d.ts`: dichiarazioni TypeScript esportate dal pacchetto.
|
|
15
|
+
- `AI_GUIDELINES.md`: guida operativa per AI/Codex.
|
|
16
|
+
- `AI_GUIDELINES_EN.md`: versione inglese della guida.
|
|
17
|
+
|
|
18
|
+
## Installazione
|
|
19
|
+
|
|
20
|
+
Da registry npm:
|
|
10
21
|
|
|
11
22
|
```bash
|
|
12
23
|
npm install mypgs
|
|
13
24
|
```
|
|
14
25
|
|
|
15
|
-
##
|
|
26
|
+
## Uso rapido
|
|
27
|
+
|
|
28
|
+
Importa JavaScript e CSS compilato nell'entrypoint del progetto:
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
```js
|
|
31
|
+
import "mypgs";
|
|
32
|
+
import "mypgs/style.css";
|
|
33
|
+
```
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
Se ti serve accedere direttamente all'helper:
|
|
20
36
|
|
|
21
37
|
```js
|
|
22
|
-
import
|
|
38
|
+
import { pgs } from "mypgs";
|
|
39
|
+
import "mypgs/style.css";
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Markup minimo consigliato:
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<html lang="it" pgs="htmlBase initP">
|
|
46
|
+
<body pgs="bodyBase bodyImg bodyText bodyHeading">
|
|
47
|
+
<main pgs="main"></main>
|
|
48
|
+
</body>
|
|
49
|
+
</html>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`initP` e' importante: molti layout, componenti e pattern SCSS sono definiti sotto `[pgs~=initP]`.
|
|
53
|
+
|
|
54
|
+
## Uso SCSS sorgente
|
|
55
|
+
|
|
56
|
+
Se il progetto vuole compilare un CSS unico, importa gli SCSS sorgenti:
|
|
57
|
+
|
|
58
|
+
```scss
|
|
59
|
+
@import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
|
|
60
|
+
@import "../../node_modules/mypgs/assets/scss/index.scss";
|
|
23
61
|
```
|
|
24
62
|
|
|
25
|
-
|
|
63
|
+
Se servono solo i mixin:
|
|
64
|
+
|
|
65
|
+
```scss
|
|
66
|
+
@import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
La libreria espone molte custom properties da preferire agli hardcode, per esempio:
|
|
70
|
+
|
|
71
|
+
```scss
|
|
72
|
+
:root {
|
|
73
|
+
--color-primary: #5c7d6f;
|
|
74
|
+
--padding: 30px;
|
|
75
|
+
--gap-texts: 1rem;
|
|
76
|
+
--gap-elements: 4rem;
|
|
77
|
+
--border-radius: 4.5rem;
|
|
78
|
+
--border-radius-input: 2.25rem;
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Override consigliato:
|
|
83
|
+
|
|
84
|
+
```scss
|
|
85
|
+
#danger-action {
|
|
86
|
+
--button-background: var(--color-error);
|
|
87
|
+
--button-color: var(--color-whiteFixed);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Evita di riscrivere da zero padding, gap, border-radius o colori se esiste gia' una variabile o un token PGS adatto.
|
|
92
|
+
|
|
93
|
+
## Il sistema `pgs`
|
|
94
|
+
|
|
95
|
+
Il markup usa token separati da spazio dentro l'attributo `pgs`:
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<button pgs="button buttonStrong" type="button">Salva</button>
|
|
99
|
+
<section pgs="section flexColumnElements"></section>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Gli stessi token collegano HTML, SCSS e JavaScript.
|
|
103
|
+
|
|
104
|
+
### Helper JavaScript
|
|
105
|
+
|
|
106
|
+
`pgs(root)` permette di cercare e modificare token PGS senza scrivere selettori manuali:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
const modal = pgs(document).querySelector("modal");
|
|
110
|
+
|
|
111
|
+
pgs(modal).contains("modal");
|
|
112
|
+
pgs(modal).add("custom-token");
|
|
113
|
+
pgs(modal).remove("custom-token");
|
|
114
|
+
pgs(modal).toggle("custom-token", true);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Stati runtime:
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
pgs(modal).state.add("open");
|
|
121
|
+
pgs(modal).state.toggle("open", false);
|
|
122
|
+
pgs(modal).state.contains("open");
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Opzioni:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
pgs(modal).option.contains("history");
|
|
129
|
+
pgs(modal).option.getValueBrackets("containerID");
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Esempio markup con opzioni:
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<div pgs="modal" pgs-option="containerID[modal-container]"></div>
|
|
136
|
+
<div pgs="slides" pgs-option="singleScroll shadowDesktop"></div>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## JavaScript inizializzato automaticamente
|
|
140
|
+
|
|
141
|
+
Importando `mypgs`, l'entrypoint inizializza:
|
|
26
142
|
|
|
27
143
|
- helper globale `pgs`
|
|
28
144
|
- dark mode
|
|
29
|
-
- gestione
|
|
145
|
+
- gestione object SVG
|
|
30
146
|
- accordion
|
|
31
147
|
- dropdown
|
|
32
148
|
- menu
|
|
@@ -38,55 +154,309 @@ L'entrypoint di MyPGS inizializza:
|
|
|
38
154
|
- header
|
|
39
155
|
- cookie consent
|
|
40
156
|
|
|
41
|
-
|
|
157
|
+
I componenti inizializzati usano `WeakMap` interne per esporre API di istanza.
|
|
42
158
|
|
|
43
|
-
|
|
159
|
+
## API dei moduli
|
|
44
160
|
|
|
45
|
-
|
|
161
|
+
I moduli principali sono registrati in `assets/javascript/_imports.js` in due modi.
|
|
46
162
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
163
|
+
### Registro diretto
|
|
164
|
+
|
|
165
|
+
Serve per usare i moduli direttamente da `pgs`:
|
|
166
|
+
|
|
167
|
+
```js
|
|
168
|
+
pgs.registerModules({
|
|
169
|
+
accordion: PGS_accordion,
|
|
170
|
+
dropdown: PGS_dropdown,
|
|
171
|
+
menu: PGS_menu,
|
|
172
|
+
modal: PGS_modal,
|
|
173
|
+
notification: PGS_notification,
|
|
174
|
+
slides: PGS_slides,
|
|
175
|
+
stepTabs: PGS_stepTabs,
|
|
176
|
+
steps: PGS_steps,
|
|
177
|
+
formValidate: PGS_formValidate,
|
|
178
|
+
scrollHorizontal: PGS_scrollHorizontal,
|
|
179
|
+
});
|
|
50
180
|
```
|
|
51
181
|
|
|
52
|
-
|
|
182
|
+
Uso consigliato:
|
|
53
183
|
|
|
54
|
-
```
|
|
55
|
-
|
|
184
|
+
```js
|
|
185
|
+
pgs.notification.toast.success("Salvato");
|
|
186
|
+
pgs.modal.api(modalEl)?.open();
|
|
187
|
+
pgs.dropdown.api(dropdownEl)?.close();
|
|
188
|
+
pgs.slides.api(slidesEl)?.next();
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Shortcut disponibili dopo `import "mypgs"`:
|
|
192
|
+
|
|
193
|
+
- `pgs.accordion`
|
|
194
|
+
- `pgs.dropdown`
|
|
195
|
+
- `pgs.menu`
|
|
196
|
+
- `pgs.modal`
|
|
197
|
+
- `pgs.notification`
|
|
198
|
+
- `pgs.slides`
|
|
199
|
+
- `pgs.stepTabs`
|
|
200
|
+
- `pgs.steps`
|
|
201
|
+
- `pgs.formValidate`
|
|
202
|
+
- `pgs.scrollHorizontal`
|
|
203
|
+
|
|
204
|
+
## Struttura dei moduli componente
|
|
205
|
+
|
|
206
|
+
I componenti con istanze seguono questo schema:
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
export const PGS_modal = {
|
|
210
|
+
init: PGS_modal_init,
|
|
211
|
+
api: PGS_modal_api
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
- `PGS_name`: nome ufficiale del modulo per il registro legacy.
|
|
216
|
+
- `init`: inizializza o reinizializza markup, utile dopo contenuti dinamici.
|
|
217
|
+
- `api`: recupera l'API di una singola istanza gia' inizializzata.
|
|
218
|
+
|
|
219
|
+
Esempio:
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
pgs.modal.init();
|
|
223
|
+
pgs.modal.init(container);
|
|
224
|
+
pgs.modal.api(modalEl)?.open();
|
|
56
225
|
```
|
|
57
226
|
|
|
58
|
-
|
|
227
|
+
`PGS_notification` e' un caso diverso: funziona piu' come service/helper e espone `alert`, `toast` e `trigger`.
|
|
228
|
+
|
|
229
|
+
## Componenti e markup
|
|
230
|
+
|
|
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
|
|
59
234
|
|
|
60
235
|
```html
|
|
61
|
-
<
|
|
62
|
-
<
|
|
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>
|
|
63
244
|
```
|
|
64
245
|
|
|
65
|
-
|
|
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
|
+
```
|
|
66
266
|
|
|
67
|
-
|
|
267
|
+
### Accordion
|
|
68
268
|
|
|
69
269
|
```html
|
|
70
|
-
<nav pgs="menuHorizontal"></nav>
|
|
71
|
-
<button pgs="button modal-button"></button>
|
|
72
270
|
<div pgs="accordion">
|
|
73
|
-
<button pgs="accordion-button"
|
|
74
|
-
<div pgs="accordion-content"
|
|
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>
|
|
75
335
|
</div>
|
|
76
336
|
```
|
|
77
337
|
|
|
78
|
-
|
|
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:
|
|
79
349
|
|
|
80
|
-
|
|
350
|
+
```js
|
|
351
|
+
const form = document.querySelector("form");
|
|
352
|
+
const validator = new pgs.formValidate({ form });
|
|
81
353
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
```
|
|
398
|
+
|
|
399
|
+
## Componenti disponibili
|
|
400
|
+
|
|
401
|
+
Layout e utility:
|
|
402
|
+
|
|
403
|
+
- `main`
|
|
404
|
+
- `section`
|
|
405
|
+
- `sectionFull`
|
|
406
|
+
- `sectionMax`
|
|
407
|
+
- `sectionNoPadding`
|
|
408
|
+
- `container`
|
|
409
|
+
- `pageShell`
|
|
410
|
+
- `aside`
|
|
411
|
+
- `flexColumn`
|
|
412
|
+
- `flexColumnTexts`
|
|
413
|
+
- `flexColumnElements`
|
|
414
|
+
- `flexColumnSections`
|
|
415
|
+
- `flexRow`
|
|
416
|
+
- `grid-*`
|
|
417
|
+
- `gapTexts`
|
|
418
|
+
- `gapElements`
|
|
419
|
+
- `gapSections`
|
|
420
|
+
- `card`
|
|
421
|
+
- `boxtext`
|
|
422
|
+
|
|
423
|
+
Componenti:
|
|
424
|
+
|
|
425
|
+
- `button`
|
|
426
|
+
- `buttonStrong`
|
|
427
|
+
- `buttonIcon`
|
|
428
|
+
- `buttonMini`
|
|
429
|
+
- `buttonBig`
|
|
430
|
+
- `buttonClose`
|
|
431
|
+
- `form`
|
|
432
|
+
- `input`
|
|
433
|
+
- `textarea`
|
|
434
|
+
- `select`
|
|
435
|
+
- `toggle`
|
|
436
|
+
- `checkbox`
|
|
437
|
+
- `radio`
|
|
438
|
+
- `dropdown`
|
|
439
|
+
- `tooltip`
|
|
440
|
+
- `modal`
|
|
441
|
+
- `accordion`
|
|
442
|
+
- `slides`
|
|
443
|
+
- `steps`
|
|
444
|
+
- `stepTabs`
|
|
445
|
+
- `notification`
|
|
446
|
+
- `toast`
|
|
447
|
+
- `table`
|
|
448
|
+
- `breadcrumb`
|
|
449
|
+
- `searchbar`
|
|
450
|
+
- `logo`
|
|
451
|
+
- `menuHorizontal`
|
|
452
|
+
- `menuVertical`
|
|
453
|
+
- `menuFooter`
|
|
454
|
+
|
|
455
|
+
Pattern:
|
|
456
|
+
|
|
457
|
+
- `header`
|
|
458
|
+
- `footer`
|
|
459
|
+
- `cookieConsent`
|
|
90
460
|
|
|
91
461
|
## Export npm
|
|
92
462
|
|
|
@@ -94,20 +464,29 @@ Il pacchetto espone:
|
|
|
94
464
|
|
|
95
465
|
```json
|
|
96
466
|
{
|
|
97
|
-
".":
|
|
467
|
+
".": {
|
|
468
|
+
"types": "./dist/index.d.ts",
|
|
469
|
+
"import": "./assets/javascript/index.js",
|
|
470
|
+
"default": "./dist/javascript/index.js"
|
|
471
|
+
},
|
|
98
472
|
"./style.css": "./dist/css/index.css",
|
|
99
473
|
"./style.min.css": "./dist/css/index.min.css"
|
|
100
474
|
}
|
|
101
475
|
```
|
|
102
476
|
|
|
103
|
-
Uso
|
|
477
|
+
Uso compilato:
|
|
104
478
|
|
|
105
479
|
```js
|
|
106
480
|
import "mypgs";
|
|
107
481
|
import "mypgs/style.css";
|
|
108
482
|
```
|
|
109
483
|
|
|
110
|
-
|
|
484
|
+
Uso sorgente SCSS:
|
|
485
|
+
|
|
486
|
+
```scss
|
|
487
|
+
@import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
|
|
488
|
+
@import "../../node_modules/mypgs/assets/scss/index.scss";
|
|
489
|
+
```
|
|
111
490
|
|
|
112
491
|
## Sviluppo
|
|
113
492
|
|
|
@@ -123,24 +502,75 @@ Build in watch mode:
|
|
|
123
502
|
npm run "start watch"
|
|
124
503
|
```
|
|
125
504
|
|
|
126
|
-
|
|
505
|
+
Creare un pacchetto locale:
|
|
127
506
|
|
|
128
507
|
```bash
|
|
129
508
|
npm pack
|
|
130
509
|
```
|
|
131
510
|
|
|
132
|
-
|
|
511
|
+
Flusso consigliato quando modifichi la libreria:
|
|
512
|
+
|
|
513
|
+
1. modifica i sorgenti in `assets/`;
|
|
514
|
+
2. aggiorna template o documentazione se cambia il modo d'uso;
|
|
515
|
+
3. ricompila con `npm run start`;
|
|
516
|
+
4. verifica `dist/`;
|
|
517
|
+
5. crea il pacchetto con `npm pack`;
|
|
518
|
+
6. installa il `.tgz` nel progetto che consuma la libreria.
|
|
133
519
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
520
|
+
Nota: se la build Webpack fallisce, non modificare manualmente `dist/javascript` come sorgente primaria. Sistema la toolchain e rigenera gli asset compilati.
|
|
521
|
+
|
|
522
|
+
## Aggiungere un nuovo modulo
|
|
523
|
+
|
|
524
|
+
Esempio componente:
|
|
525
|
+
|
|
526
|
+
```js
|
|
527
|
+
export function PGS_myComponent_init(root = document) {
|
|
528
|
+
pgs(root).querySelectorAll("myComponent").forEach((element) => {
|
|
529
|
+
// init
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export function PGS_myComponent_api(element) {
|
|
534
|
+
// return instance API
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export const PGS_myComponent = {
|
|
538
|
+
PGS_name: "PGS_myComponent",
|
|
539
|
+
init: PGS_myComponent_init,
|
|
540
|
+
api: PGS_myComponent_api
|
|
541
|
+
};
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Registrazione in `assets/javascript/_imports.js`:
|
|
545
|
+
|
|
546
|
+
```js
|
|
547
|
+
import { PGS_myComponent } from "./components/_myComponent.js";
|
|
548
|
+
|
|
549
|
+
pgs.registerImport({
|
|
550
|
+
PGS_myComponent,
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
pgs.registerModules({
|
|
554
|
+
myComponent: PGS_myComponent,
|
|
555
|
+
});
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
Uso:
|
|
559
|
+
|
|
560
|
+
```js
|
|
561
|
+
pgs.myComponent.init();
|
|
562
|
+
pgs.myComponent.api(element);
|
|
563
|
+
```
|
|
139
564
|
|
|
140
565
|
## Convenzioni
|
|
141
566
|
|
|
142
|
-
- Usa
|
|
143
|
-
- Mantieni i token
|
|
144
|
-
-
|
|
145
|
-
-
|
|
146
|
-
-
|
|
567
|
+
- Usa `pgs` come prima scelta per markup, layout, componenti e comportamenti.
|
|
568
|
+
- Mantieni coerenti i token tra template, SCSS e JS.
|
|
569
|
+
- Usa `pgs-state` per stati runtime.
|
|
570
|
+
- Usa `pgs-option` per opzioni dichiarative.
|
|
571
|
+
- Preferisci custom properties e mixin a CSS hardcoded.
|
|
572
|
+
- Non duplicare componenti gia' presenti nella libreria.
|
|
573
|
+
- Non inventare API: verifica i sorgenti in `assets/javascript/`.
|
|
574
|
+
- Mantieni in `mypgs` solo stili e comportamenti riutilizzabili.
|
|
575
|
+
- Mantieni nel progetto finale le personalizzazioni specifiche del progetto.
|
|
576
|
+
- Aggiorna `AI_GUIDELINES.md` quando introduci pattern importanti.
|
|
@@ -11,15 +11,16 @@ import { PGS_steps } from "./components/_steps.js";
|
|
|
11
11
|
import { PGS_formValidate } from "./functions/_formValidate.js";
|
|
12
12
|
import { PGS_scrollHorizontal } from "./functions/_scrollY.js";
|
|
13
13
|
|
|
14
|
-
pgs.
|
|
15
|
-
PGS_accordion,
|
|
16
|
-
PGS_dropdown,
|
|
17
|
-
PGS_menu,
|
|
18
|
-
PGS_modal,
|
|
19
|
-
PGS_notification,
|
|
20
|
-
PGS_slides,
|
|
21
|
-
PGS_stepTabs,
|
|
22
|
-
PGS_steps,
|
|
23
|
-
PGS_formValidate,
|
|
24
|
-
PGS_scrollHorizontal,
|
|
14
|
+
pgs.registerModules({
|
|
15
|
+
accordion: PGS_accordion,
|
|
16
|
+
dropdown: PGS_dropdown,
|
|
17
|
+
menu: PGS_menu,
|
|
18
|
+
modal: PGS_modal,
|
|
19
|
+
notification: PGS_notification,
|
|
20
|
+
slides: PGS_slides,
|
|
21
|
+
stepTabs: PGS_stepTabs,
|
|
22
|
+
steps: PGS_steps,
|
|
23
|
+
formValidate: PGS_formValidate,
|
|
24
|
+
scrollHorizontal: PGS_scrollHorizontal,
|
|
25
25
|
});
|
|
26
|
+
|
|
@@ -220,7 +220,6 @@ export function pgs(root) {
|
|
|
220
220
|
const api = createBasePgs();
|
|
221
221
|
api.state = createState("pgs-state");
|
|
222
222
|
api.option = createOption("pgs-option");
|
|
223
|
-
api.modules = createOption("pgs-modules");
|
|
224
223
|
return api;
|
|
225
224
|
}
|
|
226
225
|
|
|
@@ -250,6 +249,22 @@ pgs.registerImport = function (...modules) {
|
|
|
250
249
|
return pgs;
|
|
251
250
|
};
|
|
252
251
|
|
|
252
|
+
pgs.registerModules = function (modules = {}) {
|
|
253
|
+
Object.entries(modules).forEach(([name, module]) => {
|
|
254
|
+
const key = String(name || "").trim();
|
|
255
|
+
if (!key) return;
|
|
256
|
+
|
|
257
|
+
const hasOwn = Object.prototype.hasOwnProperty.call(pgs, key);
|
|
258
|
+
if (hasOwn && pgs[key] !== module) {
|
|
259
|
+
throw new Error(`pgs.registerModules(): "${key}" e' gia' definito su pgs`);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
pgs[key] = module;
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
return pgs;
|
|
266
|
+
};
|
|
267
|
+
|
|
253
268
|
pgs.import = function (...names) {
|
|
254
269
|
return names.flat().reduce((imports, name) => {
|
|
255
270
|
const key = String(name || "").trim().replace(/^pgs[_-\s]*/i, "").toLowerCase();
|