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.24.0.pre.alpha.PLAY1181circleiconkitfixsizingerrorglobalspacingprops2675 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.24.0.pre.alpha.PLAY998backgroundkitremoveemptyinlinline2666 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.23.0.pre.alpha.PLAY1284investigation2657 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.24.0 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.22.0.pre.alpha.pbntr254barchartnegativenumber2640 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.22.0.pre.alpha.PLAY1297updatetextstyles2636 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.22.0.pre.alpha.playbookgemspecrailsversion2608 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.23.0 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PLAY12582531 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PLAY12582516 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PLAY12582515 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PLAY12582514 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.22.0 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PBNTR243globalpositioningpropinset2504 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PLAY12652489 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PLAY12582474 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PBNTR224letuserresetrowexpansion2466 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PLAY120322465 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.pbntr220improveexpansionspeed2451 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.21.0.pre.alpha.PBNTR224letuserresetrowexpansion2441 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx