All files / molecule/carousel/src settings.js

93.33% Statements 14/15
54.54% Branches 6/11
83.33% Functions 5/6
92.3% Lines 12/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57    1x   1x 1x 1x   144x     22x 22x       10x 10x     1x 11x   1x                                                                  
import {Children} from 'react'
 
export const BASE_CLASS = 'sui-MoleculeCarousel'
 
export const CLASS_IMAGE_OBJECT_FIT = `${BASE_CLASS}--image-object-fit`
export const CLASS_FULL_HEIGHT = `${BASE_CLASS}--fullHeight`
export const CLASS_FULL_WIDTH = `${BASE_CLASS}--fullWidth`
 
export const handleFn = fn => (typeof fn === 'function' ? fn : () => null)
 
export function getItemsToRender({maxIndex, items, itemsToPreload, numOfSlides}) {
  const preload = Math.max(itemsToPreload, numOfSlides)
  return items.slice(0, maxIndex + preload)
}
 
export function destroySlider(slidyInstance, doAfterDestroy) {
  slidyInstance && slidyInstance.clean() && slidyInstance.destroy()
  doAfterDestroy()
}
 
export const getNumOfSlidesSanitized = ({numOfSlides, children, isSanitized}) =>
  isSanitized ? Math.min(numOfSlides, Children.count(children)) : numOfSlides
 
export const adaptReactSlidyProps = ({
  useFullWidth: isFullWidth,
  useFullHeight: isFullHeight,
  keyboardNavigation: hasKeyboardNavigation,
  infiniteLoop: hasInfiniteLoop,
  lazyLoadSlider: hasLazyLoadSlider,
  sanitize: isSanitized,
  showArrows: hasArrows,
  doAfterInit: onInit,
  doAfterDestroy: onDestroy,
  doAfterSlide: onSlideAfter,
  doBeforeSlide: onSlideBefore,
  initialSlide: defaultSlide,
  ArrowLeft,
  ArrowRight,
  ...props
}) => ({
  ...props,
  isFullWidth,
  isFullHeight,
  hasKeyboardNavigation,
  hasInfiniteLoop,
  hasLazyLoadSlider,
  isSanitized,
  hasArrows,
  onInit,
  onDestroy,
  onSlideAfter,
  onSlideBefore,
  defaultSlide,
  arrowLeft: ArrowLeft ? <ArrowLeft /> : undefined,
  arrowRight: ArrowRight ? <ArrowRight /> : undefined
})