@openeuropa/bcl-dropdown 0.1.2 → 0.1.202408021145
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/dropdown.html.twig +53 -39
- package/package.json +4 -4
package/dropdown.html.twig
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{% spaceless %}
|
|
1
|
+
{% apply spaceless %}
|
|
2
2
|
|
|
3
3
|
{# Parameters:
|
|
4
|
-
- id (string) (default:
|
|
5
|
-
- trigger (
|
|
4
|
+
- id (string) (default: dropdown-random(1000))
|
|
5
|
+
- trigger (link or button)
|
|
6
6
|
- link (boolean) (default: false)
|
|
7
7
|
- direction (string) (default: '')
|
|
8
8
|
- options ['dropup', 'dropend', 'dropstart']
|
|
@@ -23,87 +23,101 @@
|
|
|
23
23
|
]
|
|
24
24
|
- dark (boolean) (default: false)
|
|
25
25
|
- remove_wrapper (boolean) (default: false)
|
|
26
|
-
- items (
|
|
26
|
+
- items (object[])
|
|
27
27
|
format: [
|
|
28
28
|
{
|
|
29
|
-
-
|
|
29
|
+
- link or button object
|
|
30
30
|
- active (boolean)
|
|
31
31
|
- divider (bolean) - show divider
|
|
32
32
|
- button (boolean) - set to button
|
|
33
33
|
}
|
|
34
34
|
]
|
|
35
|
+
- attributes (drupal attrs)
|
|
35
36
|
#}
|
|
36
37
|
|
|
37
38
|
{% set _id = id|default('dropdown-' ~ random(1000)) %}
|
|
38
39
|
{% set _trigger = trigger|default({}) %}
|
|
39
|
-
{% set _link = link
|
|
40
|
+
{% set _link = link ?? false %}
|
|
40
41
|
{% set _direction = direction|default('') %}
|
|
41
42
|
{% set _alignment = alignment|default('') %}
|
|
42
|
-
{% set _dark = dark
|
|
43
|
-
{% set _remove_wrapper = remove_wrapper
|
|
43
|
+
{% set _dark = dark ?? false %}
|
|
44
|
+
{% set _remove_wrapper = remove_wrapper ?? false %}
|
|
44
45
|
{% set _items = items|default([]) %}
|
|
46
|
+
|
|
45
47
|
{% set _class = 'dropdown' %}
|
|
46
|
-
{% set
|
|
48
|
+
{% set _dropdown_classes = ['dropdown-menu'] %}
|
|
47
49
|
|
|
48
50
|
{% if _dark %}
|
|
49
|
-
{% set
|
|
51
|
+
{% set _dropdown_classes = _dropdown_classes|merge(['dropdown-menu-dark']) %}
|
|
50
52
|
{% endif %}
|
|
51
53
|
{% if _alignment %}
|
|
52
|
-
{% set
|
|
54
|
+
{% set _dropdown_classes = _dropdown_classes|merge([_alignment]) %}
|
|
53
55
|
{% endif %}
|
|
54
56
|
{% if _direction %}
|
|
55
57
|
{% set _class = _class ~ ' ' ~ _direction %}
|
|
56
58
|
{% endif %}
|
|
57
59
|
|
|
58
|
-
{%
|
|
59
|
-
{%
|
|
60
|
-
|
|
60
|
+
{% if attributes is empty %}
|
|
61
|
+
{% set attributes = create_attribute() %}
|
|
62
|
+
{% endif %}
|
|
63
|
+
|
|
64
|
+
{% set attributes = attributes.setAttribute('aria-labelledby', _id).addClass(_dropdown_classes) %}
|
|
65
|
+
|
|
66
|
+
{% if _trigger.attributes is empty %}
|
|
67
|
+
{% set _trigger = _trigger|merge({
|
|
68
|
+
attributes: create_attribute()
|
|
69
|
+
}) %}
|
|
61
70
|
{% endif %}
|
|
71
|
+
{% set _trigger = _trigger|merge({
|
|
72
|
+
attributes: _trigger.attributes.addClass(['dropdown-toggle'])
|
|
73
|
+
.setAttribute('aria-expanded', 'false')
|
|
74
|
+
.setAttribute('data-bs-toggle', 'dropdown')
|
|
75
|
+
.setAttribute('id', _id)
|
|
76
|
+
}) %}
|
|
62
77
|
|
|
63
|
-
{% set _trigger_attributes = [
|
|
64
|
-
{ name: "aria-expanded", value: "false" },
|
|
65
|
-
{ name: "data-bs-toggle", value: 'dropdown' },
|
|
66
|
-
]
|
|
67
|
-
%}
|
|
68
78
|
{% if _link %}
|
|
69
|
-
{% set
|
|
70
|
-
|
|
79
|
+
{% set _trigger = _trigger|merge({
|
|
80
|
+
attributes: _trigger.attributes.setAttribute('role', 'button')
|
|
81
|
+
}) %}
|
|
71
82
|
{% else %}
|
|
72
|
-
{% set
|
|
73
|
-
|
|
83
|
+
{% set _trigger = _trigger|merge({
|
|
84
|
+
attributes: _trigger.attributes.setAttribute('autocomplete', 'off')
|
|
85
|
+
}) %}
|
|
74
86
|
{% endif %}
|
|
75
87
|
|
|
76
|
-
{% set _trigger = _trigger|merge({
|
|
77
|
-
id: _id,
|
|
78
|
-
extra_classes: _trigger_extra_classes,
|
|
79
|
-
extra_attributes: _trigger_attributes })
|
|
80
|
-
%}
|
|
81
|
-
|
|
82
88
|
{% if not _remove_wrapper %}
|
|
83
89
|
<div class="{{ _class }}">
|
|
84
90
|
{% endif %}
|
|
85
91
|
{% if _link %}
|
|
86
|
-
{% include '@oe-bcl/link/link.html.twig' with _trigger only %}
|
|
92
|
+
{% include '@oe-bcl/bcl-link/link.html.twig' with _trigger only %}
|
|
87
93
|
{% else %}
|
|
88
|
-
{% include '@oe-bcl/button/button.html.twig' with _trigger only %}
|
|
94
|
+
{% include '@oe-bcl/bcl-button/button.html.twig' with _trigger only %}
|
|
89
95
|
{% endif %}
|
|
90
|
-
<ul
|
|
96
|
+
<ul
|
|
97
|
+
{{ attributes }}
|
|
98
|
+
>
|
|
91
99
|
{% if _items is not empty and _items is iterable %}
|
|
92
100
|
{% for _item in _items %}
|
|
93
|
-
{%
|
|
101
|
+
{% if _item.attributes is empty %}
|
|
102
|
+
{% set _item = _item|merge({
|
|
103
|
+
attributes: create_attribute()
|
|
104
|
+
}) %}
|
|
105
|
+
{% endif %}
|
|
106
|
+
{% set _item_classes = ['dropdown-item'] %}
|
|
94
107
|
{% if _item.active %}
|
|
95
|
-
{% set
|
|
108
|
+
{% set _item_classes = _item_classes|merge(['active']) %}
|
|
96
109
|
{% endif %}
|
|
97
110
|
{% set _item = _item|merge({
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
clean_class: true,
|
|
112
|
+
attributes: _item.attributes.addClass(_item_classes)
|
|
113
|
+
}) %}
|
|
100
114
|
<li>
|
|
101
115
|
{% if _item.divider is defined %}
|
|
102
116
|
<hr class="dropdown-divider">
|
|
103
117
|
{% elseif _item.button is defined %}
|
|
104
|
-
{% include '@oe-bcl/button/button.html.twig' with _item only %}
|
|
118
|
+
{% include '@oe-bcl/bcl-button/button.html.twig' with _item only %}
|
|
105
119
|
{% else %}
|
|
106
|
-
{% include '@oe-bcl/link/link.html.twig' with _item only %}
|
|
120
|
+
{% include '@oe-bcl/bcl-link/link.html.twig' with _item only %}
|
|
107
121
|
{% endif %}
|
|
108
122
|
</li>
|
|
109
123
|
{% endfor %}
|
|
@@ -113,4 +127,4 @@
|
|
|
113
127
|
</div>
|
|
114
128
|
{% endif %}
|
|
115
129
|
|
|
116
|
-
{%
|
|
130
|
+
{% endapply %}
|
package/package.json
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"name": "@openeuropa/bcl-dropdown",
|
|
3
3
|
"author": "European Commission",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.202408021145",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"description": "OE - BCL dropdown",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@openeuropa/bcl-button": "^0.1.
|
|
12
|
-
"@openeuropa/bcl-link": "^0.1.
|
|
11
|
+
"@openeuropa/bcl-button": "^0.1.202408021145",
|
|
12
|
+
"@openeuropa/bcl-link": "^0.1.202408021145"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"design-system",
|
|
26
26
|
"twig"
|
|
27
27
|
],
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "7ee2013f7f64a70ddfa35228a9a65967dd71eec3"
|
|
29
29
|
}
|