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

Announcements slideshow #2394

Merged
merged 30 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9c438fd
Add slideshow for announcements
eugenekasimov Mar 14, 2023
ab95fb1
Add full width for announcements slider
eugenekasimov Mar 14, 2023
7798534
Add component-slider.css
eugenekasimov Mar 15, 2023
eea8fe8
Add 100% height for buttons. Vertical aligning for text.
eugenekasimov Mar 15, 2023
b75b672
Fix conflicts
eugenekasimov Mar 15, 2023
e596ae8
Merge branch 'main' into add-announcements-slideshow
eugenekasimov Mar 15, 2023
e2209e5
Add missed class that caused wrong alignment
eugenekasimov Mar 15, 2023
3985d50
Change accessibility attributes from slideshow to announcements
eugenekasimov Mar 16, 2023
410d963
Minor change for aria-label
eugenekasimov Mar 16, 2023
f96e12d
Update en.default.json file
eugenekasimov Mar 17, 2023
006f8a8
Refactor and change naming of classes
eugenekasimov Mar 17, 2023
5452ddc
Add missing role for slideshow-component
eugenekasimov Mar 20, 2023
c8ad9a7
Remove hover for announcement link
eugenekasimov Mar 20, 2023
d0caa81
Refactor css classes. Remove unnecessary chunk of code.
eugenekasimov Mar 23, 2023
a85a5dd
Fix if logic in liquid
eugenekasimov Mar 23, 2023
c0a1d44
Add JS logic for prefers-reduced-motion for both announcements and sl…
eugenekasimov Mar 24, 2023
40da407
Refactoring
eugenekasimov Mar 24, 2023
4c77e36
Cancel preventing auto-rotation from slideshow when reduced-motion. A…
eugenekasimov Mar 28, 2023
8f579e4
Merge branch 'main' into add-announcements-slideshow
eugenekasimov Mar 28, 2023
8687422
Correct focus-visible for announcements slideshow buttons
eugenekasimov Mar 28, 2023
570c23a
Add settings to en.default.schema.json
eugenekasimov Mar 28, 2023
36204d9
Minor refactoring
eugenekasimov Mar 29, 2023
2ec496c
Update 6 translation files
translation-platform[bot] Mar 30, 2023
08e0521
Update 5 translation files
translation-platform[bot] Mar 30, 2023
a7fccc7
Add underline decoration for link
eugenekasimov Mar 30, 2023
0731f8e
Merge branch 'main' into add-announcements-slideshow
eugenekasimov Mar 30, 2023
87a678e
Update 24 translation files
translation-platform[bot] Mar 30, 2023
d2fea77
Update 15 translation files
translation-platform[bot] Mar 30, 2023
e2f0d24
Remove unnecessary class. Move css styles for announcements-slider to…
eugenekasimov Apr 1, 2023
1cc56cc
Add min-width for buttons.
eugenekasimov Apr 3, 2023
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
71 changes: 66 additions & 5 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ html.no-js .no-js-hidden {
padding: 0 1.5rem;
}

body:has(.section-header .drawer-menu) .announcement-bar-section slideshow-component {
max-width: 100%;
}

.page-width.drawer-menu {
max-width: 100%;
}
Expand Down Expand Up @@ -2246,22 +2250,78 @@ product-info .loading-overlay:not(.hidden) ~ *,
line-height: calc(1 + 0.1 / var(--font-body-scale));
}

