Skip to content

Commit

Permalink
Merge branch 'feat/#120/Carousel' of https://github.com/TEAM-BEAT/BEA…
Browse files Browse the repository at this point in the history
…T-Client into feat/#122/MainNavigation
  • Loading branch information
sinji2102 committed Jul 13, 2024
2 parents a592027 + 0f7016e commit af20a41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pages/main/components/carousel/Carousel.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const CarouselContainer = styled.ul`
width: 100%;
`;

export const CarouselItem = styled.li`
export const CarouselItem = styled.button`
flex-shrink: 0;
width: 100%;
Expand Down
13 changes: 11 additions & 2 deletions src/pages/main/components/carousel/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useEffect, useRef } from "react";
import { useNavigate } from "react-router-dom";
import * as S from "./Carousel.styled";

import carouselImg from "../../../../assets/images/banner_roll.png";
Expand All @@ -16,6 +17,8 @@ interface PromotionComponentProps {
const ImgList = [carouselImg, carouselImg, carouselImg, carouselImg, carouselImg];

const Carousel = (promotionList: PromotionComponentProps) => {
const navigate = useNavigate();

const carouselList = ImgList;
const [currIndex, setCurrIndex] = useState(1);
const [currList, setCurrList] = useState<string[]>();
Expand Down Expand Up @@ -65,7 +68,7 @@ const Carousel = (promotionList: PromotionComponentProps) => {
if (carouselRef.current !== null) {
carouselRef.current.style.transition = "all 0.5s ease-in-out";
}
}, 5000);
}, 3000);
return () => {
clearInterval(time);
};
Expand All @@ -79,7 +82,13 @@ const Carousel = (promotionList: PromotionComponentProps) => {
const key = `${image}-${idx}`;

return (
<S.CarouselItem key={key}>
<S.CarouselItem
key={key}
onClick={() => {
// id값 줘서 클릭하면 해당 공연으로 넘어갈 수 있도록
navigate("/lookup");
}}
>
<img src={image} alt="carousel-img" />
</S.CarouselItem>
);
Expand Down

0 comments on commit af20a41

Please sign in to comment.