@openeuropa/bcl-gallery 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.
- package/LICENSE.md +21 -0
- package/gallery-item.html.twig +64 -0
- package/gallery.html.twig +195 -0
- package/package.json +31 -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,64 @@
|
|
|
1
|
+
{% apply spaceless %}
|
|
2
|
+
|
|
3
|
+
{#
|
|
4
|
+
Parameters:
|
|
5
|
+
- item (object) (default: {})
|
|
6
|
+
format: {
|
|
7
|
+
thumbnail (string) img path
|
|
8
|
+
media: (string) <img> tag
|
|
9
|
+
caption (string)
|
|
10
|
+
caption_title (string)
|
|
11
|
+
is_playable (boolean)
|
|
12
|
+
}
|
|
13
|
+
- carousel_id (string) (default: '')
|
|
14
|
+
- modal_id (string) (default: '')
|
|
15
|
+
- carousel_anchor (string) (default: '')
|
|
16
|
+
- icon_path (string) (default: '')
|
|
17
|
+
- attributes (drupal attrs)
|
|
18
|
+
#}
|
|
19
|
+
|
|
20
|
+
{% set _item = item|default({}) %}
|
|
21
|
+
{% set _carousel_id = carousel_id|default('') %}
|
|
22
|
+
{% set _modal_id = modal_id|default('') %}
|
|
23
|
+
{% set _icon_path = icon_path|default('') %}
|
|
24
|
+
{% set _carousel_anchor = carousel_anchor|default('') %}
|
|
25
|
+
|
|
26
|
+
{% if attributes is empty %}
|
|
27
|
+
{% set attributes = create_attribute() %}
|
|
28
|
+
{% endif %}
|
|
29
|
+
|
|
30
|
+
{% set attributes = attributes.addClass(['bcl-gallery__item', 'd-block', 'w-100', 'img-fluid'])
|
|
31
|
+
.setAttribute('data-bs-target', '#' ~ _carousel_id)
|
|
32
|
+
.setAttribute('data-bs-slide-to', _carousel_anchor)
|
|
33
|
+
%}
|
|
34
|
+
|
|
35
|
+
<a
|
|
36
|
+
{{ attributes }}
|
|
37
|
+
>
|
|
38
|
+
<div class="bcl-gallery__item-overlay" data-bs-target="#{{ _modal_id }}" data-bs-toggle="modal">
|
|
39
|
+
{% if _item.is_playable %}
|
|
40
|
+
<span class="bcl-gallery__item-play-icon">
|
|
41
|
+
{% include '@oe-bcl/bcl-icon/icon.html.twig' with {
|
|
42
|
+
name: 'play-fill',
|
|
43
|
+
size: 's',
|
|
44
|
+
path: _icon_path,
|
|
45
|
+
} only %}
|
|
46
|
+
</span>
|
|
47
|
+
{% endif %}
|
|
48
|
+
{% if _item.caption is not empty or item.caption_title is not empty %}
|
|
49
|
+
<div class="bcl-gallery__item-caption">
|
|
50
|
+
{% if _item.caption_title is not empty %}
|
|
51
|
+
<div class="fs-5">{{ _item.caption_title }}</div>
|
|
52
|
+
{% endif %}
|
|
53
|
+
{% if _item.caption is not empty %}
|
|
54
|
+
<div class="bcl-gallery__item-description">
|
|
55
|
+
{{ _item.caption }}
|
|
56
|
+
</div>
|
|
57
|
+
{% endif %}
|
|
58
|
+
</div>
|
|
59
|
+
{% endif %}
|
|
60
|
+
</div>
|
|
61
|
+
{{ _item.thumbnail }}
|
|
62
|
+
</a>
|
|
63
|
+
|
|
64
|
+
{% endapply %}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
{% apply spaceless %}
|
|
2
|
+
|
|
3
|
+
{#
|
|
4
|
+
Parameters:
|
|
5
|
+
- id (string) (default: gallery-random(1000))
|
|
6
|
+
- title (string) (default: '')
|
|
7
|
+
- title_tag (string) (default: 'h2')
|
|
8
|
+
- title_link: (link object) (default: {})
|
|
9
|
+
- title_attributes (drupal attrs)
|
|
10
|
+
- counter (string) (default: '')
|
|
11
|
+
- toggle_collapsed (string) (default: '')
|
|
12
|
+
- toggle_expanded (string) (default: '')
|
|
13
|
+
- next_label (string) (default: 'Next')
|
|
14
|
+
- prev_label (string) (default: 'Previous')
|
|
15
|
+
- max_visible_thumbnails (int) (default: 5)
|
|
16
|
+
- items (object[]) format: [
|
|
17
|
+
{
|
|
18
|
+
thumbnail (string) img path
|
|
19
|
+
media: (string) <img> tag
|
|
20
|
+
caption (string)
|
|
21
|
+
caption_title (string)
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
- icon_path (string) (default: '')
|
|
25
|
+
- attributes (drupal attrs)
|
|
26
|
+
|
|
27
|
+
Blocks:
|
|
28
|
+
carousel
|
|
29
|
+
#}
|
|
30
|
+
|
|
31
|
+
{% set _id = id|default('gallery-' ~ random(1000)) %}
|
|
32
|
+
{% set _title = title|default('') %}
|
|
33
|
+
{% set _title_tag = title_tag|default('h2') %}
|
|
34
|
+
{% set _title_link = title_link|default({}) %}
|
|
35
|
+
{% set _title_attributes = title_attributes ?: create_attribute() %}
|
|
36
|
+
{% set _counter = counter|default('') %}
|
|
37
|
+
{% set _toggle_collapsed = toggle_collapsed|default('') %}
|
|
38
|
+
{% set _toggle_expanded = toggle_expanded|default('') %}
|
|
39
|
+
{% set _next_label = next_label|default('Next') %}
|
|
40
|
+
{% set _prev_label = prev_label|default('Previous') %}
|
|
41
|
+
{% set _max_visible_thumbnails = max_visible_thumbnails|default(5) %}
|
|
42
|
+
{% set _items = items|default([]) %}
|
|
43
|
+
{% set _icon_path = icon_path|default('') %}
|
|
44
|
+
{% set _carousel_id = "carousel" ~ _id|capitalize %}
|
|
45
|
+
{% set _modal_id = "modal" ~ _id|capitalize %}
|
|
46
|
+
{% set _collapse_id = "collapse" ~ _id|capitalize %}
|
|
47
|
+
{% set _carousel_items = [] %}
|
|
48
|
+
|
|
49
|
+
{% if attributes is empty %}
|
|
50
|
+
{% set attributes = create_attribute() %}
|
|
51
|
+
{% endif %}
|
|
52
|
+
|
|
53
|
+
{% set attributes = attributes.addClass('bcl-gallery') %}
|
|
54
|
+
|
|
55
|
+
{% if _items is not empty and _items is iterable %}
|
|
56
|
+
<div
|
|
57
|
+
{{ attributes }}
|
|
58
|
+
>
|
|
59
|
+
{% if _title is not empty or _counter is not empty %}
|
|
60
|
+
<div class="d-sm-flex flex-sm-row align-items-sm-center">
|
|
61
|
+
{% if _title is not empty %}
|
|
62
|
+
<div class="flex-sm-grow-1">
|
|
63
|
+
{% include '@oe-bcl/bcl-heading/heading.html.twig' with {
|
|
64
|
+
title: _title,
|
|
65
|
+
title_tag: _title_tag,
|
|
66
|
+
title_link: _title_link,
|
|
67
|
+
attributes: _title_attributes,
|
|
68
|
+
} only %}
|
|
69
|
+
</div>
|
|
70
|
+
{% endif %}
|
|
71
|
+
{%- if _counter is not empty -%}
|
|
72
|
+
<div class="mb-3 mb-sm-0 fw-bold">
|
|
73
|
+
{{- _counter|replace({'%d': _items|length}) -}}
|
|
74
|
+
</div>
|
|
75
|
+
{%- endif -%}
|
|
76
|
+
</div>
|
|
77
|
+
{% endif %}
|
|
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 }}">
|
|
82
|
+
{% endif %}
|
|
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 %}
|
|
95
|
+
</ul>
|
|
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 %}
|
|
138
|
+
</div>
|
|
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>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
{% endif %}
|
|
194
|
+
|
|
195
|
+
{% endapply %}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openeuropa/bcl-gallery",
|
|
3
|
+
"author": "European Commission",
|
|
4
|
+
"license": "EUPL-1.2",
|
|
5
|
+
"version": "0.1.202408021145",
|
|
6
|
+
"description": "OE - BCL gallery",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@openeuropa/bcl-button": "^0.1.202408021145",
|
|
12
|
+
"@openeuropa/bcl-carousel": "^0.1.202408021145",
|
|
13
|
+
"@openeuropa/bcl-heading": "^0.1.202408021145",
|
|
14
|
+
"@openeuropa/bcl-icon": "^0.1.202408021145"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/openeuropa/bootstrap-component-library.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/openeuropa/bootstrap-component-library.git/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/openeuropa/bootstrap-component-library",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"openeuropa",
|
|
26
|
+
"bootstrap-component-library",
|
|
27
|
+
"design-system",
|
|
28
|
+
"twig"
|
|
29
|
+
],
|
|
30
|
+
"gitHead": "7ee2013f7f64a70ddfa35228a9a65967dd71eec3"
|
|
31
|
+
}
|