Skip to content

Commit

Permalink
Feat: PCardSlider 컴포넌트 구현
Browse files Browse the repository at this point in the history
- react-slick 라이브러리 설치
  • Loading branch information
thsk3 committed Oct 1, 2024
1 parent 00cb2af commit 881b064
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
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 @@ -20,6 +20,8 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2",
"react-slick": "^0.30.2",
"slick-carousel": "^1.8.1",
"styled-components": "^6.1.13",
"vite-tsconfig-paths": "^5.0.1",
"xml-js": "^1.6.11",
Expand All @@ -29,6 +31,7 @@
"@eslint/js": "^9.9.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-slick": "^0.23.13",
"@types/styled-components": "^5.1.34",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
Expand Down
37 changes: 37 additions & 0 deletions src/components/PCardSlider/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Slider from 'react-slick';
import 'slick-carousel/slick/slick.css';
import 'slick-carousel/slick/slick-theme.css';
import * as S from './styles';
import { CommonResponseType } from '@/types/apis';
import { PCard } from '@/components/PCard';

interface PCardSliderProps {
pList: Pick<CommonResponseType, 'mt20id' | 'poster' | 'prfnm' | 'fcltynm' | 'prfpdfrom' | 'prfpdto'>[];
width?: string;
isRanked?: boolean;
}

export const PCardSlider = ({ pList, width = '600px', isRanked = false }: PCardSliderProps) => {
const settings = {
infinite: true,
speed: 500,
slidesToShow: 5,
slidesToScroll: 1,
};
return (
<S.PCardSlider width={width}>
<Slider {...settings}>
{pList.map((perform, index) => {
return (
<PCard
key={index}
pInfo={perform}
width={`calc(${width} / 5.2)`}
{...(isRanked && { rank: index + 1 })}
></PCard>
);
})}
</Slider>
</S.PCardSlider>
);
};
9 changes: 9 additions & 0 deletions src/components/PCardSlider/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { styled } from 'styled-components';

export const PCardSlider = styled.div<{ width: string }>`
width: ${({ width }) => width};
.slick-prev::before,
.slick-next::before {
color: ${({ theme }) => theme.colors.gray};
}
`;

0 comments on commit 881b064

Please sign in to comment.