forked from Shopify/dawn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main-list-collections.liquid
175 lines (168 loc) · 7.46 KB
/
main-list-collections.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
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'section-collection-list.css' | asset_url | stylesheet_tag }}
<div class="page-width">
<h1 class="title title--primary">{{ section.settings.title | escape }}</h1>
{%- liquid
case section.settings.sort
when 'products_high' or 'products_low'
assign collections = collections | sort: 'all_products_count'
when 'date' or 'date_reversed'
assign collections = collections | sort: 'published_at'
endcase
if section.settings.sort == 'products_high' or section.settings.sort == 'date_reversed' or section.settings.sort == 'alphabetical_reversed'
assign collections = collections | reverse
endif
-%}
<ul class="collection-list grid grid--1-col grid--3-col-tablet" role="list">
{%- for collection in collections -%}
<li class="collection-list__item grid__item">
<a{% if collection.all_products_count > 0 %} href="{{ collection.url }}"{% endif %}
class="card animate-arrow{% if 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 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 media--{{ section.settings.image_ratio }} media--hover-effect overflow-hidden"
{% if section.settings.image_ratio == 'adapt' %}style="padding-bottom: {{ 1 | divided_by: collection.featured_image.aspect_ratio | times: 100 }}%;"{% endif %}>
<img
srcset="{%- if collection.featured_image.width >= 165 -%}{{ collection.featured_image | img_url: '165x' }} 165w,{%- endif -%}
{%- if collection.featured_image.width >= 360 -%}{{ collection.featured_image | img_url: '360x' }} 360w,{%- endif -%}
{%- if collection.featured_image.width >= 535 -%}{{ collection.featured_image | img_url: '535x' }} 535w,{%- endif -%}
{%- if collection.featured_image.width >= 750 -%}{{ collection.featured_image | img_url: '750x' }} 750w,{%- endif -%}
{%- if collection.featured_image.width >= 1000 -%}{{ collection.featured_image | img_url: '1000x' }} 1000w,{%- endif -%}
{%- if collection.featured_image.width >= 1500 -%}{{ collection.featured_image | img_url: '1500x' }} 1500w,{%- endif -%}
{{ collection.featured_image | img_url: 'master' }} {{ collection.featured_image.width }}w"
src="{{ collection.featured_image | img_url: '1500x' }}"
sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 3 }}px, (min-width: 750px) calc((100vw - 130px) / 3), calc(100vw - 30px)"
alt="{{ collection.title | escape }}"
height="{{ collection.featured_image.height }}"
width="{{ collection.featured_image.width }}"
loading="lazy"
>
</div>
</div>
<div class="card__text card__text-spacing card__text-hover">
{% unless section.settings.image_padding %}<div class="overlay-card"></div>{% endunless %}
<h2 class="h3">{{- collection.title -}}<span class="icon-wrap"> {% render 'icon-arrow' %}</span></h2>
</div>
{%- else -%}
<div class="overlay-card"></div>
<div class="card__text-spacing card__text-hover">
<h2 class="h1">
{{- collection.title -}}{%- if collection.description == blank -%}<span class="icon-wrap"> {% render 'icon-arrow' %}</span>{% endif %}
</h2>
{%- if collection.description != blank -%}
<p>
{{- collection.description | strip_html | truncatewords: 12 -}}<span class="icon-wrap"> {% render 'icon-arrow' %}</span>
</p>
{%- endif -%}
</div>
{%- endif -%}
</div>
</a>
</li>
{%- endfor -%}
</ul>
</div>
{% schema %}
{
"name": "t:sections.main-list-collections.name",
"class": "spaced-section",
"settings": [
{
"type": "text",
"id": "title",
"label": "t:sections.main-list-collections.settings.title.label",
"default": "Collections"
},
{
"type": "select",
"id": "sort",
"options": [
{
"value": "alphabetical",
"label": "t:sections.main-list-collections.settings.sort.options__1.label"
},
{
"value": "alphabetical_reversed",
"label": "t:sections.main-list-collections.settings.sort.options__2.label"
},
{
"value": "date_reversed",
"label": "t:sections.main-list-collections.settings.sort.options__3.label"
},
{
"value": "date",
"label": "t:sections.main-list-collections.settings.sort.options__4.label"
},
{
"value": "products_high",
"label": "t:sections.main-list-collections.settings.sort.options__5.label"
},
{
"value": "products_low",
"label": "t:sections.main-list-collections.settings.sort.options__6.label"
}
],
"default": "alphabetical",
"label": "t:sections.main-list-collections.settings.sort.label"
},
{
"type": "select",
"id": "image_ratio",
"options": [
{
"value": "adapt",
"label": "t:sections.main-list-collections.settings.image_ratio.options__1.label"
},
{
"value": "portrait",
"label": "t:sections.main-list-collections.settings.image_ratio.options__2.label"
},
{
"value": "square",
"label": "t:sections.main-list-collections.settings.image_ratio.options__3.label"
}
],
"default": "adapt",
"label": "t:sections.main-list-collections.settings.image_ratio.label",
"info": "t:sections.main-list-collections.settings.image_ratio.info"
},
{
"type": "select",
"id": "color_scheme",
"options": [
{
"value": "accent-1",
"label": "t:sections.main-list-collections.settings.color_scheme.options__1.label"
},
{
"value": "accent-2",
"label": "t:sections.main-list-collections.settings.color_scheme.options__2.label"
},
{
"value": "background-1",
"label": "t:sections.main-list-collections.settings.color_scheme.options__3.label"
},
{
"value": "background-2",
"label": "t:sections.main-list-collections.settings.color_scheme.options__4.label"
},
{
"value": "inverse",
"label": "t:sections.main-list-collections.settings.color_scheme.options__5.label"
}
],
"default": "background-1",
"label": "t:sections.main-list-collections.settings.color_scheme.label"
},
{
"type": "checkbox",
"id": "image_padding",
"default": false,
"label": "t:sections.main-list-collections.settings.image_padding.label"
}
]
}
{% endschema %}