Skip to content

Commit 0498846

Browse files
committed
메인 칵테일로고 반응형
1 parent 2591b69 commit 0498846

File tree

6 files changed

+49
-20
lines changed

6 files changed

+49
-20
lines changed

src/domains/community/detail/ImageSlide.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function ImageSlide({ imageUrls }: { imageUrls: string[] }) {
3737
quality={90}
3838
priority
3939
onLoad={() => handleImageLoad(img)}
40-
onError={() => handleImageLoad(img)}
40+
onError={(e) => {
41+
// 402 에러 등으로 이미지 로딩 실패 시 fallback 이미지 사용
42+
e.currentTarget.src = '/CocktailDrop.webp';
43+
handleImageLoad(img);
44+
}}
4145
className={`object-contain w-full max-h-[400px] transition-opacity duration-300 ${
4246
loadedImages.has(img) ? 'opacity-100' : 'opacity-0'
4347
}`}

src/domains/community/main/PostCard.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ function PostCard({ posts, isLoading, isEnd, onLoadMore }: Props) {
106106
width={105}
107107
height={105}
108108
className="w-full h-full object-cover self-center rounded-md"
109+
onError={(e) => {
110+
// 402 에러 등으로 이미지 로딩 실패 시 fallback 이미지 사용
111+
e.currentTarget.src = '/CocktailDrop.webp';
112+
}}
109113
/>
110114
)}
111115
</figure>

