Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 캐러셀 라이브러리 적용 #306

Merged
merged 25 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6710e0e
chore: react-slick 설치
presentKey Nov 19, 2023
8db62fd
feat: Carousel lib 설정 파일
presentKey Nov 19, 2023
0baa03a
feat: getListOfRecentReviewed() 리턴 데이터 변경
presentKey Nov 19, 2023
63b340a
feat: AnimeMainCarousel 컴포넌트의 기본 골격 구현
presentKey Nov 19, 2023
49118d0
feat: AnimeMainCarousel 컴포넌트의 기본 골격 구현
presentKey Nov 19, 2023
005ff50
style: carousel dots 스타일 overwrite
presentKey Nov 19, 2023
7c27f02
style: SliderItem 스타일 적용
presentKey Nov 19, 2023
6b5e9ef
feat: MainCarousel autoplay 설정
presentKey Nov 19, 2023
958c082
feat: drag 중에는 페이지 이동하지 않고, 클릭 시 애니 페이지로 이동 구현
presentKey Nov 19, 2023
a6c1857
style: mediaquery md 사이즈 인 경우, 이전, 다음 버튼 스타일 변경
presentKey Nov 19, 2023
1edc69e
feat: AnimeMainCarousel 적용
presentKey Nov 19, 2023
1e9ce6a
refactor: 기존 AnimeCarousel depreacted 주석 추가
presentKey Nov 19, 2023
c19c32e
feat: pauseOnDotsHover true 설정
presentKey Nov 20, 2023
d779fd7
feat: TOP10 캐러셀 라이브러리 적용
presentKey Nov 20, 2023
3ad1f65
style: media query md 사이즈, arrow button 스타일 적용
presentKey Nov 20, 2023
1bcbbf6
feat: scroll 세팅 변경
presentKey Nov 20, 2023
9686172
feat: drag 중에는 페이지 이동하지 않도록 구현
presentKey Nov 20, 2023
1357531
feat: SyncingCarousel autoplay 및 speed 설정 변경
presentKey Nov 20, 2023
fb1a856
feat: top10 애니 캐러셀 infinite 설정 제거
presentKey Nov 21, 2023
951bf1c
feat: RowCarousel 설정
presentKey Nov 21, 2023
553e5a7
feat: RowCarousel 구현
presentKey Nov 21, 2023
8815ea6
feat: 드래그 중일땐 페이지 이동 막기 구현
presentKey Nov 21, 2023
2deb184
feat: AnimeCard Onclick prop 추가
presentKey Nov 21, 2023
e90be69
fix: type 오류 수정
presentKey Nov 21, 2023
81a8a18
Merge branch 'develop' of github.com:oduck-team/oduck-client into fea…
presentKey Nov 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"react-dom": "^18.2.0",
"react-helmet-async": "^1.3.0",
"react-router-dom": "^6.14.2",
"react-slick": "^0.29.0",
"slick-carousel": "^1.8.1",
"uuid": "^9.0.1",
"uuidv4": "^6.2.13",
"zod": "^3.22.4"
Expand All @@ -43,6 +45,7 @@
"@types/node": "^20.4.5",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@types/react-slick": "^0.23.12",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
Expand Down
15 changes: 3 additions & 12 deletions src/features/animes/api/AnimeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,10 @@ export default class AnimeApi {
}

async getListOfRecentReviewed(): Promise<getListOfRecentReviewedResponse[]> {
return [
listOfRecentReviewedMock.at(-1) as getListOfRecentReviewedResponse,
...listOfRecentReviewedMock,
listOfRecentReviewedMock[0],
];
return listOfRecentReviewedMock;

//FIXME: URI 수정
// 무한 캐러셀을 위한 배열 확장
// return get<getListOfRecentReviewedResponse[]>(`/someURI`) //
// .then((data) => [
// data.at(-1) as getListOfRecentReviewedResponse,
// ...data,
// data[0],
// ]);
// return get<getListOfRecentReviewedResponse[]>(`/someURI`);
}

async getTOP10List(): Promise<TOP10ListResponse[]> {
Expand Down
27 changes: 12 additions & 15 deletions src/features/animes/components/AnimeCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Star } from "@phosphor-icons/react";
import { Link } from "react-router-dom";

import {
AnimeCardContainer,
Expand All @@ -22,29 +21,27 @@ export interface AnimeCardProps {
/** 애니 평점 */
starScoreAvg: number;

/** UI 사이즈 */
size?: "md" | "lg";
/** 페이지 이동 */
onClick: (animeId: number, e: React.MouseEvent) => void;
}

export default function AnimeCard({
id,
thumbnail,
title,
starScoreAvg,
size,
onClick,
}: AnimeCardProps) {
return (
<AnimeCardContainer size={size}>
<Link to={`/animes/${id}`}>
<Image image={thumbnail} size={size} />
<InfoContainer size={size}>
<Title>{title}</Title>
<Rating>
<Star weight="fill" />
<span> {starScoreAvg === 0 ? "평가 전" : starScoreAvg / 2} </span>
</Rating>
</InfoContainer>
</Link>
<AnimeCardContainer onClick={(e: React.MouseEvent) => onClick(id, e)}>
<Image image={thumbnail} />
<InfoContainer>
<Title>{title}</Title>
<Rating>
<Star weight="fill" />
<span> {starScoreAvg === 0 ? "평가 전" : starScoreAvg / 2} </span>
</Rating>
</InfoContainer>
</AnimeCardContainer>
);
}
24 changes: 6 additions & 18 deletions src/features/animes/components/AnimeCard/style.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import { css } from "@emotion/react";
import styled from "@emotion/styled";

interface CardProps {
size?: "md" | "lg";
}

interface ImageProps extends CardProps {
interface ImageProps {
image: string;
}

export const AnimeCardContainer = styled.div<CardProps>`
width: ${({ size = "md" }) => (size === "md" ? `160px` : `100%`)};
flex-shrink: 0;
& > a {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
}
export const AnimeCardContainer = styled.div`
width: 100%;
`;

export const Image = styled.div<ImageProps>`
width: 100%;
height: ${({ size = "md" }) => (size === "md" ? `110px` : `152px`)};
height: 110px;
border-radius: 5px;
${({ image }) => css`
background:
Expand All @@ -31,11 +19,11 @@ export const Image = styled.div<ImageProps>`
`}
background-size: cover;
background-position: center;
margin-bottom: 8px;
`;

export const InfoContainer = styled.div<CardProps>`
export const InfoContainer = styled.div`
width: 100%;
height: ${({ size = "md" }) => (size === "md" ? `65px` : `fit-content`)};
display: flex;
flex-direction: column;
align-items: flex-start;
Expand Down
4 changes: 4 additions & 0 deletions src/features/animes/components/AnimeCarousel/SlideItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ interface SlideItemProps {
anime: getListOfRecentReviewedResponse;
}

/**
* depreacted
* SliderItem 컴포넌트로 변경
* */
export default function SlideItem({ anime }: SlideItemProps) {
const navigate = useNavigate();
return (
Expand Down
4 changes: 4 additions & 0 deletions src/features/animes/components/AnimeCarousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
IndicatorContainer,
} from "./style";

/**
* depreacted
* AnimeMainCarousel 컴포넌트로 변경
* */
export default function AnimeCarousel() {
const [currentSlide, setCurrentSlide] = useState(1); // 현재 슬라이드 인덱스
const [translateValue, setTranslateValue] = useState(0); // 슬라이드 이동(translate)를 위해 사용
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import styled from "@emotion/styled";
import { Star } from "@phosphor-icons/react";

export const SliderItemContainer = styled.section`
position: relative;
padding: 24px 16px;
`;

export const Image = styled.img`
width: 100%;
height: 497px;
object-fit: cover;
border-radius: 10px;
background: rgb(140, 140, 140);
background: linear-gradient(
180deg,
rgba(140, 140, 140, 1) 0%,
rgba(0, 0, 0, 1) 100%
);
`;

export const InfoContainer = styled.div`
width: 100%;
position: absolute;
left: 0;
bottom: 46px;
padding: 0 32px 24px;
color: ${({ theme }) => theme.colors.neutral["05"]};
`;

export const Title = styled.h5`
width: 100%;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
margin-bottom: 8px;
${({ theme }) => theme.typo["title-2-m"]}
`;

export const ReviewContainer = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`;

export const Review = styled.span`
${({ theme }) => theme.typo["body-3-r"]}
display: block;
width: 70%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
`;

export const RatingContainer = styled.div`
display: flex;
align-items: center;
color: ${({ theme }) => theme.colors.secondary[50]};
`;

export const StarIcon = styled(Star)`
color: ${({ theme }) => theme.colors.secondary[50]};
margin-right: 4px;
`;

export const Score = styled.span`
${({ theme }) => theme.typo["body-2-r"]}
`;
Loading