@ecl/mega-menu 5.0.0-alpha.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/LICENSE +296 -0
- package/README.md +105 -0
- package/mega-menu-item.html.twig +371 -0
- package/mega-menu-print.scss +8 -0
- package/mega-menu.html.twig +170 -0
- package/mega-menu.js +1703 -0
- package/mega-menu.scss +1402 -0
- package/package.json +36 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
{% apply spaceless %}
|
|
2
|
+
|
|
3
|
+
{#
|
|
4
|
+
Parameters:
|
|
5
|
+
- "id" (string) Unique id for this item. Needed for accessibility. Generated automatically
|
|
6
|
+
- "icon_path" (string) Path to the icon sprite
|
|
7
|
+
- "item" (object)
|
|
8
|
+
- "label" (string) Label of the menu link
|
|
9
|
+
- "external" (boolean) External link
|
|
10
|
+
- "sr_external" (string) (default: '') Additional label for the external icon
|
|
11
|
+
- "path" (string) Href of the menu link
|
|
12
|
+
- "extra_attributes" (optional) (array) (default: []) Extra attributes for link
|
|
13
|
+
- "name" (string) Attribute name, eg. 'data-test'
|
|
14
|
+
- "value" (optional) (string) Attribute value, eg: 'data-test-1'
|
|
15
|
+
- "info" (object) (default: {}) Info column
|
|
16
|
+
- "title" (string) Title of the info panel
|
|
17
|
+
- "content" (string) Content of the info panel
|
|
18
|
+
- "link" (object) Structure for the "discover more" link, following ECL Link
|
|
19
|
+
- "featured": (object) (default({})) Featured column
|
|
20
|
+
- "title" (string) Title of the featured panel
|
|
21
|
+
- "content" (string) Content of the featured panel
|
|
22
|
+
- "items" (associative array) Array of items
|
|
23
|
+
- "path" (string) Path or Url for the href
|
|
24
|
+
- "label" (string) Label of the item
|
|
25
|
+
- "external" (boolean) Whether the link is external
|
|
26
|
+
- "sr_external" (string) (default: '') Additional label for the external icon
|
|
27
|
+
- "extra_attributes" (array)
|
|
28
|
+
- "name" (string) Attribute name, eg. 'data-test'
|
|
29
|
+
- "value" (optional) (string) Attribute value, eg: 'data-test-1'
|
|
30
|
+
- "container": (string) White panel to be filled at will
|
|
31
|
+
- "see_all": (boolean) (default: false) Whether to show the "view all" link
|
|
32
|
+
- "see_all_label": (string) (default: ''): Label for the "view all" link
|
|
33
|
+
- "see_all_attributes" (optional) (array) Custom attributes for the "view all" link
|
|
34
|
+
- "name" (string) Attribute name, eg. 'data-test'
|
|
35
|
+
- "value" (optional) (string) Attribute value, eg: 'data-test-1'
|
|
36
|
+
- "children" (array of object) Array of sub-items
|
|
37
|
+
- "external": (boolean) External link
|
|
38
|
+
- "sr_external" (string) (default: '') Additional label for the external icon
|
|
39
|
+
- "path" (string) Href of the sub-item link
|
|
40
|
+
- "label" (string) Label of the sub-item link
|
|
41
|
+
- "extra_attributes" (optional) (array) (default: []) Extra attributes for link
|
|
42
|
+
- "name" (string) Attribute name, eg. 'data-test'
|
|
43
|
+
- "value" (optional) (string) Attribute value, eg: 'data-test-1'
|
|
44
|
+
#}
|
|
45
|
+
|
|
46
|
+
{% set _id = id|default('') %}
|
|
47
|
+
{% set _item = item|default({}) %}
|
|
48
|
+
{% set _menu_link_class = 'ecl-mega-menu__link' %}
|
|
49
|
+
{% set _menu_link_attribute = 'data-ecl-mega-menu-link' %}
|
|
50
|
+
{% set _menu_sublink_attribute = 'data-ecl-mega-menu-sublink' %}
|
|
51
|
+
{% set _menu_list_item_attributes = 'data-ecl-mega-menu-item' %}
|
|
52
|
+
{% set _menu_list_item_class = 'ecl-mega-menu__item' %}
|
|
53
|
+
{% set _icon_path = icon_path|default('') %}
|
|
54
|
+
{% set _featured = _item.featured|default({}) %}
|
|
55
|
+
{% set _info = _item.info|default({}) %}
|
|
56
|
+
{% set _see_all = see_all|default(false) %}
|
|
57
|
+
{% set _sublist_class = 'ecl-mega-menu__sublist' %}
|
|
58
|
+
{% set _mega_class = 'ecl-mega-menu__mega' %}
|
|
59
|
+
{% set _see_all_label = see_all_label|default('') %}
|
|
60
|
+
{% set _see_all_attributes = see_all_attributes|default([]) %}
|
|
61
|
+
{% set _can_be_external = true %}
|
|
62
|
+
{% set _icon = {} %}
|
|
63
|
+
|
|
64
|
+
{# Internal logic - Process properties #}
|
|
65
|
+
|
|
66
|
+
{% if _item.container is defined and _item.container is not empty %}
|
|
67
|
+
{% set _can_be_external = false %}
|
|
68
|
+
{% set _menu_list_item_class = _menu_list_item_class ~ ' ecl-mega-menu__item--has-container' %}
|
|
69
|
+
{% set _menu_list_item_attributes = _menu_list_item_attributes ~ ' data-ecl-has-container aria-haspopup' %}
|
|
70
|
+
{% endif %}
|
|
71
|
+
|
|
72
|
+
{% if _item.children is defined and _item.children is not empty and _item.children is iterable %}
|
|
73
|
+
{% set _menu_list_item_attributes = _menu_list_item_attributes ~ ' data-ecl-has-children aria-haspopup' %}
|
|
74
|
+
{% set _menu_list_item_class = _menu_list_item_class ~ ' ecl-mega-menu__item--has-children' %}
|
|
75
|
+
{% endif %}
|
|
76
|
+
|
|
77
|
+
{% if _item.level == 2 %}
|
|
78
|
+
{% set _mega_class = _mega_class ~ ' ecl-mega-menu__mega--level-2' %}
|
|
79
|
+
{% endif %}
|
|
80
|
+
|
|
81
|
+
{% if (_item.children is defined and _item.children is not empty and _item.children is iterable) or _item.container is not empty %}
|
|
82
|
+
{% set _can_be_external = false %}
|
|
83
|
+
{% set _icon = [{
|
|
84
|
+
name: 'corner-arrow',
|
|
85
|
+
transform: 'rotate-90',
|
|
86
|
+
path: _icon_path,
|
|
87
|
+
size: '2xs',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'arrow-left',
|
|
91
|
+
transform: 'flip-horizontal',
|
|
92
|
+
path: _icon_path,
|
|
93
|
+
size: 's',
|
|
94
|
+
}] %}
|
|
95
|
+
{% endif %}
|
|
96
|
+
|
|
97
|
+
{%- if _item.label is not empty -%}
|
|
98
|
+
<li class="{{ _menu_list_item_class }}" {{ _menu_list_item_attributes|raw }} id="{{ _id }}">
|
|
99
|
+
{% set _menu_link_attributes = _item.extra_attributes|default([])|merge([
|
|
100
|
+
{ name: _menu_link_attribute },
|
|
101
|
+
{ name: 'id', value: _id ~ "-link" },
|
|
102
|
+
]) %}
|
|
103
|
+
{% if (_item.children is defined and _item.children is not empty and _item.children is iterable) or _item.container is not empty %}
|
|
104
|
+
{% set _menu_link_attributes = _menu_link_attributes|merge([
|
|
105
|
+
{ name: 'aria-expanded', value: 'false' },
|
|
106
|
+
]) %}
|
|
107
|
+
{% include '@ecl/button/button.html.twig' with {
|
|
108
|
+
type: 'button',
|
|
109
|
+
label: _item.label,
|
|
110
|
+
icon_path: _icon_path,
|
|
111
|
+
icon_position: 'after',
|
|
112
|
+
icon: _icon,
|
|
113
|
+
extra_classes: _menu_link_class,
|
|
114
|
+
extra_attributes: _menu_link_attributes,
|
|
115
|
+
} only %}
|
|
116
|
+
{% else %}
|
|
117
|
+
{% include '@ecl/link/link.html.twig' with {
|
|
118
|
+
link: {
|
|
119
|
+
type: 'standalone',
|
|
120
|
+
label: _item.label,
|
|
121
|
+
path: _item.path,
|
|
122
|
+
icon_path: _icon_path,
|
|
123
|
+
external: _can_be_external ? _item.external|default(false),
|
|
124
|
+
sr_external: _item.sr_external|default(''),
|
|
125
|
+
icon_position: 'after',
|
|
126
|
+
},
|
|
127
|
+
icon: _icon,
|
|
128
|
+
extra_classes: _menu_link_class,
|
|
129
|
+
extra_attributes: _menu_link_attributes,
|
|
130
|
+
} only %}
|
|
131
|
+
{% endif %}
|
|
132
|
+
{%- endif -%}
|
|
133
|
+
|
|
134
|
+
{# Container #}
|
|
135
|
+
{%- if _item.container is defined and _item.container is not empty -%}
|
|
136
|
+
<div
|
|
137
|
+
class="{{ _mega_class }} ecl-mega-menu__mega-container"
|
|
138
|
+
data-ecl-mega-menu-mega
|
|
139
|
+
>
|
|
140
|
+
<div class="ecl-container">
|
|
141
|
+
<div class="ecl-mega-menu__mega-container-scrollable">
|
|
142
|
+
{{ _item.container }}
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
{# Children #}
|
|
147
|
+
{%- elseif _item.children is defined and _item.children is not empty and _item.children is iterable -%}
|
|
148
|
+
{% set _sublist_aria_label = '' %}
|
|
149
|
+
{% if _item.level|default(0) < 2 %}
|
|
150
|
+
{% set _sublist_aria_label = second_level_aria_label|default('') %}
|
|
151
|
+
<div class="ecl-mega-menu__wrapper">
|
|
152
|
+
<div class="ecl-container">
|
|
153
|
+
{% else %}
|
|
154
|
+
{% set _sublist_aria_label = third_level_aria_label|default('') %}
|
|
155
|
+
{% endif %}
|
|
156
|
+
{# Info #}
|
|
157
|
+
{% if _info is not empty %}
|
|
158
|
+
{% set _info_classes = 'ecl-mega-menu__info' %}
|
|
159
|
+
{% set _info_title_id = _id ~ '-info-title' %}
|
|
160
|
+
{% if _info.link is not empty %}
|
|
161
|
+
{% set _info_classes = _info_classes ~ ' ecl-mega-menu__info--has-link' %}
|
|
162
|
+
{% endif %}
|
|
163
|
+
<div
|
|
164
|
+
class="{{ _info_classes }}"
|
|
165
|
+
data-ecl-mega-menu-mega
|
|
166
|
+
>
|
|
167
|
+
{% if _info.title is not empty %}
|
|
168
|
+
<span
|
|
169
|
+
class="ecl-mega-menu__info-title"
|
|
170
|
+
id="{{ _info_title_id }}"
|
|
171
|
+
>
|
|
172
|
+
{{- _info.title -}}
|
|
173
|
+
</span>
|
|
174
|
+
{% endif %}
|
|
175
|
+
<div class="ecl-mega-menu__info-scrollable">
|
|
176
|
+
{%- if _info.content is not empty -%}
|
|
177
|
+
<div class="ecl-mega-menu__info-content">{{ _info.content }}</div>
|
|
178
|
+
{%- endif -%}
|
|
179
|
+
{%- if _info.link is not empty -%}
|
|
180
|
+
{% set _path = (_info.link.link.path is not empty) ? _info.link.link.path : _item.path %}
|
|
181
|
+
{% include '@ecl/link/link.html.twig' with _info.link|merge({
|
|
182
|
+
link: _info.link.link|merge({
|
|
183
|
+
type: 'standalone',
|
|
184
|
+
path: _path,
|
|
185
|
+
}),
|
|
186
|
+
icon: {
|
|
187
|
+
name: 'arrow-left',
|
|
188
|
+
transform: 'flip-horizontal',
|
|
189
|
+
path: _icon_path,
|
|
190
|
+
size: 'xs',
|
|
191
|
+
},
|
|
192
|
+
extra_classes: _info.link.extra_classes|default('') ~ ' ecl-mega-menu__info-link',
|
|
193
|
+
extra_attributes: [{
|
|
194
|
+
name: 'aria-describedby',
|
|
195
|
+
value: _info_title_id,
|
|
196
|
+
}],
|
|
197
|
+
}) only %}
|
|
198
|
+
{%- endif -%}
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
</div>
|
|
202
|
+
{% endif %}
|
|
203
|
+
<div
|
|
204
|
+
class="{{ _mega_class }}"
|
|
205
|
+
data-ecl-mega-menu-mega
|
|
206
|
+
>
|
|
207
|
+
<ul
|
|
208
|
+
class="{{ _sublist_class }}"
|
|
209
|
+
{%- if _sublist_aria_label -%}
|
|
210
|
+
aria-label="{{ _sublist_aria_label }}"
|
|
211
|
+
{%- endif -%}
|
|
212
|
+
>
|
|
213
|
+
{% for child in _item.children %}
|
|
214
|
+
{% set _can_be_external = true %}
|
|
215
|
+
{% set _icon = {} %}
|
|
216
|
+
{% set _subitem_attrs = 'data-ecl-mega-menu-subitem' %}
|
|
217
|
+
{% set _subitem_class = 'ecl-mega-menu__subitem' %}
|
|
218
|
+
{% set _sublink_class = 'ecl-mega-menu__sublink' %}
|
|
219
|
+
{% if loop.last %}
|
|
220
|
+
{% set _sublink_class = _sublink_class ~ ' ecl-mega-menu__sublink--last' %}
|
|
221
|
+
{% endif %}
|
|
222
|
+
{% set _sublink_attrs = child.extra_attributes|default([])|merge([
|
|
223
|
+
{ name: _menu_sublink_attribute },
|
|
224
|
+
]) %}
|
|
225
|
+
{% if child.children is defined and child.children is not empty %}
|
|
226
|
+
{% set _sublink_attrs = _sublink_attrs|merge([
|
|
227
|
+
{ name: 'aria-expanded', value: 'false' },
|
|
228
|
+
]) %}
|
|
229
|
+
{% endif %}
|
|
230
|
+
{% if child.children is defined and child.children is not empty and _item.level|default(0) < 2 %}
|
|
231
|
+
{%- if child.see_all and child.see_all_label is not empty -%}
|
|
232
|
+
{% if child.sublink_id is empty %}
|
|
233
|
+
{% set _sublink_id = 'ecl-mega-menu-sublink-' ~ random() %}
|
|
234
|
+
{% else %}
|
|
235
|
+
{% set _sublink_id = child.sublink_id %}
|
|
236
|
+
{% endif %}
|
|
237
|
+
{% set _sublink_attrs = _sublink_attrs|merge([{ name: 'id', value: _sublink_id }]) %}
|
|
238
|
+
{%- endif -%}
|
|
239
|
+
|
|
240
|
+
{% set _can_be_external = false %}
|
|
241
|
+
{% set _icon = {
|
|
242
|
+
name: 'corner-arrow',
|
|
243
|
+
transform: 'rotate-90',
|
|
244
|
+
path: _icon_path,
|
|
245
|
+
size: '2xs',
|
|
246
|
+
} %}
|
|
247
|
+
{% endif %}
|
|
248
|
+
<li
|
|
249
|
+
class="{{ _subitem_class }}"
|
|
250
|
+
{{- _subitem_attrs|raw -}}
|
|
251
|
+
>
|
|
252
|
+
{%- if child.children is defined and child.children is not empty -%}
|
|
253
|
+
{# Children, 2nd level #}
|
|
254
|
+
{% include '@ecl/button/button.html.twig' with {
|
|
255
|
+
type: 'button',
|
|
256
|
+
label: child.label,
|
|
257
|
+
icon_path: _icon_path,
|
|
258
|
+
icon: _icon,
|
|
259
|
+
extra_classes: _sublink_class,
|
|
260
|
+
extra_attributes: _sublink_attrs,
|
|
261
|
+
} only %}
|
|
262
|
+
{% include '@ecl/mega-menu/mega-menu-item.html.twig' with {
|
|
263
|
+
see_all_label: child.see_all_label|default(''),
|
|
264
|
+
see_all: child.see_all|default(false),
|
|
265
|
+
third_level_aria_label: third_level_aria_label|default(''),
|
|
266
|
+
see_all_attributes: child.see_all_attributes|default([]),
|
|
267
|
+
icon_path: _icon_path,
|
|
268
|
+
sublink_id: _sublink_id|default(''),
|
|
269
|
+
item: {
|
|
270
|
+
path: child.path,
|
|
271
|
+
children: child.children,
|
|
272
|
+
level: 2,
|
|
273
|
+
info: child.info|default({}),
|
|
274
|
+
featured: child.featured|default({}),
|
|
275
|
+
},
|
|
276
|
+
} only %}
|
|
277
|
+
{%- else -%}
|
|
278
|
+
{% include '@ecl/link/link.html.twig' with {
|
|
279
|
+
link: {
|
|
280
|
+
type: 'standalone',
|
|
281
|
+
label: child.label,
|
|
282
|
+
path: child.path,
|
|
283
|
+
external: _can_be_external ? child.external|default(false),
|
|
284
|
+
sr_external: child.sr_external|default(''),
|
|
285
|
+
icon_path: _icon_path,
|
|
286
|
+
},
|
|
287
|
+
icon: _icon,
|
|
288
|
+
extra_classes: _sublink_class,
|
|
289
|
+
extra_attributes: _sublink_attrs,
|
|
290
|
+
} only %}
|
|
291
|
+
{% endif %}
|
|
292
|
+
</li>
|
|
293
|
+
{% endfor %}
|
|
294
|
+
{%- if _see_all and _see_all_label is not empty -%}
|
|
295
|
+
<li class="ecl-mega-menu__spacer" data-ecl-mega-menu-subitem></li>
|
|
296
|
+
<li class="ecl-mega-menu__subitem ecl-mega-menu__see-all" data-ecl-mega-menu-subitem>
|
|
297
|
+
{% include '@ecl/link/link.html.twig' with {
|
|
298
|
+
link: {
|
|
299
|
+
type: 'standalone',
|
|
300
|
+
label: _see_all_label,
|
|
301
|
+
path: _item.path,
|
|
302
|
+
},
|
|
303
|
+
icon: {
|
|
304
|
+
path: _icon_path,
|
|
305
|
+
name: 'arrow-left',
|
|
306
|
+
size: 'xs',
|
|
307
|
+
transform: 'rotate-180',
|
|
308
|
+
},
|
|
309
|
+
extra_attributes: [{
|
|
310
|
+
name: 'aria-describedby',
|
|
311
|
+
value: sublink_id,
|
|
312
|
+
}]|merge(_see_all_attributes|default([])),
|
|
313
|
+
} only %}
|
|
314
|
+
</li>
|
|
315
|
+
{%- endif -%}
|
|
316
|
+
</ul>
|
|
317
|
+
|
|
318
|
+
{# Featured #}
|
|
319
|
+
{% if _featured is not empty %}
|
|
320
|
+
<div
|
|
321
|
+
class="ecl-mega-menu__featured"
|
|
322
|
+
data-ecl-mega-menu-featured
|
|
323
|
+
>
|
|
324
|
+
<div class="ecl-mega-menu__featured-scrollable">
|
|
325
|
+
{% if _featured.picture is not empty %}
|
|
326
|
+
{% include '@ecl/picture/picture.html.twig' with {
|
|
327
|
+
picture: _featured.picture,
|
|
328
|
+
extra_classes: 'ecl-mega-menu__featured-picture',
|
|
329
|
+
extra_image_classes: 'ecl-mega-menu__featured-image',
|
|
330
|
+
} only %}
|
|
331
|
+
{% endif %}
|
|
332
|
+
{% if _featured.title is not empty %}
|
|
333
|
+
<span
|
|
334
|
+
class="ecl-mega-menu__featured-title"
|
|
335
|
+
id="{{ 'ecl-mega-menu-featured-title-' ~ sublink_id }}"
|
|
336
|
+
>
|
|
337
|
+
{{- _featured.title -}}
|
|
338
|
+
</span>
|
|
339
|
+
{% endif %}
|
|
340
|
+
{%- if _featured.content is not empty -%}
|
|
341
|
+
<div class="ecl-mega-menu__featured-content">{{ _featured.content }}</div>
|
|
342
|
+
{%- endif -%}
|
|
343
|
+
{%- if _featured.items is not empty and _featured.items is iterable -%}
|
|
344
|
+
<ul
|
|
345
|
+
class="ecl-mega-menu__featured-list"
|
|
346
|
+
aria-labelledby="{{ 'ecl-mega-menu-featured-title-' ~ sublink_id ~ ' ' ~ sublink_id }}"
|
|
347
|
+
>
|
|
348
|
+
{% for item in _featured.items %}
|
|
349
|
+
<li class="ecl-mega-menu__featured-list__item">
|
|
350
|
+
{% include '@ecl/link/link.html.twig' with {
|
|
351
|
+
link: item|merge({ type: 'standalone', icon_path: _icon_path }),
|
|
352
|
+
extra_attributes: [
|
|
353
|
+
{ name: 'data-ecl-mega-menu-featured-link' },
|
|
354
|
+
]|merge(item.extra_attributes|default([])),
|
|
355
|
+
extra_classes: item.extra_classes|default(''),
|
|
356
|
+
} only %}
|
|
357
|
+
</li>
|
|
358
|
+
{% endfor %}
|
|
359
|
+
</ul>
|
|
360
|
+
{%- endif -%}
|
|
361
|
+
</div>
|
|
362
|
+
</div>
|
|
363
|
+
{% if _item.level|default(0) < 2 %}
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
{% endif %}
|
|
367
|
+
{% endif %}
|
|
368
|
+
{% endif %}
|
|
369
|
+
</li>
|
|
370
|
+
|
|
371
|
+
{% endapply %}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
{% apply spaceless %}
|
|
2
|
+
|
|
3
|
+
{#
|
|
4
|
+
Parameters:
|
|
5
|
+
- "id": (string) (default: random): Unique id for the menu
|
|
6
|
+
- "toggle": (associative array) (default: {}): Toggle (hamburger) button, using ECL Button structure
|
|
7
|
+
- "close": (associative array) (default: {}): Close button, using ECL Button structure
|
|
8
|
+
- "back_label": (string): (default: ''): Back button label
|
|
9
|
+
- "aria_label" (string) (default: '') Aria label for the main nav
|
|
10
|
+
- "second_level_aria_label" (string) (default: '') Aria label for the sub-lists, second level
|
|
11
|
+
- "third_level_aria_label" (string) (default: '') Aria label for the sub-lists, third level
|
|
12
|
+
- "icon_path": (string) (default: ''): Path to the icon sprite
|
|
13
|
+
- "items": (array) (default: []): The menu items - format: [
|
|
14
|
+
{
|
|
15
|
+
"label": (string) (default: '')
|
|
16
|
+
"path": (string) (default: '')
|
|
17
|
+
"external": (boolean) (optional),
|
|
18
|
+
"sr_external" (string) (default: '') Additional label for the external icon
|
|
19
|
+
"extra_attributes" (optional) (array) (default: []) Extra attributes for link,
|
|
20
|
+
- "name" (string) Attribute name, eg. 'data-test'
|
|
21
|
+
- "value" (optional) (string) Attribute value, eg: 'data-test-1'
|
|
22
|
+
"container": (string) Empty container to be filled in with content
|
|
23
|
+
- "info" (object) (default: {}) Info column
|
|
24
|
+
- "title" (string) Title of the info panel
|
|
25
|
+
- "content" (string) Content of the info panel
|
|
26
|
+
- "link" (object) Structure for the "discover more" link, following ECL Link
|
|
27
|
+
"featured" (oject) (optional) {
|
|
28
|
+
- "title": (string) Title of the featured panel
|
|
29
|
+
- "content": (string) Top content of the featured panel
|
|
30
|
+
- "items": (associative array) (optional) Object of type ECL link
|
|
31
|
+
}
|
|
32
|
+
"children": (associative array) (optional): [
|
|
33
|
+
{
|
|
34
|
+
"label": (string) (default: '')
|
|
35
|
+
"path": (string) (default: '')
|
|
36
|
+
"external": (boolean),
|
|
37
|
+
"sr_external" (string) (default: '') Additional label for the external icon
|
|
38
|
+
"see_all" (boolean)
|
|
39
|
+
"see_all_label" (string)
|
|
40
|
+
"see_all_attributes" (optional) (array) (default: [])
|
|
41
|
+
- "name" (string) Attribute name, eg. 'data-test'
|
|
42
|
+
- "value" (optional) (string) Attribute value, eg: 'data-test-1'
|
|
43
|
+
"extra_attributes" (optional) (array) (default: []) Extra attributes for link,
|
|
44
|
+
- "name" (string) Attribute name, eg. 'data-test'
|
|
45
|
+
- "value" (optional) (string) Attribute value, eg: 'data-test-1'
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
- "extra_classes" (optional) (string) (default: '') Extra classes (space separated) for the nav element
|
|
51
|
+
- "extra_attributes" (optional) (array) (default: []) Extra attributes for the nav element
|
|
52
|
+
- "name" (string) Attribute name, eg. 'data-test'
|
|
53
|
+
- "value" (optional) (string) Attribute value, eg: 'data-test-1'
|
|
54
|
+
#}
|
|
55
|
+
|
|
56
|
+
{# Internal properties #}
|
|
57
|
+
|
|
58
|
+
{% set _id = id|default('ecl-mega-menu-' ~ random()) %}
|
|
59
|
+
{% set _back_label = back_label|default('') %}
|
|
60
|
+
{% set _aria_label = aria_label|default('') %}
|
|
61
|
+
{% set _second_level_aria_label = second_level_aria_label|default('') %}
|
|
62
|
+
{% set _third_level_aria_label = third_level_aria_label|default('') %}
|
|
63
|
+
{% set _toggle = toggle|default({}) %}
|
|
64
|
+
{% set _close = close|default({}) %}
|
|
65
|
+
{% set _items = items|default([{}]) %}
|
|
66
|
+
{% set _css_class = 'ecl-mega-menu' %}
|
|
67
|
+
{% set _extra_attributes = '' %}
|
|
68
|
+
{% set _icon_path = icon_path|default('') %}
|
|
69
|
+
|
|
70
|
+
{# Internal logic - Process properties #}
|
|
71
|
+
|
|
72
|
+
{% if extra_classes is defined and extra_classes is not empty %}
|
|
73
|
+
{% set _css_class = _css_class ~ ' ' ~ extra_classes %}
|
|
74
|
+
{% endif %}
|
|
75
|
+
|
|
76
|
+
{% if extra_attributes is defined and extra_attributes is not empty and extra_attributes is iterable %}
|
|
77
|
+
{% for attr in extra_attributes %}
|
|
78
|
+
{% if attr.value is defined %}
|
|
79
|
+
{% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name|e('html_attr') ~ '="' ~ attr.value|e('html_attr') ~ '"' %}
|
|
80
|
+
{% else %}
|
|
81
|
+
{% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name|e('html_attr') %}
|
|
82
|
+
{% endif %}
|
|
83
|
+
{% endfor %}
|
|
84
|
+
{% endif %}
|
|
85
|
+
|
|
86
|
+
<nav
|
|
87
|
+
class="{{ _css_class }}"
|
|
88
|
+
data-ecl-mega-menu
|
|
89
|
+
data-ecl-auto-init="MegaMenu"
|
|
90
|
+
{%- if _toggle is not empty and _toggle.label is not empty -%}
|
|
91
|
+
data-ecl-mega-menu-label-open="{{ _toggle.label }}"
|
|
92
|
+
{%- endif -%}
|
|
93
|
+
{%- if _close is not empty and _close.label is defined and _close.label is not empty -%}
|
|
94
|
+
data-ecl-mega-menu-label-close="{{ _close.label }}"
|
|
95
|
+
{%- endif -%}
|
|
96
|
+
aria-expanded="false"
|
|
97
|
+
role="navigation"
|
|
98
|
+
id={{ _id }}
|
|
99
|
+
{%- if _aria_label is not empty %}
|
|
100
|
+
aria-label="{{ _aria_label }}"
|
|
101
|
+
{%- endif -%}
|
|
102
|
+
{{- _extra_attributes|raw -}}
|
|
103
|
+
>
|
|
104
|
+
<div class="ecl-mega-menu__overlay"></div>
|
|
105
|
+
<div class="ecl-container ecl-mega-menu__container">
|
|
106
|
+
{% set _toggle_icon = {} %}
|
|
107
|
+
{% if _toggle.icon is defined %}
|
|
108
|
+
{% if _close is not empty and _close.icon is not empty %}
|
|
109
|
+
{% set _toggle_icon = [ _toggle.icon, _close.icon ] %}
|
|
110
|
+
{% else %}
|
|
111
|
+
{% set _toggle_icon = _toggle.icon %}
|
|
112
|
+
{% endif %}
|
|
113
|
+
{% endif %}
|
|
114
|
+
{% include '@ecl/button/button.html.twig' with _toggle|merge({
|
|
115
|
+
type: 'button',
|
|
116
|
+
variant: 'tertiary',
|
|
117
|
+
icon_path: _icon_path,
|
|
118
|
+
icon_position: 'before',
|
|
119
|
+
icon: _toggle_icon,
|
|
120
|
+
hide_label: true,
|
|
121
|
+
extra_classes: 'ecl-mega-menu__open',
|
|
122
|
+
extra_attributes: [
|
|
123
|
+
{ name: 'data-ecl-mega-menu-open' },
|
|
124
|
+
{ name: 'aria-expanded', value: 'false' }
|
|
125
|
+
],
|
|
126
|
+
}) only %}
|
|
127
|
+
|
|
128
|
+
<section class="ecl-mega-menu__inner" data-ecl-mega-menu-inner>
|
|
129
|
+
<header class="ecl-mega-menu__inner-header">
|
|
130
|
+
{%- if _back_label is not empty -%}
|
|
131
|
+
{% include '@ecl/button/button.html.twig' with {
|
|
132
|
+
type: 'submit',
|
|
133
|
+
variant: 'tertiary',
|
|
134
|
+
label: _back_label,
|
|
135
|
+
icon: {
|
|
136
|
+
path: _icon_path,
|
|
137
|
+
name: 'corner-arrow',
|
|
138
|
+
size: 'xs',
|
|
139
|
+
transform: 'rotate-270',
|
|
140
|
+
},
|
|
141
|
+
icon_position: 'before',
|
|
142
|
+
extra_classes: 'ecl-mega-menu__back',
|
|
143
|
+
extra_attributes: [{
|
|
144
|
+
name: 'data-ecl-mega-menu-back',
|
|
145
|
+
}],
|
|
146
|
+
} only %}
|
|
147
|
+
{%- endif -%}
|
|
148
|
+
</header>
|
|
149
|
+
|
|
150
|
+
<ul class="ecl-mega-menu__list">
|
|
151
|
+
{% if _items is not empty and _items is iterable %}
|
|
152
|
+
{% for key, item in _items %}
|
|
153
|
+
{% if item is defined and item is not empty %}
|
|
154
|
+
{% include '@ecl/mega-menu/mega-menu-item.html.twig' with {
|
|
155
|
+
item: item,
|
|
156
|
+
id: "ecl-mega-menu-item-" ~ _id ~ '-' ~ key,
|
|
157
|
+
icon_path: _icon_path,
|
|
158
|
+
see_all_label: _see_all_label,
|
|
159
|
+
second_level_aria_label: _second_level_aria_label,
|
|
160
|
+
third_level_aria_label: _third_level_aria_label,
|
|
161
|
+
} only %}
|
|
162
|
+
{% endif %}
|
|
163
|
+
{% endfor %}
|
|
164
|
+
{% endif %}
|
|
165
|
+
</ul>
|
|
166
|
+
</section>
|
|
167
|
+
</div>
|
|
168
|
+
</nav>
|
|
169
|
+
|
|
170
|
+
{% endapply %}
|