src/domains/community/write/image-upload/UploadedImage.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ function UploadedImage({ uploadedFile, setUploadedFile }: Props) {
6868
width={100}
6969
height={100}
7070
unoptimized={true} // next/image가 외부 url 처리 못 하면 이 옵션도 추가 가능
71+
onError={(e) => {
72+
// 402 에러 등으로 이미지 로딩 실패 시 fallback 이미지 사용
73+
e.currentTarget.src = '/CocktailDrop.webp';
74+
}}
7175
/>
7276
<figcaption className="sr-only">업로드된 이미지입니다</figcaption>
7377
<button

src/domains/main/cocktailDrop/CocktailDrop.tsx

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import Image from 'next/image';
44
import Cocktailcup from '../../../../public/CocktailDrop.webp';
5-
import { useLayoutEffect, useRef } from 'react';
5+
import { useLayoutEffect, useRef, useState } from 'react';
66
import gsap from 'gsap';
77
import { ScrollTrigger } from 'gsap/all';
88
import PassBtn from './PassBtn';
@@ -15,6 +15,7 @@ interface CocktailDropProps {
1515

1616
function CocktailDrop({ isDesktop = false }: CocktailDropProps) {
1717
const containerRef = useRef<HTMLDivElement>(null);
18+
const cupRef = useRef<HTMLDivElement>(null);
1819
const logoRef = useRef<HTMLDivElement>(null);
1920
const line1Ref = useRef<HTMLDivElement>(null);
2021
const line2Ref = useRef<HTMLDivElement>(null);
@@ -43,25 +44,37 @@ function CocktailDrop({ isDesktop = false }: CocktailDropProps) {
4344
}
4445
);
4546

46-
// 로고 위에서 아래로 자연스럽게 등장
47-
const screenWidth = window.innerWidth;
47+
const cupElement = cupRef.current;
48+
const logoElement = logoRef.current;
4849

49-
const viewportHeight = window.innerHeight;
50-
const isTablet = screenWidth >= 640 && screenWidth < 1024;
51-
const isMobile = screenWidth < 640;
50+
if (!cupElement || !logoElement) return;
5251

53-
// 뷰포트 높이 기반으로 로고 위치 계산
54-
const logoFinalY = isMobile
55-
? `-${viewportHeight * 0.3}px`
56-
: isTablet
57-
? `-${viewportHeight * -0.8}px`
58-
: '210px';
52+
const cupRect = cupElement.getBoundingClientRect();
53+
const logoRect = logoElement.getBoundingClientRect();
5954

55+
// container 기준 상대 위치 계산
56+
const containerTop = containerRef.current?.getBoundingClientRect().top || 0;
57+
const cupTopRelative = cupRect.top - containerTop + 10;
58+
console.log('containerTop', containerTop);
59+
console.log('cupTopRelative', cupTopRelative);
60+
console.log('logoRect.height', logoRect.height);
61+
62+
const getFinalY = (width: number): number => {
63+
if (width >= 1800) return 200;
64+
if (width >= 1400) return 10;
65+
if (width >= 1024) return 295;
66+
if (width >= 800) return 50;
67+
return -235;
68+
};
69+
70+
// 내부에서 사용
71+
const finalY = getFinalY(window.innerWidth);
72+
console.log('finalY', finalY);
6073
gsap.fromTo(
6174
logoRef.current,
6275
{ y: -300, opacity: 0 },
6376
{
64-
y: logoFinalY, // 뷰포트 높이 기반 계산
77+
y: finalY, // 뷰포트 높이 기반 계산
6578
opacity: 1,
6679
duration: 3,
6780
ease: 'power3.out',
@@ -82,22 +95,22 @@ function CocktailDrop({ isDesktop = false }: CocktailDropProps) {
8295
return (
8396
<div
8497
ref={containerRef}
85-
className="relative w-full lg:min-h-[120vh] md:min-h-[95vh] min-h-[87vh] flex flex-col lg:justify-center md:justify-center justify-end items-center mt-10 overflow-hidden"
98+
className="relative w-full xl:min-h-[140vh] lg:min-h-[120vh] md:min-h-[95vh] min-h-[87vh] flex flex-col lg:justify-center md:justify-center justify-end items-center mt-10 overflow-hidden"
8699
id="scroll-fixed"
87100
>
88101
{/* 대각선 줄 1 */}
89102
<div
90103
ref={line1Ref}
91-
className="absolute lg:top-[150px] md:top-[100px] top-[75px] left-[-50%] w-[200%] md:h-[80px] h-[50px] bg-secondary/80 rotate-[8deg] z-10"
104+
className="absolute md:top-[100px] top-[75px] left-[-50%] w-[200%] md:h-[80px] h-[50px] bg-secondary/80 rotate-[8deg] z-10"
92105
/>
93106
{/* 대각선 줄 2 */}
94107
<div
95108
ref={line2Ref}
96-
className="absolute lg:top-[250px] md:top-[200px] top-[150px] left-[-50%] w-[200%] md:h-[80px] h-[50px] bg-secondary rotate-[8deg] z-10"
109+
className="absolute md:top-[200px] top-[150px] left-[-50%] w-[200%] md:h-[80px] h-[50px] bg-secondary rotate-[8deg] z-10"
97110
/>
98111

99112
{/* 로고 */}
100-
<div ref={logoRef} className="absolute z-4 lg:w-125 md:w-115 w-65 lg:h-110 md:h-90 h-40">
113+
<div ref={logoRef} className="absolute z-4 lg:w-125 md:w-115 w-65 lg:h-60 md:h-50 h-20">
101114
<Image
102115
src="/logo.svg"
103116
alt="로고 이미지"
@@ -109,7 +122,7 @@ function CocktailDrop({ isDesktop = false }: CocktailDropProps) {
109122
</div>
110123

111124
{/* 컵 이미지 - 모바일에서 바닥에 붙도록 */}
112-
<div className="z-5 absolute bottom-0">
125+
<div className="z-5 absolute bottom-0" ref={cupRef}>
113126
<Image
114127
src={Cocktailcup}
115128
alt="칵테일 컵"

src/domains/main/components/3d/HomeText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function HomeText({ isDesktop }: { isDesktop: boolean }) {
77
SSoul이 쉽게 골라드릴게요.
88
</p>
99
) : (
10-
<p className="absolute bottom-45 right-32 font-serif text-2xl text-right font-normal z-20">
10+
<p className="absolute bottom-45 right-32 font-serif text-xl text-right font-normal z-20">
1111
어떤 칵테일이 끌리시나요? <br /> SSoul이 쉽게 골라드릴게요.
1212
</p>
1313
)}

src/domains/recipe/components/details/DetailItem.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ function DetailItem({ name, nameKo, story, src, abv, glassType }: Props) {
6060
className="object-cover"
6161
sizes="300px"
6262
priority
63+
onError={(e) => {
64+
// 402 에러 등으로 이미지 로딩 실패 시 fallback 이미지 사용
65+
e.currentTarget.src = '/CocktailDrop.webp';
66+
}}
6367
/>
6468
</div>
6569

0 commit comments

Comments
 (0)