desy-html 7.1.0 → 7.1.1
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/README.md +2 -2
- package/docs/index.html +5 -0
- package/package.json +1 -1
- package/src/js/aria/checkBoxes.js +36 -0
- package/src/js/aria/radioButton.js +34 -0
- package/src/js/desy-html.js +10 -0
- package/src/js/index.js +5 -1
- package/src/templates/components/checkboxes/_styles.checkboxes.css +12 -0
- package/src/templates/components/checkboxes/_template.checkboxes.njk +3 -3
- package/src/templates/components/notification/_template.notification.njk +1 -1
- package/src/templates/components/radios/_examples.radios.njk +4 -2
- package/src/templates/components/radios/_styles.radios.css +12 -0
- package/src/templates/components/radios/_template.radios.njk +3 -3
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ See live examples of desy-html components: [https://desy.aragon.es/](https://des
|
|
|
11
11
|
* Run `npm install` first.
|
|
12
12
|
* Use `npm run dev` to generate CSS from `src/styles.css` to `/dist/styles.css`, listen to changes in njk, css and html, and browser-sync reload.
|
|
13
13
|
* Use `npm run prod` to generate CSS, Purge it and Minify it.
|
|
14
|
-
* Dependencies: Node.js
|
|
14
|
+
* Dependencies: Node.js v16.17.1, Tailwind CSS and AutoPrefixer configed in PostCSS
|
|
15
15
|
|
|
16
16
|
### How do I start a project that uses desy-html components? ###
|
|
17
17
|
|
|
@@ -26,7 +26,7 @@ To start a new project that uses desy-html as dependency, don't use this repo, u
|
|
|
26
26
|
* 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.
|
|
27
27
|
|
|
28
28
|
### Software license ###
|
|
29
|
-
Unless stated otherwise, the codebase is released under the [https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
29
|
+
Unless stated otherwise, the codebase is released under the [EUPL-1.2 License](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12). This covers both the codebase and any sample code in the documentation.
|
|
30
30
|
|
|
31
31
|
### Thanks ###
|
|
32
32
|
|
package/docs/index.html
CHANGED
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
|
|
39
39
|
<h2>Changelog (English)</h2>
|
|
40
40
|
<p>What's new in the latest version of desy-html</p>
|
|
41
|
+
<h3>v.7.1.1</h3>
|
|
42
|
+
<ul class="text-sm">
|
|
43
|
+
<li>Fixed a bug in checkboxes and radios. Now the conditionals work properly.</li>
|
|
44
|
+
<li>Minor fixes.</li>
|
|
45
|
+
</ul>
|
|
41
46
|
<h3>v.7.1.0</h3>
|
|
42
47
|
<ul class="text-sm">
|
|
43
48
|
<li>Added class to Tabs to better display them inline with scroll if needed in mobile.</li>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desy-html",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.1",
|
|
4
4
|
"description": "desy-html contains the code you need to start building a user interface for Gobierno de Aragón government webapps.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Desy (SDA Servicios Digitales de Aragón)",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function CheckBox(aria) {
|
|
2
|
+
|
|
3
|
+
class CheckBox {
|
|
4
|
+
constructor(domNode) {
|
|
5
|
+
this.rootEl = domNode;
|
|
6
|
+
this.rootEl.querySelectorAll('.c-checkboxes__conditional').forEach(item => {
|
|
7
|
+
item.addEventListener('click', this.toggleConditional.bind(this))
|
|
8
|
+
})
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
toggleConditional(event) {
|
|
12
|
+
const { target: { nodeName, checked, type }, target } = event
|
|
13
|
+
if(nodeName === 'INPUT' && type === 'checkbox') {
|
|
14
|
+
this.rootEl.querySelectorAll('.c-checkboxes__conditional').forEach(item => {
|
|
15
|
+
if(item.contains(target) && checked){
|
|
16
|
+
item.classList.remove('c-checkboxes__conditional-hidden')
|
|
17
|
+
item.classList.add('c-checkboxes__conditional-active')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if(item.contains(target) && !checked){
|
|
21
|
+
item.classList.remove('c-checkboxes__conditional-active')
|
|
22
|
+
item.classList.add('c-checkboxes__conditional-hidden')
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const checkBoxesElements = document.querySelectorAll('[data-module="c-checkboxes"]');
|
|
30
|
+
checkBoxesElements.forEach((checkBoxElement) => {
|
|
31
|
+
if (checkBoxElement.querySelector('.c-checkboxes__conditional')) {
|
|
32
|
+
new CheckBox(checkBoxElement);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function RadioButton(aria) {
|
|
2
|
+
|
|
3
|
+
class RadioButton {
|
|
4
|
+
constructor(domNode) {
|
|
5
|
+
this.rootEl = domNode;
|
|
6
|
+
this.rootEl.querySelectorAll('.c-radios__conditional').forEach(item => {
|
|
7
|
+
item.addEventListener('click', this.toggleConditional.bind(this))
|
|
8
|
+
})
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
toggleConditional(event) {
|
|
12
|
+
const { target: { nodeName, type }, target } = event
|
|
13
|
+
if(type === 'radio' && nodeName === 'INPUT') {
|
|
14
|
+
this.rootEl.querySelectorAll('.c-radios__conditional').forEach(item => {
|
|
15
|
+
if(item.contains(target)){
|
|
16
|
+
item.classList.remove('c-radios__conditional-hidden')
|
|
17
|
+
item.classList.add('c-radios__conditional-active')
|
|
18
|
+
} else {
|
|
19
|
+
item.classList.remove('c-radios__conditional-active')
|
|
20
|
+
item.classList.add('c-radios__conditional-hidden')
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const radioElements = document.querySelectorAll('[data-module="c-radios"]');
|
|
28
|
+
radioElements.forEach((radioElement) => {
|
|
29
|
+
if (radioElement.querySelector('.c-radios__conditional')) {
|
|
30
|
+
new RadioButton(radioElement);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
}
|
package/src/js/desy-html.js
CHANGED
|
@@ -15,6 +15,8 @@ import { Tree } from './aria/tree.js';
|
|
|
15
15
|
import { Toggle } from './aria/toggle.js';
|
|
16
16
|
import { Collapsible } from './aria/collapsible.js';
|
|
17
17
|
import { notification } from './aria/notification.js';
|
|
18
|
+
import { RadioButton } from './aria/radioButton.js';
|
|
19
|
+
import { CheckBox } from './aria/checkBoxes.js';
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
export function accordionComponent(aria) {
|
|
@@ -367,3 +369,11 @@ export function treeComponent(aria) {
|
|
|
367
369
|
export function notificationComponent(aria) {
|
|
368
370
|
notification(aria);
|
|
369
371
|
}
|
|
372
|
+
|
|
373
|
+
export function radioButtonComponent(aria) {
|
|
374
|
+
RadioButton(aria);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export function checkBoxComponent(aria) {
|
|
378
|
+
CheckBox(aria);
|
|
379
|
+
}
|
package/src/js/index.js
CHANGED
|
@@ -17,7 +17,9 @@ import {
|
|
|
17
17
|
tooltipComponent,
|
|
18
18
|
toggleComponent,
|
|
19
19
|
treeComponent,
|
|
20
|
-
notificationComponent
|
|
20
|
+
notificationComponent,
|
|
21
|
+
radioButtonComponent,
|
|
22
|
+
checkBoxComponent
|
|
21
23
|
} from './desy-html.js';
|
|
22
24
|
|
|
23
25
|
var aria = aria || {};
|
|
@@ -36,6 +38,8 @@ tooltipComponent(aria);
|
|
|
36
38
|
toggleComponent(aria);
|
|
37
39
|
treeComponent(aria);
|
|
38
40
|
notificationComponent(aria);
|
|
41
|
+
radioButtonComponent(aria);
|
|
42
|
+
checkBoxComponent(aria);
|
|
39
43
|
|
|
40
44
|
document.querySelectorAll('.c-code-snippet__button').forEach(button => {
|
|
41
45
|
button.addEventListener('click', (event) => {
|
|
@@ -16,4 +16,16 @@
|
|
|
16
16
|
@apply h-base !important;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
.c-checkboxes__conditional-active {
|
|
21
|
+
.c-checkboxes__conditional-item{
|
|
22
|
+
@apply block;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.c-checkboxes__conditional-hidden {
|
|
27
|
+
.c-checkboxes__conditional-item{
|
|
28
|
+
@apply hidden;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
19
31
|
}
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
visuallyHiddenText: params.errorMessage.visuallyHiddenText
|
|
50
50
|
}) | indent(2) | trim }}
|
|
51
51
|
{% endif %}
|
|
52
|
-
<div class="c-checkboxes {%- if params.classes %} {{ params.classes }}{% endif %}"
|
|
52
|
+
<div class="c-checkboxes {%- if params.classes %} {{ params.classes }}{% endif %}" data-module="c-checkboxes"
|
|
53
53
|
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
54
54
|
{% for item in params.items %}
|
|
55
55
|
{% if item %}
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
{% set itemHintId = id + "-item-hint" if hasHint else "" %}
|
|
71
71
|
{% set itemDescribedBy = describedBy if not hasFieldset else "" %}
|
|
72
72
|
{% set itemDescribedBy = (itemDescribedBy + " " + itemHintId) | trim %}
|
|
73
|
-
<div class="{%- if params.hasDividers %} border-t border-b border-neutral-base -mb-px{% endif %} {%- if item.classes %} {{ item.classes }}{% endif %}">
|
|
73
|
+
<div class="{%- if params.hasDividers %} border-t border-b border-neutral-base -mb-px{% endif %} {%- if item.classes %} {{ item.classes }}{% endif %} {%- if item.conditional.html %} c-checkboxes__conditional{% endif %} {%- if item.checked %} c-checkboxes__conditional-active {% else %} c-checkboxes__conditional-hidden {% endif %}">
|
|
74
74
|
<div class="relative flex items-start py-base">
|
|
75
75
|
<div class="flex items-center mx-sm">
|
|
76
76
|
<input class="w-6 h-6 transition duration-150 ease-in-out border-black focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-offset-0 focus:ring-warning-base disabled:bg-neutral-base disabled:border-neutral-base text-primary-base" id="{{ id }}" name="{{ name }}" type="checkbox" value="{{ item.value }}"
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
</div>
|
|
103
103
|
</div>
|
|
104
104
|
{% if item.conditional.html %}
|
|
105
|
-
<div class="mb-base ml-5 py-sm pl-6 origin-top-left border-l-2 border-primary-base" id="{{ conditionalId }}">
|
|
105
|
+
<div class="mb-base ml-5 py-sm pl-6 origin-top-left border-l-2 border-primary-base c-checkboxes__conditional-item" id="{{ conditionalId }}">
|
|
106
106
|
{{ item.conditional.html | safe }}
|
|
107
107
|
</div>
|
|
108
108
|
{% endif %}
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
{% if params.isDismissible %}
|
|
60
60
|
<div class="absolute top-0 right-0 p-sm">
|
|
61
61
|
<button class="c-notification-button__close p-sm focus:bg-warning-base focus:border-warning-base focus:shadow-outline-black focus:text-black focus:outline-none" aria-label="X: Cerrar notificación">
|
|
62
|
-
<svg class="pointer-events-none
|
|
62
|
+
<svg class="w-4 h-4 pointer-events-none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 140" width="1em" height="1em" aria-hidden="true" role="presentation"><path d="M85.91 71.77a2.5 2.5 0 010-3.54l46.16-46.16a10 10 0 10-14.14-14.14L71.77 54.09a2.5 2.5 0 01-3.54 0L22.07 7.93A10 10 0 007.93 22.07l46.16 46.16a2.5 2.5 0 010 3.54L7.93 117.93a10 10 0 0014.14 14.14l46.16-46.16a2.5 2.5 0 013.54 0l46.16 46.16a10 10 0 0014.14-14.14z" fill="currentColor"/></svg>
|
|
63
63
|
</button>
|
|
64
64
|
</div>
|
|
65
65
|
{% endif %}
|
|
@@ -353,6 +353,7 @@
|
|
|
353
353
|
{
|
|
354
354
|
"value": "email",
|
|
355
355
|
"text": "Email",
|
|
356
|
+
"checked": true,
|
|
356
357
|
"conditional": {
|
|
357
358
|
"html": "<label class=\" block font-semibold \" for=\"context-email\">Mobile phone number</label>\n<input class=\" c-input block mt-sm px-base py-sm border-black rounded font-semibold leading-normal placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base \" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
|
|
358
359
|
}
|
|
@@ -389,6 +390,7 @@
|
|
|
389
390
|
{
|
|
390
391
|
"value": "email",
|
|
391
392
|
"text": "Email",
|
|
393
|
+
"checked": true,
|
|
392
394
|
"classes": "mr-sm",
|
|
393
395
|
"conditional": {
|
|
394
396
|
"html": "<label class=\" block font-semibold \" for=\"context-email\">Mobile phone number</label>\n<input class=\" c-input block mt-sm px-base py-sm border-black rounded font-semibold leading-normal placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base \" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
|
|
@@ -434,7 +436,6 @@
|
|
|
434
436
|
{
|
|
435
437
|
"value": "phone",
|
|
436
438
|
"text": "Phone",
|
|
437
|
-
"checked": true,
|
|
438
439
|
"conditional": {
|
|
439
440
|
"html": "<label class=\" block font-semibold \" for=\"contact-phone\">Phone number</label>\n<input class=\" c-input block mt-sm px-base py-sm border-black rounded font-semibold leading-normal placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base \" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
|
|
440
441
|
}
|
|
@@ -442,6 +443,7 @@
|
|
|
442
443
|
{
|
|
443
444
|
"value": "text",
|
|
444
445
|
"text": "Text message",
|
|
446
|
+
"checked": true,
|
|
445
447
|
"conditional": {
|
|
446
448
|
"html": "<label class=\" block font-semibold \" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\" c-input block mt-sm px-base py-sm border-black rounded font-semibold leading-normal placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base \" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
|
|
447
449
|
}
|
|
@@ -514,4 +516,4 @@
|
|
|
514
516
|
]
|
|
515
517
|
}
|
|
516
518
|
}
|
|
517
|
-
] %}
|
|
519
|
+
] %}
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
visuallyHiddenText: params.errorMessage.visuallyHiddenText
|
|
44
44
|
}) | indent(2) | trim }}
|
|
45
45
|
{% endif %}
|
|
46
|
-
<div class="c-radios {%- if params.classes %} {{ params.classes }}{% endif %}"
|
|
46
|
+
<div class="c-radios {%- if params.classes %} {{ params.classes }}{% endif %}" data-module="c-radios"
|
|
47
47
|
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
48
48
|
{% for item in params.items %}
|
|
49
49
|
{% if item %}
|
|
50
|
-
<div class="{%- if params.hasDividers %} border-t border-b border-neutral-base -mb-px{% endif %} {%- if item.classes %} {{ item.classes }}{% endif %}">
|
|
50
|
+
<div class="{%- if params.hasDividers %} border-t border-b border-neutral-base -mb-px{% endif %} {%- if item.classes %} {{ item.classes }}{% endif %}{%- if item.conditional.html %} c-radios__conditional{% endif %} {%- if item.checked %} c-radios__conditional-active {% else %} c-radios__conditional-hidden {% endif %}">
|
|
51
51
|
{#- If the user explicitly sets an id, use this instead of the regular idPrefix -#}
|
|
52
52
|
{%- if item.id -%}
|
|
53
53
|
{%- set id = item.id -%}
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
</div>
|
|
98
98
|
</div>
|
|
99
99
|
{% if item.conditional.html %}
|
|
100
|
-
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base" id="{{ conditionalId }}">
|
|
100
|
+
<div class="mb-lg ml-5 pt-sm pb-base pl-6 origin-top-left border-l-2 border-primary-base c-radios__conditional-item" id="{{ conditionalId }}">
|
|
101
101
|
{{ item.conditional.html | safe }}
|
|
102
102
|
</div>
|
|
103
103
|
{% endif %}
|