@italia/section 0.1.0-alpha.2

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/AUTHORS ADDED
@@ -0,0 +1,3 @@
1
+ Copyright (c) 2025 Dipartimento per la trasformazione digitale - Presidenza del Consiglio dei Ministri
2
+
3
+ The version control system provides attribution for specific lines of code.
package/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Copyright (c) 2025, the respective contributors, as shown by the AUTHORS file.
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # \<it-section>
2
+
3
+ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i it-section
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import '@italia/it-section';
16
+ </script>
17
+
18
+ <it-section></it-section>
19
+ ```
20
+
21
+ ## Linting and formatting
22
+
23
+ To scan the project for linting and formatting errors, run
24
+
25
+ ```bash
26
+ npm run lint
27
+ ```
28
+
29
+ To automatically fix linting and formatting errors, run
30
+
31
+ ```bash
32
+ npm run format
33
+ ```
34
+
35
+ ## Testing with Web Test Runner
36
+
37
+ To execute a single test run:
38
+
39
+ ```bash
40
+ npm run test
41
+ ```
42
+
43
+ To run the tests in interactive watch mode run:
44
+
45
+ ```bash
46
+ npm run test:watch
47
+ ```
48
+
49
+ ## Demoing with Storybook
50
+
51
+ To run a local instance of Storybook for your component, run
52
+
53
+ ```bash
54
+ npm run storybook
55
+ ```
56
+
57
+ To build a production version of Storybook, run
58
+
59
+ ```bash
60
+ npm run storybook:build
61
+ ```
62
+
63
+ ## Tooling configs
64
+
65
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
66
+
67
+ If you customize the configuration a lot, you can consider moving them to individual files.
68
+
69
+ ## Local Demo with `web-dev-server`
70
+
71
+ ```bash
72
+ npm start
73
+ ```
74
+
75
+ To run a local development server that serves the basic demo located in `demo/index.html`
@@ -0,0 +1,260 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/index.ts",
8
+ "declarations": [],
9
+ "exports": [
10
+ {
11
+ "kind": "js",
12
+ "name": "ItSection",
13
+ "declaration": {
14
+ "name": "ItSection",
15
+ "module": "./it-section.js"
16
+ }
17
+ }
18
+ ]
19
+ },
20
+ {
21
+ "kind": "javascript-module",
22
+ "path": "src/it-section.ts",
23
+ "declarations": [
24
+ {
25
+ "kind": "class",
26
+ "description": "",
27
+ "name": "ItSection",
28
+ "members": [
29
+ {
30
+ "kind": "field",
31
+ "name": "variant",
32
+ "type": {
33
+ "text": "'muted' | 'emphasis' | 'primary' | undefined"
34
+ },
35
+ "attribute": "variant"
36
+ },
37
+ {
38
+ "kind": "field",
39
+ "name": "image",
40
+ "type": {
41
+ "text": "string"
42
+ },
43
+ "default": "''",
44
+ "attribute": "image"
45
+ },
46
+ {
47
+ "kind": "field",
48
+ "name": "inverse",
49
+ "type": {
50
+ "text": "boolean"
51
+ },
52
+ "default": "false",
53
+ "attribute": "inverse"
54
+ },
55
+ {
56
+ "kind": "field",
57
+ "name": "sectionId",
58
+ "type": {
59
+ "text": "string | undefined"
60
+ },
61
+ "privacy": "private"
62
+ },
63
+ {
64
+ "kind": "method",
65
+ "name": "updateInverseClass",
66
+ "privacy": "private"
67
+ },
68
+ {
69
+ "kind": "method",
70
+ "name": "organizeContent",
71
+ "privacy": "private"
72
+ },
73
+ {
74
+ "kind": "method",
75
+ "name": "updateAriaLabelledBy",
76
+ "privacy": "private"
77
+ }
78
+ ],
79
+ "attributes": [
80
+ {
81
+ "name": "variant",
82
+ "type": {
83
+ "text": "'muted' | 'emphasis' | 'primary' | undefined"
84
+ },
85
+ "fieldName": "variant"
86
+ },
87
+ {
88
+ "name": "image",
89
+ "type": {
90
+ "text": "string"
91
+ },
92
+ "default": "''",
93
+ "fieldName": "image"
94
+ },
95
+ {
96
+ "name": "inverse",
97
+ "type": {
98
+ "text": "boolean"
99
+ },
100
+ "default": "false",
101
+ "fieldName": "inverse"
102
+ }
103
+ ],
104
+ "superclass": {
105
+ "name": "BaseComponent",
106
+ "package": "@italia/globals"
107
+ },
108
+ "tagName": "it-section",
109
+ "customElement": true
110
+ }
111
+ ],
112
+ "exports": [
113
+ {
114
+ "kind": "js",
115
+ "name": "ItSection",
116
+ "declaration": {
117
+ "name": "ItSection",
118
+ "module": "src/it-section.ts"
119
+ }
120
+ },
121
+ {
122
+ "kind": "custom-element-definition",
123
+ "name": "it-section",
124
+ "declaration": {
125
+ "name": "ItSection",
126
+ "module": "src/it-section.ts"
127
+ }
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ "kind": "javascript-module",
133
+ "path": "src/types.ts",
134
+ "declarations": [
135
+ {
136
+ "kind": "variable",
137
+ "name": "SECTION_VARIANTS",
138
+ "type": {
139
+ "text": "['muted', 'emphasis', 'primary']"
140
+ },
141
+ "default": "['muted', 'emphasis', 'primary']"
142
+ }
143
+ ],
144
+ "exports": [
145
+ {
146
+ "kind": "js",
147
+ "name": "SECTION_VARIANTS",
148
+ "declaration": {
149
+ "name": "SECTION_VARIANTS",
150
+ "module": "src/types.ts"
151
+ }
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ "kind": "javascript-module",
157
+ "path": "stories/it-section.stories.ts",
158
+ "declarations": [
159
+ {
160
+ "kind": "variable",
161
+ "name": "meta",
162
+ "type": {
163
+ "text": "object"
164
+ },
165
+ "default": "{ title: 'Componenti/Section', tags: ['autodocs'], component: 'it-section', parameters: { docs: { description: { component: `<Description>Per creare sezioni di layout orizzontale con differenti sfondi.</Description> Il componente \\`<it-section>\\` rappresenta un contenitore visivo per introdurre sezioni di contenuto con o senza immagine. Per indicazioni su \"Come e Quando usarlo\" si fa riferimento alla [guida del design-system](https://designers.italia.it/design-system/componenti/sections/) <div class=\"callout callout-success\"><div class=\"callout-inner\"><div class=\"callout-title\"><span class=\"text\">Accessibilità (Draft)</span></div><p> Il titolo h2 dello snippet è solo indicativo: assicurati che il contenuto contenga un'intestazione semantica per garantire la corretta navigazione assistiva. <br>Il tag it-section contraddistingue una sezione semanticamente riconoscibile, associata all’id del titolo dall’attributo aria-labelledby. <br>Gli autori dovrebbero dividere la pagina in sezioni semantiche reali e non per solo scopo decorativo. <br> Qualora si utilizzino sezioni al solo scopo decorativo sostituire it-section con div ed eliminare l’attributo aria-labelledby. <br><br> Le immagini fornite tramite l'attributo <code>image</code> sono considerate <strong>decorative</strong>: sono rese con un tag <code>&lt;img&gt;</code> e <code>aria-hidden=\"true\"</code>. In questo modo non vengono annunciate dagli screen reader.</p><p class=\"pt-2\"> </p></div></div> `, }, }, }, args: { variant: '', image: '', inverse: false, }, argTypes: { variant: { control: { type: 'select' }, options: SECTION_VARIANTS, description: 'Variante grafica del componente, corrisponde alle classi di Bootstrap Italia', table: { defaultValue: { summary: undefined } }, }, image: { control: { type: 'text' }, description: 'URL immagine di sfondo, ad esempio https://picsum.photos/1600/500', }, inverse: { control: { type: 'boolean' }, description: 'Quando attivo, l’attributo inverse applica il colore bianco ai testi. È utile quando la sezione ha uno sfondo scuro o un’immagine di sfondo, così da garantire il corretto contrasto e la leggibilità dei contenuti.', table: { defaultValue: { summary: false } }, }, }, }"
166
+ },
167
+ {
168
+ "kind": "variable",
169
+ "name": "EsempioInterattivo",
170
+ "type": {
171
+ "text": "Story"
172
+ },
173
+ "default": "{ name: 'Esempio interattivo', tags: ['!autodocs', '!dev'], parameters: { docs: { canvas: { sourceState: 'shown', }, }, }, render: (args) => html`${renderSection(args)}`, }"
174
+ },
175
+ {
176
+ "kind": "variable",
177
+ "name": "PersonalizzazioneDegliStili",
178
+ "type": {
179
+ "text": "Story"
180
+ },
181
+ "default": "{ name: 'Personalizzazione degli stili', tags: ['!dev'], parameters: { viewMode: 'docs', // assicura che si apra la tab Docs anziché Canvas docs: { canvas: { hidden: true, sourceState: 'none' }, // nasconde solo il canvas nella docs page description: { story: ` Per la personalizzazione degli stili si può usare il selettore \\`::part\\` passando il valore \\`section\\`. [Vedi qui la guida dettagliata](/docs/personalizzazione-degli-stili--documentazione#selettore-part). Quando si organizzano i contenuti usando le classi della griglia, non serve aggiungere spazio ai lati. Se proprio necessario, si può aggiungere spazio laterale usando la variabile \\`--bs-section-padding-x\\`. Si può usare la variabile \\`--bs-section-image-overlay\\` per regolare l'opacità dell'overlay applicato all'immagine. `, }, }, }, render: () => html`<div class=\"hide-preview\"></div>`, }"
182
+ },
183
+ {
184
+ "kind": "variable",
185
+ "name": "VariantiColore",
186
+ "type": {
187
+ "text": "Story"
188
+ },
189
+ "default": "{ name: 'Varianti di sfondo', render: () => html` <div class=\"d-flex flex-column gap-4\"> ${(['muted', 'emphasis', 'primary'] as const).map((variant) => renderSection({ variant, inverse: variant !== 'muted', content: html` <div class=\"container\"> <h3 id=\"section-heading-${variant}\">Sezione ${variant}</h3> <p> Questa sezione usa la variante <code>${variant}</code> ${variant !== 'muted' ? \"con testo bianco attraverso l'attributo inverse\" : ''} </p> </div> `, }), )} </div> `, parameters: { docs: { description: { story: ` Sono disponibili le varianti colore di sfondo per le sezioni, corrispondenti alle classi di Bootstrap italia: - \\`muted\\` - \\`emphasis\\` - \\`primary\\` Il componente Section ha, per default, uno sfondo trasparente. `, }, }, }, }"
190
+ },
191
+ {
192
+ "kind": "variable",
193
+ "name": "VarianteConImmagine",
194
+ "type": {
195
+ "text": "Story"
196
+ },
197
+ "default": "{ name: 'Sezione con immagine decorativa', args: { image: 'https://picsum.photos/1280/720?image=81', inverse: true, }, render: (params) => renderSection({ ...params, }), parameters: { docs: { description: { story: ` Valorizzando l'attributo \\`image\\` del componente con l’URL dell’immagine da utilizzare la Section utilizzerà l’immagine indicata come sfondo, adattandone automaticamente le dimensioni per coprire l’intera Section. A seconda della luminosità dell’immagine si consiglia di valorizzare o meno l'attributo \\`inverse\\` per garantire il corretto contrasto fra testi e sfondo. `, }, }, }, }"
198
+ },
199
+ {
200
+ "kind": "variable",
201
+ "name": "SectionConCard",
202
+ "type": {
203
+ "text": "Story"
204
+ },
205
+ "default": "{ name: 'Sezione con card', args: { variant: 'muted', }, render: (params) => renderSection({ ...params, content: html` <div class=\"container\"> <div class=\"row\"> <div class=\"col\"> <h2 id=\"section-heading-card\" class=\"mb-4\">Morbi fermentum amet</h2> </div> </div> <div class=\"row gy-3\"> <div class=\"col-12 col-md-6\"> <div class=\"card shadow\"> <div class=\"card-body\"> <p class=\"card-text font-serif\"> Platea dictumst vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras. </p> </div> </div> </div> <div class=\"col-12 col-md-6\"> <div class=\"card shadow\"> <div class=\"card-body\"> <p class=\"card-text font-serif\"> Dictum sit amet justo donec enim diam vulputate ut. Eu nisl nunc mi ipsum faucibus. </p> </div> </div> </div> </div> </div> `, }), parameters: { docs: { description: { story: ` Per aggiungere una serie di card all’interno di una Section si consiglia di utilizzare le griglie per garantire un corretto margine fra gli elementi . `, }, }, }, }"
206
+ }
207
+ ],
208
+ "exports": [
209
+ {
210
+ "kind": "js",
211
+ "name": "default",
212
+ "declaration": {
213
+ "name": "meta",
214
+ "module": "stories/it-section.stories.ts"
215
+ }
216
+ },
217
+ {
218
+ "kind": "js",
219
+ "name": "EsempioInterattivo",
220
+ "declaration": {
221
+ "name": "EsempioInterattivo",
222
+ "module": "stories/it-section.stories.ts"
223
+ }
224
+ },
225
+ {
226
+ "kind": "js",
227
+ "name": "PersonalizzazioneDegliStili",
228
+ "declaration": {
229
+ "name": "PersonalizzazioneDegliStili",
230
+ "module": "stories/it-section.stories.ts"
231
+ }
232
+ },
233
+ {
234
+ "kind": "js",
235
+ "name": "VariantiColore",
236
+ "declaration": {
237
+ "name": "VariantiColore",
238
+ "module": "stories/it-section.stories.ts"
239
+ }
240
+ },
241
+ {
242
+ "kind": "js",
243
+ "name": "VarianteConImmagine",
244
+ "declaration": {
245
+ "name": "VarianteConImmagine",
246
+ "module": "stories/it-section.stories.ts"
247
+ }
248
+ },
249
+ {
250
+ "kind": "js",
251
+ "name": "SectionConCard",
252
+ "declaration": {
253
+ "name": "SectionConCard",
254
+ "module": "stories/it-section.stories.ts"
255
+ }
256
+ }
257
+ ]
258
+ }
259
+ ]
260
+ }
@@ -0,0 +1,2 @@
1
+ export { ItSection } from './it-section.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { ItSection } from './it-section.js';
2
+ import 'lit';
3
+ import 'lit/decorators.js';
4
+ import 'lit/directives/class-map.js';
5
+ import 'lit/directive.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,20 @@
1
+ import { BaseComponent } from '@italia/globals';
2
+ export declare class ItSection extends BaseComponent {
3
+ variant?: 'muted' | 'emphasis' | 'primary';
4
+ image: string;
5
+ inverse: boolean;
6
+ private sectionId?;
7
+ createRenderRoot(): this;
8
+ connectedCallback(): void;
9
+ updated(): void;
10
+ private updateInverseClass;
11
+ private organizeContent;
12
+ private updateAriaLabelledBy;
13
+ render(): import("lit").TemplateResult<1>;
14
+ }
15
+ declare global {
16
+ interface HTMLElementTagNameMap {
17
+ 'it-section': ItSection;
18
+ }
19
+ }
20
+ //# sourceMappingURL=it-section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"it-section.d.ts","sourceRoot":"","sources":["../../src/it-section.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,qBACa,SAAU,SAAQ,aAAa;IACd,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;IAE3C,KAAK,SAAM;IAEV,OAAO,UAAS;IAE7C,OAAO,CAAC,SAAS,CAAC,CAAS;IAI3B,gBAAgB;IAIhB,iBAAiB;IAKjB,OAAO;IAMP,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,oBAAoB;IAkC5B,MAAM;CAuBP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}