Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
35 changes: 0 additions & 35 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,38 +133,3 @@ div.swiper-scrollbar-drag {
div.swiper-scrollbar {
background: var(--color-gray-300);
}

/* 스켈레톤 애니메이션 */

@-webkit-keyframes skeleton-gradient {
0% {
background-color: rgba(165, 165, 165, 0.1);
}

50% {
background-color: rgba(165, 165, 165, 0.3);
}

100% {
background-color: rgba(165, 165, 165, 0.1);
}
}

@keyframes skeleton-gradient {
0% {
background-color: rgba(165, 165, 165, 0.1);
}

50% {
background-color: rgba(165, 165, 165, 0.3);
}

100% {
background-color: rgba(165, 165, 165, 0.1);
}
}

.skeleton-gradient {
-webkit-animation: skeleton-gradient 1.8s infinite ease-in-out;
animation: skeleton-gradient 1.8s infinite ease-in-out;
}
144 changes: 74 additions & 70 deletions src/app/myprofile/_components/my-profile/my-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import { useInfiniteScroll } from "@/hooks/use-infinite-scroll";
import getUserReview from "@/api/my-profile/get-user-review";
import getUserWines from "@/api/user/get-user-wines";
import { EmptyState } from "@/components";
import Loader from "@/components/loader/loader";
import CardSkeleton from "@/components/card/card-skeleton";

const WINE_ITEM_CONTAINER = cn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

별거 아니지만 모바일 -> 태블릿 -> 데스크탑 순서로 바꾸시면 연수님이 작성하신 다른 파일들과 동일해서 좋을 것 같아요!

"grid w-full gap-y-[16px] pt-[24px]",
"tablet:grid-cols-2 tablet:gap-x-[16px] tablet:gap-y-[32px]",
"pc:grid-cols-3 pc:gap-x-[15px] pc:gap-y-[40px] pc:pt-[40px]"
);

