@ilo-org/twig 0.16.2 → 0.16.3
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/.turbo/turbo-build:lib.log +2 -2
- package/CHANGELOG.md +12 -0
- package/package.json +4 -4
- package/src/patterns/components/accordion/accordion-item.twig +9 -3
- package/src/patterns/components/accordion/accordion.js +35 -2
- package/src/patterns/components/accordion/accordion.wingsuit.yml +23 -7
- package/src/patterns/components/pagination/pagination.twig +2 -1
- package/src/patterns/components/tabs/tabs.twig +3 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @ilo-org/twig@0.16.
|
|
2
|
+
> @ilo-org/twig@0.16.3 build:lib /home/runner/work/designsystem/designsystem/packages/twig
|
|
3
3
|
> node importprefix.js && node importsvgs.js && pnpm output
|
|
4
4
|
|
|
5
5
|
theme prefix added
|
|
6
6
|
|
|
7
|
-
> @ilo-org/twig@0.16.
|
|
7
|
+
> @ilo-org/twig@0.16.3 output /home/runner/work/designsystem/designsystem/packages/twig
|
|
8
8
|
> node outputtwigs.js
|
|
9
9
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ilo-org/twig
|
|
2
2
|
|
|
3
|
+
## 0.16.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9a326f047: fixed accordion a11y
|
|
8
|
+
- 77fbf565d: Fix lighthouse accessibility audit error of tabs attributes not matching their roles
|
|
9
|
+
- 10dadfad7: Fix design bug in pagination for rtl
|
|
10
|
+
- Updated dependencies [7e1460a88]
|
|
11
|
+
- Updated dependencies [10dadfad7]
|
|
12
|
+
- Updated dependencies [5bc989f5d]
|
|
13
|
+
- @ilo-org/styles@0.15.0
|
|
14
|
+
|
|
3
15
|
## 0.16.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ilo-org/twig",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Twig components for the ILO's Design System",
|
|
6
6
|
"main": "",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@ilo-org/brand-assets": "0.4.0",
|
|
28
28
|
"@ilo-org/fonts": "0.1.2",
|
|
29
29
|
"@ilo-org/icons": "0.2.1",
|
|
30
|
-
"@ilo-org/styles": "0.
|
|
31
|
-
"@ilo-org/
|
|
32
|
-
"@ilo-org/
|
|
30
|
+
"@ilo-org/styles": "0.15.0",
|
|
31
|
+
"@ilo-org/themes": "0.7.2",
|
|
32
|
+
"@ilo-org/utils": "0.0.11"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@babel/core": "^7.20.12",
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
ACCORDION ITEM COMPONENT
|
|
3
3
|
#}
|
|
4
4
|
{% set uid = "now"|date('Uv') %}
|
|
5
|
-
|
|
5
|
+
{% set accordion_id = id ~ uid %}
|
|
6
|
+
{% set button_id = 'button-' ~ accordion_id %}
|
|
7
|
+
{% set panel_id = 'panel-' ~ accordion_id %}
|
|
8
|
+
{% set expanded_class = defaultExpanded ? prefix ~ '--accordion--panel--open' : '' %}
|
|
9
|
+
{% set scroll_class = scroll ? prefix ~ '--accordion--panel__scroll' : '' %}
|
|
10
|
+
|
|
11
|
+
<li class="{{prefix}}--accordion--item" id="{{ accordion_id }}">
|
|
6
12
|
<div class="ilo--h3">
|
|
7
|
-
<button class="{{prefix}}--accordion--button {{prefix}}--accordion--button--{{ size|default('small') }}" aria-expanded="{{ defaultExpanded }}" aria-controls="
|
|
13
|
+
<button class="{{prefix}}--accordion--button {{prefix}}--accordion--button--{{ size|default('small') }}" aria-expanded="{{ defaultExpanded }}" aria-controls="{{ panel_id }}" id="{{ button_id }}">
|
|
8
14
|
{{label}}
|
|
9
15
|
</button>
|
|
10
16
|
</div>
|
|
11
|
-
<div class="{{prefix}}--accordion--panel {
|
|
17
|
+
<div class="{{prefix}}--accordion--panel {{ expanded_class }} {{ scroll_class }}" id="{{ panel_id }}" aria-labelledby="{{ button_id }}" role="region" aria-hidden={{defaultExpanded ? 'false' : 'true'}}>
|
|
12
18
|
<div class="{{prefix}}--accordion--innerpanel">
|
|
13
19
|
{{content|raw}}
|
|
14
20
|
</div>
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { EVENTS, ARIA } from "@ilo-org/utils";
|
|
2
2
|
|
|
3
|
+
const FOCUSABLE_SELECTORS = [
|
|
4
|
+
"a",
|
|
5
|
+
"button",
|
|
6
|
+
"input",
|
|
7
|
+
"select",
|
|
8
|
+
"textarea",
|
|
9
|
+
"[tabindex]:not([tabindex='-1'])",
|
|
10
|
+
];
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* The Accordion module which handles rendering field labels inline on a form.
|
|
5
14
|
*
|
|
@@ -91,6 +100,12 @@ export default class Accordion {
|
|
|
91
100
|
});
|
|
92
101
|
}
|
|
93
102
|
|
|
103
|
+
if (this.accordionPanels.length > 0) {
|
|
104
|
+
this.accordionPanels.forEach((panel) => {
|
|
105
|
+
this.handleTabIndex(panel, "REMOVE");
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
94
109
|
return this;
|
|
95
110
|
}
|
|
96
111
|
|
|
@@ -147,7 +162,8 @@ export default class Accordion {
|
|
|
147
162
|
element.parentElement
|
|
148
163
|
.querySelector(".ilo--accordion--button")
|
|
149
164
|
.setAttribute(ARIA.EXPANDED, "false");
|
|
150
|
-
element.setAttribute(ARIA.HIDDEN, "
|
|
165
|
+
element.setAttribute(ARIA.HIDDEN, "true");
|
|
166
|
+
this.handleTabIndex(element, "REMOVE");
|
|
151
167
|
}
|
|
152
168
|
|
|
153
169
|
/**
|
|
@@ -161,7 +177,24 @@ export default class Accordion {
|
|
|
161
177
|
element.parentElement
|
|
162
178
|
.querySelector(".ilo--accordion--button")
|
|
163
179
|
.setAttribute(ARIA.EXPANDED, "true");
|
|
164
|
-
element.setAttribute(ARIA.HIDDEN, "
|
|
180
|
+
element.setAttribute(ARIA.HIDDEN, "false");
|
|
165
181
|
element.classList.add("ilo--accordion--panel--open");
|
|
182
|
+
this.handleTabIndex(element, "ADD");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* @param {HTMLElement} element - REQUIRED - the accordion panel to be adjusted
|
|
188
|
+
* @param {('ADD' | 'REMOVE')} mode - REQUIRED - weather to set or remove tabindex
|
|
189
|
+
*/
|
|
190
|
+
handleTabIndex(element, mode) {
|
|
191
|
+
element.querySelectorAll(FOCUSABLE_SELECTORS.join(", ")).forEach((item) => {
|
|
192
|
+
if (mode === "ADD") {
|
|
193
|
+
item.removeAttribute("tabindex");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
item.setAttribute("tabindex", "-1");
|
|
198
|
+
});
|
|
166
199
|
}
|
|
167
200
|
}
|
|
@@ -2,9 +2,8 @@ accordion:
|
|
|
2
2
|
namespace: Components/Content
|
|
3
3
|
use: "@components/accordion/accordion.twig"
|
|
4
4
|
label: Accordion
|
|
5
|
-
description:
|
|
6
|
-
|
|
7
|
-
related content on a page. Items in the accordion can be expanded by default or scrollable if the content is very long.
|
|
5
|
+
description: The accordion component allows the user to show and hide sections of related content on a page. Items in the accordion can be expanded by default or scrollable if the content is very long.
|
|
6
|
+
|
|
8
7
|
fields:
|
|
9
8
|
items:
|
|
10
9
|
type: object
|
|
@@ -22,6 +21,7 @@ accordion:
|
|
|
22
21
|
id: item2
|
|
23
22
|
defaultExpanded: false
|
|
24
23
|
scroll: false
|
|
24
|
+
|
|
25
25
|
settings:
|
|
26
26
|
size:
|
|
27
27
|
type: select
|
|
@@ -41,22 +41,38 @@ accordion:
|
|
|
41
41
|
false: False
|
|
42
42
|
preview: "true"
|
|
43
43
|
required: false
|
|
44
|
+
|
|
44
45
|
variants:
|
|
45
46
|
default:
|
|
46
|
-
label:
|
|
47
|
+
label: Default
|
|
47
48
|
scrollable:
|
|
48
49
|
label: "Scrollable"
|
|
49
50
|
description: "You can make an accordion item scrollable simply by passing it scroll: true in the preview."
|
|
50
51
|
fields:
|
|
51
52
|
items:
|
|
52
53
|
- label: Topics
|
|
53
|
-
content: '<div style="padding: 20px"><ul class="ilo--list--unordered"><li>Employment Promotion and Job Creation</li><li>Social Protection</li><li>International Labour Standards</li><li>Social Dialogue and Tripartism</li><li>Occupational Safety and Health</li><li>Labor Migration</li><li>Child Labour and Forced Labour Elimination</li><li>Gender Equality and Non-Discrimination</li
|
|
54
|
+
content: '<div style="padding: 20px"><ul class="ilo--list--unordered"><li>Employment Promotion and Job Creation</li><li>Social Protection</li><li>International Labour Standards</li><li>Social Dialogue and Tripartism</li><li>Occupational Safety and Health</li><li>Labor Migration</li><li>Child Labour and Forced Labour Elimination</li><li>Gender Equality and Non-Discrimination</li></ul></div>'
|
|
54
55
|
id: item1
|
|
55
56
|
defaultExpanded: false
|
|
56
57
|
scroll: true
|
|
57
58
|
- label: Sectors
|
|
58
|
-
content: '<div style="padding: 20px"><ul class="ilo--list--unordered"><li>Agriculture, Forestry, and Fishing</li><li>Construction</li><li>Manufacturing</li><li>Transport and Storage</li><li>Wholesale and Retail Trade</li><li>Information and Communication</li><li>Finance and Insurance</li><li>Health and Social Work</li><li>Educational Services</li><li>Public Administration and Defense</li><li>Other Services</li
|
|
59
|
+
content: '<div style="padding: 20px"><ul class="ilo--list--unordered"><li>Agriculture, Forestry, and Fishing</li><li>Construction</li><li>Manufacturing</li><li>Transport and Storage</li><li>Wholesale and Retail Trade</li><li>Information and Communication</li><li>Finance and Insurance</li><li>Health and Social Work</li><li>Educational Services</li><li>Public Administration and Defense</li><li>Other Services</li></ul></div>'
|
|
59
60
|
id: item2
|
|
60
61
|
defaultExpanded: false
|
|
61
62
|
scroll: true
|
|
62
|
-
|
|
63
|
+
focus:
|
|
64
|
+
label: "Focus elements"
|
|
65
|
+
description: "This variant includes checkboxes inside the accordion item."
|
|
66
|
+
fields:
|
|
67
|
+
items:
|
|
68
|
+
- label: User Preferences
|
|
69
|
+
content: '<div style="padding: 20px"><form><input type="checkbox" id="option1" name="option1"><label for="option1">Option 1</label><br><input type="checkbox" id="option2" name="option2"><label for="option2">Option 2</label><br><input type="checkbox" id="option3" name="option3"><label for="option3">Option 3</label><br><input type="checkbox" id="option4" name="option4"><label for="option4">Option 4</label><br><input type="checkbox" id="option5" name="option5"><label for="option5">Option 5</label></form></div>'
|
|
70
|
+
id: item1
|
|
71
|
+
defaultExpanded: false
|
|
72
|
+
scroll: false
|
|
73
|
+
- label: More Preferences
|
|
74
|
+
content: '<div style="padding: 20px"><form><input type="checkbox" id="option3" name="option3"><label for="option3">Option 3</label><br><input type="checkbox" id="option4" name="option4"><label for="option4">Option 4</label></form></div>'
|
|
75
|
+
id: item2
|
|
76
|
+
defaultExpanded: false
|
|
77
|
+
scroll: false
|
|
78
|
+
visibility: storybook
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
{% set currentPageZeroIndex = currentPage * 1 %}
|
|
25
25
|
{% set currentPageIndex = currentPageZeroIndex + 1 %}
|
|
26
26
|
|
|
27
|
-
<span>{{currentPageIndex}}</span>
|
|
27
|
+
<span>{{currentPageIndex}}</span>
|
|
28
|
+
<span>{{pageCountPreposition}}</span>
|
|
28
29
|
<span>{{totalPages}}</span>
|
|
29
30
|
</p>
|
|
30
31
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
{#
|
|
2
|
-
TABS COMPONENT
|
|
3
|
-
#}
|
|
4
1
|
{% set uid = "now"|date('Uv') %}
|
|
5
2
|
{% set tabids = [] %}
|
|
6
3
|
{% for item in items %}
|
|
@@ -9,8 +6,8 @@
|
|
|
9
6
|
<div class="{{prefix}}--tabs" data-prefix="{{prefix}}" id="tabs--{{uid}}" data-loadcomponent="Tabs">
|
|
10
7
|
<ul class="{{prefix}}--tabs--selection" aria-controls="tabs--{{uid}}" role="tablist" style="--tabscount: {{items|length}};">
|
|
11
8
|
{% for item in items %}
|
|
12
|
-
<li class="{{prefix}}--tabs--selection--item" role="
|
|
13
|
-
<a href="#tab--{{tabids[loop.index - 1]}}" class="{{prefix}}--tabs--selection--button{% if item.icon is defined %} icon{% endif %}" aria-controls="tab--{{tabids[loop.index - 1]}}" tabindex="0"
|
|
9
|
+
<li class="{{prefix}}--tabs--selection--item" role="presentation"> {# changed role to presentation for list item #}
|
|
10
|
+
<a href="#tab--{{tabids[loop.index - 1]}}" class="{{prefix}}--tabs--selection--button{% if item.icon is defined %} icon{% endif %}" aria-controls="tab--{{tabids[loop.index - 1]}}" role="tab" tabindex="0" {% if loop.index == 1 %}aria-selected="true"{% else %}aria-selected="false"{% endif %} title="{{item.label}}">
|
|
14
11
|
<span class="{{prefix}}--tabs--selection--label">{{item.label}}</span>
|
|
15
12
|
{% if item.icon is defined %}
|
|
16
13
|
{% include '@components/icon/icon.twig' with {icon: item.icon} %}
|
|
@@ -21,7 +18,7 @@
|
|
|
21
18
|
</ul>
|
|
22
19
|
<div class="{{prefix}}--tabs--content">
|
|
23
20
|
{% for item in items %}
|
|
24
|
-
<div id="tab--{{tabids[loop.index - 1]}}" role="tabpanel" aria-
|
|
21
|
+
<div id="tab--{{tabids[loop.index - 1]}}" role="tabpanel" aria-labelledby="tab--{{tabids[loop.index - 1]}}" {% if loop.index == 1 %}aria-expanded="true"{% else %}aria-expanded="false"{% endif %}>
|
|
25
22
|
{% include '@components/' ~ item.component ~ '/' ~ item.component ~ '.twig' with item.componentdata %}
|
|
26
23
|
</div>
|
|
27
24
|
{% endfor %}
|