@openeuropa/bcl-mega-menu 0.1.202510071430
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.md +21 -0
- package/mega-menu-items.html.twig +35 -0
- package/mega-menu-submenu.html.twig +65 -0
- package/mega-menu.html.twig +115 -0
- package/package.json +30 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2021 Mark Otto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{% apply spaceless %}
|
|
2
|
+
|
|
3
|
+
{% set _label = label ?? null %}
|
|
4
|
+
{% set _items = items ?? [] %}
|
|
5
|
+
{% set _icon_path = icon_path ?? '' %}
|
|
6
|
+
{% set _level = level ?? 1 %}
|
|
7
|
+
{% set _see_all = see_all ?? null %}
|
|
8
|
+
|
|
9
|
+
<ul class="bcl-mega-menu__items __level-{{ _level }}">
|
|
10
|
+
{% for _item in _items %}
|
|
11
|
+
{% set _li_attributes = _item.li_attributes ?? create_attribute() %}
|
|
12
|
+
{% if _item.items is defined and _item.items is not empty %}
|
|
13
|
+
{# This is a parent item. #}
|
|
14
|
+
<li{{ _li_attributes.addClass('__parent') }}>
|
|
15
|
+
{% include '@oe-bcl/bcl-mega-menu/mega-menu-submenu.html.twig' with _item|merge({
|
|
16
|
+
icon_path: _icon_path,
|
|
17
|
+
level: _level + 1,
|
|
18
|
+
}) only %}
|
|
19
|
+
</li>
|
|
20
|
+
{% else %}
|
|
21
|
+
{# This is a leaf item. #}
|
|
22
|
+
<li{{ _li_attributes.addClass('__leaf') }}>
|
|
23
|
+
{% if _item.path is empty %}
|
|
24
|
+
{# This is a nolink item. #}
|
|
25
|
+
<span{{ _item.attributes ?? '' }}>{{ _item.label }}</span>
|
|
26
|
+
{% else %}
|
|
27
|
+
{# This is a link. #}
|
|
28
|
+
{% include '@oe-bcl/bcl-link/link.html.twig' with _item only %}
|
|
29
|
+
{% endif %}
|
|
30
|
+
</li>
|
|
31
|
+
{% endif %}
|
|
32
|
+
{% endfor %}
|
|
33
|
+
</ul>
|
|
34
|
+
|
|
35
|
+
{% endapply %}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{% apply spaceless %}
|
|
2
|
+
|
|
3
|
+
{% set _items = items ?? [] %}
|
|
4
|
+
{% set _trigger = trigger ?? null %}
|
|
5
|
+
{% set _icon_path = icon_path ?? '' %}
|
|
6
|
+
{% set _level = level ?? 2 %}
|
|
7
|
+
{% set _see_all = see_all ?? null %}
|
|
8
|
+
|
|
9
|
+
{% set _trigger_id = _trigger.id|default('mm-trigger-' ~ random(10000)) %}
|
|
10
|
+
{% set _panel_id = 'mm-panel-' ~ _trigger_id %}
|
|
11
|
+
|
|
12
|
+
{% set _trigger_attributes = _trigger.attributes ?? create_attribute() %}
|
|
13
|
+
{% set _trigger = _trigger|merge({
|
|
14
|
+
attributes: _trigger_attributes
|
|
15
|
+
.setAttribute('id', _trigger_id)
|
|
16
|
+
.setAttribute('aria-controls', _panel_id)
|
|
17
|
+
.setAttribute('aria-expanded', 'false')
|
|
18
|
+
.setAttribute('aria-haspopup', 'menu'),
|
|
19
|
+
remove_icon_spacers: true,
|
|
20
|
+
clean_class: true,
|
|
21
|
+
}) %}
|
|
22
|
+
{% include '@oe-bcl/bcl-button/button.html.twig' with _trigger only %}
|
|
23
|
+
|
|
24
|
+
{# Add an optional "See all" link as last item. #}
|
|
25
|
+
{% if _see_all is not empty %}
|
|
26
|
+
{# Wrap the label for an ellipsis. #}
|
|
27
|
+
{% set _see_all_label %}
|
|
28
|
+
<span>{{- _see_all.label -}}</span>
|
|
29
|
+
{% endset %}
|
|
30
|
+
{% set _see_all_attr = (_see_all.attributes is defined ? _see_all.attributes : create_attribute()) %}
|
|
31
|
+
{% set _see_all = _see_all|merge({
|
|
32
|
+
label: _see_all_label,
|
|
33
|
+
icon: {
|
|
34
|
+
name: 'arrow-right',
|
|
35
|
+
path: _icon_path,
|
|
36
|
+
},
|
|
37
|
+
li_attributes: create_attribute()
|
|
38
|
+
.addClass('__see_all'),
|
|
39
|
+
attributes: _see_all_attr
|
|
40
|
+
.addClass(['see-all-button'])
|
|
41
|
+
.setAttribute('aria-label', 'See all items in ‘' ~ _trigger.label ~ '’')
|
|
42
|
+
}) %}
|
|
43
|
+
{% set _items = _items|merge([_see_all]) %}
|
|
44
|
+
{% endif %}
|
|
45
|
+
{% set submenu_attributes = create_attribute()
|
|
46
|
+
.setAttribute('id', _panel_id)
|
|
47
|
+
.setAttribute('hidden', '')
|
|
48
|
+
.setAttribute('role', 'group')
|
|
49
|
+
.setAttribute('aria-labelledby', _trigger_id)
|
|
50
|
+
.addClass('bcl-mega-menu__submenu', '__level-' ~ _level)
|
|
51
|
+
%}
|
|
52
|
+
<div{{ submenu_attributes }}>
|
|
53
|
+
{% if _trigger %}
|
|
54
|
+
<div class="__header">
|
|
55
|
+
<p class="__label">{{ _trigger.label }}</p>
|
|
56
|
+
</div>
|
|
57
|
+
{% endif %}
|
|
58
|
+
{% include '@oe-bcl/bcl-mega-menu/mega-menu-items.html.twig' with {
|
|
59
|
+
items: _items,
|
|
60
|
+
icon_path: _icon_path,
|
|
61
|
+
level: _level,
|
|
62
|
+
} only %}
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
{% endapply %}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{% apply spaceless %}
|
|
2
|
+
|
|
3
|
+
{# Parameters:
|
|
4
|
+
- id (string) (default: dropdown-random(1000))
|
|
5
|
+
- link (boolean) (default: false) - sets trigger to link, default is button
|
|
6
|
+
- trigger (link or button)
|
|
7
|
+
- content_block (block) (default: '')
|
|
8
|
+
- content_link (link)
|
|
9
|
+
- icon_path (string) (default: '')
|
|
10
|
+
- min_height (string) (default: '300px')
|
|
11
|
+
! set min-height of mega-menu
|
|
12
|
+
- items (object[])
|
|
13
|
+
format: [
|
|
14
|
+
{
|
|
15
|
+
- link or dropdown
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
- back_button_label (string) (default: 'Back')
|
|
19
|
+
- icon_path (string) (default: '')
|
|
20
|
+
#}
|
|
21
|
+
|
|
22
|
+
{% set _id = id|default('dropdown-' ~ random(1000)) %}
|
|
23
|
+
{% set _link = link ?? false %}
|
|
24
|
+
{% set _trigger = trigger|default({}) %}
|
|
25
|
+
{% set _content_block = content_block|default('') %}
|
|
26
|
+
{% set _content_link = content_link|default({}) %}
|
|
27
|
+
{% set _icon_path = icon_path|default('') %}
|
|
28
|
+
{% set _items = items|default([]) %}
|
|
29
|
+
{% set _back_button_label = back_button_label|default('Back') %}
|
|
30
|
+
{% set _icon_path = icon_path|default('') %}
|
|
31
|
+
{% set _menu_id = 'mega-menu-' ~ _id %}
|
|
32
|
+
|
|
33
|
+
{% if attributes is empty %}
|
|
34
|
+
{% set attributes = create_attribute() %}
|
|
35
|
+
{% endif %}
|
|
36
|
+
|
|
37
|
+
{% set _classes = ['bcl-mega-menu'] %}
|
|
38
|
+
|
|
39
|
+
{% set attributes = attributes.addClass(_classes) %}
|
|
40
|
+
|
|
41
|
+
{% if _trigger.attributes is empty %}
|
|
42
|
+
{% set _trigger = _trigger|merge({
|
|
43
|
+
attributes: create_attribute()
|
|
44
|
+
}) %}
|
|
45
|
+
{% endif %}
|
|
46
|
+
{% set _trigger = _trigger|merge({
|
|
47
|
+
attributes: _trigger.attributes.addClass(['dropdown-toggle', 'nav-link'])
|
|
48
|
+
.setAttribute('aria-expanded', 'false')
|
|
49
|
+
.setAttribute('aria-haspopup', 'menu')
|
|
50
|
+
.setAttribute('aria-controls', _menu_id)
|
|
51
|
+
.setAttribute('data-bs-toggle', 'dropdown')
|
|
52
|
+
.setAttribute('data-bs-auto-close', 'outside')
|
|
53
|
+
.setAttribute('id', _id)
|
|
54
|
+
}) %}
|
|
55
|
+
|
|
56
|
+
<div {{ attributes }}>
|
|
57
|
+
{% include '@oe-bcl/bcl-button/button.html.twig' with _trigger|merge({
|
|
58
|
+
variant: 'link',
|
|
59
|
+
clean_class: true,
|
|
60
|
+
}) only %}
|
|
61
|
+
{# Mega menu panel. #}
|
|
62
|
+
<nav id="{{ _menu_id }}" class="bcl-mega-menu__container dropdown-menu" aria-labelledby="{{ _id }}" aria-label="Main mega menu">
|
|
63
|
+
<div class="container">
|
|
64
|
+
{# Mobile back button. #}
|
|
65
|
+
<div class="container d-lg-none bcl-mega-menu__back-button-block">
|
|
66
|
+
{% include '@oe-bcl/bcl-button/button.html.twig' with {
|
|
67
|
+
label: _back_button_label,
|
|
68
|
+
icon_position: "before",
|
|
69
|
+
variant: 'link',
|
|
70
|
+
icon: {
|
|
71
|
+
path: _icon_path,
|
|
72
|
+
name: "arrow-left",
|
|
73
|
+
},
|
|
74
|
+
attributes: create_attribute().addClass(['back-button']).setAttribute('aria-label', 'Back to main menu')
|
|
75
|
+
} only %}
|
|
76
|
+
</div>
|
|
77
|
+
{# Info/summary and submenu columns. #}
|
|
78
|
+
<div class="position-relative">
|
|
79
|
+
<div class="row">
|
|
80
|
+
{# Content / summary column. #}
|
|
81
|
+
{% if content_block is defined %}
|
|
82
|
+
<div class="col-md-12 col-xl-3 position-relative bcl-mega-menu__info">
|
|
83
|
+
<div class="content-block">
|
|
84
|
+
{%- block content_block -%}
|
|
85
|
+
{{ _content_block }}
|
|
86
|
+
{%- endblock -%}
|
|
87
|
+
{% if _content_link.path is not empty %}
|
|
88
|
+
{% set _content_link = _content_link|merge({
|
|
89
|
+
icon: _content_link.icon|default({})|merge({
|
|
90
|
+
path: _icon_path
|
|
91
|
+
}),
|
|
92
|
+
attributes: (_content_link.attributes is defined
|
|
93
|
+
? _content_link.attributes
|
|
94
|
+
: create_attribute()
|
|
95
|
+
).addClass('content-link')
|
|
96
|
+
}) %}
|
|
97
|
+
<p class="m-0">{% include '@oe-bcl/bcl-link/link.html.twig' with _content_link only %}</p>
|
|
98
|
+
{% endif %}
|
|
99
|
+
</div>
|
|
100
|
+
<div class="shadow-container">
|
|
101
|
+
<span class="shadow-bg"></span>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
{% endif %}
|
|
105
|
+
{# Submenu column. #}
|
|
106
|
+
<div class="col-md-12 col-lg-4 col-xl-3 bcl-mega-menu__menu">
|
|
107
|
+
{% include '@oe-bcl/bcl-mega-menu/mega-menu-items.html.twig' %}
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</nav>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
{% endapply %}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openeuropa/bcl-mega-menu",
|
|
3
|
+
"author": "European Commission",
|
|
4
|
+
"license": "EUPL-1.2",
|
|
5
|
+
"version": "0.1.202510071430",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"description": "OE - BCL mega menu",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@openeuropa/bcl-button": "^0.1.202510071430",
|
|
12
|
+
"@openeuropa/bcl-dropdown": "^0.1.202510071430",
|
|
13
|
+
"@openeuropa/bcl-link": "^0.1.202510071430"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/openeuropa/bootstrap-component-library.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/openeuropa/bootstrap-component-library.git/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/openeuropa/bootstrap-component-library",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"openeuropa",
|
|
25
|
+
"bootstrap-component-library",
|
|
26
|
+
"design-system",
|
|
27
|
+
"twig"
|
|
28
|
+
],
|
|
29
|
+
"gitHead": "43791350771d614a6aab0e13003f33a8aa789ea5"
|
|
30
|
+
}
|