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

fix: Rework logic for grid ordering in hero component #1799

Merged
merged 2 commits into from
Mar 27, 2020
Merged
Changes from 1 commit
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
25 changes: 19 additions & 6 deletions packages/components/bolt-hero/hero.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@
{% set _imagePaddingTop = imageValign == "top" ? "none" : "large" %}
{% set _imagePaddingBottom = this.data["image_valign"] == "bottom" ? "none" : "large" %}

{% set _isImageFirstOnMobile = (imageValign != 'bottom') or (imageValign == 'top') %}
{# Image order on desktop is always determined by the reverseOrder prop; order on mobile is always set automatically #}
{% set _isImageFirstOnDesktop = reverseOrder == true %}
{% set _isImageLastOnMobile = (imageValign != 'top') or (imageValign == 'bottom') %}
{% set _isImageFirstOnMobile = imageValign != 'bottom' %}

{#
Image and content will be printed in the order they should appear on mobile. For desktop, leave it the same unless:
- An image is present, in which case check to see if mobile and desktop ordering should be different
- No image is present, in which case simply honor the reverseOrder prop.
#}
{% set _reverseGrid = image ? (_isImageFirstOnDesktop != _isImageFirstOnMobile) : reverseOrder %}

{% if image %}
{% set renderedImage %}
Expand All @@ -32,7 +39,7 @@
u-bolt-width-6/12@{{ _largeBreakpoint }}
u-bolt-padding-{{_isImageFirstOnDesktop ? 'right' : 'left'}}-large@{{_largeBreakpoint}}
{{ _isImageFirstOnMobile and imageValign != 'top' ? 'u-bolt-padding-top-large' : '' }}
{{ _isImageLastOnMobile and imageValign != 'bottom' and not _isImageFirstOnMobile ? 'u-bolt-padding-bottom-large' : '' }}
{{ _isImageFirstOnMobile == false and imageValign != 'bottom' ? 'u-bolt-padding-bottom-large' : '' }}
u-bolt-padding-top-{{_imagePaddingTop}}@{{_mediumBreakpoint}}
u-bolt-padding-bottom-{{_imagePaddingBottom}}@{{_mediumBreakpoint}}
">
Expand All @@ -54,11 +61,17 @@
{% endset %}
{% endif %}

{#
Image and content are printed in the order they should appear on mobile. For desktop, leave it the same unless:
remydenton marked this conversation as resolved.
Show resolved Hide resolved
- An image is present, in which case check to see if mobile and desktop ordering should be different.
- No image is present, in which case simply honor the reverseOrder prop.
#}
{% set _reverseGrid = image ? (_isImageFirstOnDesktop != _isImageFirstOnMobile) : reverseOrder %}

{% set content %}
{% grid "o-bolt-grid--flex o-bolt-grid--middle o-bolt-grid--medium #{(reverseOrder == false and imageValign != 'bottom') or (reverseOrder == true and not image) ? 'o-bolt-grid--rev' : '' }" %}
{% grid "o-bolt-grid--flex o-bolt-grid--middle o-bolt-grid--medium #{_reverseGrid ? 'o-bolt-grid--rev' : '' }" %}

{% if _isImageFirstOnMobile and image %}
{% if image and _isImageFirstOnMobile %}
{{ renderedImage }}
{% endif %}

Expand All @@ -72,7 +85,7 @@
{{ content }}
{% endcell %}

{% if _isImageLastOnMobile and image and not _isImageFirstOnMobile %}
{% if image and _isImageFirstOnMobile == false %}
{{ renderedImage }}
{% endif %}

Expand Down