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

[Image with Text] Add ambient movement to image #2385

Merged
merged 9 commits into from
Mar 20, 2023
24 changes: 12 additions & 12 deletions locales/en.default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,18 @@
},
"sections": {
"all": {
"animation": {
"label": "Animations",
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should use the key label here as this is used as a header content on the schema. We usually keep a similar structure to what's used in our schema to make mapping easier. However, I see that just below we're using a section_padding_heading which also doesn't map to anything, so, not a big deal right now 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem! We're waiting on translations anyway, so doesn't hurt to make it consistent now. Updated in e315fc6.

"image_behavior": {
"options__1": {
"label": "None"
},
"options__2": {
"label": "Ambient movement"
},
"label": "Image behavior"
}
},
"padding": {
"section_padding_heading": "Section padding",
"padding_top": "Top padding",
Expand Down Expand Up @@ -1170,18 +1182,6 @@
"color_scheme": {
"info": "Visible when container displayed."
},
"animations": {
"content": "Animations"
},
"image_behavior": {
"options__1": {
"label": "None"
},
"options__2": {
"label": "Ambient movement"
},
"label": "Image behavior"
},
"mobile": {
"content": "Mobile Layout"
},
Expand Down
8 changes: 4 additions & 4 deletions sections/image-banner.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,23 @@
},
{
"type": "header",
"content": "t:sections.image-banner.settings.animations.content"
"content": "t:sections.all.animation.label"
},
{
"type": "select",
"id": "image_behavior",
"options": [
{
"value": "none",
"label": "t:sections.image-banner.settings.image_behavior.options__1.label"
"label": "t:sections.all.animation.image_behavior.options__1.label"
},
{
"value": "ambient",
"label": "t:sections.image-banner.settings.image_behavior.options__2.label"
"label": "t:sections.all.animation.image_behavior.options__2.label"
}
],
"default": "none",
"label": "t:sections.image-banner.settings.image_behavior.label"
"label": "t:sections.all.animation.image_behavior.label"
},
{
"type": "header",
Expand Down
41 changes: 35 additions & 6 deletions sections/image-with-text.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,29 @@
<div class="image-with-text__grid grid grid--gapless grid--1-col grid--{% if section.settings.desktop_image_width == 'medium' %}2-col-tablet{% else %}3-col-tablet{% endif %}{% if section.settings.layout == 'text_first' %} image-with-text__grid--reverse{% endif %}">
<div class="image-with-text__media-item image-with-text__media-item--{{ section.settings.desktop_image_width }} image-with-text__media-item--{{ section.settings.desktop_content_position }} grid__item">
<div
class="image-with-text__media image-with-text__media--{{ section.settings.height }} gradient color-{{ section.settings.color_scheme }} global-media-settings {% if section.settings.image != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
class="image-with-text__media image-with-text__media--{{ section.settings.height }} gradient color-{{ section.settings.color_scheme }} global-media-settings {% if section.settings.image != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}{% if section.settings.image_behavior != 'none' %} animate--{{ section.settings.image_behavior }}{% endif %}"
{% if section.settings.height == 'adapt' and section.settings.image != blank %}
style="padding-bottom: {{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100 }}%;"
{% endif %}
>
{%- if section.settings.image != blank -%}
{%- capture sizes -%}
(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px,
(min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)
{%- endcapture -%}
{%- if section.settings.image_behavior == 'ambient' -%}
{%- assign widths = '198, 432, 642, 900, 1284, 1800' -%}
{%- capture sizes -%}
(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 1.6667 }}px,
(min-width: 750px) calc((100vw - 130px) / 1.667), calc((100vw - 50px) / 1.667)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The 1.6667 number here is admittedly a little weird. I could alternatively do calc(((100vw - 50px) / 2) * 1.2) and get the same result if we think that's easier to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is easier to read 😅 I'm switching it in my PR for collage's ambient movement

{%- endcapture -%}
{%- else -%}
{%- assign widths = '165, 360, 535, 750, 1070, 1500' -%}
{%- capture sizes -%}
(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px,
(min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)
{%- endcapture -%}
{%- endif -%}
{{
section.settings.image
| image_url: width: 1500
| image_tag: loading: 'lazy', sizes: sizes, widths: '165, 360, 535, 750, 1070, 1500'
| image_tag: loading: 'lazy', sizes: sizes, widths: widths
}}
{%- else -%}
{{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
Expand Down Expand Up @@ -243,6 +252,26 @@
"default": "background-1",
"label": "t:sections.all.colors.label"
},
{
"type": "header",
"content": "t:sections.all.animation.label"
},
{
"type": "select",
"id": "image_behavior",
"options": [
{
"value": "none",
"label": "t:sections.all.animation.image_behavior.options__1.label"
},
{
"value": "ambient",
"label": "t:sections.all.animation.image_behavior.options__2.label"
}
],
"default": "none",
"label": "t:sections.all.animation.image_behavior.label"
},
{
"type": "header",
"content": "Mobile layout"
Expand Down