@openeuropa/bcl-dropdown 0.1.3 → 0.1.202411051450

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.
Files changed (2) hide show
  1. package/dropdown.html.twig +27 -17
  2. package/package.json +4 -4
@@ -1,8 +1,8 @@
1
- {% spaceless %}
1
+ {% apply spaceless %}
2
2
 
3
3
  {# Parameters:
4
- - id (string) (default: '')
5
- - trigger (object of Button or Link component)
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,38 +23,46 @@
23
23
  ]
24
24
  - dark (boolean) (default: false)
25
25
  - remove_wrapper (boolean) (default: false)
26
- - items (array of objects)
26
+ - items (object[])
27
27
  format: [
28
28
  {
29
- - Link or Button object component
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|default(false) %}
40
+ {% set _link = link ?? false %}
40
41
  {% set _direction = direction|default('') %}
41
42
  {% set _alignment = alignment|default('') %}
42
- {% set _dark = dark|default(false) %}
43
- {% set _remove_wrapper = remove_wrapper|default(false) %}
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 _dropdown_class = 'dropdown-menu' %}
48
+ {% set _dropdown_classes = ['dropdown-menu'] %}
47
49
 
48
50
  {% if _dark %}
49
- {% set _dropdown_class = _dropdown_class ~ ' dropdown-menu-dark' %}
51
+ {% set _dropdown_classes = _dropdown_classes|merge(['dropdown-menu-dark']) %}
50
52
  {% endif %}
51
53
  {% if _alignment %}
52
- {% set _dropdown_class = _dropdown_class ~ ' ' ~ _alignment %}
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
 
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
+
58
66
  {% if _trigger.attributes is empty %}
59
67
  {% set _trigger = _trigger|merge({
60
68
  attributes: create_attribute()
@@ -81,11 +89,13 @@
81
89
  <div class="{{ _class }}">
82
90
  {% endif %}
83
91
  {% if _link %}
84
- {% include '@oe-bcl/link/link.html.twig' with _trigger only %}
92
+ {% include '@oe-bcl/bcl-link/link.html.twig' with _trigger only %}
85
93
  {% else %}
86
- {% include '@oe-bcl/button/button.html.twig' with _trigger only %}
94
+ {% include '@oe-bcl/bcl-button/button.html.twig' with _trigger only %}
87
95
  {% endif %}
88
- <ul class="{{ _dropdown_class }}" aria-labelledby="{{ _id }}">
96
+ <ul
97
+ {{ attributes }}
98
+ >
89
99
  {% if _items is not empty and _items is iterable %}
90
100
  {% for _item in _items %}
91
101
  {% if _item.attributes is empty %}
@@ -105,9 +115,9 @@
105
115
  {% if _item.divider is defined %}
106
116
  <hr class="dropdown-divider">
107
117
  {% elseif _item.button is defined %}
108
- {% include '@oe-bcl/button/button.html.twig' with _item only %}
118
+ {% include '@oe-bcl/bcl-button/button.html.twig' with _item only %}
109
119
  {% else %}
110
- {% include '@oe-bcl/link/link.html.twig' with _item only %}
120
+ {% include '@oe-bcl/bcl-link/link.html.twig' with _item only %}
111
121
  {% endif %}
112
122
  </li>
113
123
  {% endfor %}
@@ -117,4 +127,4 @@
117
127
  </div>
118
128
  {% endif %}
119
129
 
120
- {% endspaceless %}
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.3",
5
+ "version": "0.1.202411051450",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "description": "OE - BCL dropdown",
10
10
  "dependencies": {
11
- "@openeuropa/bcl-button": "^0.1.3",
12
- "@openeuropa/bcl-link": "^0.1.3"
11
+ "@openeuropa/bcl-button": "^0.1.202411051450",
12
+ "@openeuropa/bcl-link": "^0.1.202411051450"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -25,5 +25,5 @@
25
25
  "design-system",
26
26
  "twig"
27
27
  ],
28
- "gitHead": "ab1587b9ba4971ea0ca72c3de6b632f2c314c200"
28
+ "gitHead": "d553864c2d2214729cf74aa765606f2c447bb456"
29
29
  }