forked from Shopify/dawn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollection-list.liquid
227 lines (215 loc) · 11.2 KB
/
collection-list.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
{{ 'section-collection-list.css' | asset_url | stylesheet_tag }}
<link rel="stylesheet" href="{{ 'component-slider.css' | asset_url }}" media="print" onload="this.media='all'">
<noscript>{{ 'component-slider.css' | asset_url | stylesheet_tag }}</noscript>
{{ 'component-card.css' | asset_url | stylesheet_tag }}
<div class="collection-list-wrapper page-width{% if section.settings.swipe_on_mobile == true %} page-width-desktop{% endif %}{% if section.settings.title == blank %} no-heading{% endif %}{% if section.settings.show_view_all == false or section.blocks.size > collections.size %} no-mobile-link{% endif %}">
<div class="title-wrapper-with-link{% if section.settings.swipe_on_mobile == true %} title-wrapper--self-padded-tablet-down{% else %} title-wrapper--self-padded-mobile{% endif %}{% if section.settings.title == blank %} title-wrapper-with-link--no-heading{% endif %}">
<h2 class="collection-list-title">{{ section.settings.title | escape }}</h2>
{%- if section.settings.show_view_all and section.settings.swipe_on_mobile -%}
<a href="{{ routes.collections_url }}" class="link underlined-link large-up-hide">{{ 'sections.collection_list.view_all' | t }}</a>
{%- endif -%}
</div>
<slider-component class="slider-mobile-gutter">
<ul class="collection-list grid grid--1-col{% if section.blocks.size < 5 %} grid--{{ section.blocks.size }}-col-tablet{% else %} grid--3-col-tablet{% endif %}{% if section.settings.swipe_on_mobile %} slider slider--tablet grid--peek{% endif %} collection-list--{{ section.blocks.size }}-items{% if section.settings.show_view_all == false or section.blocks.size > collections.size %} negative-margin--small{% endif %}"
id="Slider-{{ section.id }}"
role="list"
>
{%- assign columns = section.blocks.size -%}
{%- if columns > 3 -%}
{%- assign columns = 3 -%}
{%- endif -%}
{%- for block in section.blocks -%}
<li class="collection-list__item grid__item{% if section.settings.swipe_on_mobile %} slider__slide{% endif %}" {{ block.shopify_attributes }}>
<a{% if block.settings.collection != blank and block.settings.collection.all_products_count > 0 %} href="{{ block.settings.collection.url }}"{% endif %}
class="card animate-arrow link{% if block.settings.collection.featured_image != blank %} card--media{% else %}{% if section.settings.image_ratio != 'adapt' %} card--stretch{% endif %}{% endif %}{% unless section.settings.image_padding %} card--light-border{% endunless %}"
>
<div class="card--stretch card-colored color-{{ section.settings.color_scheme }}">
{%- if block.settings.collection.featured_image != blank -%}
<div{% if section.settings.image_padding %} class="card__media-spacer"{% endif %}>
{% if section.settings.image_padding %}<div class="overlay-card"></div>{% endif %}
<div class="media{% if section.blocks.size > 1 %} media--{{ section.settings.image_ratio }}{% endif %} media--hover-effect overflow-hidden"
{% if section.settings.image_ratio == 'adapt' and section.blocks.size > 1 %}style="padding-bottom: {{ 1 | divided_by: block.settings.collection.featured_image.aspect_ratio | times: 100 }}%;"{% endif %}>
<img
srcset="{%- if block.settings.collection.featured_image.width >= 165 -%}{{ block.settings.collection.featured_image | img_url: '165x' }} 165w,{%- endif -%}
{%- if block.settings.collection.featured_image.width >= 330 -%}{{ block.settings.collection.featured_image | img_url: '330x' }} 330w,{%- endif -%}
{%- if block.settings.collection.featured_image.width >= 535 -%}{{ block.settings.collection.featured_image | img_url: '535x' }} 535w,{%- endif -%}
{%- if block.settings.collection.featured_image.width >= 750 -%}{{ block.settings.collection.featured_image | img_url: '750x' }} 750w,{%- endif -%}
{%- if block.settings.collection.featured_image.width >= 1000 -%}{{ block.settings.collection.featured_image | img_url: '1000x' }} 1000w,{%- endif -%}
{%- if block.settings.collection.featured_image.width >= 1500 -%}{{ block.settings.collection.featured_image | img_url: '1500x' }} 1500w,{%- endif -%}
{%- if block.settings.collection.featured_image.width >= 3000 -%}{{ block.settings.collection.featured_image | img_url: '3000x' }} 3000w{%- endif -%}"
src="{{ block.settings.collection.featured_image | img_url: '1500x' }}"
sizes="
(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: columns }}px,
(min-width: 750px) {% if section.blocks.size > 1 %}calc((100vw - 10rem) / 2){% else %}calc(100vw - 10rem){% endif %},
calc(100vw - 3rem)"
alt="{{ block.settings.collection.title | escape }}"
height="{{ block.settings.collection.featured_image.height }}"
width="{{ block.settings.collection.featured_image.width }}"
loading="lazy"
class="motion-reduce"
>
</div>
</div>
<div class="card__text card__text-spacing card-colored card__text-hover{% if section.settings.image_padding == false %} color-{{ section.settings.color_scheme }}{% endif %}">
{% unless section.settings.image_padding %}<div class="overlay-card"></div>{% endunless %}
<h3>
{%- if block.settings.collection.title != blank -%}
{{- block.settings.collection.title | escape -}}<span class="icon-wrap"> {% render 'icon-arrow' %}</span>
{%- else -%}
{{ 'onboarding.collection_title' | t }}
{%- endif -%}
</h3>
</div>
{%- else -%}
<div class="overlay-card"></div>
<div class="card__text-spacing card__text-hover">
<h3 class="h1">
{%- if block.settings.collection.title != blank -%}
{{- block.settings.collection.title | escape -}}{%- if block.settings.collection.description == blank -%}<span class="icon-wrap"> {% render 'icon-arrow' %}</span>{% endif %}
{%- else -%}
{{ 'onboarding.collection_title' | t }}
{%- endif -%}
</h3>
{%- if block.settings.collection.description != blank -%}
<p class="card__caption">
{{- block.settings.collection.description | strip_html | truncatewords: 12 -}}<span class="icon-wrap"> {% render 'icon-arrow' %}</span>
</p>
{%- endif -%}
</div>
{%- endif -%}
</div>
</a>
</li>
{%- endfor -%}
</ul>
{%- if section.settings.swipe_on_mobile -%}
<div class="slider-buttons no-js-hidden{% if section.blocks.size < 5 %} medium-hide{% endif %}{% if section.blocks.size < 2 %} small-hide{% endif %}">
<div class="slider-counter caption">
<span class="slider-counter--current">1</span>
<span aria-hidden="true"> / </span>
<span class="visually-hidden">{{ 'accessibility.of' | t }}</span>
<span class="slider-counter--total">{{ section.blocks.size }}</span>
</div>
<button type="button" class="slider-button slider-button--prev" name="previous" aria-label="{{ 'accessibility.previous_slide' | t }}">{% render 'icon-caret' %}</button>
<button type="button" class="slider-button slider-button--next" name="next" aria-label="{{ 'accessibility.next_slide' | t }}">{% render 'icon-caret' %}</button>
</div>
{%- endif -%}
</slider-component>
{%- if section.settings.show_view_all and section.blocks.size < collections.size -%}
<div class="center{% if section.settings.swipe_on_mobile %} small-hide medium-hide{% endif %}">
<a href="{{ routes.collections_url }}" class="button">{{ 'sections.collection_list.view_all' | t }}</a>
</div>
{%- endif -%}
</div>
{% schema %}
{
"name": "t:sections.collection-list.name",
"tag": "section",
"class": "spaced-section collection-list-section",
"max_blocks": 12,
"settings": [
{
"type": "text",
"id": "title",
"default": "Collections",
"label": "t:sections.collection-list.settings.title.label"
},
{
"type": "select",
"id": "image_ratio",
"options": [
{
"value": "adapt",
"label": "t:sections.collection-list.settings.image_ratio.options__1.label"
},
{
"value": "portrait",
"label": "t:sections.collection-list.settings.image_ratio.options__2.label"
},
{
"value": "square",
"label": "t:sections.collection-list.settings.image_ratio.options__3.label"
}
],
"default": "square",
"label": "t:sections.collection-list.settings.image_ratio.label",
"info": "t:sections.collection-list.settings.image_ratio.info"
},
{
"type": "select",
"id": "color_scheme",
"options": [
{
"value": "accent-1",
"label": "t:sections.collection-list.settings.color_scheme.options__1.label"
},
{
"value": "accent-2",
"label": "t:sections.collection-list.settings.color_scheme.options__2.label"
},
{
"value": "background-1",
"label": "t:sections.collection-list.settings.color_scheme.options__3.label"
},
{
"value": "background-2",
"label": "t:sections.collection-list.settings.color_scheme.options__4.label"
},
{
"value": "inverse",
"label": "t:sections.collection-list.settings.color_scheme.options__5.label"
}
],
"default": "background-1",
"label": "t:sections.collection-list.settings.color_scheme.label"
},
{
"type": "checkbox",
"id": "swipe_on_mobile",
"default": false,
"label": "t:sections.collection-list.settings.swipe_on_mobile.label"
},
{
"type": "checkbox",
"id": "image_padding",
"default": false,
"label": "t:sections.collection-list.settings.image_padding.label"
},
{
"type": "checkbox",
"id": "show_view_all",
"default": false,
"label": "t:sections.collection-list.settings.show_view_all.label"
}
],
"blocks": [
{
"type": "featured_collection",
"name": "t:sections.collection-list.blocks.featured_collection.name",
"settings": [
{
"type": "collection",
"id": "collection",
"label": "t:sections.collection-list.blocks.featured_collection.settings.collection.label"
}
]
}
],
"presets": [
{
"name": "t:sections.collection-list.presets.name",
"blocks": [
{
"type": "featured_collection"
},
{
"type": "featured_collection"
},
{
"type": "featured_collection"
}
]
}
]
}
{% endschema %}