Edit Carousel

Took 1 hour 41 minutes
This commit is contained in:
Lucàs
2023-03-23 15:36:13 +01:00
parent c241c8b4fe
commit ae9fd9ee16
22 changed files with 2624 additions and 3033 deletions
+45
View File
@@ -0,0 +1,45 @@
import {useState} from 'react';
import {Flex, IconButton} from '@chakra-ui/react';
import { BiLeftArrowAlt, BiRightArrowAlt } from "react-icons/bi";
interface Props {
images: string[];
}
const Carousel = ({images}: Props) => {
const [currentIndex, setCurrentIndex] = useState(0);
const handleClickPrevious = () => {
setCurrentIndex(
(currentIndex === 0)
? images.length - 1
: currentIndex - 1,
);
};
const handleClickNext = () => {
setCurrentIndex(
(currentIndex === images.length - 1)
? 0
: currentIndex + 1,
);
};
return (
<Flex px={2} align="center" justify={'space-between'}
bgImage={images[currentIndex]} bgSize={'cover'} width={'100%'}
height={500}>
<IconButton aria-label="left-arrow" colorScheme="purple"
borderRadius="full" onClick={handleClickPrevious}>
<BiLeftArrowAlt/>
</IconButton>
<IconButton aria-label="left-arrow" colorScheme="purple"
borderRadius="full" onClick={handleClickNext}>
<BiRightArrowAlt/>
</IconButton>
</Flex>
);
};
export default Carousel;