Skip to content

Commit

Permalink
grunt2 and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
yurytut1993 committed Oct 30, 2020
1 parent 6750678 commit 88742c1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
10 changes: 5 additions & 5 deletions assets/js/theme/common/carousel/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'slick-carousel';

import {
heroCarouselSetup,
getRealSlidesQuantityAndCurrentSlide,
arrowAriaLabling,
dotsSetup,
setTabindexes,
arrowAriaLabling,
heroCarouselSetup,
getRealSlidesQuantityAndCurrentSlide,
} from './utils';

const onCarouselChange = (event, carousel) => {
Expand All @@ -16,15 +16,15 @@ const onCarouselChange = (event, carousel) => {
$dots,
$slider,
breakpointSettings,
activeBreakpoint
activeBreakpoint,
} = carousel;

const { realSlideCount, realSlide } = getRealSlidesQuantityAndCurrentSlide(
breakpointSettings,
activeBreakpoint,
currentSlide,
slideCount,
$slider.data('slick').slidesToScroll
$slider.data('slick').slidesToScroll,
);

const $prevArrow = $slider.find(prevArrow);
Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme/common/carousel/utils/arrowAriaLabling.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const NUMBER = '[NUMBER]';
const integerRegExp = /[0-9]+/;
const lastIntegerRegExp = /(\d+)(?!.*\d)/;

export const arrowAriaLabling = ($prevArrow, $nextArrow, realCurrentSlide, realSlideCount) => {
export default ($prevArrow, $nextArrow, realCurrentSlide, realSlideCount) => {
if (realSlideCount < 2) return;
if ($prevArrow.length === 0 || $nextArrow.length === 0) return;

Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme/common/carousel/utils/dotsSetup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const dotsSetup = ($dots, currentSlide, realSlideCount, dotLabels) => {
export default ($dots, currentSlide, realSlideCount, dotLabels) => {
if (!$dots) return;

if (realSlideCount === 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const getRealSlidesQuantityAndCurrentSlide = (
export default (
breakpointSettings,
activeBreakpoint,
currentSlide,
slideCount,
defaultSlidesToScrollQuantity = 1
defaultSlidesToScrollQuantity = 1,
) => {
const slidesToScrollQuantity = activeBreakpoint
/* eslint-disable dot-notation */
Expand All @@ -14,4 +14,4 @@ export const getRealSlidesQuantityAndCurrentSlide = (
realSlideCount: Math.ceil(slideCount / slidesToScrollQuantity),
realSlide: Math.ceil(currentSlide / slidesToScrollQuantity),
};
}
};
2 changes: 1 addition & 1 deletion assets/js/theme/common/carousel/utils/heroCarouselSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const showCarouselIfSlidesAnalyzedSetup = ($carousel) => {
};
};

export const heroCarouselSetup = ($heroCarousel) => {
export default ($heroCarousel) => {
if ($heroCarousel.length === 0) return;

const $slidesNodes = $heroCarousel.find('.heroCarousel-slide');
Expand Down
10 changes: 5 additions & 5 deletions assets/js/theme/common/carousel/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { heroCarouselSetup } from './heroCarouselSetup';
export { arrowAriaLabling } from './arrowAriaLabling';
export { dotsSetup } from './dotsSetup';
export { getRealSlidesQuantityAndCurrentSlide } from './getRealSlidesQuantityAndCurrentSlide';
export { setTabindexes } from './setTabindexes';
export { default as heroCarouselSetup } from './heroCarouselSetup';
export { default as arrowAriaLabling } from './arrowAriaLabling';
export { default as dotsSetup } from './dotsSetup';
export { default as getRealSlidesQuantityAndCurrentSlide } from './getRealSlidesQuantityAndCurrentSlide';
export { default as setTabindexes } from './setTabindexes';
2 changes: 1 addition & 1 deletion assets/js/theme/common/carousel/utils/setTabindexes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const allFocusableElementsSelector = '[href], button, input, textarea, select, details, [contenteditable="true"], [tabindex]';

export const setTabindexes = ($slides, $prevArrow, $nextArrow, realSlide, realSlideCount) => {
export default ($slides, $prevArrow, $nextArrow, realSlide, realSlideCount) => {
$slides.each((index, element) => {
const $element = $(element);
const tabIndex = $element.hasClass('slick-active') ? 0 : -1;
Expand Down
2 changes: 1 addition & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@
},
"carousel": {
"arrowAriaLabel": "Go to slide [NUMBER] of",
"dotAriaLabel": "Go to slide",
"dotAriaLabel": "Slide number",
"activeDotAriaLabel": "active"
},
"validation_messages": {
Expand Down
1 change: 1 addition & 0 deletions templates/components/carousel.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<section class="heroCarousel"
data-slick='{
"arrows": {{arrows}},
"mobileFirst": true,
"slidesToShow": 1,
"slidesToScroll": 1,
Expand Down

0 comments on commit 88742c1

Please sign in to comment.