@openeuropa/bcl-theme-default 0.15.0 → 0.16.0

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.
@@ -38,11 +38,14 @@
38
38
 
39
39
  {% if _items is not empty %}
40
40
  {% for _card in _items %}
41
+ {% set _alignment_class = '' %}
41
42
  {% set _max_width = '' %}
42
43
  {% set _image = {} %}
43
44
  {% if _card.image is not empty %}
44
45
  {% set _max_width = 'mw-listing-img' %}
45
- {% set _image_classes = _card.image.classes ? _card.image.classes ~ " mb-3" : "mb-3" %}
46
+ {% if not _alignment == 'center' %}
47
+ {% set _image_classes = _card.image.classes ? _card.image.classes ~ ' mb-3' : 'mb-3' %}
48
+ {% endif %}
46
49
  {% set _card = _card|merge({image: _card.image|merge({
47
50
  classes: _image_classes
48
51
  })}) %}
@@ -50,7 +53,7 @@
50
53
  {% set _max_width = 'mw-date mb-3' %}
51
54
  {% endif %}
52
55
  {% if _alignment is not empty %}
53
- {% set _alignment = ' align-self-' ~ _alignment %}
56
+ {% set _alignment_class = ' align-self-' ~ _alignment %}
54
57
  {% endif %}
55
58
  {% set _card_classes = [] %}
56
59
  {% set _card_attributes = card.attributes ? card.attributes : create_attribute() %}
@@ -67,8 +70,8 @@
67
70
  horizontal: true,
68
71
  extra_classes_body: 'p-0 pb-md-0 pb-3',
69
72
  horizontal_grid: {
70
- left_col_classes: 'col-md-3 col-lg-2 rounded ' ~ _max_width ~ _alignment,
71
- right_col_classes: 'col-md-9 col-lg-10' ~ _alignment,
73
+ left_col_classes: 'col-md-3 col-lg-2 rounded ' ~ _max_width ~ _alignment_class,
74
+ right_col_classes: 'col-md-9 col-lg-10' ~ _alignment_class,
72
75
  },
73
76
  attributes: _card_attributes,
74
77
  }) %}
@@ -91,8 +94,8 @@
91
94
  {% if _variant == 'default-2-col' %}
92
95
  {% set _card = _card|merge({
93
96
  horizontal_grid: {
94
- left_col_classes: 'col-xl-3 col-md-5 ' ~ _max_width ~ _alignment,
95
- right_col_classes: 'col-xl-9 col-md-7' ~ _alignment,
97
+ left_col_classes: 'col-xl-3 col-md-5 ' ~ _max_width ~ _alignment_class,
98
+ right_col_classes: 'col-xl-9 col-md-7' ~ _alignment_class,
96
99
  },
97
100
  }) %}
