-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproducts.liquid
422 lines (396 loc) · 11.9 KB
/
products.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
{%- assign blocks = section.blocks -%}
{%- assign collection = section.settings.collection -%}
{%- if collection != blank -%}
{%- assign items = collection.items -%}
{%- assign items_type = "collection" -%}
{%- assign size = collection.items_count -%}
{%- else -%}
{%- assign items = blocks -%}
{%- assign items_type = "blocks" -%}
{%- assign product_items = "" -%}
{%- for item in items -%}
{%- if product_items == "" -%}
{%- assign product_items = item.id -%}
{%- else -%}
{%- assign product_items = product_items | append: ", " | append: item.id -%}
{%- endif -%}
{%- endfor -%}
{%- assign product_items_arr = product_items | split: ", " -%}
{%- assign size = product_items_arr | size -%}
{%- endif -%}
{%- if size > 0 -%}
{{ "products.css" | asset_url | stylesheet_tag }}
{{ "product-card.css" | asset_url | stylesheet_tag }}
{%- assign button_outline_label = section.settings.button_outline_label -%}
{%- assign button_outline_url = section.settings.button_outline_url -%}
{%- assign color_scheme = section.settings.color_scheme -%}
{%- assign image = section.settings.image -%}
{%- assign limit = 8 -%}
{%- assign padding_top = section.settings.padding_top -%}
{%- assign padding_bottom = section.settings.padding_bottom -%}
{%- assign padding_top_mobile = section.settings.padding_top_mobile -%}
{%- assign padding_bottom_mobile = section.settings.padding_bottom_mobile -%}
{%- assign show_navigation = section.settings.show_navigation -%}
{%- assign show_pagination = section.settings.show_pagination -%}
{%- assign tag = section.settings.tag -%}
{%- assign tag_image = section.settings.tag_image -%}
{%- assign timer = section.settings.timer -%}
{%- assign title = section.settings.title -%}
{%- assign carousel = false -%}
{%- if size > 1 -%}
{{ "carousel.css" | asset_url | stylesheet_tag }}
{%- assign carousel = true -%}
{% unless show_pagination %}
{%- assign limit = nil -%}
{% endunless %}
{%- endif -%}
{% comment %} CSS variables start {% endcomment %}
{%- capture variables -%}
{%- case padding_top -%}
{%- when 'small' -%}
--padding-top: 40px;
{%- when 'medium' -%}
--padding-top: 80px;
{%- when 'large' -%}
--padding-top: 112px;
{%- endcase -%}
{%- case padding_bottom -%}
{%- when 'small' -%}
--padding-bottom: 40px;
{%- when 'medium' -%}
--padding-bottom: 80px;
{%- when 'large' -%}
--padding-bottom: 112px;
{%- endcase -%}
{%- case padding_top_mobile -%}
{%- when 'small' -%}
--padding-top-mobile: 18px;
{%- when 'medium' -%}
--padding-top-mobile: 40px;
{%- when 'large' -%}
--padding-top-mobile: 60px;
{%- endcase -%}
{%- case padding_bottom_mobile -%}
{%- when 'small' -%}
--padding-bottom-mobile: 18px;
{%- when 'medium' -%}
--padding-bottom-mobile: 40px;
{%- when 'large' -%}
--padding-bottom-mobile: 60px;
{%- endcase -%}
{%- endcapture -%}
{% comment %} CSS variables end {% endcomment %}
<div
class="products__wrapper color-{{ color_scheme.id }}{% if padding_top != blank or padding_top_mobile != blank %} products__wrapper--padding-top{% endif %}{% if padding_bottom != blank or padding_bottom_mobile != blank %} products__wrapper--padding-bottom{% endif %}{% if image.url != blank %} products__wrapper--with-background{%- endif -%}"
style="{{- variables | escape -}}"
>
<div class="products__container container">
{%- if title != blank or tag != blank or tag_image.url != blank -%}
<div class="products__top">
{%- if tag_image.url != blank -%}
<div class="products__tag-image-wrapper">
{%- render 'image',
image: tag_image,
loading: 'lazy',
class: 'products__tag-image',
custom_width: '100',
custom_size: '100px'
-%}
</div>
{%- endif -%}
{%- if tag != blank -%}
<strong class="products__tag tagline">{{- tag -}}</strong>
{%- endif -%}
{%- if title != blank -%}
<h2 class="products__title h4">{{- title -}}</h2>
{%- endif -%}
</div>
{%- endif -%}
<div class="products__list{% if carousel %} carousel carousel__pause{%- endif -%}"{% if carousel %} aria-role="Gallery"{% endif %}>
{%- if carousel -%}
<input class="carousel__timer" type="hidden" name="hidden" value="{{- timer -}}" aria-hidden="true">
<div class="carousel__wrapper">
{%- endif -%}
{%- for item in items limit: limit -%}
{% case items_type %}
{% when "blocks" %}
{% assign product = item.settings.product %}
{% when "collection" %}
{% assign product = item %}
{% endcase %}
{%- if carousel -%}
<div class="carousel__item">
<div class="carousel__inner">
{%- endif -%}
{%- render 'product-card',
product: product,
settings: settings
-%}
{%- if carousel -%}
</div>
</div>
{%- endif -%}
{%- endfor -%}
{%- if carousel -%}
</div>
{%- if show_navigation -%}
<div class="carousel__navigation hidden" aria-role="Carousel navigation">
<span class="carousel__btn prev" aria-label="Prev slide">
Previous slide
{%- render 'icon-arrow-right-full' -%}
</span>
<span class="carousel__btn next" aria-label="Next slide">
Next slide
{%- render 'icon-arrow-right-full' -%}
</span>
</div>
{%- endif -%}
{%- if show_pagination -%}
<div class="carousel__pagination hidden" aria-role="Carousel navigation">
{%- for item in items limit: limit -%}
{%- assign first = forloop.first -%}
{%- assign index = forloop.index -%}
<span class="carousel__dot{% if first %} active{%- endif -%}" data-index="{{- index -}}" aria-label="Jump to slide {{ index }}">
Go to slide {{ index }}
</span>
{%- endfor -%}
</div>
{%- endif -%}
{%- endif -%}
</div>
{%- if button_outline_label != blank and button_outline_url != blank -%}
<div class="products__buttons">
<a href="{{ button_outline_url }}" class="products__button button button--outlined button--large">
{{- button_outline_label -}}
</a>
</div>
{%- endif -%}
</div>
{%- if image.url != blank -%}
<div class="products__background-wrapper">
{%- render 'image',
image: image,
loading: 'lazy',
class: 'products__background',
size: 'xxl'
-%}
</div>
{%- endif -%}
</div>
{%- endif -%}
{% schema %}
{
"name": "Products",
"description": "Display individual products or items from a collection in a grid or sliding carousel",
"tag": "section",
"class": "products",
"settings": [
{
"type": "header",
"content": "General settings"
},
{
"type": "color_scheme",
"id": "color_scheme",
"label": "Color scheme",
"default": "set-1"
},
{
"type": "text",
"id": "tag",
"label": "Tagline",
"default": "This week"
},
{
"type": "image_picker",
"id": "tag_image",
"label": "Tagline image (optional)",
"info": "Shown above the tagline text"
},
{
"type": "text",
"id": "title",
"label": "Title",
"default": "Popular products"
},
{
"type": "image_picker",
"id": "image",
"label": "Background image"
},
{
"type": "header",
"content": "Collection (optional)"
},
{
"type": "paragraph",
"content": "When you select a collection, any product blocks will be ignored"
},
{
"type": "collection",
"id": "collection",
"label": "Collection"
},
{
"type": "header",
"content": "Buttons settings"
},
{
"type": "text",
"id": "button_outline_label",
"label": "Button label",
"default": "See all products",
"info": "Leave blank to hide the button"
},
{
"type": "url",
"id": "button_outline_url",
"label": "Button link",
"default": "boqable://products"
},
{
"type": "header",
"content": "Carousel settings"
},
{
"type": "checkbox",
"id": "show_navigation",
"default": true,
"label": "Show navigation buttons"
},
{
"type": "checkbox",
"id": "show_pagination",
"default": true,
"label": "Show page bullets"
},
{
"type": "number",
"id": "timer",
"label": "Rotation time",
"min": 0,
"max": 100,
"default": 5,
"info": "In seconds. Set to 0 to disable auto rotation"
},
{
"type": "header",
"content": "Desktop settings"
},
{
"type": "select",
"id": "padding_top",
"label": "Padding top",
"options": [
{
"value": "none",
"label": "None"
},
{
"value": "small",
"label": "Small"
},
{
"value": "medium",
"label": "Medium"
},
{
"value": "large",
"label": "Large"
}
],
"default": "large"
},
{
"type": "select",
"id": "padding_bottom",
"label": "Padding bottom",
"options": [
{
"value": "none",
"label": "None"
},
{
"value": "small",
"label": "Small"
},
{
"value": "medium",
"label": "Medium"
},
{
"value": "large",
"label": "Large"
}
],
"default": "large"
},
{
"type": "header",
"content": "Mobile settings"
},
{
"type": "select",
"id": "padding_top_mobile",
"label": "Padding top",
"options": [
{
"value": "none",
"label": "None"
},
{
"value": "small",
"label": "Small"
},
{
"value": "medium",
"label": "Medium"
},
{
"value": "large",
"label": "Large"
}
],
"default": "medium"
},
{
"type": "select",
"id": "padding_bottom_mobile",
"label": "Padding bottom",
"options": [
{
"value": "none",
"label": "None"
},
{
"value": "small",
"label": "Small"
},
{
"value": "medium",
"label": "Medium"
},
{
"value": "large",
"label": "Large"
}
],
"default": "medium"
}
],
"max_blocks": 8,
"blocks": [
{
"type": "product",
"name": "Product",
"settings": [
{
"type": "product",
"id": "product",
"label": "Product"
}
]
}
]
}
{% endschema %}