Skip to content

Commit

Permalink
Move slideshow control buttons when set to autorotate (Shopify#1523)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoboludo authored Mar 29, 2022
1 parent f25c9e0 commit b3c1a63
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
10 changes: 8 additions & 2 deletions assets/component-slideshow.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
slideshow-component {
position: relative;
display: block;
display: flex;
flex-direction: column;
}

@media screen and (max-width: 989px) {
Expand Down Expand Up @@ -108,8 +109,13 @@ slideshow-component .slideshow.banner {
border: 0.1rem solid rgba(var(--color-foreground), 0.08);
}

.slideshow__controls--top {
order: 2;
z-index: 1;
}

@media screen and (max-width: 749px) {
slideshow-component.page-width .slideshow.banner--mobile-bottom + .slideshow__controls {
.slideshow__controls--border-radius-mobile {
border-bottom-right-radius: var(--text-boxes-radius);
border-bottom-left-radius: var(--text-boxes-radius);
}
Expand Down
47 changes: 43 additions & 4 deletions sections/slideshow.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,47 @@
{%- endif -%}

<slideshow-component class="slider-mobile-gutter{% if section.settings.layout == 'grid' %} page-width{% endif %}{% if section.settings.show_text_below %} mobile-text-below{% endif %}" role="region" aria-roledescription="{{ 'sections.slideshow.carousel' | t }}" aria-label="{{ section.settings.accessibility_info | escape }}">
{%- if section.settings.auto_rotate and section.blocks.size > 1 -%}
<div class="slideshow__controls slideshow__controls--top slider-buttons no-js-hidden{% if section.settings.show_text_below %} slideshow__controls--border-radius-mobile{% endif %}">
<button type="button" class="slider-button slider-button--prev" name="previous" aria-label="{{ 'sections.slideshow.previous_slideshow' | t }}" aria-controls="Slider-{{ section.id }}">{% render 'icon-caret' %}</button>
<div class="slider-counter slider-counter--{{ section.settings.slider_visual }}{% if section.settings.slider_visual == 'counter' or section.settings.slider_visual == 'numbers' %} caption{% endif %}">
{%- if section.settings.slider_visual == 'counter' -%}
<span class="slider-counter--current">1</span>
<span aria-hidden="true"> / </span>
<span class="visually-hidden">{{ 'general.slider.of' | t }}</span>
<span class="slider-counter--total">{{ section.blocks.size }}</span>
{%- else-%}
<div class="slideshow__control-wrapper">
{%- for block in section.blocks -%}
<button class="slider-counter__link slider-counter__link--{{ section.settings.slider_visual }} link" aria-label="{{ 'sections.slideshow.load_slide' | t }} {{ forloop.index }} {{ 'general.slider.of' | t }} {{ forloop.length }}" aria-controls="Slider-{{ section.id }}">
{%- if section.settings.slider_visual == 'numbers' -%}{{ forloop.index }}{% else %}<span class="dot"></span>{%- endif -%}
</button>
{%- endfor -%}
</div>
{%- endif -%}
</div>
<button type="button" class="slider-button slider-button--next" name="next" aria-label="{{ 'sections.slideshow.next_slideshow' | t }}" aria-controls="Slider-{{ section.id }}">{% render 'icon-caret' %}</button>

{%- if section.settings.auto_rotate -%}
<button type="button" class="slideshow__autoplay slider-button no-js-hidden{% if section.settings.auto_rotate == false %} slideshow__autoplay--paused{% endif %}" aria-label="{{ 'sections.slideshow.pause_slideshow' | t }}">
{%- render 'icon-pause' -%}
{%- render 'icon-play' -%}
</button>
{%- endif -%}
</div>
<noscript>
<div class="slider-buttons">
<div class="slider-counter">
{%- for block in section.blocks -%}
<a href="#Slide-{{ section.id }}-{{ forloop.index }}" class="slider-counter__link link" aria-label="{{ 'sections.slideshow.load_slide' | t }} {{ forloop.index }} {{ 'general.slider.of' | t }} {{ forloop.length }}">
{{ forloop.index }}
</a>
{%- endfor -%}
</div>
</div>
</noscript>
{%- endif -%}

<div class="slideshow banner banner--{{ section.settings.slide_height }} grid grid--1-col slider slider--everywhere{% if section.settings.show_text_below %} banner--mobile-bottom{% endif %}{% if section.blocks.first.settings.image == blank %} slideshow--placeholder{% endif %}"
id="Slider-{{ section.id }}"
aria-live="polite"
Expand Down Expand Up @@ -93,8 +134,8 @@
{%- endfor -%}
</div>

{%- if section.blocks.size > 1 -%}
<div class="slideshow__controls slider-buttons no-js-hidden">
{%- if section.blocks.size > 1 and section.settings.auto_rotate == false -%}
<div class="slideshow__controls slider-buttons no-js-hidden{% if section.settings.show_text_below %} slideshow__controls--border-radius-mobile{% endif %}">
<button type="button" class="slider-button slider-button--prev" name="previous" aria-label="{{ 'sections.slideshow.previous_slideshow' | t }}" aria-controls="Slider-{{ section.id }}">{% render 'icon-caret' %}</button>
<div class="slider-counter slider-counter--{{ section.settings.slider_visual }}{% if section.settings.slider_visual == 'counter' or section.settings.slider_visual == 'numbers' %} caption{% endif %}">
{%- if section.settings.slider_visual == 'counter' -%}
Expand All @@ -121,7 +162,6 @@
</button>
{%- endif -%}
</div>

<noscript>
<div class="slider-buttons">
<div class="slider-counter">
Expand All @@ -134,7 +174,6 @@
</div>
</noscript>
{%- endif -%}

</slideshow-component>

{%- if request.design_mode -%}
Expand Down

0 comments on commit b3c1a63

Please sign in to comment.