@ecl/gallery 5.0.0-RC1

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.
@@ -0,0 +1,213 @@
1
+ {% apply spaceless %}
2
+
3
+ {#
4
+ Parameters:
5
+ - "grid" (boolean) (default: false) Display gallery as a grid
6
+ - "grid_template" (int) (default: 0) Id of the template to be used. Grid display only
7
+ - "column" (int) (default: 3) Number of columns. Grid display only
8
+ - "ratio" (string) (default: '3-2') Image aspect ratio. Grid display only
9
+ - "picture_zoom" (bool) (default: false): Should the thumbnail pictures be animated?
10
+ - "id": (string) (default: random): Unique id for the gallery
11
+ - "counter_label" (string) (default: '') Label of the counter
12
+ - "view_all_label" (string) (default: '') Label of the view all button
13
+ - "view_all_expanded_label" (string) (default: '') Label of the view all button when expanded
14
+ - "expandable": (boolean) (default: true) If false all items will be visible by default
15
+ - "visible_items": (integer) (default: 8)
16
+ - "full_width": (boolean) (default: false)
17
+ - "disable_hover": (boolean) (default: false)
18
+ - "disable_overlay": (boolean) (default: false)
19
+ - "overlay" (object) (default: {})
20
+ - "close" (object) (default: {}): object of type button
21
+ - "previous" (object) (default: {}): object of type button
22
+ - "next" (object) (default: {}): object of type button
23
+ - "counter_separator" (string) (default: '')
24
+ - "full_screen_label" (string) (default: '')
25
+ - "download" (object) (default: {}): object of type link
26
+ - "share" (object) (default: {}): object of type link
27
+ - "sr_overlay_label" (string) (default: '') aria-label for the overlay
28
+ - "footer" (object) (default: {}): object of type link
29
+ - "items" (array) (default: [])
30
+ - "title" (string) (default: '')
31
+ - "description" (string) (default: '')
32
+ - "meta" (string) (default: '')
33
+ - "icon" (object) (default: {}): object of type icon
34
+ - "thumbnail" (optional) (object) (default: {}) Picture to the thumbnail, type Picture; uses "picture" if empty
35
+ - "picture" (optional) (object) (default: {}) Object of type Picture; always needed, even for video
36
+ - "video" (optional) (object) (default: {})
37
+ - "embedded_video" (optional) (object) (default: {})
38
+ - "sr_video_audio" (string) (default: ''): additional text to indicate if there is an audio description; for screen readers
39
+ - "share_path" (optional) (string) (default: '')
40
+ - "sr_gallery_label" (string) (default: ''): additional label for the gallery, providing instruction; for screen readers
41
+ - "sr_video_label" (string) (default: ''): additional label for the video items; for screen readers
42
+ - "sr_video_player" (string) (default: ''): additional label for the video player; for screen readers
43
+ - "selected_item_id" (int) (default: 0)
44
+ - "extra_classes" (string) (default: '')
45
+ - "extra_attributes" (optional) (array) (default: [])
46
+ - "name" (string) Attribute name, eg. 'data-test'
47
+ - "value" (string) Attribute value, eg: 'data-test-1'
48
+ #}
49
+
50
+ {# variables #}
51
+
52
+ {% set _grid = grid|default(false) %}
53
+ {% set _grid_template = grid_template|default(0) %}
54
+ {% set _column = column|default(3) %}
55
+ {% set _ratio = ratio|default('3-2') %}
56
+ {% set _picture_zoom = picture_zoom|default(false) %}
57
+ {% set _id = id|default('ecl-gallery-' ~ random()) %}
58
+ {% set _css_class = 'ecl-gallery' %}
59
+ {% set _extra_attributes = '' %}
60
+ {% set _overlay = overlay|default({}) %}
61
+ {% set _counter_label = counter_label|default('') %}
62
+ {% set _view_all_label = view_all_label|default('') %}
63
+ {% set _view_all_expanded_label = view_all_expanded_label|default('') %}
64
+ {% set _items = items|default([]) %}
65
+ {% set _footer = footer|default({}) %}
66
+ {% set _visible_items = visible_items|default(8) %}
67
+ {% set _disable_hover = disable_hover|default(false) %}
68
+ {% set _disable_overlay = disable_overlay|default(false) %}
69
+ {% set _sr_gallery_label = sr_gallery_label|default('') %}
70
+ {% set _sr_video_label = sr_video_label|default('') %}
71
+ {% set _expandable = expandable ?? true %}
72
+ {% set _selected_item_id = selected_item_id|default(0) %}
73
+ {% set _extra_attributes = 'data-ecl-auto-init="Gallery"' %}
74
+ {% set _overlay_class = '' %}
75
+ {% set _overlay_attrs = [] %}
76
+ {% set _full_width = full_width|default(false) %}
77
+ {% set _sr_video_player = sr_video_player|default('') %}
78
+
79
+ {# Internal logic - Process properties #}
80
+
81
+ {% if extra_classes is defined and extra_classes is not empty %}
82
+ {% set _css_class = _css_class ~ ' ' ~ extra_classes %}
83
+ {% endif %}
84
+
85
+ {% if _grid %}
86
+ {% set _css_class = _css_class ~ ' ecl-gallery--grid' %}
87
+
88
+ {% if _grid_template is not empty %}
89
+ {% set _css_class = _css_class ~ ' ecl-gallery--template-' ~ _grid_template %}
90
+ {% endif %}
91
+
92
+ {% if _column is not empty and _grid_template == 0 %}
93
+ {% set _css_class = _css_class ~ ' ecl-gallery--col-' ~ _column %}
94
+ {% endif %}
95
+
96
+ {% if _ratio is not empty %}
97
+ {% set _css_class = _css_class ~ ' ecl-gallery--ratio-' ~ _ratio %}
98
+ {% endif %}
99
+ {% endif %}
100
+
101
+ {% if _full_width %}
102
+ {% set _css_class = _css_class ~ ' ecl-gallery--full-width' %}
103
+ {% endif %}
104
+
105
+ {% if _disable_hover %}
106
+ {% set _css_class = _css_class ~ ' ecl-gallery--no-hover' %}
107
+ {% endif %}
108
+
109
+ {% if not _expandable %}
110
+ {% set _extra_attributes = _extra_attributes ~ ' data-ecl-gallery-not-expandable' %}
111
+ {% else %}
112
+ {% set _extra_attributes = _extra_attributes ~ ' data-ecl-gallery-visible-items="' ~ _visible_items ~ '"' %}
113
+ {% endif %}
114
+
115
+ {% if _disable_overlay %}
116
+ {% set _extra_attributes = _extra_attributes ~ ' data-ecl-gallery-no-overlay' %}
117
+ {% set _css_class = _css_class ~ ' ecl-gallery--no-overlay' %}
118
+ {% endif %}
119
+
120
+ {% if extra_attributes is defined and extra_attributes is not empty and extra_attributes is iterable %}
121
+ {% for attr in extra_attributes %}
122
+ {% if attr.value is defined %}
123
+ {% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name|e('html_attr') ~ '="' ~ attr.value|e('html_attr') ~ '"' %}
124
+ {% else %}
125
+ {% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name|e('html_attr') %}
126
+ {% endif %}
127
+ {% endfor %}
128
+ {% endif %}
129
+
130
+ {# Print the result #}
131
+
132
+ <section
133
+ class="{{ _css_class }}"
134
+ {% if _sr_gallery_label is not empty and not _disable_overlay %}
135
+ aria-label="{{ _sr_gallery_label }}"
136
+ {% endif %}
137
+ {{ _extra_attributes|raw }}
138
+ data-ecl-gallery
139
+ >
140
+ <ul class="ecl-gallery__list">
141
+ {% for _key, _item in _items %}
142
+ {% set _item_class = '' %}
143
+ {% set _item_attrs = [] %}
144
+ {% if _item.extra_classes is defined and _item.extra_classes is not empty %}
145
+ {% set _item_class = _item.extra_classes %}
146
+ {% endif %}
147
+ {% if _item.extra_attributes is defined and _item.extra_attributes is not empty %}
148
+ {% set _item_attrs = _item.extra_attributes %}
149
+ {% endif %}
150
+ {% include '@ecl/gallery/gallery-item.html.twig' with {
151
+ id: "ecl-gallery-item-" ~ _id ~ '-' ~ _key,
152
+ item: _item,
153
+ sr_video_label: _sr_video_label,
154
+ sr_video_player: _sr_video_player,
155
+ disable_overlay: _disable_overlay,
156
+ picture_zoom: _picture_zoom,
157
+ extra_attributes: _item_attrs,
158
+ extra_classes: _item_class,
159
+ } only %}
160
+ {% endfor %}
161
+ </ul>
162
+ <div class="ecl-gallery__footer">
163
+ {%- if _expandable -%}
164
+ <div class="ecl-gallery__info">
165
+ <div class="ecl-gallery__info-total" id="{{ _id }}-info">
166
+ <strong data-ecl-gallery-count>0</strong> {{- _counter_label -}}
167
+ </div>
168
+ {% include '@ecl/button/button.html.twig' with {
169
+ label: _view_all_label,
170
+ type: 'submit',
171
+ variant: 'tertiary',
172
+ extra_attributes: [
173
+ { name: 'data-ecl-gallery-all' },
174
+ { name: 'data-ecl-gallery-collapsed-label', value: _view_all_label },
175
+ { name: 'data-ecl-gallery-expanded-label', value: _view_all_expanded_label },
176
+ { name: 'aria-describedby', value: _id ~ '-info' },
177
+ ],
178
+ extra_classes: 'ecl-gallery__view-all',
179
+ } only %}
180
+ </div>
181
+ {%- endif -%}
182
+ {% if _footer.link is defined and _footer.link is not empty %}
183
+ <hr class="ecl-gallery__footer-divider" />
184
+ <div class="ecl-gallery__footer-link">
185
+ {% include '@ecl/link/link.html.twig' with _footer|merge({
186
+ link: _footer.link|merge({
187
+ type: 'standalone',
188
+ icon_position: 'after',
189
+ }),
190
+ icon: _footer.icon
191
+ }) only %}
192
+ </div>
193
+ {% endif %}
194
+ </div>
195
+ {% set _selected_item = {} %}
196
+ {% if _items[_selected_item_id] is defined and _items[_selected_item_id] is not empty %}
197
+ {% set _selected_item = _items[_selected_item_id] %}
198
+ {% endif %}
199
+ {% if overlay.extra_classes is defined and overlay.extra_classes is not empty %}
200
+ {% set _overlay_class = overlay.extra_classes %}
201
+ {% endif %}
202
+ {% if overlay.extra_attributes is defined and overlay.extra_attributes is not empty %}
203
+ {% set _overlay_attrs = overlay.extra_attributes %}
204
+ {% endif %}
205
+ {% include '@ecl/gallery/gallery-overlay.html.twig' with {
206
+ overlay: _overlay,
207
+ extra_attributes: _overlay_attrs,
208
+ extra_classes: _overlay_class,
209
+ item: _selected_item,
210
+ } only %}
211
+ </section>
212
+
213
+ {% endapply %}