Sha256: 366432cdae29503f0ee197d28ce11d4f17aebed8e265f3a37bcec13ac816ad35

Contents?: true

Size: 1.25 KB

Versions: 162

Compression:

Stored size: 1.25 KB

Contents

/* eslint-disable jsx-control-statements/jsx-use-if-tag */
import React, { useEffect } from 'react'
import Slides from './Slides'
import Thumbnails from './Thumbnails'

type CarouselType = {
  initialPhoto?: string,
  onClose?: () => void,
  icon?: string,
  currentIndex: number,
  photos: {
    url: string,
    thumbnail: string,
  }[],
  onChange: (index: number) => void,
  onClick?: (index: number) => void,
  setIndex?: (index: number)=> void,
}

export default function Carousel({
  currentIndex,
  photos,
  onClick,
  onChange = () => undefined,
  setIndex,
}: CarouselType): React.ReactElement {
  useEffect(() => {
    document.body.style.overflow = 'hidden'

    return () => {
      document.body.style.overflow = 'initial'
    }
  }, [])

  const handleChange = (index: number) => {
    onChange(index)
  }

  return (
    <div className="Lightbox">
      <Slides
          current={currentIndex}
          onChange={handleChange}
          onClick={onClick}
          setIndex={setIndex}
          urls={photos.map((photo) => photo.url)}
      />
      {photos.length > 1 ? (
        <Thumbnails
            current={currentIndex}
            onChange={handleChange}
            urls={photos.map((photo) => photo.thumbnail)}
        />
      ) : null}
    </div>
  )
}

Version data entries

162 entries across 162 versions & 1 rubygems

Version Path
playbook_ui-13.34.1.pre.alpha.play1407statvaluekitinconsistencies3388 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.1.pre.alpha.PLAY14703378 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0.pre.alpha.PLAY14143373 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0.pre.alpha.PLAY14143372 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.1 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3370 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3369 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3368 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3366 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0.pre.alpha.PLAY14143358 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0.pre.alpha.PLAY14143357 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.34.0 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.33.1.pre.alpha.play1407statvaluekitinconsistencies3352 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.33.1.pre.alpha.PLAY14143340 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.33.1.pre.alpha.PLAY14143336 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.33.1.pre.alpha.PLAY14063320 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.33.1 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.33.0.pre.alpha.PLAY14143318 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.33.0.pre.alpha.PLAY14143312 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.33.0.pre.alpha.PBNTR405dropdownformfixesrails3311 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx