fonctionnalités de la page Profile user

This commit is contained in:
Laurian-Dufrechou
2023-03-27 23:41:10 +02:00
parent 2def92dc25
commit e3344c5103
9 changed files with 416 additions and 204 deletions
+36 -26
View File
@@ -1,45 +1,55 @@
import {useState} from 'react';
import {Flex, IconButton} from '@chakra-ui/react';
import { useState } from "react";
import { Flex, IconButton } from "@chakra-ui/react";
import { BiLeftArrowAlt, BiRightArrowAlt } from "react-icons/bi";
interface Props {
images: string[]
images: string[];
borderRadius?: string | number;
}
const Carousel = ({images, borderRadius: bRadius}: Props) => {
const Carousel = ({ images, borderRadius: bRadius }: Props) => {
const [currentIndex, setCurrentIndex] = useState(0);
const handleClickPrevious = () => {
setCurrentIndex(
(currentIndex === 0)
? images.length - 1 : currentIndex - 1,
);
setCurrentIndex(currentIndex === 0 ? images.length - 1 : currentIndex - 1);
};
const handleClickNext = () => {
setCurrentIndex(
(currentIndex === images.length - 1)
? 0 : currentIndex + 1,
);
setCurrentIndex(currentIndex === images.length - 1 ? 0 : currentIndex + 1);
};
if (images.length === 0) images = ["blank_profile_picture.webp"];
return (
<Flex px={2} align="center" borderRadius={bRadius} overflow={"hidden"} justify={'space-between'}
bgImage={images[currentIndex]} bgSize={'cover'} width={'100%'}
height={500}>
<Flex
px={2}
align="center"
borderRadius={bRadius}
overflow={"hidden"}
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={handleClickPrevious}>
<BiLeftArrowAlt/>
</IconButton>
<IconButton aria-label="left-arrow" colorScheme="purple"
borderRadius="full" onClick={handleClickNext}>
<BiRightArrowAlt/>
</IconButton>
</Flex>
<IconButton
aria-label="left-arrow"
colorScheme="purple"
borderRadius="full"
onClick={handleClickNext}
>
<BiRightArrowAlt />
</IconButton>
</Flex>
);
};