desy-html 14.0.0 → 15.0.0-beta.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/.node-version +1 -0
- package/.nvmrc +1 -0
- package/README.md +171 -22
- package/attached_assets/Pasted--desy-html-starter-Node-Version-https-img-shields-io-ba_1765448923362.txt +431 -0
- package/docs/_global.foot.njk +0 -3
- package/docs/_macro.example-render.njk +0 -41
- package/docs/ds/_ds.example.card.njk +2 -2
- package/docs/ds/_ds.example.checkboxes.njk +6 -6
- package/docs/ds/_ds.example.color-de-interaccion.njk +4 -4
- package/docs/ds/_ds.example.colores-cabecera.njk +3 -3
- package/docs/ds/_ds.example.colores-de-soporte.njk +16 -16
- package/docs/ds/_ds.example.colores-neutros.njk +6 -6
- package/docs/ds/_ds.example.header-advanced.njk +3 -3
- package/docs/ds/_ds.example.header.njk +4 -4
- package/docs/ds/_ds.example.links-list.njk +1 -1
- package/docs/ds/_ds.example.menu-vertical.njk +1 -1
- package/docs/ds/_ds.example.menubar-en-uso.njk +2 -2
- package/docs/ds/_ds.example.radios.njk +6 -6
- package/docs/ds/_ds.example.tabs.njk +4 -4
- package/docs/ds/_ds.example.textos.njk +1 -1
- package/docs/ds/_ds.example.toggle.njk +2 -2
- package/docs/ds/_ds.example.treegrid.njk +811 -0
- package/docs/ds/_ds.section.color.njk +8 -8
- package/docs/ds/_ds.section.datos.njk +5 -0
- package/docs/ds/_ds.section.textos.njk +1 -1
- package/docs/index.html +132 -21
- package/package.json +22 -34
- package/public/images/general-lg.svg +1 -0
- package/public/images/general.svg +1 -0
- package/public/images/logo-educa-aragon.svg +1 -0
- package/public/images/logo-feader.svg +1 -0
- package/public/images/logo-feder.svg +1 -0
- package/public/images/logo-fse.svg +1 -0
- package/public/images/logo-plurifondo.svg +1 -0
- package/public/images/logo-ue.svg +1 -0
- package/replit.md +75 -0
- package/src/css/base.css +3 -3
- package/src/css/component.form-group.css +15 -14
- package/src/css/component.headroom.css +3 -2
- package/src/css/component.text.css +127 -126
- package/src/css/styles.css +228 -45
- package/src/js/aria/dialog.js +0 -10
- package/src/js/aria/listbox.js +18 -24
- package/src/js/aria/tabs.js +2 -0
- package/src/js/aria/tree.js +4 -4
- package/src/js/aria/treeitem.js +1 -1
- package/src/js/aria/utils.js +27 -1
- package/src/js/desy-html.js +451 -213
- package/src/js/index.js +1 -4
- package/src/main.js +2 -0
- package/src/templates/components/accordion/_template.accordion.njk +2 -2
- package/src/templates/components/accordion-history/_examples.accordion-history.njk +1 -1
- package/src/templates/components/accordion-history/_template.accordion-history.njk +2 -2
- package/src/templates/components/alert/_examples.alert.njk +1 -1
- package/src/templates/components/breadcrumbs/_styles.breadcrumbs.css +11 -11
- package/src/templates/components/breadcrumbs/_template.breadcrumbs.njk +17 -17
- package/src/templates/components/button/_styles.button.css +26 -35
- package/src/templates/components/button-loader/_styles.button-loader.css +15 -25
- package/src/templates/components/card/_examples.card.njk +3 -3
- package/src/templates/components/checkboxes/_styles.checkboxes.css +6 -7
- package/src/templates/components/collapsible/_examples.collapsible.njk +3 -3
- package/src/templates/components/collapsible/_styles.collapsible.css +21 -19
- package/src/templates/components/collapsible/_template.collapsible.njk +1 -1
- package/src/templates/components/datepicker/_examples.datepicker.njk +12 -12
- package/src/templates/components/datepicker/_styles.datepicker.css +15 -17
- package/src/templates/components/datepicker/_template.datepicker.njk +1 -1
- package/src/templates/components/description-list/_examples.description-list.njk +1 -1
- package/src/templates/components/details/_template.details.njk +1 -1
- package/src/templates/components/dialog/_styles.dialog.css +16 -8
- package/src/templates/components/dropdown/_styles.dropdown.css +22 -35
- package/src/templates/components/dropdown/_template.dropdown.njk +1 -1
- package/src/templates/components/file-upload/_template.file-upload.njk +1 -1
- package/src/templates/components/footer/_styles.footer.css +7 -8
- package/src/templates/components/header/_examples.header.njk +3 -2
- package/src/templates/components/header/_template.header.header__offcanvas.njk +1 -1
- package/src/templates/components/header/_template.header.header__offcanvasButton.njk +1 -1
- package/src/templates/components/header/_template.header.njk +1 -1
- package/src/templates/components/header-advanced/_examples.header-advanced.njk +3 -3
- package/src/templates/components/header-advanced/_template.header-advanced.njk +4 -4
- package/src/templates/components/header-mini/_template.header-mini.njk +1 -1
- package/src/templates/components/input/_styles.input.css +0 -1
- package/src/templates/components/input/_template.input.njk +1 -1
- package/src/templates/components/item/_template.item.njk +1 -1
- package/src/templates/components/links-list/_examples.links-list.njk +4 -4
- package/src/templates/components/listbox/_examples.listbox.njk +2 -1
- package/src/templates/components/listbox/_styles.listbox.css +24 -38
- package/src/templates/components/listbox/_template.listbox.njk +3 -3
- package/src/templates/components/menu-horizontal/_examples.menu-horizontal.njk +5 -5
- package/src/templates/components/menu-horizontal/_styles.menu-horizontal.css +23 -18
- package/src/templates/components/menu-horizontal/_template.menu-horizontal.njk +4 -4
- package/src/templates/components/menu-navigation/_styles.menu-navigation.css +113 -111
- package/src/templates/components/menu-navigation/_template.menu-navigation.njk +1 -1
- package/src/templates/components/menu-vertical/_template.menu-vertical.njk +2 -2
- package/src/templates/components/menubar/_examples.menubar.njk +13 -13
- package/src/templates/components/menubar/_styles.menubar.css +36 -50
- package/src/templates/components/menubar/_template.menubar.njk +1 -1
- package/src/templates/components/modal/_examples.modal.njk +1 -1
- package/src/templates/components/modal/_template.modal.njk +3 -3
- package/src/templates/components/nav/_template.nav.njk +1 -1
- package/src/templates/components/notification/_styles.notification.css +7 -5
- package/src/templates/components/notification/_template.notification.njk +2 -2
- package/src/templates/components/pagination/_template.pagination.njk +1 -1
- package/src/templates/components/pill/_styles.pill.css +15 -19
- package/src/templates/components/radios/_styles.radios.css +4 -5
- package/src/templates/components/searchbar/_template.searchbar.njk +2 -2
- package/src/templates/components/select/_styles.select.css +5 -7
- package/src/templates/components/select/_template.select.njk +1 -1
- package/src/templates/components/skip-link/_styles.skip-link.css +3 -4
- package/src/templates/components/skip-link/_template.skip-link.njk +1 -1
- package/src/templates/components/spinner/_styles.spinner.css +4 -3
- package/src/templates/components/table/_examples.table.njk +3 -3
- package/src/templates/components/table/_styles.table.css +5 -6
- package/src/templates/components/table-advanced/_styles.table-advanced.css +1 -1
- package/src/templates/components/tabs/_examples.tabs.njk +4 -4
- package/src/templates/components/tabs/_styles.tabs.css +65 -11
- package/src/templates/components/tabs/_template.tabs.njk +1 -1
- package/src/templates/components/textarea/_template.textarea.njk +1 -1
- package/src/templates/components/toggle/_examples.toggle.njk +12 -12
- package/src/templates/components/toggle/_styles.toggle.css +4 -4
- package/src/templates/components/tooltip/_styles.tooltip.css +1 -5
- package/src/templates/components/tooltip/_template.tooltip.njk +3 -3
- package/src/templates/components/tree/_styles.tree.css +12 -11
- package/src/templates/components/tree/_template.tree.njk +5 -5
- package/src/templates/components/treegrid/_examples.treegrid.njk +5 -5
- package/src/templates/components/treegrid/_styles.treegrid.css +21 -29
- package/src/templates/components/treegrid/_template.treegrid.njk +5 -5
- package/src/templates/pages/_page.foot-headroom.njk +1 -4
- package/src/templates/pages/_page.foot.njk +1 -4
- package/src/templates/pages/_page.head.njk +2 -2
- package/vite.config.js +740 -0
- package/config/tailwind.config.js +0 -218
- package/gulpfile.js +0 -141
- package/src/css/component.tippy-box.css +0 -11
- package/src/js/cally.js +0 -1114
- package/src/js/filters/filter-caller.js +0 -8
- package/src/js/filters/filter-escape-ltgt.js +0 -7
- package/src/js/filters/filter-quotes.js +0 -50
- package/src/js/filters/filter-slugify.js +0 -11
- package/src/js/filters/filter-version.js +0 -8
- package/src/js/filters/highlight.js +0 -14
- package/src/js/filters/index.js +0 -19
- package/src/js/globals/get-html-code-from-example.js +0 -31
- package/src/js/globals/get-html-code-from-file.js +0 -26
- package/src/js/globals/get-nunjucks-code-from-example.js +0 -31
- package/src/js/globals/get-nunjucks-code-from-file.js +0 -24
- package/src/js/globals/index.js +0 -14
- package/src/js/popper.min.js +0 -6
- package/src/js/tippy-bundle.umd.min.js +0 -2
package/.node-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.21.1
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.21.1
|
package/README.md
CHANGED
|
@@ -1,36 +1,185 @@
|
|
|
1
|
-
#
|
|
1
|
+
# desy-html
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
An NPM library for building user interfaces for Government of Aragón web applications. It uses Vite, Tailwind CSS and Nunjucks to render HTML+CSS+JS components. It's useful to create lightweight webapps or HTML mockups.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## Overview
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
**desy-html** is the core design system library that provides:
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
- **Vite** - Fast build tool and development server with hot module replacement
|
|
14
|
+
- **Tailwind CSS v4** - Utility-first CSS framework
|
|
15
|
+
- **Nunjucks** - Powerful templating engine for generating HTML
|
|
16
|
+
- **Sharp** - Image optimization for production builds
|
|
17
|
+
- **Accessible Components** - Pre-built UI components following ARIA patterns
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
If you need a more powerful library based on this, use its Angular port instead: [desy-angular](https://bitbucket.org/sdaragon/desy-angular)
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
## Quick Links
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
- **Documentation:** [https://desy.aragon.es/](https://desy.aragon.es/)
|
|
24
|
+
- **Repository:** [https://bitbucket.org/sdaragon/desy-html/](https://bitbucket.org/sdaragon/desy-html/)
|
|
25
|
+
- **Starter Project:** [https://bitbucket.org/sdaragon/desy-html-starter/](https://bitbucket.org/sdaragon/desy-html-starter/)
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
## How do I start a project that uses desy-html components?
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
To start a new project that uses desy-html as dependency, **don't use this repo**, use the **desy-html-starter** repo instead:
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
1. Download the desy-html-starter project from [https://bitbucket.org/sdaragon/desy-html-starter](https://bitbucket.org/sdaragon/desy-html-starter)
|
|
32
|
+
2. Personalize the downloaded project for your needs
|
|
33
|
+
3. You'll be able to use any desy-html component in that project
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
## Prerequisites
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
Before you begin, ensure you have the following installed:
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
- **Node.js** >=20.19.2 <23.0.0
|
|
40
|
+
- **npm** >=10.0.0
|
|
41
|
+
|
|
42
|
+
## Getting Started
|
|
43
|
+
|
|
44
|
+
### 1. Clone the Repository
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
git clone https://bitbucket.org/sdaragon/desy-html.git
|
|
48
|
+
cd desy-html
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Install Dependencies
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm install
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 3. Start Development Server
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npm run dev
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This starts the Vite development server with hot module replacement. Open your browser at the URL displayed in the terminal output.
|
|
64
|
+
|
|
65
|
+
### 4. Build for Production
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
npm run build
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This compiles HTML, purges and minifies CSS, and optimizes JavaScript into the `/dist` folder.
|
|
72
|
+
|
|
73
|
+
### 5. Preview Production Build
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
npm run preview
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Project Structure
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
desy-html/
|
|
83
|
+
├── public/
|
|
84
|
+
│ └── images/ # Library images
|
|
85
|
+
├── src/
|
|
86
|
+
│ ├── css/ # Stylesheets
|
|
87
|
+
│ ├── js/ # JavaScript files
|
|
88
|
+
│ └── templates/
|
|
89
|
+
│ ├── components/ # UI component macros
|
|
90
|
+
│ ├── includes/ # Reusable template partials
|
|
91
|
+
│ └── pages/ # Page templates
|
|
92
|
+
├── docs/ # Documentation files
|
|
93
|
+
├── vite.config.js # Vite configuration
|
|
94
|
+
├── package.json
|
|
95
|
+
└── README.md
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Styling
|
|
99
|
+
|
|
100
|
+
### Using Tailwind CSS
|
|
101
|
+
|
|
102
|
+
The project uses Tailwind CSS v4. All Tailwind utility classes are available in your templates:
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<div class="flex items-center gap-4 p-6 bg-white rounded-lg shadow">
|
|
106
|
+
<h1 class="text-2xl font-bold text-gray-900">Hello World</h1>
|
|
107
|
+
</div>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Theme Variables
|
|
111
|
+
|
|
112
|
+
desy-html provides CSS custom properties (variables) for consistent theming. These are included in the main [stylesheet](https://bitbucket.org/sdaragon/desy-html/src/master/src/css/styles.css).
|
|
113
|
+
|
|
114
|
+
## Images
|
|
115
|
+
|
|
116
|
+
### Image Structure
|
|
117
|
+
|
|
118
|
+
Images are stored in `public/images/` and can be referenced in templates using the `/images/` path:
|
|
119
|
+
|
|
120
|
+
```html
|
|
121
|
+
<img src="/images/my-image.png" alt="Description">
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Image Optimization
|
|
125
|
+
|
|
126
|
+
During production builds, images are automatically optimized using Sharp:
|
|
127
|
+
|
|
128
|
+
- Supported formats: jpg, png, webp, avif
|
|
129
|
+
- File sizes are optimized for production
|
|
130
|
+
|
|
131
|
+
## Development Tips
|
|
132
|
+
|
|
133
|
+
### Hot Module Replacement
|
|
134
|
+
|
|
135
|
+
The development server supports HMR. Changes to CSS, JavaScript, and templates will automatically refresh in the browser.
|
|
136
|
+
|
|
137
|
+
### Debugging
|
|
138
|
+
|
|
139
|
+
- Check the browser console for JavaScript errors
|
|
140
|
+
- Use the Vite terminal output for build errors
|
|
141
|
+
- Inspect generated HTML in browser developer tools
|
|
142
|
+
|
|
143
|
+
## Scripts Reference
|
|
144
|
+
|
|
145
|
+
| Command | Description |
|
|
146
|
+
|---------|-------------|
|
|
147
|
+
| `npm run dev` | Start development server with HMR |
|
|
148
|
+
| `npm run build` | Build for production |
|
|
149
|
+
| `npm run preview` | Preview production build locally |
|
|
150
|
+
|
|
151
|
+
## Accessibility
|
|
152
|
+
|
|
153
|
+
All desy-html components are built with accessibility in mind:
|
|
154
|
+
|
|
155
|
+
- Proper ARIA attributes and roles
|
|
156
|
+
- Keyboard navigation support
|
|
157
|
+
- Screen reader compatibility
|
|
158
|
+
- Focus management
|
|
159
|
+
|
|
160
|
+
## Browser Support
|
|
161
|
+
|
|
162
|
+
The project targets modern browsers. For specific compatibility information, refer to the [desy documentation](https://desy.aragon.es/).
|
|
163
|
+
|
|
164
|
+
## Contributing
|
|
165
|
+
|
|
166
|
+
1. Fork the repository
|
|
167
|
+
2. Create a feature branch
|
|
168
|
+
3. Make your changes
|
|
169
|
+
4. Submit a pull request
|
|
170
|
+
|
|
171
|
+
## Contact the Team
|
|
172
|
+
|
|
173
|
+
desy-html is maintained by a team at SDA Servicios Digitales de Aragón (Spain). If you want to know more about desy-html, please email any of the commiters.
|
|
174
|
+
|
|
175
|
+
## Author
|
|
176
|
+
|
|
177
|
+
**SDA Servicios Digitales de Aragón**
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
This project is licensed under the [EUPL-1.2](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12) license.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
For more information and detailed component documentation, visit [https://desy.aragon.es/](https://desy.aragon.es/)
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
# desy-html-starter
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
|
|
6
|
+
|
|
7
|
+
A starter project for building user interfaces for Government of Aragón web applications using the **desy-html** design system library.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
**desy-html-starter** provides a pre-configured environment with all the dependencies needed to build accessible, consistent web applications using the desy-html component library. It includes:
|
|
12
|
+
|
|
13
|
+
- **Vite** - Fast build tool and development server with hot module replacement
|
|
14
|
+
- **Tailwind CSS v4** - Utility-first CSS framework
|
|
15
|
+
- **Nunjucks** - Powerful templating engine for generating HTML
|
|
16
|
+
- **Sharp** - Image optimization for production builds
|
|
17
|
+
- **Accessible Components** - Pre-built UI components following ARIA patterns
|
|
18
|
+
|
|
19
|
+
## Quick Links
|
|
20
|
+
|
|
21
|
+
- **Documentation:** [https://desy.aragon.es/](https://desy.aragon.es/)
|
|
22
|
+
- **Repository:** [https://bitbucket.org/sdaragon/desy-html-starter/](https://bitbucket.org/sdaragon/desy-html-starter/)
|
|
23
|
+
|
|
24
|
+
## Prerequisites
|
|
25
|
+
|
|
26
|
+
Before you begin, ensure you have the following installed:
|
|
27
|
+
|
|
28
|
+
- **Node.js** ^22.0.0
|
|
29
|
+
- **npm** ^10.0.0
|
|
30
|
+
|
|
31
|
+
## Getting Started
|
|
32
|
+
|
|
33
|
+
### 1. Clone or Fork the Repository
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
git clone https://bitbucket.org/sdaragon/desy-html-starter.git my-project
|
|
37
|
+
cd my-project
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Install Dependencies
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm install
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 3. Start Development Server
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npm run dev
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This starts the Vite development server with hot module replacement. Open your browser at the URL displayed in the terminal output.
|
|
53
|
+
|
|
54
|
+
### 4. Build for Production
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npm run build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This compiles HTML, purges and minifies CSS, and optimizes JavaScript into the `/dist` folder.
|
|
61
|
+
|
|
62
|
+
### 5. Preview Production Build
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
npm run preview
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Project Structure
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
desy-html-starter/
|
|
72
|
+
├── public/
|
|
73
|
+
│ └── images/ # Project images (override desy-html images here)
|
|
74
|
+
├── src/
|
|
75
|
+
│ ├── css/
|
|
76
|
+
│ │ ├── styles.css # Main stylesheet (imports desy-html styles)
|
|
77
|
+
│ │ └── custom.css # Your custom project styles
|
|
78
|
+
│ ├── js/
|
|
79
|
+
│ │ └── index.js # JavaScript entry point (component initialization)
|
|
80
|
+
│ └── templates/
|
|
81
|
+
│ ├── components/ # Custom project components
|
|
82
|
+
│ ├── includes/ # Reusable template partials
|
|
83
|
+
│ └── pages/ # Page templates
|
|
84
|
+
├── vite.config.js # Vite configuration
|
|
85
|
+
├── package.json
|
|
86
|
+
└── README.md
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Working with Components
|
|
90
|
+
|
|
91
|
+
### Using desy-html Components
|
|
92
|
+
|
|
93
|
+
Find component examples on [desy.aragon.es](https://desy.aragon.es) such as [this button component](https://desy.aragon.es/componente-botones-codigo.html). Copy the Nunjucks code and paste it into your template's content area.
|
|
94
|
+
|
|
95
|
+
Components are available as Nunjucks macros. Import and use them in your templates:
|
|
96
|
+
|
|
97
|
+
```njk
|
|
98
|
+
{% from "components/button/_macro.button.njk" import componentButton %}
|
|
99
|
+
|
|
100
|
+
{{ componentButton({
|
|
101
|
+
"text": "Transparent",
|
|
102
|
+
"classes": "c-button--transparent"
|
|
103
|
+
}) }}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Available Components
|
|
107
|
+
|
|
108
|
+
The desy-html library includes many [accessible components](https://desy.aragon.es/componentes.html):
|
|
109
|
+
|
|
110
|
+
- **Navigation:** Menu, Menubar, Nav, Tabs
|
|
111
|
+
- **Forms:** Checkbox, Radio Button, Listbox, Datepicker, Toggle
|
|
112
|
+
- **Feedback:** Alert, Notification, Dialog, Tooltip
|
|
113
|
+
- **Layout:** Accordion, Collapsible, Tree, Treegrid
|
|
114
|
+
- **Data:** Table Advanced, Dropdown
|
|
115
|
+
|
|
116
|
+
## Styling
|
|
117
|
+
|
|
118
|
+
### Using Tailwind CSS
|
|
119
|
+
|
|
120
|
+
The project uses Tailwind CSS v4. All Tailwind utility classes are available in your templates:
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<div class="flex items-center gap-4 p-6 bg-white rounded-lg shadow">
|
|
124
|
+
<h1 class="text-2xl font-bold text-gray-900">Hello World</h1>
|
|
125
|
+
</div>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Adding Custom Styles
|
|
129
|
+
|
|
130
|
+
Add your project-specific styles in `src/css/custom.css`:
|
|
131
|
+
|
|
132
|
+
```css
|
|
133
|
+
/* src/css/custom.css */
|
|
134
|
+
.my-custom-class {
|
|
135
|
+
/* Your custom styles */
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Theme Variables
|
|
140
|
+
|
|
141
|
+
desy-html provides CSS custom properties (variables) for consistent theming. These are automatically included when you import the main [stylesheet](https://bitbucket.org/sdaragon/desy-html/src/master/src/css/styles.css).
|
|
142
|
+
|
|
143
|
+
## Templates
|
|
144
|
+
|
|
145
|
+
### Page Templates
|
|
146
|
+
|
|
147
|
+
Create new pages by extending the base layouts. Several templates are provided:
|
|
148
|
+
|
|
149
|
+
| Template | Description |
|
|
150
|
+
|----------|-------------|
|
|
151
|
+
| `plantilla-sin-loguear.html` | Public pages (not logged in) |
|
|
152
|
+
| `plantilla-logueado-con-cabecera-fija.html` | Logged-in pages with fixed header |
|
|
153
|
+
| `plantilla-logueado-con-selector-de-app.html` | Logged-in with app selector |
|
|
154
|
+
| `plantilla-con-header-advanced.html` | Advanced header layout |
|
|
155
|
+
|
|
156
|
+
### Creating Custom Components
|
|
157
|
+
|
|
158
|
+
Custom components follow a consistent file structure. Create a new folder in `src/templates/components/` with the following files:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
src/templates/components/my-component/
|
|
162
|
+
├── _macro.my-component.njk # Exports the macro (entry point)
|
|
163
|
+
├── _template.my-component.njk # HTML template with the component markup
|
|
164
|
+
├── _examples.my-component.njk # Example data for testing/documentation
|
|
165
|
+
└── params.my-component.yaml # Parameter documentation
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### Step 1: Create the Macro File
|
|
169
|
+
|
|
170
|
+
The macro file exports your component and includes the template:
|
|
171
|
+
|
|
172
|
+
```njk
|
|
173
|
+
{# _macro.my-component.njk #}
|
|
174
|
+
{% macro componentMyComponent(params) %}
|
|
175
|
+
{% include "./_template.my-component.njk" %}
|
|
176
|
+
{% endmacro %}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Step 2: Create the Template File
|
|
180
|
+
|
|
181
|
+
The template contains the actual HTML markup. Use the `params` object to access component properties:
|
|
182
|
+
|
|
183
|
+
```njk
|
|
184
|
+
{# _template.my-component.njk #}
|
|
185
|
+
<div {%- if params.classes %} class="{{ params.classes }}"{% endif %}
|
|
186
|
+
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
|
|
187
|
+
{{ params.html | safe if params.html else params.text }}
|
|
188
|
+
</div>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### Step 3: Define Examples (Optional)
|
|
192
|
+
|
|
193
|
+
Examples help document component usage and can be used for testing:
|
|
194
|
+
|
|
195
|
+
```njk
|
|
196
|
+
{# _examples.my-component.njk #}
|
|
197
|
+
{% set exampleComponent = "my-component" %}
|
|
198
|
+
{% set examples = [
|
|
199
|
+
{
|
|
200
|
+
"name": "default",
|
|
201
|
+
"data": {
|
|
202
|
+
"text": "This is my component"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"name": "with html",
|
|
207
|
+
"data": {
|
|
208
|
+
"html": "This is <strong class=\"font-bold\">my component</strong>"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
] %}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Step 4: Document Parameters (Optional)
|
|
215
|
+
|
|
216
|
+
The YAML file documents available parameters for the component:
|
|
217
|
+
|
|
218
|
+
```yaml
|
|
219
|
+
# params.my-component.yaml
|
|
220
|
+
params:
|
|
221
|
+
- name: text
|
|
222
|
+
type: string
|
|
223
|
+
required: true
|
|
224
|
+
description: Text content for the component. Ignored if `html` is provided.
|
|
225
|
+
- name: html
|
|
226
|
+
type: string
|
|
227
|
+
required: false
|
|
228
|
+
description: HTML content for the component. Takes priority over `text`.
|
|
229
|
+
- name: classes
|
|
230
|
+
type: string
|
|
231
|
+
required: false
|
|
232
|
+
description: CSS classes to add to the component.
|
|
233
|
+
- name: attributes
|
|
234
|
+
type: object
|
|
235
|
+
required: false
|
|
236
|
+
description: HTML attributes (e.g., data attributes) to add to the component.
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### Using Your Component
|
|
240
|
+
|
|
241
|
+
Import and use your component in any template. The project configures Nunjucks to resolve paths from `src/templates/`, so use the `components/` prefix:
|
|
242
|
+
|
|
243
|
+
```njk
|
|
244
|
+
{% from "components/my-component/_macro.my-component.njk" import componentMyComponent %}
|
|
245
|
+
|
|
246
|
+
{{ componentMyComponent({
|
|
247
|
+
text: "Hello world",
|
|
248
|
+
classes: "text-lg text-gray-700"
|
|
249
|
+
}) }}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Components with Nested Content (Caller)
|
|
253
|
+
|
|
254
|
+
For components that need to accept nested content, use Nunjucks' `call` block pattern:
|
|
255
|
+
|
|
256
|
+
```njk
|
|
257
|
+
{# _template.my-container.njk #}
|
|
258
|
+
<div class="container">
|
|
259
|
+
<p>{{ params.text }}</p>
|
|
260
|
+
{% if caller %}
|
|
261
|
+
{{ caller() }}
|
|
262
|
+
{% elseif params.caller %}
|
|
263
|
+
{{ params.caller | safe }}
|
|
264
|
+
{% endif %}
|
|
265
|
+
</div>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Usage with `call` block:
|
|
269
|
+
|
|
270
|
+
```njk
|
|
271
|
+
{% call componentMyContainer({ text: "Container title" }) %}
|
|
272
|
+
<p>This nested content appears inside the container.</p>
|
|
273
|
+
<button>Click me</button>
|
|
274
|
+
{% endcall %}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Using Includes
|
|
278
|
+
|
|
279
|
+
Includes are reusable template fragments that can be inserted into multiple pages. Unlike components (which receive parameters), includes are static snippets that can import and use components internally.
|
|
280
|
+
|
|
281
|
+
#### Creating an Include
|
|
282
|
+
|
|
283
|
+
Create include files in `src/templates/includes/` with names starting with underscore:
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
src/templates/includes/
|
|
287
|
+
└── _my-include.njk
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Example include file:
|
|
291
|
+
|
|
292
|
+
```njk
|
|
293
|
+
{# _my-include.njk #}
|
|
294
|
+
{% from "components/test-component/_macro.test-component.njk" import componentTestComponent %}
|
|
295
|
+
|
|
296
|
+
<div class="p-base border border-neutral-base">
|
|
297
|
+
<p>This is reusable content</p>
|
|
298
|
+
{{ componentTestComponent({
|
|
299
|
+
"text": "A component inside the include"
|
|
300
|
+
}) }}
|
|
301
|
+
</div>
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### Using an Include
|
|
305
|
+
|
|
306
|
+
Insert an include into any page or template with the `{% include %}` tag:
|
|
307
|
+
|
|
308
|
+
```njk
|
|
309
|
+
{% include "includes/_my-include.njk" %}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
#### When to Use Includes vs Components
|
|
313
|
+
|
|
314
|
+
| Use Case | Includes | Components |
|
|
315
|
+
|----------|----------|------------|
|
|
316
|
+
| Static, repeated content | Yes | No |
|
|
317
|
+
| Configurable, reusable UI elements | No | Yes |
|
|
318
|
+
| Content that needs parameters | No | Yes |
|
|
319
|
+
| Quick content reuse without configuration | Yes | No |
|
|
320
|
+
|
|
321
|
+
## Images
|
|
322
|
+
|
|
323
|
+
### Image Inheritance System
|
|
324
|
+
|
|
325
|
+
This project uses an image inheritance system that allows you to use images from the desy-html library while also being able to override them with your own:
|
|
326
|
+
|
|
327
|
+
1. **Base images** come from `node_modules/desy-html/public/images/`
|
|
328
|
+
2. **Project images** in `public/images/` override base images with the same name
|
|
329
|
+
|
|
330
|
+
### Adding Project Images
|
|
331
|
+
|
|
332
|
+
Place your images in `public/images/`. Reference them in templates using the `/images/` path:
|
|
333
|
+
|
|
334
|
+
```html
|
|
335
|
+
<img src="/images/my-image.png" alt="Description">
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Overriding desy-html Images
|
|
339
|
+
|
|
340
|
+
To replace a desy-html image with your own version, simply place a file with the same name in `public/images/`. Your image will take priority.
|
|
341
|
+
|
|
342
|
+
### Using Images in CSS
|
|
343
|
+
|
|
344
|
+
For background images in your custom CSS, use the `/images/` path:
|
|
345
|
+
|
|
346
|
+
```css
|
|
347
|
+
.my-element {
|
|
348
|
+
background-image: url('/images/my-background.png');
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Image Optimization
|
|
353
|
+
|
|
354
|
+
During production builds, images are automatically optimized using Sharp:
|
|
355
|
+
|
|
356
|
+
- Images from both desy-html and your project are processed
|
|
357
|
+
- Supported formats: jpg, png, webp, avif
|
|
358
|
+
- File sizes are optimized for production
|
|
359
|
+
- Paths are automatically adjusted for the dist folder
|
|
360
|
+
|
|
361
|
+
## Development Tips
|
|
362
|
+
|
|
363
|
+
### Hot Module Replacement
|
|
364
|
+
|
|
365
|
+
The development server supports HMR. Changes to CSS, JavaScript, and templates will automatically refresh in the browser.
|
|
366
|
+
|
|
367
|
+
### Nunjucks Template Syntax
|
|
368
|
+
|
|
369
|
+
```njk
|
|
370
|
+
{# Comments #}
|
|
371
|
+
{% set variable = "value" %}
|
|
372
|
+
{{ variable }}
|
|
373
|
+
|
|
374
|
+
{% if condition %}
|
|
375
|
+
...
|
|
376
|
+
{% endif %}
|
|
377
|
+
|
|
378
|
+
{% for item in items %}
|
|
379
|
+
{{ item }}
|
|
380
|
+
{% endfor %}
|
|
381
|
+
|
|
382
|
+
{% include "includes/_partial.njk" %}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Debugging
|
|
386
|
+
|
|
387
|
+
- Check the browser console for JavaScript errors
|
|
388
|
+
- Use the Vite terminal output for build errors
|
|
389
|
+
- Inspect generated HTML in browser developer tools
|
|
390
|
+
|
|
391
|
+
## Scripts Reference
|
|
392
|
+
|
|
393
|
+
| Command | Description |
|
|
394
|
+
|---------|-------------|
|
|
395
|
+
| `npm run dev` | Start development server with HMR |
|
|
396
|
+
| `npm run build` | Build for production |
|
|
397
|
+
| `npm run preview` | Preview production build locally |
|
|
398
|
+
|
|
399
|
+
## Accessibility
|
|
400
|
+
|
|
401
|
+
All desy-html components are built with accessibility in mind:
|
|
402
|
+
|
|
403
|
+
- Proper ARIA attributes and roles
|
|
404
|
+
- Keyboard navigation support
|
|
405
|
+
- Screen reader compatibility
|
|
406
|
+
- Focus management
|
|
407
|
+
|
|
408
|
+
When creating custom components, follow the same accessibility patterns.
|
|
409
|
+
|
|
410
|
+
## Browser Support
|
|
411
|
+
|
|
412
|
+
The project targets modern browsers. For specific compatibility information, refer to the [desy documentation](https://desy.aragon.es/).
|
|
413
|
+
|
|
414
|
+
## Contributing
|
|
415
|
+
|
|
416
|
+
1. Fork the repository
|
|
417
|
+
2. Create a feature branch
|
|
418
|
+
3. Make your changes
|
|
419
|
+
4. Submit a pull request
|
|
420
|
+
|
|
421
|
+
## Author
|
|
422
|
+
|
|
423
|
+
**SDA Servicios Digitales de Aragón**
|
|
424
|
+
|
|
425
|
+
## License
|
|
426
|
+
|
|
427
|
+
This project is licensed under the [EUPL-1.2](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12) license.
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
For more information and detailed component documentation, visit [https://desy.aragon.es/](https://desy.aragon.es/)
|
package/docs/_global.foot.njk
CHANGED