@ecl/mega-menu 5.0.0-alpha.9 → 5.0.0-aplha.13

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 CHANGED
@@ -15,12 +15,20 @@ npm install --save @ecl/mega-menu
15
15
  - **"second_level_aria_label"** (string): (default: ''): Second level list aria label
16
16
  - **"third_level_aria_label"** (string): (default: ''): Third level list aria label
17
17
  - **"back_label"** (string): (default: ''): Back button label
18
- - **"icon_path"** (string) (default: ''): Path to the icon sprite
18
+ - **featured_priority"** (string) (default: secondary) Can be primary otherwise: determines which featured panel will be visible
19
19
  - **"items"**: (array) (default: []): The menu items - format: [
20
20
  {
21
21
  "label": (string) (default: '')
22
22
  "path": (string) (default: '')
23
23
  "external": (boolean) (optional)
24
+ "promotional" (boolean) (default: false) Promotional menu item, styles can be custommized defining:
25
+ --ecl-mega-menu-item-promotional-bg
26
+ --ecl-mega-menu-item-promotional-hover-bg
27
+ --ecl-mega-menu-item-promotional-focus-bg
28
+ --ecl-mega-menu-item-promotional-outline-color
29
+ --ecl-mega-menu-item-promotional-text-color
30
+ --ecl-mega-menu-item-promotional-hover-text-color
31
+ --ecl-mega-menu-item-promotional-focus-text-color
24
32
  "sr_external" (string) (default: '') Additional label for the external icon
25
33
  "container": (string) Empty container to be filled in with content
26
34
  "info" (object) (default: {}) Info column
@@ -30,7 +38,7 @@ npm install --save @ecl/mega-menu
30
38
  "featured" (object) (optional) {
31
39
  "title": (string)
32
40
  "content": (string)
33
- "items": (associative array) Array of items with image and link
41
+ "items": (associative array) Array of items with image, link and description
34
42
  },
35
43
  "children": (associative array) (optional): [
36
44
  {
@@ -62,7 +70,6 @@ npm install --save @ecl/mega-menu
62
70
  },
63
71
  icon:
64
72
  {
65
- path: '/icons.svg',
66
73
  name: 'hamburger',
67
74
  size: 'm',
68
75
  },
@@ -71,13 +78,11 @@ npm install --save @ecl/mega-menu
71
78
  close: {
72
79
  label: 'Close',
73
80
  icon: {
74
- path: '/icons.svg',
75
81
  name: 'close',
76
82
  size: 'm',
77
83
  },
78
84
  },
79
85
  back_label: 'Back',
80
- icon_path: '/icons.svg',
81
86
  items: [
82
87
  {
83
88
  label: "Menu item",
@@ -4,6 +4,7 @@
4
4
  Parameters:
5
5
  - "label" (string) Label of the textual link
6
6
  - "path" (string) Path or Url for the href of the link
7
+ - "description" (string) Description of the link or the image
7
8
  - "icon_path": Path to the icons sprite
8
9
  - "picture" (associative array) ECL picture
9
10
  - "img" (associative array) (default: {}):
@@ -28,6 +29,7 @@
28
29
  {% set _item_css_class = 'ecl-mega-menu__featured-list__item' %}
29
30
  {% set _css_class = 'ecl-mega-menu__featured-link' %}
30
31
  {% set _label = label|default('') %}
32
+ {% set _description = description|default('') %}
31
33
  {% set _path = path|default('') %}
32
34
  {% set _picture = picture|default({}) %}
33
35
  {% set _icon_path = icon_path|default('') %}
@@ -97,6 +99,11 @@
97
99
  extra_classes: _css_class,
98
100
  } only %}
99
101
  {% endif %}
102
+ {% if _description is not empty %}
103
+ <div class="ecl-mega-menu__featured-list__item-description">
104
+ {{- _description -}}
105
+ </div>
106
+ {% endif %}
100
107
  </li>
101
108
 
102
109
  {% endapply %}
@@ -3,10 +3,17 @@
3
3
  {#
4
4
  Parameters:
5
5
  - "id" (string) Unique id for this item. Needed for accessibility. Generated automatically
6
- - "icon_path" (string) Path to the icon sprite
7
6
  - "item" (object)
8
7
  - "label" (string) Label of the menu link
9
8
  - "external" (boolean) External link
9
+ - "promotional" (boolean) (default: false) Promotional menu item, styles can be custommized defining:
10
+ --ecl-mega-menu-item-promotional-bg
11
+ --ecl-mega-menu-item-promotional-hover-bg
12
+ --ecl-mega-menu-item-promotional-focus-bg
13
+ --ecl-mega-menu-item-promotional-outline-color
14
+ --ecl-mega-menu-item-promotional-text-color
15
+ --ecl-mega-menu-item-promotional-hover-text-color
16
+ --ecl-mega-menu-item-promotional-focus-text-color
10
17
  - "sr_external" (string) (default: '') Additional label for the external icon
11
18
  - "path" (string) Href of the menu link
12
19
  - "extra_attributes" (optional) (array) (default: []) Extra attributes for link
@@ -23,6 +30,7 @@
23
30
  - "picture": (object) (default: {}) Object of type Picture
24
31
  - "path" (string) Path or Url for the href
25
32
  - "label" (string) Label of the item
33
+ - "description" (string) Description for the item
26
34
  - "external" (boolean) Whether the link is external
27
35
  - "icon_path" (string) Path to the icons sprite
28
36
  - "sr_external" (string) (default: '') Additional label for the external icon
@@ -52,9 +60,9 @@
52
60
  {% set _menu_sublink_attribute = 'data-ecl-mega-menu-sublink' %}
53
61
  {% set _menu_list_item_attributes = 'data-ecl-mega-menu-item' %}
54
62
  {% set _menu_list_item_class = 'ecl-mega-menu__item' %}
55
- {% set _icon_path = icon_path|default('') %}
56
63
  {% set _featured = _item.featured|default({}) %}
57
64
  {% set _info = _item.info|default({}) %}
65
+ {% set _promotional = _item.promotional|default(false) %}
58
66
  {% set _see_all = see_all|default(false) %}
59
67
  {% set _sublist_class = 'ecl-mega-menu__sublist' %}
60
68
  {% set _mega_class = 'ecl-mega-menu__mega' %}
@@ -68,16 +76,27 @@
68
76
  {% if _item.container is defined and _item.container is not empty %}
69
77
  {% set _can_be_external = false %}
70
78
  {% set _menu_list_item_class = _menu_list_item_class ~ ' ecl-mega-menu__item--has-container' %}
71
- {% set _menu_list_item_attributes = _menu_list_item_attributes ~ ' data-ecl-has-container aria-haspopup' %}
79
+ {% set _menu_list_item_attributes = _menu_list_item_attributes ~ ' data-ecl-has-container aria-haspopup="true"' %}
72
80
  {% endif %}
73
81
 
74
82
  {% if _item.children is defined and _item.children is not empty and _item.children is iterable %}
75
- {% set _menu_list_item_attributes = _menu_list_item_attributes ~ ' data-ecl-has-children aria-haspopup' %}
83
+ {% set _menu_list_item_attributes = _menu_list_item_attributes ~ ' data-ecl-has-children aria-haspopup="true"' %}
76
84
  {% set _menu_list_item_class = _menu_list_item_class ~ ' ecl-mega-menu__item--has-children' %}
77
85
  {% endif %}
78
86
 
87
+ {% if _item.level|default(0) < 2 and _featured is not empty %}
88
+ {% set _mega_class = _mega_class ~ ' ecl-mega-menu__mega--has-featured' %}
89
+ {% endif %}
90
+
79
91
  {% if _item.level == 2 %}
80
92
  {% set _mega_class = _mega_class ~ ' ecl-mega-menu__mega--level-2' %}
93
+ {% if _item.children is empty %}
94
+ {% set _mega_class = _mega_class ~ ' ecl-mega-menu-featured-only' %}
95
+ {% endif %}
96
+ {% endif %}
97
+
98
+ {% if _promotional %}
99
+ {% set _menu_list_item_class = _menu_list_item_class ~ ' ecl-mega-menu__item--promotional' %}
81
100
  {% endif %}
82
101
 
83
102
  {% if (_item.children is defined and _item.children is not empty and _item.children is iterable) or _item.container is not empty %}
@@ -85,13 +104,11 @@
85
104
  {% set _icon = [{
86
105
  name: 'corner-arrow',
87
106
  transform: 'rotate-90',
88
- path: _icon_path,
89
107
  size: '2xs',
90
108
  },
91
109
  {
92
110
  name: 'arrow-left',
93
111
  transform: 'flip-horizontal',
94
- path: _icon_path,
95
112
  size: 's',
96
113
  }] %}
97
114
  {% endif %}
@@ -109,7 +126,6 @@
109
126
  {% include '@ecl/button/button.html.twig' with {
110
127
  type: 'button',
111
128
  label: _item.label,
112
- icon_path: _icon_path,
113
129
  icon_position: 'after',
114
130
  icon: _icon,
115
131
  extra_classes: _menu_link_class,
@@ -121,7 +137,6 @@
121
137
  type: 'standalone',
122
138
  label: _item.label,
123
139
  path: _item.path,
124
- icon_path: _icon_path,
125
140
  external: _can_be_external ? _item.external|default(false),
126
141
  sr_external: _item.sr_external|default(''),
127
142
  icon_position: 'after',
@@ -146,7 +161,7 @@
146
161
  </div>
147
162
  </div>
148
163
  {# Children #}
149
- {%- elseif _item.children is defined and _item.children is not empty and _item.children is iterable -%}
164
+ {%- elseif (_item.children is defined and _item.children is not empty and _item.children is iterable) or _featured is not empty -%}
150
165
  {% set _sublist_aria_label = '' %}
151
166
  {% if _item.level|default(0) < 2 %}
152
167
  {% set _sublist_aria_label = second_level_aria_label|default('') %}
@@ -178,34 +193,14 @@
178
193
  {%- if _info.content is not empty -%}
179
194
  <div class="ecl-mega-menu__info-content">{{ _info.content }}</div>
180
195
  {%- endif -%}
181
- {%- if _info.link is not empty -%}
182
- {% set _path = (_info.link.link.path is not empty) ? _info.link.link.path : _item.path %}
183
- {% include '@ecl/link/link.html.twig' with _info.link|merge({
184
- link: _info.link.link|merge({
185
- type: 'standalone',
186
- path: _path,
187
- }),
188
- icon: {
189
- name: 'arrow-left',
190
- transform: 'flip-horizontal',
191
- path: _icon_path,
192
- size: 'xs',
193
- },
194
- extra_classes: _info.link.extra_classes|default('') ~ ' ecl-mega-menu__info-link',
195
- extra_attributes: _info.link.extra_attributes|default([])|merge([{
196
- name: 'aria-describedby',
197
- value: _info_title_id,
198
- }]),
199
- }) only %}
200
- {%- endif -%}
201
196
  </div>
202
-
203
197
  </div>
204
198
  {% endif %}
205
199
  <div
206
200
  class="{{ _mega_class }}"
207
201
  data-ecl-mega-menu-mega
208
202
  >
203
+ {% if _item.children is defined and _item.children is not empty and _item.children is iterable %}
209
204
  <ul
210
205
  class="{{ _sublist_class }}"
211
206
  {%- if _sublist_aria_label -%}
@@ -224,12 +219,12 @@
224
219
  {% set _sublink_attrs = child.extra_attributes|default([])|merge([
225
220
  { name: _menu_sublink_attribute },
226
221
  ]) %}
227
- {% if child.children is defined and child.children is not empty %}
222
+ {% if (child.children is defined and child.children is not empty) or child.featured is not empty %}
228
223
  {% set _sublink_attrs = _sublink_attrs|merge([
229
224
  { name: 'aria-expanded', value: 'false' },
230
225
  ]) %}
231
226
  {% endif %}
232
- {% if child.children is defined and child.children is not empty and _item.level|default(0) < 2 %}
227
+ {% if (child.children is defined and child.children is not empty and _item.level|default(0) < 2) or child.featured is not empty %}
233
228
  {%- if child.see_all and child.see_all_label is not empty -%}
234
229
  {% if child.sublink_id is empty %}
235
230
  {% set _sublink_id = 'ecl-mega-menu-sublink-' ~ random() %}
@@ -243,20 +238,18 @@
243
238
  {% set _icon = {
244
239
  name: 'corner-arrow',
245
240
  transform: 'rotate-90',
246
- path: _icon_path,
247
241
  size: '2xs',
248
242
  } %}
249
243
  {% endif %}
250
244
  <li
251
245
  class="{{ _subitem_class }}"
252
- {{ _subitem_attrs|raw }}
246
+ {{ ' ' ~ _subitem_attrs|raw }}
253
247
  >
254
- {%- if child.children is defined and child.children is not empty -%}
248
+ {%- if (child.children is defined and child.children is not empty) or child.featured is not empty -%}
255
249
  {# Children, 2nd level #}
256
250
  {% include '@ecl/button/button.html.twig' with {
257
251
  type: 'button',
258
252
  label: child.label,
259
- icon_path: _icon_path,
260
253
  icon: _icon,
261
254
  extra_classes: _sublink_class,
262
255
  extra_attributes: _sublink_attrs,
@@ -266,7 +259,6 @@
266
259
  see_all: child.see_all|default(false),
267
260
  third_level_aria_label: third_level_aria_label|default(''),
268
261
  see_all_attributes: child.see_all_attributes|default([]),
269
- icon_path: _icon_path,
270
262
  sublink_id: _sublink_id|default(''),
271
263
  item: {
272
264
  path: child.path,
@@ -284,7 +276,6 @@
284
276
  path: child.path,
285
277
  external: _can_be_external ? child.external|default(false),
286
278
  sr_external: child.sr_external|default(''),
287
- icon_path: _icon_path,
288
279
  },
289
280
  icon: _icon,
290
281
  extra_classes: _sublink_class,
@@ -294,7 +285,7 @@
294
285
  </li>
295
286
  {% endfor %}
296
287
  {%- if _see_all and _see_all_label is not empty -%}
297
- <li class="ecl-mega-menu__spacer" data-ecl-mega-menu-subitem></li>
288
+ <li class="ecl-mega-menu__spacer" data-ecl-mega-menu-subitem>&nbsp;</li>
298
289
  <li class="ecl-mega-menu__subitem ecl-mega-menu__see-all" data-ecl-mega-menu-subitem>
299
290
  {% include '@ecl/link/link.html.twig' with {
300
291
  link: {
@@ -303,7 +294,6 @@
303
294
  path: _item.path,
304
295
  },
305
296
  icon: {
306
- path: _icon_path,
307
297
  name: 'arrow-left',
308
298
  size: 'xs',
309
299
  transform: 'rotate-180',
@@ -315,7 +305,30 @@
315
305
  } only %}
316
306
  </li>
317
307
  {%- endif -%}
308
+ {%- if _info.link is not empty -%}
309
+ <li class="ecl-mega-menu__spacer" data-ecl-mega-menu-subitem>&nbsp;</li>
310
+ <li class="ecl-mega-menu__subitem ecl-mega-menu__see-all" data-ecl-mega-menu-subitem>
311
+ {% set _path = (_info.link.link.path is not empty) ? _info.link.link.path : _item.path %}
312
+ {% include '@ecl/link/link.html.twig' with _info.link|merge({
313
+ link: _info.link.link|merge({
314
+ type: 'standalone',
315
+ path: _path,
316
+ }),
317
+ icon: {
318
+ name: 'arrow-left',
319
+ transform: 'flip-horizontal',
320
+ size: 'xs',
321
+ },
322
+ extra_classes: _info.link.extra_classes|default('') ~ ' ecl-mega-menu__info-link',
323
+ extra_attributes: _info.link.extra_attributes|default([])|merge([{
324
+ name: 'aria-describedby',
325
+ value: _info_title_id,
326
+ }]),
327
+ }) only %}
328
+ </li>
329
+ {%- endif -%}
318
330
  </ul>
331
+ {% endif %}
319
332
 
320
333
  {# Featured #}
321
334
  {% if _featured is not empty %}
@@ -324,34 +337,35 @@
324
337
  data-ecl-mega-menu-featured
325
338
  >
326
339
  <div class="ecl-mega-menu__featured-scrollable">
327
- {% if _featured.title is not empty %}
328
- <span
329
- class="ecl-mega-menu__featured-title"
330
- id="{{ 'ecl-mega-menu-featured-title-' ~ sublink_id }}"
331
- >
332
- {{- _featured.title -}}
333
- </span>
334
- {% endif %}
340
+ {% if _featured.title is not empty %}
341
+ <span
342
+ class="ecl-mega-menu__featured-title"
343
+ id="{{ 'ecl-mega-menu-featured-title-' ~ sublink_id }}"
344
+ >
345
+ {{- _featured.title -}}
346
+ </span>
347
+ {% endif %}
335
348
  {%- if _featured.content is not empty -%}
336
349
  <div class="ecl-mega-menu__featured-content">{{ _featured.content }}</div>
337
350
  {%- endif -%}
338
351
  {%- if _featured.items is not empty and _featured.items is iterable -%}
352
+ {% set sublink_id = sublink_id ? sublink_id : _id %}
339
353
  <ul
340
354
  class="ecl-mega-menu__featured-list"
341
355
  aria-labelledby="{{ 'ecl-mega-menu-featured-title-' ~ sublink_id ~ ' ' ~ sublink_id }}"
342
356
  >
343
357
  {% for item in _featured.items %}
344
- {% include '@ecl/mega-menu/mega-menu-featured-item.html.twig' with item|merge({ icon_path: _icon_path }) only %}
358
+ {% include '@ecl/mega-menu/mega-menu-featured-item.html.twig' with item only %}
345
359
  {% endfor %}
346
360
  </ul>
347
361
  {%- endif -%}
348
362
  </div>
349
363
  </div>
364
+ {% endif %}
350
365
  {% if _item.level|default(0) < 2 %}
351
366
  </div>
352
367
  </div>
353
368
  {% endif %}
354
- {% endif %}
355
369
  {% endif %}
356
370
  </li>
357
371
 
@@ -10,7 +10,7 @@
10
10
  - "second_level_aria_label" (string) (default: '') Aria label for the sub-lists, second level
11
11
  - "third_level_aria_label" (string) (default: '') Aria label for the sub-lists, third level
12
12
  - "see_all_label": (string) (default: ''): Label for the "view all" link
13
- - "icon_path": (string) (default: ''): Path to the icon sprite
13
+ - "featured_priority": (string) (default: secondary) Can be primary otherwise: determines which featured panel will be visible in desktop
14
14
  - "items": (array) (default: []): The menu items - format: [
15
15
  {
16
16
  "label": (string) (default: '')
@@ -28,7 +28,7 @@
28
28
  "featured" (oject) (optional) {
29
29
  - "title": (string) Title of the featured panel
30
30
  - "content": (string) Top content of the featured panel
31
- - "items": (associative array) (optional) Array of items with image and link
31
+ - "items": (associative array) (optional) Array of items with image, link and description
32
32
  }
33
33
  "children": (associative array) (optional): [
34
34
  {
@@ -36,7 +36,22 @@
36
36
  "path": (string) (default: '')
37
37
  "external": (boolean),
38
38
  "sr_external" (string) (default: '') Additional label for the external icon
39
+ "featured" (oject) (optional) {
40
+ - "title": (string) Title of the featured panel
41
+ - "content": (string) Top content of the featured panel
42
+ - "items": (associative array) (optional) Array of items with image, link and description
39
43
  "see_all" (boolean) controls visibility of "View All" button
44
+ "children": (associative array) (optional): [
45
+ {
46
+ "label": (string) (default: '')
47
+ "path": (string) (default: '')
48
+ "external": (boolean),
49
+ "sr_external" (string) (default: '') Additional label for the external icon
50
+ "extra_attributes" (optional) (array) (default: []) Extra attributes for link,
51
+ - "name" (string) Attribute name, eg. 'data-test'
52
+ - "value" (optional) (string) Attribute value, eg: 'data-test-1'
53
+ }
54
+ ]
40
55
  "see_all_label" (string)
41
56
  "see_all_attributes" (optional) (array) (default: [])
42
57
  - "name" (string) Attribute name, eg. 'data-test'
@@ -64,13 +79,17 @@
64
79
  {% set _toggle = toggle|default({}) %}
65
80
  {% set _close = close|default({}) %}
66
81
  {% set _items = items|default([{}]) %}
82
+ {% set _featured_priority = featured_priority|default('secondary') %}
67
83
  {% set _see_all_label = see_all_label|default('') %}
68
84
  {% set _css_class = 'ecl-mega-menu' %}
69
85
  {% set _extra_attributes = '' %}
70
- {% set _icon_path = icon_path|default('') %}
71
86
 
72
87
  {# Internal logic - Process properties #}
73
88
 
89
+ {% if _featured_priority == 'primary' %}
90
+ {% set _css_class = _css_class ~ ' ecl-mega-menu--featured--primary' %}
91
+ {% endif %}
92
+
74
93
  {% if extra_classes is defined and extra_classes is not empty %}
75
94
  {% set _css_class = _css_class ~ ' ' ~ extra_classes %}
76
95
  {% endif %}
@@ -102,7 +121,7 @@
102
121
  {%- endif -%}
103
122
  {{- _extra_attributes|raw -}}
104
123
  >
105
- <div class="ecl-mega-menu__overlay"></div>
124
+ <div class="ecl-mega-menu__overlay">&nbsp;</div>
106
125
  <div class="ecl-container ecl-mega-menu__container">
107
126
  {% set _toggle_icon = {} %}
108
127
  {% if _toggle.icon is defined %}
@@ -115,7 +134,6 @@
115
134
  {% include '@ecl/button/button.html.twig' with _toggle|merge({
116
135
  type: 'button',
117
136
  variant: 'tertiary',
118
- icon_path: _icon_path,
119
137
  icon_position: 'before',
120
138
  icon: _toggle_icon,
121
139
  hide_label: true,
@@ -134,7 +152,6 @@
134
152
  variant: 'tertiary',
135
153
  label: _back_label,
136
154
  icon: {
137
- path: _icon_path,
138
155
  name: 'corner-arrow',
139
156
  size: 'xs',
140
157
  transform: 'rotate-270',
@@ -155,7 +172,6 @@
155
172
  {% include '@ecl/mega-menu/mega-menu-item.html.twig' with {
156
173
  item: item,
157
174
  id: "ecl-mega-menu-item-" ~ _id ~ '-' ~ key,
158
- icon_path: _icon_path,
159
175
  see_all_label: _see_all_label,
160
176
  second_level_aria_label: _second_level_aria_label,
161
177
  third_level_aria_label: _third_level_aria_label,