import React from 'react' import type { ComponentType, FC } from 'react' import { Box } from 'theme-ui' import { useSlider } from '../Slider/hooks/useSlider' import CarouselArrowLeft from './ArrowLeft' import CarouselArrowRight from './ArrowRight' import CarouselPaginationDots from './PaginationDots' import CarouselPage from './Page' import type { Item } from './Page' interface Props { allItems: Item[] width: string height: string link?: ComponentType loading?: 'lazy' | 'eager' showArrows?: boolean showDots?: boolean autoplay?: number variant?: string } const Carousel: FC = ({ allItems, link, loading = 'eager', showArrows = true, showDots = true, width, height, autoplay, variant = 'carousel', }) => { const { page, items, totalPages, setPage, setNextPage, setPreviousPage, dragHandlers, } = useSlider({ allItems, pageSize: 1, autoplay, }) // this is safe, since there is only one item per page const [item] = items return ( {showArrows ? ( setPreviousPage()} /> ) : null} {showArrows ? ( setNextPage()} /> ) : null} {showDots ? ( ) : null} ) } export default Carousel