/* section-announcement-bar */
.announcement-bar {
/* utility-bar */
.utility-bar {
height: 100%;
}

.utility-bar--bottom-border {
border-bottom: 0.1rem solid rgba(var(--color-foreground), 0.08);
}

.announcement-bar,
.announcement-bar__announcement {
color: rgb(var(--color-foreground));
width: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a huge fan of how far the arrows are from the content: video

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey Ludo, thanks for the opinion. I'm afraid there is no optimal way to set it right, because it really depends on the message size. Setting the width for the slider based on the first slide might have the same visual issue if the first slide is wide and the next is super narrow. I think the current design decision works well for the average case, plus a merchant can always set the menu to a different type such as the dropdown to make it more narrow. Plus, we are about to start adding other features into it and it's going to be more compact anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @YoannJailin this needs your attention. Thanks.

Choose a reason for hiding this comment

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

Hello @eugenekasimov @ludoboludo i think it could be good to make the arrow icons more centered so the user can see them more easily / he won't have to go too far to hover it on large screens.

Let's just add the additional options for now (selectors, social media icons) that will shrink the Announcements slider to the middle including the arrows. We can still make that narrow version of the slider default later, even if there's no other options activated.

height: 100%;
display: flex;
justify-content: center;
flex-wrap: wrap;
align-content: center;
}
Comment on lines +2262 to +2271
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we need all these styles applied to both of these classes. I know we've moved some classes around, so I feel like some of these are redundant now. I should have flagged this sooner though and I don't want to send us backward. If we feel we can confidently clean some of this up that'd be great but I won't block this PR for it.


.announcement-bar-slider,
.announcement-bar-slider .slider {
width: 100%;
}
ludoboludo marked this conversation as resolved.
Show resolved Hide resolved

.announcement-bar .slider-button--next {
margin-right: -1.6rem;
}

.announcement-bar .slider-button--prev {
margin-left: -1.6rem;
}

.announcement-bar .slider-button--next:focus-visible,
.announcement-bar .slider-button--prev:focus-visible {
outline-offset: -0.3rem;
box-shadow: 0 0 0 -0.2rem rgb(var(--color-foreground));
}

@media screen and (min-width: 750px) {
.announcement-bar .slider-button--next {
margin-right: -3.8rem;
}

.announcement-bar .slider-button--prev {
margin-left: -3.8rem;
}
}

@media screen and (min-width: 990px) {
body:has(.section-header .header:not(.drawer-menu)) .announcement-bar-section .announcement-bar .slider-button--next {
margin-right: -1.8rem;
}

body:has(.section-header .header:not(.drawer-menu)) .announcement-bar-section .announcement-bar .slider-button--prev {
margin-left: -1.8rem;
}

}

.announcement-bar__link {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm aligned with the decision to remove the background hover effect, but now not sure if the arrow animation alone is enough feedback to visually indicate the hover state. I wonder if it might be worth reducing the initial opacity of the text and changing to 100% on hover, like many other links do (example)

Not sure if this was considered or not, but wanted to run it by @YoannJailin just in case.

Choose a reason for hiding this comment

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

Hey! Agree an additional effect could help. Did some testing, the only matter i see with opacity is that some announcements may be clickable, some others not. Might look strange to switch between annoucements more or less transparent depending of they are clickable or not.

Is it worth considering a line on hover when it's clickable?
Capture d’écran, le 2023-03-30 à 14 22 58

Copy link
Contributor

Choose a reason for hiding this comment

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

True true, good point. I don't mind the underline myself and we do it for many other elements including the nearby L1 nav items. I'll defer to your judgement though.

Choose a reason for hiding this comment

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

Cool then! @eugenekasimov would that be easy to add this state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@YoannJailin done ✅

display: block;
display: flex;
width: 100%;
padding: 1rem 0;
text-decoration: none;
height: 100%;
justify-content: center;
align-items: center;
}

.announcement-bar__link:hover {
color: rgb(var(--color-foreground));
background-color: rgba(var(--color-card-hover), 0.06);
text-decoration: underline;
}

.announcement-bar__link .icon-arrow {
Expand All @@ -2277,6 +2337,7 @@ product-info .loading-overlay:not(.hidden) ~ *,
}

.announcement-bar__message {
text-align: center;
padding: 1rem 0;
margin: 0;
letter-spacing: 0.1rem;
Expand Down
4 changes: 4 additions & 0 deletions assets/component-slider.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ slider-component.slider-component-full-width {
scroll-snap-align: center;
}

.announcement-bar .slider--everywhere {
margin-bottom: 0;
}

@media screen and (min-width: 990px) {
.slider-component-desktop.page-width {
max-width: none;
Expand Down
40 changes: 28 additions & 12 deletions assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,21 +675,29 @@ class SlideshowComponent extends SliderComponent {
this.slider.addEventListener('scroll', this.setSlideVisibility.bind(this));
this.setSlideVisibility();

this.reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
this.reducedMotion.addEventListener('change',() => {
if (this.slider.getAttribute('data-autoplay') === 'true') this.setAutoPlay();
});

if (this.slider.getAttribute('data-autoplay') === 'true') this.setAutoPlay();
}

setAutoPlay() {
this.sliderAutoplayButton = this.querySelector('.slideshow__autoplay');
this.autoplaySpeed = this.slider.dataset.speed * 1000;

this.sliderAutoplayButton.addEventListener('click', this.autoPlayToggle.bind(this));
this.addEventListener('mouseover', this.focusInHandling.bind(this));
this.addEventListener('mouseleave', this.focusOutHandling.bind(this));
this.addEventListener('focusin', this.focusInHandling.bind(this));
this.addEventListener('focusout', this.focusOutHandling.bind(this));

this.play();
this.autoplayButtonIsSetToPlay = true;
if(this.querySelector('.slideshow__autoplay')) {
this.sliderAutoplayButton = this.querySelector('.slideshow__autoplay');
this.sliderAutoplayButton.addEventListener('click', this.autoPlayToggle.bind(this));
this.autoplayButtonIsSetToPlay = true;
this.play();
} else {
this.reducedMotion.matches ? this.pause() : this.play();
}
}

onButtonClick(event) {
Expand Down Expand Up @@ -731,16 +739,24 @@ class SlideshowComponent extends SliderComponent {
}

focusOutHandling(event) {
const focusedOnAutoplayButton = event.target === this.sliderAutoplayButton || this.sliderAutoplayButton.contains(event.target);
if (!this.autoplayButtonIsSetToPlay || focusedOnAutoplayButton) return;
this.play();
if (this.sliderAutoplayButton) {
const focusedOnAutoplayButton = event.target === this.sliderAutoplayButton || this.sliderAutoplayButton.contains(event.target);
if (!this.autoplayButtonIsSetToPlay || focusedOnAutoplayButton) return;
this.play();
} else if(!this.reducedMotion.matches) {
this.play();
}
}

focusInHandling(event) {
const focusedOnAutoplayButton = event.target === this.sliderAutoplayButton || this.sliderAutoplayButton.contains(event.target);
if (focusedOnAutoplayButton && this.autoplayButtonIsSetToPlay) {
this.play();
} else if (this.autoplayButtonIsSetToPlay) {
if (this.sliderAutoplayButton) {
const focusedOnAutoplayButton = event.target === this.sliderAutoplayButton || this.sliderAutoplayButton.contains(event.target);
if (focusedOnAutoplayButton && this.autoplayButtonIsSetToPlay) {
this.play();
} else if (this.autoplayButtonIsSetToPlay) {
this.pause();
}
} else if (this.querySelector('.announcement-bar-slider').contains(event.target)) {
this.pause();
}
}
Expand Down
7 changes: 7 additions & 0 deletions locales/bg-BG.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
},
"page": {
"title": "Заглавие на страница"
},
"announcements": {
"previous_announcement": "Предишно известие",
"next_announcement": "Следващо известие",
"carousel": "Въртележка",
"announcement": "Известие",
"announcement_bar": "Лента с известия"
}
},
"localization": {
Expand Down
7 changes: 7 additions & 0 deletions locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@
},
"page": {
"title": "Název stránky"
},
"announcements": {
"previous_announcement": "Předchozí oznámení",
"next_announcement": "Další oznámení",
"carousel": "Karusel",
"announcement": "Oznámení",
"announcement_bar": "Panel oznámení"
}
},
"localization": {
Expand Down
8 changes: 8 additions & 0 deletions locales/cs.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@
}
}
}
},
"settings": {
"auto_rotate": {
"label": "Automaticky otočit snímky"
},
"change_slides_speed": {
"label": "Změnit snímek co"
}
}
},
"collage": {
Expand Down
7 changes: 7 additions & 0 deletions locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
},
"page": {
"title": "Sidetitel"
},
"announcements": {
"previous_announcement": "Forrige meddelelse",
"next_announcement": "Næste meddelelse",
"carousel": "Karrusel",
"announcement": "Meddelelse",
"announcement_bar": "Meddelelseslinje"
}
},
"localization": {
Expand Down
8 changes: 8 additions & 0 deletions locales/da.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@
}
}
}
},
"settings": {
"auto_rotate": {
"label": "Roter automatisk slides"
},
"change_slides_speed": {
"label": "Skift slide hver"
}
}
},
"collage": {
Expand Down
7 changes: 7 additions & 0 deletions locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
},
"page": {
"title": "Seitentitel"
},
"announcements": {
"previous_announcement": "Vorherige Ankündigung",
"next_announcement": "Nächste Ankündigung",
"carousel": "Karussell",
"announcement": "Ankündigung",
"announcement_bar": "Ankündigungsleiste"
}
},
"localization": {
Expand Down
8 changes: 8 additions & 0 deletions locales/de.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@
}
}
}
},
"settings": {
"auto_rotate": {
"label": "Autorotieren der Slides"
},
"change_slides_speed": {
"label": "Slides überall ändern"
}
}
},
"collage": {
Expand Down
7 changes: 7 additions & 0 deletions locales/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
},
"page": {
"title": "Τίτλος σελίδας"
},
"announcements": {
"previous_announcement": "Προηγούμενη ανακοίνωση",
"next_announcement": "Επόμενη ανακοίνωση",
"carousel": "Καρουζέλ",
"announcement": "Ανακοίνωση",
"announcement_bar": "Γραμμή ανακοινώσεων"
}
},
"localization": {
Expand Down
8 changes: 8 additions & 0 deletions locales/en.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@
}
},
"sections": {
"announcements": {
"previous_announcement": "Previous announcement",
"next_announcement": "Next announcement",
"carousel": "Carousel",
"announcement": "Announcement",
"announcement_bar": "Announcement bar"
},

"header": {
"announcement": "Announcement",
"menu": "Menu",
Expand Down
8 changes: 8 additions & 0 deletions locales/en.default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@
},
"announcement-bar": {
"name": "Announcement bar",
"settings": {
"auto_rotate": {
"label": "Auto-rotate slides"
},
"change_slides_speed": {
"label": "Change slides every"
}
},
Comment on lines +480 to +487
Copy link
Contributor

@kmeleta kmeleta Mar 29, 2023

Choose a reason for hiding this comment

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

Just calling out that I agree with duplicating these particular translations for the announcement bar vs reusing the entries from slideshow.

These are not particularly verbose and even though slideshow code is being used as a layer of abstraction here, slideshow is a mostly-unrelated, fully independent section on its own and I don't know if there's a strong case to rely on its settings here.

"blocks": {
"announcement": {
"name": "Announcement",
Expand Down
7 changes: 7 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@
},
"page": {
"title": "Título de la página"
},
"announcements": {
"previous_announcement": "Anuncio anterior",
"next_announcement": "Anuncio siguiente",
"carousel": "Carrusel",
"announcement": "Anuncio",
"announcement_bar": "Barra de anuncios"
}
},
"localization": {
Expand Down
8 changes: 8 additions & 0 deletions locales/es.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@
}
}
}
},
"settings": {
"auto_rotate": {
"label": "Girar las diapositivas automáticamente"
},
"change_slides_speed": {
"label": "Cambiar de diapositiva cada"
}
}
},
"collage": {
Expand Down
7 changes: 7 additions & 0 deletions locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
},
"page": {
"title": "Sivun otsikko"
},
"announcements": {
"previous_announcement": "Edellinen ilmoitus",
"next_announcement": "Ilmoitus",
"carousel": "Karuselli",
"announcement": "Ilmoitus",
"announcement_bar": "Ilmoituspalkki"
}
},
"localization": {
Expand Down
8 changes: 8 additions & 0 deletions locales/fi.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@
}
}
}
},
"settings": {
"auto_rotate": {
"label": "Käännä diat automaattisesti"
},
"change_slides_speed": {
"label": "Vaihda diat joka"
}
}
},
"collage": {
Expand Down
7 changes: 7 additions & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@
},
"page": {
"title": "Titre de la page"
},
"announcements": {
"previous_announcement": "Annonce précédente",
"next_announcement": "Annonce suivante",
"carousel": "Carrousel",
"announcement": "Annonce",
"announcement_bar": "Barre d’annonces"
}
},
"localization": {
Expand Down
Loading