@openeuropa/bcl-navbar 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.
Files changed (2) hide show
  1. package/navbar.html.twig +61 -35
  2. package/package.json +4 -4
package/navbar.html.twig CHANGED
@@ -1,4 +1,4 @@
1
- {% spaceless %}
1
+ {% apply spaceless %}
2
2
 
3
3
  {# Parameters:
4
4
  - collapse_id (string) (default: '')
@@ -17,67 +17,93 @@
17
17
  options: ['sm', 'md', 'lg']
18
18
  - color_set (string) (default: 'light')
19
19
  options ['light', 'dark']
20
- - extra_classes (string) (default: '')
20
+ - disable_collapse (boolean) (default: false)
21
+ - attributes (drupal attrs)
22
+
23
+ Blocks
24
+ - branding
25
+ - navigation
26
+ - right
21
27
  #}
28
+
22
29
  {% set _collapse_id = collapse_id|default('') %}
23
30
  {% set _background = background|default('') %}
31
+ {% set _brand = brand|default({}) %}
24
32
  {% set _navigation = navigation|default({}) %}
25
33
  {% set _form = form|default({}) %}
26
34
  {% set _expand = expand|default('lg') %}
27
- {% set _brand = brand|default({}) %}
28
35
  {% set _color_set = color_set|default('light') %}
29
- {% set _extra_classes = extra_classes|default('') %}
30
- {% set _class = 'navbar' %}
31
- {% set _class = _class ~ ' navbar-expand-' ~ _expand %}
32
- {% if _extra_classes is not empty %}
33
- {% set _class = _class ~ ' ' ~ _extra_classes %}
34
- {% endif %}
36
+ {% set _disable_collapse = disable_collapse ?? false %}
37
+
38
+ {% set _classes = ['navbar', 'navbar-expand-' ~ _expand] %}
35
39
  {% if _background is not empty %}
36
- {% set _class = _class ~ ' bg-' ~ _background %}
40
+ {% set _classes = _classes|merge(['bg-' ~ _background]) %}
37
41
  {% endif %}
38
42
  {% if _color_set is not empty %}
39
- {% set _class = _class ~ ' navbar-' ~ _color_set %}
43
+ {% set _classes = _classes|merge(['navbar-' ~ _color_set]) %}
40
44
  {% endif %}
41
45
 
42
- <nav class='{{ _class }}'>
46
+ {% if attributes is empty %}
47
+ {% set attributes = create_attribute() %}
48
+ {% endif %}
49
+
50
+ {% set attributes = attributes.addClass(_classes) %}
51
+
52
+ <nav
53
+ {{ attributes }}
54
+ >
43
55
  <div class='container'>
56
+ {% block branding %}
44
57
  {% if _brand is not empty %}
45
58
  <a class='navbar-brand' href='{{ _brand.link }}'>
46
- {%- if _brand.label is defined -%}
47
- {{- _brand.label -}}
48
- {%- else -%}
59
+ {% for logo in _brand.logos %}
49
60
  <img
50
- src='{{ _brand.src }}'
51
- {% if _brand.alt is not empty %}
52
- alt='{{ _brand.alt }}'
61
+ src='{{ logo.src }}'
62
+ {% if logo.alt is not empty %}
63
+ alt='{{ logo.alt }}'
53
64
  {% endif %}
54
- {% if _brand.class is not empty %}
55
- class='{{ _brand.class }}'
65
+ {% if logo.class is not empty %}
66
+ class='{{ logo.class }}'
56
67
  {% endif %}
57
68
  />
58
- {%- endif -%}
69
+ {% endfor %}
70
+ {%- if _brand.label is defined -%}
71
+ <div class="h5 ms-4-5 d-none d-lg-inline-block">
72
+ {{- _brand.label -}}
73
+ </div>
74
+ {% endif %}
59
75
  </a>
60
76
  {% endif %}
77
+ {% endblock %}
78
+
79
+ {% if not _disable_collapse %}
61
80
  <button
62
- class='navbar-toggler'
63
- type='button'
64
- data-bs-toggle='collapse'
81
+ class="navbar-toggler"
82
+ type="button"
83
+ data-bs-toggle="collapse"
65
84
  data-bs-target='#{{ _collapse_id }}'
66
85
  aria-controls='{{ _collapse_id }}'
67
- aria-expanded='false'
68
- aria-label='Toggle navigation'
86
+ aria-expanded="false"
87
+ aria-label="Toggle navigation"
69
88
  >
70
- <span class='navbar-toggler-icon'></span>
89
+ <span class="navbar-toggler-icon"></span>
71
90
  </button>
72
- <div class='collapse navbar-collapse' id='{{ _collapse_id }}'>
73
- {% if _navigation is not empty %}
74
- {% include '@oe-bcl/navigation/navigation.html.twig' with _navigation only %}
75
- {% endif %}
76
- {% if _form is not empty %}
77
- {% include '@oe-bcl/form/form.html.twig' with _form only %}
78
- {% endif %}
91
+ <div class="collapse navbar-collapse" id='{{ _collapse_id }}'>
92
+ {% endif %}
93
+ {% block navigation %}
94
+ {% if _navigation is not empty %}
95
+ {% include '@oe-bcl/bcl-navigation/navigation.html.twig' with _navigation only %}
96
+ {% endif %}
97
+ {% endblock %}
98
+ {% block right %}
99
+ {% if _form is not empty %}
100
+ {% include '@oe-bcl/bcl-form/form.html.twig' with _form only %}
101
+ {% endif %}
102
+ {% endblock %}
103
+ {% if not _disable_collapse %}
79
104
  </div>
105
+ {% endif %}
80
106
  </div>
81
107
  </nav>
82
108
 
83
- {% endspaceless %}
109
+ {% endapply %}
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "name": "@openeuropa/bcl-navbar",
3
3
  "author": "European Commission",
4
4
  "license": "EUPL-1.2",
5
- "version": "0.1.2",
5
+ "version": "0.1.202408021145",
6
6
  "dependencies": {
7
- "@openeuropa/bcl-form": "^0.1.2",
8
- "@openeuropa/bcl-navigation": "^0.1.2"
7
+ "@openeuropa/bcl-form": "^0.1.202408021145",
8
+ "@openeuropa/bcl-navigation": "^0.1.202408021145"
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public"
@@ -25,5 +25,5 @@
25
25
  "design-system",
26
26
  "twig"
27
27
  ],
28
- "gitHead": "b242dcb5ed9578fcd212c98cf722eabc845d313b"
28
+ "gitHead": "7ee2013f7f64a70ddfa35228a9a65967dd71eec3"
29
29
  }