@openeuropa/bcl-gallery 0.28.1 → 1.0.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.
@@ -2,17 +2,17 @@
2
2
 
3
3
  {#
4
4
  Parameters:
5
- - item (object) (default: '')
5
+ - item (object) (default: {})
6
6
  format: {
7
- thumbnails (string) img path
7
+ thumbnail (string) img path
8
8
  media: (string) <img> tag
9
9
  caption (string)
10
10
  caption_title (string)
11
- caption_classes (string)
12
- interval (integer) (default: 0)
11
+ is_playable (boolean)
13
12
  }
14
13
  - carousel_id (string) (default: '')
15
14
  - modal_id (string) (default: '')
15
+ - carousel_anchor (string) (default: '')
16
16
  - icon_path (string) (default: '')
17
17
  - attributes (drupal attrs)
18
18
  #}
@@ -21,6 +21,7 @@ Parameters:
21
21
  {% set _carousel_id = carousel_id|default('') %}
22
22
  {% set _modal_id = modal_id|default('') %}
23
23
  {% set _icon_path = icon_path|default('') %}
24
+ {% set _carousel_anchor = carousel_anchor|default('') %}
24
25
 
25
26
  {% if attributes is empty %}
26
27
  {% set attributes = create_attribute() %}
@@ -28,14 +29,14 @@ Parameters:
28
29
 
29
30
  {% set attributes = attributes.addClass(['bcl-gallery__item', 'd-block', 'w-100', 'img-fluid'])
30
31
  .setAttribute('data-bs-target', '#' ~ _carousel_id)
31
- .setAttribute('data-bs-slide-to', loop.index - 1)
32
+ .setAttribute('data-bs-slide-to', _carousel_anchor)
32
33
  %}
33
34
 
34
35
  <a
35
36
  {{ attributes }}
36
37
  >
37
38
  <div class="bcl-gallery__item-overlay" data-bs-target="#{{ _modal_id }}" data-bs-toggle="modal">
38
- {% if '<iframe' in _item.media or '<video' in _item.media %}
39
+ {% if _item.is_playable %}
39
40
  <span class="bcl-gallery__item-play-icon">
40
41
  {% include '@oe-bcl/bcl-icon/icon.html.twig' with {
41
42
  name: 'play-fill',
package/gallery.html.twig CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {#
4
4
  Parameters:
5
- - id (string) (default: '')
5
+ - id (string) (default: gallery-random(1000))
6
6
  - title (string) (default: '')
7
7
  - title_tag (string) (default: 'h2')
8
8
  - title_link: (link object) (default: {})
@@ -13,18 +13,19 @@ Parameters:
13
13
  - next_label (string) (default: 'Next')
14
14
  - prev_label (string) (default: 'Previous')
15
15
  - max_visible_thumbnails (int) (default: 5)
16
- - items (array of objects) format: [
16
+ - items (object[]) format: [
17
17
  {
18
- thumbnails (string) img path
18
+ thumbnail (string) img path
19
19
  media: (string) <img> tag
20
20
  caption (string)
21
21
  caption_title (string)
22
- caption_classes (string)
23
- interval (integer) (default: 0)
24
22
  }
25
23
  ]
26
24
  - icon_path (string) (default: '')
27
25
  - attributes (drupal attrs)
26
+
27
+ Blocks:
28
+ carousel
28
29
  #}
29
30
 
30
31
  {% set _id = id|default('gallery-' ~ random(1000)) %}
@@ -43,7 +44,7 @@ Parameters:
43
44
  {% set _carousel_id = "carousel" ~ _id|capitalize %}
44
45
  {% set _modal_id = "modal" ~ _id|capitalize %}
45
46
  {% set _collapse_id = "collapse" ~ _id|capitalize %}
46
- {% set _max_visible_thumbnails = _max_visible_thumbnails + 1 %}
47
+ {% set _carousel_items = [] %}
47
48
 
48
49
  {% if attributes is empty %}
49
50
  {% set attributes = create_attribute() %}
@@ -51,10 +52,11 @@ Parameters:
51
52
 
52
53
  {% set attributes = attributes.addClass('bcl-gallery') %}
53
54
 
55
+ {% if _items is not empty and _items is iterable %}
54
56
  <div
55
57
  {{ attributes }}
56
58
  >
57
- {% if _title is not empty or _counter is not empty %}
59
+ {% if _title is not empty or _counter is not empty %}
58
60
  <div class="d-sm-flex flex-sm-row align-items-sm-center">
59
61
  {% if _title is not empty %}
60
62
  <div class="flex-sm-grow-1">
@@ -72,83 +74,122 @@ Parameters:
72
74
  </div>
73
75
  {%- endif -%}
74
76
  </div>
75
- {% endif %}
76
- {% if _items is not empty and _items is iterable %}
77
- {% for _item in _items %}
78
- {% if loop.first %}
79
- <div class="bcl-gallery__thumbnails">
80
77
  {% endif %}
81
- {% if loop.index == _max_visible_thumbnails %}
82
- <div class="bcl-gallery__thumbnails-collaspe collapse" id="{{ _collapse_id }}">
83
- {% endif %}
84
- {% if loop.index % _max_visible_thumbnails == 0 or loop.first %}
85
- <ul class="bcl-gallery__grid">
78
+ <div class="bcl-gallery__thumbnails">
79
+ {% for _batch in _items|batch(_max_visible_thumbnails) %}
80
+ {% if loop.index0 == 1 %}
81
+ <div class="bcl-gallery__thumbnails-collaspe collapse" id="{{ _collapse_id }}">
86
82
  {% endif %}
87
- <li>
88
- {% include '@oe-bcl/bcl-gallery/gallery-item.html.twig' with {
89
- item: _item,
90
- carousel_id: _carousel_id,
91
- modal_id: _modal_id,
92
- icon_path: _icon_path,
93
- loop: loop,
94
- } only %}
95
- </li>
96
- {% if loop.index % 5 == 0 or loop.last %}
83
+ <ul class="bcl-gallery__grid">
84
+ {% for _item in _batch %}
85
+ <li>
86
+ {% include '@oe-bcl/bcl-gallery/gallery-item.html.twig' with {
87
+ item: _item,
88
+ carousel_id: _carousel_id,
89
+ modal_id: _modal_id,
90
+ icon_path: _icon_path,
91
+ carousel_anchor: loop.index0 + (_max_visible_thumbnails * loop.parent.loop.index0),
92
+ } only %}
93
+ </li>
94
+ {% endfor %}
97
95
  </ul>
98
- {% endif %}
99
- {% if loop.last %}
100
- </div>
101
- {% endif %}
102
- {% if loop.index > _max_visible_thumbnails and loop.last %}
96
+ {% if loop.last and loop.index0 >= 1 %}
97
+ </div>
98
+ {% endif %}
99
+ {% endfor %}
100
+ {% if _items|length > _max_visible_thumbnails %}
101
+ <div class="bg-lighter py-3 px-4 mt-2 rounded text-center">
102
+ <a
103
+ class="bcl-gallery__collapse standalone d-none d-sm-inline-block"
104
+ aria-controls="{{ _collapse_id }}"
105
+ data-bs-toggle="collapse"
106
+ aria-expanded="false"
107
+ role="button"
108
+ href="#{{ _collapse_id }}"
109
+ >
110
+ <span class="label-collapsed">{{ _toggle_collapsed|replace({'%d': _items|length}) }}</span>
111
+ <span class="label-expanded">{{ _toggle_expanded }}</span>
112
+ {% include '@oe-bcl/bcl-icon/icon.html.twig' with {
113
+ name: 'caret-down-fill',
114
+ size: '2xs',
115
+ path: _icon_path,
116
+ attributes: create_attribute().addClass('ms-2-5'),
117
+ } only %}
118
+ </a>
119
+ <a
120
+ class="bcl-gallery__mobile-view-more standalone d-inline-block d-sm-none"
121
+ data-bs-target="#{{ _carousel_id }}"
122
+ data-bs-slide-to="{{ _max_visible_thumbnails - 1 }}"
123
+ role="button"
124
+ href="#"
125
+ >
126
+ <span data-bs-target="#{{ _modal_id }}" data-bs-toggle="modal">
127
+ <span class="label-collapsed">{{ _toggle_collapsed|replace({'%d': _items|length}) }}</span>
128
+ {% include '@oe-bcl/bcl-icon/icon.html.twig' with {
129
+ name: 'caret-down-fill',
130
+ size: '2xs',
131
+ path: _icon_path,
132
+ attributes: create_attribute().addClass('ms-2-5'),
133
+ } only %}
134
+ <span>
135
+ </a>
136
+ </div>
137
+ {% endif %}
103
138
  </div>
104
- <div class="bg-lighter py-3 px-4 mt-2 rounded text-center">
105
- <a
106
- class="bcl-gallery__collapse standalone d-none d-sm-inline-block"
107
- aria-controls="{{ _collapse_id }}"
108
- data-bs-toggle="collapse"
109
- aria-expanded="false"
110
- role="button"
111
- href="#{{ _collapse_id }}"
112
- >
113
- <span class="label-collapsed">{{ _toggle_collapsed|replace({'%d': _items|length}) }}</span>
114
- <span class="label-expanded">{{ _toggle_expanded }}</span>
115
- {% include '@oe-bcl/bcl-icon/icon.html.twig' with {
116
- name: 'caret-down-fill',
117
- size: '2xs',
118
- path: _icon_path,
119
- attributes: create_attribute().addClass('ms-2-5'),
120
- } only %}
121
- </a>
122
- <a
123
- class="bcl-gallery__mobile-view-more standalone d-inline-block d-sm-none"
124
- data-bs-target="#{{ _carousel_id }}"
125
- data-bs-slide-to="{{ _max_visible_thumbnails - 1 }}"
126
- role="button"
127
- href="#"
128
- >
129
- <span data-bs-target="#{{ _modal_id }}" data-bs-toggle="modal">
130
- <span class="label-collapsed">{{ _toggle_collapsed|replace({'%d': _items|length}) }}</span>
131
- {% include '@oe-bcl/bcl-icon/icon.html.twig' with {
132
- name: 'caret-down-fill',
133
- size: '2xs',
134
- path: _icon_path,
135
- attributes: create_attribute().addClass('ms-2-5'),
136
- } only %}
137
- <span>
138
- </a>
139
+ <div class="modal" id="{{ _modal_id }}" tabindex="-1" aria-labelledby="{{ _modal_id }}" aria-hidden="true" data-bs-backdrop="false">
140
+ <div class="modal-dialog modal-dialog-centered modal-fullscreen">
141
+ <div class="modal-content">
142
+ <div class="modal-header border-0 justify-content-between">
143
+ {% if _title is not empty %}
144
+ <div class="modal-title">
145
+ {% if _title is not empty %}
146
+ {% include '@oe-bcl/bcl-heading/heading.html.twig' with {
147
+ title: _title,
148
+ title_tag: 'h3',
149
+ attributes: create_attribute().addClass(['d-sm-block', 'd-none']),
150
+ } only %}
151
+ {% endif %}
152
+ </div>
153
+ {% endif %}
154
+ <div class="carousel-pager">
155
+ <span>1</span> / {{ _items|length -}}
156
+ </div>
157
+ <div class="modal-close">
158
+ {% set button_attributes = create_attribute()
159
+ .addClass('btn-close')
160
+ .setAttribute('aria-label', 'Close')
161
+ .setAttribute('data-bs-dismiss', 'modal')
162
+ %}
163
+ {% include '@oe-bcl/bcl-button/button.html.twig' with {
164
+ clean_class: true,
165
+ attributes: button_attributes
166
+ } only %}
167
+ </div>
168
+ </div>
169
+ <div class="modal-body d-flex align-items-center justify-content-center">
170
+ {% block carousel %}
171
+ {% for _item in _items %}
172
+ {% set _carousel_items = _carousel_items|merge([_item|merge({
173
+ caption_title: ('<iframe' in _item.media or '<video' in _item.media) ? '' : _item.caption_title,
174
+ caption: ('<iframe' in _item.media or '<video' in _item.media) ? '' : _item.caption,
175
+ image: ('<iframe' in _item.media or '<img' in _item.media) ? _item.media|replace({'src=': 'data-src='}) : _item.media,
176
+ })]) %}
177
+ {% endfor %}
178
+ {% include '@oe-bcl/bcl-carousel/carousel.html.twig' with {
179
+ id: _carousel_id,
180
+ with_controls: true,
181
+ with_indicators: false,
182
+ prev_label: _prev_label,
183
+ next_label: _next_label,
184
+ autoplay: false,
185
+ items: _carousel_items,
186
+ } only %}
187
+ {% endblock %}
188
+ </div>
189
+ </div>
190
+ </div>
139
191
  </div>
140
- {% endif %}
141
- {% endfor %}
142
- {% endif %}
143
- {% include '@oe-bcl/bcl-gallery/gallery-modal.html.twig' with {
144
- id: _modal_id,
145
- carousel_id: _carousel_id,
146
- next_label: _next_label,
147
- prev_label: _prev_label,
148
- title: _title,
149
- items: _items,
150
- icon_path: _icon_path
151
- } only %}
152
192
  </div>
193
+ {% endif %}
153
194
 
154
195
  {% endapply %}
package/package.json CHANGED
@@ -2,16 +2,16 @@
2
2
  "name": "@openeuropa/bcl-gallery",
3
3
  "author": "European Commission",
4
4
  "license": "EUPL-1.2",
5
- "version": "0.28.1",
5
+ "version": "1.0.0",
6
6
  "description": "OE - BCL gallery",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
10
  "dependencies": {
11
- "@openeuropa/bcl-button": "^0.28.1",
12
- "@openeuropa/bcl-carousel": "^0.28.1",
13
- "@openeuropa/bcl-heading": "^0.28.1",
14
- "@openeuropa/bcl-icon": "^0.28.1"
11
+ "@openeuropa/bcl-button": "^1.0.0",
12
+ "@openeuropa/bcl-carousel": "^1.0.0",
13
+ "@openeuropa/bcl-heading": "^1.0.0",
14
+ "@openeuropa/bcl-icon": "^1.0.0"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -27,5 +27,5 @@
27
27
  "design-system",
28
28
  "twig"
29
29
  ],
30
- "gitHead": "3b0d2f4a85c727f38ae4e3403110c98302d09117"
30
+ "gitHead": "16b986722345644e83a37dc8091c07eecbdf4c8c"
31
31
  }
@@ -1,105 +0,0 @@
1
- {% apply spaceless %}
2
-
3
- {#
4
- Parameters:
5
- - id (string) (default: '')
6
- - title (string) (default: '')
7
- - title_tag (string) (default: 'h2')
8
- - title_link: (link object) (default: {})
9
- - title_attributes (drupal attrs)
10
- - items (array of objects) format: [
11
- {
12
- thumbnails (string) img path
13
- media: (string) <img> tag
14
- caption (string)
15
- caption_title (string)
16
- caption_classes (string)
17
- interval (integer) (default: 0)
18
- }
19
- ]
20
- - carousel_id (string) (default: '')
21
- - next_label (string) (default: '')
22
- - prev_label (string) (default: '')
23
- - icon_path (string) (default: '')
24
- - attributes (drupal attrs)
25
- #}
26
-
27
- {% set _id = id|default('') %}
28
- {% set _title = title|default('') %}
29
- {% set _title_tag = title_tag|default('h3') %}
30
- {% set _title_link = title_link|default({}) %}
31
- {% set _title_attributes = title_attributes ?: create_attribute() %}
32
- {% set _items = items|default([]) %}
33
- {% set _carousel_id = carousel_id|default('') %}
34
- {% set _next_label = next_label|default('Next') %}
35
- {% set _prev_label = prev_label|default('Previous') %}
36
- {% set _icon_path = icon_path|default('') %}
37
- {% set _carousel_items = [] %}
38
-
39
- {% if attributes is empty %}
40
- {% set attributes = create_attribute() %}
41
- {% endif %}
42
-
43
- {% set attributes = attributes.addClass('modal')
44
- .setAttribute('id', _id)
45
- .setAttribute('tabindex', '-1')
46
- .setAttribute('aria-labelledby', _id)
47
- .setAttribute('aria-hidden', 'true')
48
- .setAttribute('data-bs-backdrop', 'false')
49
- %}
50
-
51
- <div
52
- {{ attributes }}
53
- >
54
- <div class="modal-dialog modal-dialog-centered modal-fullscreen">
55
- <div class="modal-content">
56
- <div class="modal-header border-0 justify-content-between">
57
- {% if _title is not empty %}
58
- <div class="modal-title">
59
- {% if _title is not empty %}
60
- {% include '@oe-bcl/bcl-heading/heading.html.twig' with {
61
- title: _title,
62
- title_tag: _title_tag,
63
- title_link: _title_link,
64
- attributes: _title_attributes.addClass(['d-sm-block', 'd-none']),
65
- } only %}
66
- {% endif %}
67
- </div>
68
- {% endif %}
69
- <div class="carousel-pager">
70
- <span>1</span> / {{ _items|length -}}
71
- </div>
72
- <div class="modal-close">
73
- {% set button_attributes = create_attribute()
74
- .addClass('btn-close')
75
- .setAttribute('aria-label', 'Close')
76
- .setAttribute('data-bs-dismiss', 'modal')
77
- %}
78
- {% include '@oe-bcl/bcl-button/button.html.twig' with {
79
- clean_class: true,
80
- attributes: button_attributes
81
- } only %}
82
- </div>
83
- </div>
84
- <div class="modal-body d-flex align-items-center justify-content-center">
85
- {% for _item in _items %}
86
- {% set _carousel_items = _carousel_items|merge([_item|merge({
87
- caption: ('<iframe' in _item.media or '<video' in _item.media) ? '' : _item.caption,
88
- image: ('<iframe' in _item.media or '<img' in _item.media) ? _item.media|replace({'src=': 'data-src='}) : _item.media,
89
- })]) %}
90
- {% endfor %}
91
- {% include '@oe-bcl/bcl-carousel/carousel.html.twig' with {
92
- id: _carousel_id,
93
- with_controls: true,
94
- with_indicators: false,
95
- prev_label: _prev_label,
96
- next_label: _next_label,
97
- autoplay: false,
98
- items: _carousel_items,
99
- } only %}
100
- </div>
101
- </div>
102
- </div>
103
- </div>
104
-
105
- {% endapply %}