/** * @format */ import {Box, Button, Flex, VStack} from '@chakra-ui/react' import React, {ReactNode, useState} from 'react' interface CarouselOptions { /** * If `true`, the carousel will start to autoLoop. */ autoStart: boolean /** * If `true`, the carousel will go back to the first slide, if there no further slides to move to. */ loop: boolean /** * Specifies the number of slides in the carousel */ pageLength: number /** * Determines how fast or slow the pages transition to the next. Slow = 750ms; Normal = 500ms; Fast = 350ms */ transitionSpeed?: 'slow' | 'normal' | 'fast' /** * The pages or the content of the Carousel */ children: ReactNode } export const CarouselPage = ({children}: {children: ReactNode}) => ( {children} ) export const Carousel = ({opts}: {opts: CarouselOptions}) => { const pageCompLength = [] const selectedDotColor = '#E03C31' const normalColor = '#E4E4E7' const [selectedIndex, setSelectedIndex] = useState(0) let transitionTime if (opts.transitionSpeed === 'slow') { transitionTime = '350ms' } else if (opts.transitionSpeed === 'fast') { transitionTime = '750ms' } else { transitionTime = '500ms' } for (let i = 0; i < opts.pageLength; i++) { pageCompLength.push(i) } return ( {opts.children} {pageCompLength.map((i: any) => ( ))} ) }