Skip to content

Commit f0df93c

Browse files
authored
feat : 구매 배너 추가 (#446)
* feat: 구매 오픈 배너 추가 * feat: 배너 클릭 시 새 탭 이동 * fix: 배너 순서 변경
1 parent 0c5710b commit f0df93c

4 files changed

Lines changed: 22 additions & 19 deletions

File tree

1.28 MB
Loading
1.81 MB
Loading
720 KB
Loading

src/components/banner/InfiniteBanner.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import JunhyukBanner768 from "@/assets/image/banner/banner_jh_768.png";
1313
import JinsungBanner1280 from "@/assets/image/banner/banner_js_1280.png";
1414
import JinsungBannerDefault from "@/assets/image/banner/banner_js_default.png";
1515
import JinsungBanner768 from "@/assets/image/banner/banner_js_768.png";
16+
import PurchaseBanner768 from "@/assets/image/banner/purchaseOpen/banner_purchase_768.png";
17+
import PurchaseBanner1280 from "@/assets/image/banner/purchaseOpen/banner_purchase_1280.png";
18+
import PurchaseBannerDefault from "@/assets/image/banner/purchaseOpen/banner_purchase_1920.png";
1619

1720
// bannerImages를 props로 받을 수 있게 처리
1821
type ResponsiveSrc = {
@@ -32,6 +35,14 @@ interface InfiniteBannerProps {
3235

3336
const InfiniteBanner = ({
3437
banners = [
38+
{
39+
image: {
40+
default: PurchaseBannerDefault,
41+
md: PurchaseBanner768,
42+
lg: PurchaseBanner1280,
43+
},
44+
link: "https://www.podo-store.com/post",
45+
},
3546
{
3647
image: {
3748
default: PodoalBannerDefault, // 모바일 기본
@@ -60,11 +71,7 @@ const InfiniteBanner = ({
6071
}: InfiniteBannerProps) => {
6172
const realBannerCount = banners.length;
6273

63-
const clonedBannerImages = [
64-
banners[realBannerCount - 1],
65-
...banners,
66-
banners[0],
67-
];
74+
const clonedBannerImages = [banners[realBannerCount - 1], ...banners, banners[0]];
6875

6976
const [fakeIndex, setFakeIndex] = useState(1);
7077
const [isTransitioning, setIsTransitioning] = useState(true);
@@ -130,9 +137,7 @@ const InfiniteBanner = ({
130137
className="flex h-full will-change-transform"
131138
style={{
132139
transform: `translateX(-${fakeIndex * 100}%)`,
133-
transition: isTransitioning
134-
? "transform 600ms cubic-bezier(0.25, 1, 0.5, 1)"
135-
: "none",
140+
transition: isTransitioning ? "transform 600ms cubic-bezier(0.25, 1, 0.5, 1)" : "none",
136141
width: `${clonedBannerImages.length * 100}%`,
137142
}}
138143
onTransitionEnd={handleTransitionEnd}
@@ -142,22 +147,20 @@ const InfiniteBanner = ({
142147
const isResponsive = typeof img !== "string";
143148
return (
144149
<div className="flex-none w-full h-full" key={idx}>
145-
<a href={banner.link} className="block w-full h-full">
150+
<a
151+
href={banner.link}
152+
target="_blank"
153+
rel="noopener noreferrer"
154+
className="block w-full h-full"
155+
>
146156
{isResponsive ? (
147157
<picture>
148158
{/* 데스크톱(≥1920px) → default */}
149-
<source
150-
media="(min-width: 1920px)"
151-
srcSet={img.default}
152-
/>
159+
<source media="(min-width: 1920px)" srcSet={img.default} />
153160
{/* 데스크톱(≥1280px) */}
154-
{img.lg && (
155-
<source media="(min-width: 1280px)" srcSet={img.lg} />
156-
)}
161+
{img.lg && <source media="(min-width: 1280px)" srcSet={img.lg} />}
157162
{/* 태블릿(≥768px) */}
158-
{img.md && (
159-
<source media="(min-width: 768px)" srcSet={img.md} />
160-
)}
163+
{img.md && <source media="(min-width: 768px)" srcSet={img.md} />}
161164
{/* 최종 폴백(모바일) */}
162165
<img
163166
src={img.default}

0 commit comments

Comments
 (0)