98
101
  {% set _card_layout = _card_layout|merge({
@@ -101,8 +104,8 @@
101
104
  {% else %}
102
105
  {% set _card = _card|merge({
103
106
  horizontal_grid: {
104
- left_col_classes: 'col-lg-4 col-md-6 ' ~ _max_width ~ _alignment,
105
- right_col_classes: 'col-lg-8 col-md-6' ~ _alignment,
107
+ left_col_classes: 'col-lg-4 col-md-6 ' ~ _max_width ~ _alignment_class,
108
+ right_col_classes: 'col-lg-8 col-md-6' ~ _alignment_class,
106
109
  },
107
110
  }) %}
108
111
  {% set _card_layout = _card_layout|merge({
@@ -121,10 +124,14 @@
121
124
  ] %}
122
125
  {% set _card_attributes = _card_attributes.addClass(_card_classes) %}
123
126
  {% set _card = _card|merge({
124
- extra_classes_body: 'pb-4',
125
127
  wrapper_class: 'col',
126
128
  attributes: _card_attributes,
127
129
  }) %}
130
+ {% if _card.image is defined and _card.image is not empty %}
131
+ {% set _card = _card|merge({
132
+ extra_classes_body: "pt-0",
133
+ }) %}
134
+ {% endif %}
128
135
  {% set _card_layout = _card_layout|merge({
129
136
  cols_extra_classes: 'mt-4-5',
130
137
  }) %}
@@ -141,9 +148,13 @@
141
148
  {% set _card_attributes = _card_attributes.addClass(_card_classes) %}
142
149
  {% set _card = _card|merge({
143
150
  wrapper_class: 'col',
144
- extra_classes_body: 'pt-0',
145
151
  attributes: _card_attributes,
146
152
  }) %}
153
+ {% if _card.image is defined and _card.image is not empty %}
154
+ {% set _card = _card|merge({
155
+ extra_classes_body: 'pt-0',
156
+ }) %}
157
+ {% endif %}
147
158
  {% set _card_layout = _card_layout|merge({ gutter: '4' }) %}
148
159
  {% if variant == 'highlight-2-col' %}
149
160
  {% set _card_layout = _card_layout|merge({ responsive_columns: 2 }) %}
@@ -161,9 +172,6 @@
161
172
  {% if _link is not empty %}
162
173
  {% set _link_attributes = _link.attributes ? _link.attributes : create_attribute() %}
163
174
  {% set _link_attributes = _link_attributes.addClass(['mt-3-5', 'd-inline-block']) %}
164
- {% if _variant == 'default-1-col' or _variant == 'default-2-col' or variant == 'default-3-col' %}
165
- {% set _link_attributes = _link_attributes.addClass(['ps-3-5']) %}
166
- {% endif %}
167
175
  {% include '@oe-bcl/bcl-link/link.html.twig' with _link|merge({
168
176
  attributes: _link_attributes,
169
177
  icon: _link.icon|merge({
@@ -45,26 +45,28 @@
45
45
  {{ attributes }}
46
46
  >
47
47
  <div class='container'>
48
- {% if _brand is not empty %}
49
- <a class='navbar-brand' href='{{ _brand.link }}'>
50
- {%- if _brand.label is defined -%}
51
- {{- _brand.label -}}
52
- {%- else -%}
53
- {% for logo in _brand.logos %}
54
- <img
55
- src='{{ logo.src }}'
56
- {% if logo.alt is not empty %}
57
- alt='{{ logo.alt }}'
58
- {% endif %}
59
- {% if logo.class is not empty %}
60
- class='{{ logo.class }}'
61
- {% endif %}
62
- />
63
- {% endfor %}
64
- {%- endif -%}
65
- </a>
66
- {% endif %}
67
- {% if not _disable_collapse %}
48
+ {% if _brand is not empty %}
49
+ <a class='navbar-brand' href='{{ _brand.link }}'>
50
+ {% for logo in _brand.logos %}
51
+ <img
52
+ src='{{ logo.src }}'
53
+ {% if logo.alt is not empty %}
54
+ alt='{{ logo.alt }}'
55
+ {% endif %}
56
+ {% if logo.class is not empty %}
57
+ class='{{ logo.class }}'
58
+ {% endif %}
59
+ />
60
+ {% endfor %}
61
+ {%- if _brand.label is defined -%}
62
+ <div class="h5 ms-4-5 d-none d-lg-inline-block">
63
+ {{- _brand.label -}}
64
+ </div>
65
+ {% endif %}
66
+ </a>
67
+ {% endif %}
68
+
69
+ {% if not _disable_collapse %}
68
70
  <button
69
71
  class='navbar-toggler'
70
72
  type='button'
@@ -1,3 +1,4 @@
1
+ {% import _self as navigation %}
1
2
  {% spaceless %}
2
3
 
3
4
  {# Parameters:
@@ -17,131 +18,155 @@
17
18
  - active (boolean)
18
19
  - button (boolean) - set to button
19
20
  - content (string) - content for tab
21
+ - navigation (navigation Object) - set for multiple level or navigation, items inside is required
20
22
  }
21
23
  ]
22
24
  #}
23
25
 
24
- {% set _pills = pills|default(false) %}
25
- {% set _tabs = tabs|default(false) %}
26
- {% set _vertical = vertical|default(false) %}
27
- {% set _full_width = full_width|default(false) %}
28
- {% set _alignment = alignment|default('') %}
29
- {% set _id = id|default('') %}
30
- {% set _tabs_content = tabs_content|default(false) %}
31
- {% set _nav = nav|default(false) %}
32
- {% set _navbar = navbar|default(false) %}
33
- {% set _items = items|default([]) %}
26
+ {# Define main macro #}
27
+ {% macro render(items, pills, tabs, tabs_content, vertical, full_width, alignment, id, nav, navbar, attributes) %}
28
+ {% spaceless %}
29
+ {% import _self as navigation %}
34
30
 
35
- {% if _navbar %}
36
- {% set _classes = ['navbar-nav'] %}
37
- {% else %}
38
- {% set _classes = ['nav'] %}
39
- {% endif %}
40
- {% if _pills %}
41
- {% set _classes = _classes|merge(['nav-pills']) %}
42
- {% endif %}
43
- {% if _tabs %}
44
- {% set _classes = _classes|merge(['nav-tabs']) %}
45
- {% endif %}
46
- {% if _vertical %}
47
- {% set _classes = _classes|merge(['flex-column']) %}
48
- {% endif %}
49
- {% if _full_width %}
50
- {% set _classes = _classes|merge(['nav-fill']) %}
51
- {% endif %}
52
- {% if _alignment is not empty %}
53
- {% set _classes = _classes|merge(['justify-content-' ~ _alignment]) %}
54
- {% endif %}
31
+ {% set _pills = pills|default(false) %}
32
+ {% set _tabs = tabs|default(false) %}
33
+ {% set _vertical = vertical|default(false) %}
34
+ {% set _full_width = full_width|default(false) %}
35
+ {% set _alignment = alignment|default('') %}
36
+ {% set _id = id|default('') %}
37
+ {% set _tabs_content = tabs_content|default(false) %}
38
+ {% set _nav = nav|default(false) %}
39
+ {% set _navbar = navbar|default(false) %}
40
+ {% set _items = items|default([]) %}
55
41
 
56
- {% if attributes is empty %}
57
- {% set attributes = create_attribute() %}
58
- {% endif %}
42
+ {% if _navbar %}
43
+ {% set _classes = ['navbar-nav'] %}
44
+ {% else %}
45
+ {% set _classes = ['nav'] %}
46
+ {% endif %}
47
+ {% if _pills %}
48
+ {% set _classes = _classes|merge(['nav-pills']) %}
49
+ {% endif %}
50
+ {% if _tabs %}
51
+ {% set _classes = _classes|merge(['nav-tabs']) %}
52
+ {% endif %}
53
+ {% if _vertical %}
54
+ {% set _classes = _classes|merge(['flex-column']) %}
55
+ {% endif %}
56
+ {% if _full_width %}
57
+ {% set _classes = _classes|merge(['nav-fill']) %}
58
+ {% endif %}
59
+ {% if _alignment is not empty %}
60
+ {% set _classes = _classes|merge(['justify-content-' ~ _alignment]) %}
61
+ {% endif %}
59
62
 
60
- {% if _id is not empty %}
61
- {% set attributes = attributes.setAttribute('id', _id) %}
62
- {% endif %}
63
+ {% if attributes is empty %}
64
+ {% set attributes = create_attribute() %}
65
+ {% endif %}
63
66
 
64
- {% if not _nav and _tabs %}
65
- {% set attributes = attributes.setAttribute('role', 'tablist') %}
66
- {% endif %}
67
+ {% if _id is not empty %}
68
+ {% set attributes = attributes.setAttribute('id', _id) %}
69
+ {% endif %}
67
70
 
68
- {% set attributes = attributes.addClass(_classes) %}
71
+ {% if not _nav and _tabs %}
72
+ {% set attributes = attributes.setAttribute('role', 'tablist') %}
73
+ {% endif %}
74
+ {% set attributes = attributes.addClass(_classes) %}
69
75
 
70
- {% if _nav %}
71
- <nav
72
- {{ attributes }}
73
- >
74
- {% else %}
75
- <ul
76
- {{ attributes }}
77
- >
78
- {% endif %}
79
- {% if _items is not empty and _items is iterable %}
80
- {% for _item in _items %}
81
- {% set _nav_class = 'nav-item' %}
82
- {% if _item.dropdown %}
83
- {% set _nav_class = _nav_class ~ ' dropdown' %}
84
- {% set _item = _item|merge({remove_wrapper: true}) %}
85
- {% endif %}
86
- {% if _item.dropdown %}
87
- {% set _item_classes = [] %}
88
- {% else %}
89
- {% set _item_classes = ['nav-link'] %}
90
- {% endif %}
91
- {% if _item.active %}
92
- {% set _item_classes = _item_classes|merge(['active']) %}
93
- {% endif %}
94
- {% if _item.attributes is empty %}
95
- {% set _item = _item|merge({
96
- attributes: create_attribute()
97
- }) %}
98
- {% endif %}
99
- {% set _item = _item|merge({
100
- attributes: _item.attributes.addClass(_item_classes),
101
- clean_class: true}) %}
102
- {% if not _nav %}
103
- <li
104
- class="{{ _nav_class }}"
105
- {% if _tabs %}
106
- role="presentation"
107
- {% endif %}
108
- >
109
- {% endif %}
110
- {% if _item.dropdown is defined %}
111
- {% include '@oe-bcl/bcl-dropdown/dropdown.html.twig' with _item only %}
112
- {% elseif _item.button is defined %}
113
- {% include '@oe-bcl/bcl-button/button.html.twig' with _item only %}
114
- {% else %}
115
- {% include '@oe-bcl/bcl-link/link.html.twig' with _item only %}
116
- {% endif %}
117
- {% if not _nav %}
118
- </li>
119
- {% endif %}
120
- {% endfor %}
76
+ {% if _nav %}
77
+ <nav
78
+ {{ attributes }}
79
+ >
80
+ {% else %}
81
+ <ul
82
+ {{ attributes }}
83
+ >
121
84
  {% endif %}
122
- {% if _nav %}
123
- </nav>
124
- {% else %}
125
- </ul>
126
- {% endif %}
127
- {% if _tabs_content %}
128
- <div class="tab-content">
129
- {%- block contents -%}
130
85
  {% if _items is not empty and _items is iterable %}
131
- {% for _item in _items %}
132
- {% if _item.content is not empty %}
133
- {% set _content_class = 'tab-pane fade' %}
134
- {% if _item.active %}
135
- {% set _content_class = _content_class ~ ' show active' %}
86
+ {% for _item in items %}
87
+ {% set _nav_class = 'nav-item' %}
88
+ {% if _item.dropdown %}
89
+ {% set _nav_class = _nav_class ~ ' dropdown' %}
90
+ {% set _item = _item|merge({remove_wrapper: true}) %}
91
+ {% endif %}
92
+ {% if _item.dropdown %}
93
+ {% set _item_classes = [] %}
94
+ {% else %}
95
+ {% set _item_classes = ['nav-link'] %}
96
+ {% endif %}
97
+ {% if _item.active %}
98
+ {% set _item_classes = _item_classes|merge(['active']) %}
99
+ {% endif %}
100
+ {% if _item.attributes is empty %}
101
+ {% set _item = _item|merge({
102
+ attributes: create_attribute()
103
+ }) %}
104
+ {% endif %}
105
+ {% set _item = _item|merge({
106
+ attributes: _item.attributes.addClass(_item_classes),
107
+ clean_class: true}) %}
108
+ {% if not _nav %}
109
+ <li
110
+ class="{{ _nav_class }}"
111
+ {% if _tabs %}
112
+ role="presentation"
136
113
  {% endif %}
137
- <div class="{{ _content_class }}" id="{{ _item.target }}" role="tabpanel" aria-labelledby="{{ _item.id }}">
138
- {{- _item.content -}}
139
- </div>
114
+ >
115
+ {% endif %}
116
+ {% if _item.dropdown is defined %}
117
+ {% include '@oe-bcl/bcl-dropdown/dropdown.html.twig' with _item only %}
118
+ {% elseif _item.button is defined %}
119
+ {% include '@oe-bcl/bcl-button/button.html.twig' with _item only %}
120
+ {% else %}
121
+ {% include '@oe-bcl/bcl-link/link.html.twig' with _item only %}
122
+ {% endif %}
123
+ {% if _item.navigation is defined and _item.navigation.items is not empty and _item.navigation.items is iterable %}
124
+ {{ navigation.render(
125
+ _item.navigation.items,
126
+ _item.navigation.pills,
127
+ _item.navigation.tabs,
128
+ _item.navigation.tabs_content,
129
+ _item.navigation.vertical,
130
+ _item.navigation.full_width,
131
+ _item.navigation.alignment,
132
+ _item.navigation.id,
133
+ _item.navigation.nav,
134
+ _item.navigation.navbar,
135
+ _item.navigation.attributes
136
+ ) }}
137
+ {% endif %}
138
+ {% if not _nav %}
139
+ </li>
140
140
  {% endif %}
141
141
  {% endfor %}
142
142
  {% endif %}
143
- {%- endblock -%}
144
- </div>
145
- {% endif %}
143
+ {% if _nav %}
144
+ </nav>
145
+ {% else %}
146
+ </ul>
147
+ {% endif %}
148
+ {% if _tabs_content %}
149
+ <div class="tab-content">
150
+ {%- block contents -%}
151
+ {% if _items is not empty and _items is iterable %}
152
+ {% for _item in _items %}
153
+ {% if _item.content is not empty %}
154
+ {% set _content_class = 'tab-pane fade' %}
155
+ {% if _item.active %}
156
+ {% set _content_class = _content_class ~ ' show active' %}
157
+ {% endif %}
158
+ <div class="{{ _content_class }}" id="{{ _item.target }}" role="tabpanel" aria-labelledby="{{ _item.id }}">
159
+ {{- _item.content -}}
160
+ </div>
161
+ {% endif %}
162
+ {% endfor %}
163
+ {% endif %}
164
+ {%- endblock -%}
165
+ </div>
166
+ {% endif %}
167
+ {% endspaceless %}
168
+ {% endmacro %}
169
+
170
+ {{ navigation.render(items, pills, tabs, tabs_content, vertical, full_width, alignment, id, nav, navbar, attributes) }}
146
171
 
147
172
  {% endspaceless %}