Skip to content

Commit

Permalink
Applied image shape and ratio to placeholder images (Shopify#2817)
Browse files Browse the repository at this point in the history
added classes and styles to get image shape and image ratio working

added styling on portrait placeholders

aligned placeholder when in potrait mode

applying code review suggestions and removed image-ratio
  • Loading branch information
lougoncharenko authored Dec 20, 2023
1 parent b9ebe2d commit 23319fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 0 additions & 1 deletion assets/component-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@
}

.card--standard:not(.card--horizontal) .placeholder-svg {
height: auto;
width: 100%;
}

Expand Down
2 changes: 2 additions & 0 deletions sections/featured-collection.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
{%- assign placeholder_image = 'product-apparel-' | append: forloop.rindex -%}
{% render 'card-product',
show_vendor: section.settings.show_vendor,
media_aspect_ratio: section.settings.image_ratio,
image_shape: section.settings.image_shape,
placeholder_image: placeholder_image
%}
</li>
Expand Down
18 changes: 14 additions & 4 deletions snippets/card-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,31 @@
</div>
</div>
{%- else -%}
{%- liquid
assign ratio = 1
if media_aspect_ratio == 'portrait'
assign ratio = 0.8
endif
-%}
<div class="card-wrapper product-card-wrapper underline-links-hover">
<div
class="
card card--{{ settings.card_style }}
{% if extend_height %} card--extend-height{% endif %}
{% if image_shape and image_shape != 'default' %} card--shape{% endif %}
{% if settings.card_style == 'card' %} color-{{ settings.card_color_scheme }} gradient{% endif %}
"
style="--ratio-percent: 100%;"
style="--ratio-percent: {{ 1 | divided_by: ratio | times: 100 }}%;"
>
<div
class="card__inner{% if settings.card_style == 'standard' %} color-{{ settings.card_color_scheme }} gradient{% endif %} ratio"
style="--ratio-percent: 100%;"
>
<div class="card__media">
<div class="media media--transparent">
<div
class="card__media {% if image_shape and image_shape != 'default' %} shape--{{ image_shape }} color-{{ settings.card_color_scheme }} gradient{% endif %}"
>
<div
class="media media--transparent"
>
{%- if placeholder_image -%}
{{ placeholder_image | placeholder_svg_tag: 'placeholder-svg' }}
{%- else -%}
Expand Down

0 comments on commit 23319fc

Please sign in to comment.