Skip to content

Commit f5e8b07

Browse files
committed
Add media sizing settings to featured product
1 parent 7bd9b03 commit f5e8b07

File tree

1 file changed

+67
-6
lines changed

1 file changed

+67
-6
lines changed

sections/featured-product.liquid

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,17 @@
2121

2222
<link rel="stylesheet" href="{{ 'component-deferred-media.css' | asset_url }}" media="print" onload="this.media='all'">
2323

24-
{%- assign product = section.settings.product -%}
24+
{%- liquid
25+
assign product = section.settings.product
26+
27+
if section.settings.media_size == 'large'
28+
assign media_width = 0.65
29+
elsif section.settings.media_size == 'medium'
30+
assign media_width = 0.55
31+
elsif section.settings.media_size == 'small'
32+
assign media_width = 0.45
33+
endif
34+
-%}
2535

2636
{%- assign first_3d_model = product.media | where: 'media_type', 'model' | first -%}
2737
{%- if first_3d_model -%}
@@ -44,7 +54,7 @@
4454

4555
<section class="color-{{ section.settings.color_scheme }} {% if section.settings.secondary_background %}background-secondary{% else %}gradient{% endif %}">
4656
<div class="page-width section-{{ section.id }}-padding{% if section.settings.secondary_background %} isolate{% endif %}">
47-
<div class="featured-product product grid grid--1-col gradient color-{{ section.settings.color_scheme }} product--{{ section.settings.media_position }}{% if section.settings.secondary_background == false %} isolate{% endif %} {% if product.media.size > 0 %}grid--2-col-tablet{% else %}product--no-media{% endif %}">
57+
<div class="featured-product product product--{{ section.settings.media_size }} grid grid--1-col gradient color-{{ section.settings.color_scheme }} product--{{ section.settings.media_position }}{% if section.settings.secondary_background == false %} isolate{% endif %} {% if product.media.size > 0 %}grid--2-col-tablet{% else %}product--no-media{% endif %}">
4858
<div class="grid__item product__media-wrapper{% if section.settings.media_position == 'right' %} medium-hide large-up-hide{% endif %}">
4959
<media-gallery
5060
id="MediaGallery-{{ section.id }}"
@@ -62,7 +72,9 @@
6272
loop: section.settings.enable_video_looping,
6373
modal_id: section.id,
6474
xr_button: false,
65-
media_width: 0.5
75+
media_width: media_width,
76+
media_fit: section.settings.media_fit,
77+
constrain_to_viewport: section.settings.constrain_to_viewport
6678
%}
6779
</div>
6880
{%- endif -%}
@@ -83,7 +95,9 @@
8395
loop: section.settings.enable_video_looping,
8496
modal_id: section.id,
8597
xr_button: false,
86-
media_width: 0.5
98+
media_width: media_width,
99+
media_fit: section.settings.media_fit,
100+
constrain_to_viewport: section.settings.constrain_to_viewport
87101
%}
88102
</div>
89103
{%- endif -%}
@@ -572,7 +586,9 @@
572586
loop: section.settings.enable_video_looping,
573587
modal_id: section.id,
574588
xr_button: false,
575-
media_width: 0.5
589+
media_width: media_width,
590+
media_fit: section.settings.media_fit,
591+
constrain_to_viewport: section.settings.constrain_to_viewport
576592
%}
577593
</div>
578594
{%- endif -%}
@@ -587,7 +603,9 @@
587603
loop: section.settings.enable_video_looping,
588604
modal_id: section.id,
589605
xr_button: false,
590-
media_width: 0.5
606+
media_width: media_width,
607+
media_fit: section.settings.media_fit,
608+
constrain_to_viewport: section.settings.constrain_to_viewport
591609
%}
592610
</div>
593611
{%- endif -%}
@@ -1561,6 +1579,49 @@
15611579
"content": "t:sections.featured-product.settings.header.content",
15621580
"info": "t:sections.featured-product.settings.header.info"
15631581
},
1582+
{
1583+
"type": "select",
1584+
"id": "media_size",
1585+
"options": [
1586+
{
1587+
"value": "small",
1588+
"label": "t:sections.main-product.settings.media_size.options__1.label"
1589+
},
1590+
{
1591+
"value": "medium",
1592+
"label": "t:sections.main-product.settings.media_size.options__2.label"
1593+
},
1594+
{
1595+
"value": "large",
1596+
"label": "t:sections.main-product.settings.media_size.options__3.label"
1597+
}
1598+
],
1599+
"default": "medium",
1600+
"label": "t:sections.main-product.settings.media_size.label",
1601+
"info": "t:sections.main-product.settings.media_size.info"
1602+
},
1603+
{
1604+
"type": "checkbox",
1605+
"id": "constrain_to_viewport",
1606+
"default": false,
1607+
"label": "t:sections.main-product.settings.constrain_to_viewport.label"
1608+
},
1609+
{
1610+
"type": "select",
1611+
"id": "media_fit",
1612+
"options": [
1613+
{
1614+
"value": "contain",
1615+
"label": "t:sections.main-product.settings.media_fit.options__1.label"
1616+
},
1617+
{
1618+
"value": "cover",
1619+
"label": "t:sections.main-product.settings.media_fit.options__2.label"
1620+
}
1621+
],
1622+
"default": "contain",
1623+
"label": "t:sections.main-product.settings.media_fit.label"
1624+
},
15641625
{
15651626
"type": "select",
15661627
"id": "media_position",

0 commit comments

Comments
 (0)