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.28.0.pre.alpha.pbntr312tableheaderflexremoval3019 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.28.0.pre.alpha.dialogturbostreameventlistener3017 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.28.0.pre.alpha.PLAY1338alpha3001 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.28.0.pre.alpha.PLAY1343fixTooltiprunwayissue2987 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.28.0.pre.alpha.PLAY1343fixTooltiprunwayissue2986 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.28.0.pre.alpha.PLAY1343fixTooltiprunwayissue2984 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.27.0 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.26.0.pre.alpha.PBNTR291Dropdownrailsv22840 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.26.0.pre.alpha.jasoncypretpatch12820 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.26.0.pre.alpha.jasoncypretpatch12816 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.25.0.pre.alpha.PBNTR291Dropdownrailsv22812 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.26.0 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2785 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2783 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.25.0.pre.alpha.PBNTR272Dropdownkitv42769 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.25.0.pre.alpha.barchartfix2766 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.25.0.pre.alpha.PLAY761globalpaddingpropsbuttons2713 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.25.0 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.24.0.pre.alpha.play1305drycontenttag2689 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx
playbook_ui-13.24.0.pre.alpha.PBNTR261NewKitDropdown2681 app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx