Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply image shapes to placeholders in featured collection #2817

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +113 to 114
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image_shape: section.settings.image_shape,
placeholder_image: placeholder_image
image_shape: section.settings.image_shape,
media_aspect_ratio: section.settings.image_ratio,
placeholder_image: placeholder_image

If you choose to go with the second option I mentioned then add the media_aspect_ratio: section.settings.image_ratio, here and remove height: auto; from component-card.css file on line 303.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I like this option! It looks way better and reflects an actual image! Thank you!

%}
</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
Comment on lines +330 to +332
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if media_aspect_ratio == 'portrait'
assign ratio = 0.8
endif

If you decide to go without the placeholder aspect ratio I think we can remove this chunk of code because you don't pass the media_aspect_ratio parameter to the snippet. But I don't feel this is right because the main purpose of the placeholders is to reflect a real picture.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep this in because I am going with your second suggestion :D

-%}
<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