interface MyProfileProps {
userInfo: User;
Expand Down Expand Up @@ -61,80 +65,80 @@ const MyProfile = ({ userInfo }: MyProfileProps) => {
if (!userInfo) return redirect("/login");

return (
<main className="flex-col-center mx-auto w-full pc:flex-row pc:items-start">
<article className="container w-full">
<ProfileTabs tab={tab} setTab={setTab} />
<section className="mt-[61px] tablet:mt-[67px] pc:mt-[70px]">
{tab === "review" && (
<>
{reviewIsLoading ? (
<Loader />
) : userReview?.length === 0 || reviewIsError ? (
<EmptyState
icon="EmptyStateIcon"
title="아직 등록된 리뷰가 없습니다."
description="리뷰를 등록해보세요!"
/>
) : (
(userReview as ReviewItemType[])?.map((review) => (
<ReviewItem key={review.id} review={review} />
))
)}
<div ref={reviewObserverRef} className="mt-[100px] h-1 w-full" />
</>
)}
<>
<main className="flex-col-center mx-auto w-full pc:flex-row pc:items-start">
<article className="container w-full">
<ProfileTabs tab={tab} setTab={setTab} />
<section className="mt-[61px] tablet:mt-[67px] pc:mt-[70px]">
{tab === "review" && (
<>
{reviewIsLoading && (
<>
{Array.from({ length: 4 }).map((_, i) => (
<ReviewItem key={`skeleton-${i}`} skeleton />
))}
</>
)}
{userReview?.length === 0 || reviewIsError ? (
<EmptyState
icon="EmptyStateIcon"
title="아직 등록된 리뷰가 없습니다."
description="리뷰를 등록해보세요!"
/>
) : (
(userReview as ReviewItemType[])?.map((review) => (
<ReviewItem key={review.id} review={review} />
))
)}
{isFetchingNextPage && (
<div className={WINE_ITEM_CONTAINER} ref={reviewObserverRef}>
{Array.from({ length: 4 }).map((_, i) => (
<ReviewItem key={`skeleton-${i}`} skeleton />
))}
</div>
)}
</>
)}

{tab === "registered" && (
<>
{wineIsLoading ? (
<Loader />
) : userWinesTotalCount === 0 || wineIsError ? (
<EmptyState
icon="EmptyStateIcon"
title="아직 등록한 와인이 없어요!"
description="지금 첫 번째 와인을 등록해보세요"
actionLabel="와인 등록하기"
actionHref="/register/new"
/>
) : (
<>
<div
className={cn(
"grid w-full gap-y-[16px] pt-[24px]",
"pc:grid-cols-3 pc:gap-x-[15px] pc:gap-y-[40px] pc:pt-[40px]",
"tablet:grid-cols-2 tablet:gap-x-[16px] tablet:gap-y-[32px]"
)}
>
{tab === "registered" && (
<>
{wineIsLoading && (
<div className={WINE_ITEM_CONTAINER}>
{Array.from({ length: 6 }).map((_, i) => (
<WineItem key={`skeleton-${i}`} skeleton />
))}
</div>
)}
{userWinesTotalCount === 0 || wineIsError ? (
<EmptyState
icon="EmptyStateIcon"
title="아직 등록한 와인이 없어요!"
description="지금 첫 번째 와인을 등록해보세요"
actionLabel="와인 등록하기"
actionHref="/register/new"
/>
) : (
<div className={WINE_ITEM_CONTAINER}>
{(userWines as WineType[])?.map((wine) => (
<WineItem key={wine.id} wine={wine} />
))}
</div>
<div
ref={wineObserverRef}
className="mt-[100px] h-1 w-full"
/>
{wineIsLoading === false && isFetchingNextPage && (
<div
className={cn(
"grid w-full gap-y-[16px] pt-[24px]",
"pc:grid-cols-3 pc:gap-x-[15px] pc:gap-y-[40px] pc:pt-[40px]",
"tablet:grid-cols-2 tablet:gap-x-[16px] tablet:gap-y-[32px]"
)}
>
{Array.from({ length: 6 }).map((_, i) => (
<CardSkeleton key={i} />
))}
</div>
)}
</>
)}
</>
)}
)}
{isFetchingNextPage && (
<div className={WINE_ITEM_CONTAINER} ref={wineObserverRef}>
{Array.from({ length: 6 }).map((_, i) => (
<WineItem key={`skeleton-${i}`} skeleton />
))}
</div>
)}
</>
)}

{tab === "account" && <AccountItem user={userInfo} />}
</section>
</article>
</main>
{tab === "account" && <AccountItem user={userInfo} />}
</section>
</article>
</main>
</>
);
};

Expand Down
69 changes: 69 additions & 0 deletions src/app/myprofile/_components/review-item/review-item-skeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { cn } from "@/lib/utils";
import Skeleton from "react-loading-skeleton";
import "react-loading-skeleton/dist/skeleton.css";
import Image from "next/image";

const ReviewItemSkeleton = () => {
return (
<div
className={cn(
"flex flex-col gap-[51px] border-b border-gray-300 py-[16px] pb-[28px] pt-[39px]",
"tablet:gap-[54px]",
"pc:gap-[50px] pc:py-[80px]"
)}
>
<div className="flex w-full flex-col items-start justify-center gap-8 px-[14px]">
<div className="flex w-full flex-col items-center justify-center gap-[26px]">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flex flex-col items-center justify-center 부분은 globals.css에 정의된 flex-col-center로 대체해도 좋을 것 같습니다.
사소한 부분이라 수정하지 않으셔도 괜찮습니다!

<div className="flex w-full flex-col items-start gap-5">
{/*별점 컴포넌트 */}
<Skeleton width={200} height={20} />
{/* 와인 정보 */}
<div
className={cn(
"flex w-full items-center gap-2",
"tablet:gap-4",
"pc:gap-[17px]"
)}
>
<div className="relative h-[80px] w-[60px]">
<Image
src="/images/placeholder/img-wine.svg"
alt="wine placeholder"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스켈레톤 상태에서는 alt=""로 비워두는 것이 접근성 측면에서 더 적절합니다.

  • 실제 콘텐츠가 아니라 시각적인 위치나 형태만 보여주는 용도이기 때문입니다.
  • alt=""를 사용하면 스크린 리더가 해당 이미지를 건너뛰어 불필요하게 파일명을 읽는 문제를 방지할 수 있습니다.
  • wine placeholder라는 텍스트를 읽는 것은 사용자 입장에서 오히려 혼란을 줄 수 있습니다.

스켈레톤 이미지나 placeholder 이미지는 alt를 비워두는 방식을 많이 사용합니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

웹 콘텐츠 접근성 지침 에서 alt 검색하면 나오는 내용입니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 네! 말씀해주신 부분은 인지하고 있는 내용인데 놓치고 있었습니다 체크해주셔서 감사합니다!!

fill
/>
</div>
<div>
<Skeleton width={300} height={20} style={{ marginBottom: 6 }} />
<Skeleton width={100} height={16} />
</div>
</div>
</div>
<div className="w-full">
{/* FlavorIconList 컴포넌트 */}
<Skeleton width={600} height={20} style={{ marginBottom: 6 }} />
</div>
{/* 리뷰 내용 */}
<div className="w-full">
<Skeleton width="100%" height={20} style={{ marginBottom: 8 }} />
<Skeleton width="85%" height={20} />
</div>
</div>

{/* WineTaste 컴포넌트 */}
<div
className={cn(
"flex w-full flex-col gap-3",
"tablet:grid tablet:grid-cols-2 tablet:gap-4",
"pc:grid pc:grid-cols-2 pc:gap-4"
)}
>
{Array.from({ length: 4 }).map((_, i) => (
<Skeleton key={i} width="100%" height={16} />
))}
</div>
</div>
</div>
);
};

export default ReviewItemSkeleton;
16 changes: 14 additions & 2 deletions src/app/myprofile/_components/review-item/review-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@ import { buildTasteData } from "@/components/wine-taste";
import { ReviewItemType } from "../../_types/review-type";
import { ReviewInfo, ReviewRating } from ".";
import FlavorIconList from "@/components/flavor-icon-list/flavor-icon-list";
import ReviewItemSkeleton from "./review-item-skeleton";

const ReviewItem = ({ review }: { review: ReviewItemType }) => {
const ReviewItem = ({
review,
skeleton = false,
}: {
review?: ReviewItemType;
skeleton?: boolean;
}) => {
const [optionMenu, setOptionMenu] = useState(false);

if (skeleton) {
return <ReviewItemSkeleton />;
}

if (!review) return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서는 if 문에 블록({})을 사용했는데, 아래에서는 생략되어 있네요.
일관된 코드 스타일을 유지하려면 둘 다 동일하게 처리하는 게 좋을 것 같습니다.


const tastes = buildTasteData({
lightBold: review.lightBold,
smoothTannic: review.smoothTannic,
drySweet: review.drySweet,
softAcidic: review.softAcidic,
});

return (
<div
className={cn(
Expand Down
2 changes: 1 addition & 1 deletion src/app/myprofile/_components/wine-item/wine-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const WineItem = ({ wine, skeleton = false }: WineItemProps) => {
};

if (skeleton) {
return <CardSkeleton hasActionMenu />;
return <CardSkeleton />;
}

if (!wine) return null;
Expand Down
12 changes: 1 addition & 11 deletions src/components/card/card-skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import "react-loading-skeleton/dist/skeleton.css";

interface CardSkeletonProps {
showReview?: boolean;
hasActionMenu?: boolean;
}

const CardSkeleton = ({
showReview = false,
hasActionMenu = false,
}: CardSkeletonProps) => {
const CardSkeleton = ({ showReview = false }: CardSkeletonProps) => {
return (
<div className="group relative w-full">
{/* 이미지 영역 */}
Expand All @@ -29,12 +25,6 @@ const CardSkeleton = ({
<Skeleton width="83%" height={16} />
</>
)}
{/* 액션메뉴 (우측 상단) */}
{hasActionMenu && (
<div style={{ position: "absolute", right: 0, top: 0, zIndex: 10 }}>
<Skeleton circle width={32} height={32} />
</div>
)}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export { default as Card } from "./card/card";
export { default as LikeButton } from "./button/like-button";
export { default as Carousel } from "./carousel/carousel";
export { default as EmptyState } from "./empty-state/empty-state";
export { default as FloatingActions } from "./utils/floating-actions";
export { default as FloatingActions } from "./floating-actions/floating-actions";
export { default as ChatButton } from "./button/chat-button";
export { default as ChatBot } from "./chat-bot/chat-bot";