diff --git a/web/src/components/AutoCarousel/AutoCarousel.tsx b/web/src/components/AutoCarousel/AutoCarousel.tsx deleted file mode 100644 index 14ec8ab..0000000 --- a/web/src/components/AutoCarousel/AutoCarousel.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { useState, useRef, useCallback, useEffect } from 'react' - -const SCROLL_INTERVAL_SECONDS = 3 - -interface AutoCarouselProps { - images: string[] -} - -const AutoCarousel = ({ images }: AutoCarouselProps) => { - const [activeItem, setActiveItem] = useState(0) - const ref = useRef(null) - - const scroll = useCallback(() => { - setActiveItem((prev) => { - if (images.length - 1 > prev) return prev + 1 - else return 0 - }) - }, [images.length]) - - const autoScroll = useCallback( - () => setInterval(scroll, SCROLL_INTERVAL_SECONDS * 1000), - [scroll] - ) - - useEffect(() => { - const play = autoScroll() - return () => clearInterval(play) - }, [autoScroll]) - - useEffect(() => { - const width = ref.current?.getBoundingClientRect().width - ref.current?.scroll({ left: activeItem * (width || 0) }) - }, [activeItem]) - - return ( -
- {images.map((image, i) => ( -
- {`${i}`} -
- ))} -
- ) -} - -export default AutoCarousel diff --git a/web/src/components/Project/AdminProject/AdminProject.tsx b/web/src/components/Project/AdminProject/AdminProject.tsx index 25836e0..d268729 100644 --- a/web/src/components/Project/AdminProject/AdminProject.tsx +++ b/web/src/components/Project/AdminProject/AdminProject.tsx @@ -87,7 +87,7 @@ const AdminProject = ({ project }: Props) => { key={i} href={image} target="_blank" - className="btn btn-sm btn-square" + className={`btn btn-sm btn-square ${i === 0 && 'btn-primary'}`} rel="noreferrer" > {i + 1} diff --git a/web/src/components/Project/ProjectForm/ProjectForm.tsx b/web/src/components/Project/ProjectForm/ProjectForm.tsx index c02e740..2aeec68 100644 --- a/web/src/components/Project/ProjectForm/ProjectForm.tsx +++ b/web/src/components/Project/ProjectForm/ProjectForm.tsx @@ -242,7 +242,14 @@ const ProjectForm = (props: ProjectFormProps) => { {i.toString()}
-
+
+ {i === 0 && ( +
+ Cover Image +
+ )}