Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 13 additions & 4 deletions src/pages/myPage/CheckedIdolCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const CheckedIdolCard = ({
idol,
isSelectable = true,
isSelected = false,
isDisabled = false,
sizeClass = 'w-[98px] h-[98px] tablet:w-[128px] tablet:h-[128px]',
onClick,
}) => {
Expand All @@ -15,12 +16,12 @@ const CheckedIdolCard = ({
<div className="p-1 flex flex-col items-center relative">
<div
className={`relative ${sizeClass} p-[2px] flex items-center justify-center rounded-full
${isSelectable ? 'cursor-pointer' : 'cursor-default'} transition-all`}
onClick={isSelectable ? () => onClick(idol.id) : undefined}
${isDisabled ? 'opacity-50 cursor-not-allowed' : isSelectable ? 'cursor-pointer' : 'cursor-default'} transition-all`} // 비활성화된 경우 투명도 50%
onClick={!isDisabled && isSelectable ? () => onClick(idol.id) : undefined} // 비활성화된 경우 클릭 방지
>
{children}
<div className="absolute inset-0 rounded-full border-[1.3px] border-coralRed z-10"></div>

<div className="absolute inset-0 m-1.5 rounded-full overflow-hidden">
<img
src={idol.profilePicture || defaultImage}
Expand All @@ -29,6 +30,14 @@ const CheckedIdolCard = ({
/>
</div>

{/* 비활성화된 경우 클릭 차단 & 마우스 금지 커서 적용 */}
{isDisabled && (
<div
className="absolute inset-0 w-full h-full cursor-not-allowed"
style={{ cursor: 'not-allowed', pointerEvents: 'auto' }}
/>
)}

{isSelected && isSelectable && (
<>
<div className="absolute inset-0 rounded-full bg-gradient-to-r from-coralRed to-pinkPunch opacity-50 z-20" />
Expand All @@ -40,7 +49,7 @@ const CheckedIdolCard = ({
</>
)}
</div>

<div className="mt-1 text-center">
<p className="text-white text-mobile font-bold">{idol.name}</p>
<p className="text-white/70 text-xs">{idol.group || '그룹 없음'}</p>
Expand Down
127 changes: 70 additions & 57 deletions src/pages/myPage/MyPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const MyPage = () => {
const width = window.innerWidth;
if (width >= 1200) setItemsPerPage(16);
else if (width >= 768) setItemsPerPage(8);
else if (width >= 375) setItemsPerPage(6);
else setItemsPerPage(6);
};

Expand All @@ -45,6 +46,7 @@ const MyPage = () => {
}, []);

const handleToggle = (idolId) => {
if (favoriteIdols.includes(idolId)) return;
setSelectedIdols((prev) =>
prev.includes(idolId)
? prev.filter((id) => id !== idolId)
Expand All @@ -54,13 +56,11 @@ const MyPage = () => {

const handleAddToFavorites = () => {
if (selectedIdols.length === 0) return;

setFavoriteIdols((prev) => {
const updatedFavorites = [...new Set([...prev, ...selectedIdols])];
localStorage.setItem(storageKey, updatedFavorites.join(','));
return updatedFavorites;
});

setSelectedIdols([]);
};

Expand All @@ -87,9 +87,9 @@ const MyPage = () => {
<Header />

{/* 관심 있는 아이돌 섹션 */}
<div className="w-full max-w-[1200px] flex flex-col items-center py-6 mobile:py-10">
<h1 className="text-white text-[16px] tablet:text-[20px] pc:text-[24px] font-pretendard font-bold self-start">
내가 관심있는 아이돌
<div className="w-full max-w-[1200px] flex flex-col items-center py-6 mobile:py-10 px-[24px]">
<h1 className="text-white text-[16px] tablet:text-[20px] pc:text-[24px] font-bold self-start">
내가 관심 있는 아이돌
</h1>

<div className="w-full overflow-x-auto whitespace-nowrap scrollbar-hide">
Expand All @@ -99,83 +99,96 @@ const MyPage = () => {
if (!idol) return null;

return (
<div key={idol.id} className="relative">
<div key={idol.id} className="relative cursor-default">
<CheckedIdolCard
idol={idol}
isSelectable={false}
isDisabled={false}
sizeClass="w-[100px] h-[100px]"
>
<button
onClick={() => handleRemoveFavorite(idol.id)}
className="absolute -top-2 -right-2 w-6 h-6 z-50 flex items-center justify-center bg-transparent transition-opacity"
className="absolute -top-0 -right-[0] w-7 h-7 z-50 flex items-center justify-center
bg-transparent transition-opacity cursor-pointer"
>
<img
src={xButton}
alt="Remove"
className="w-full h-full"
/>
<img src={xButton} alt="Remove" className="w-full h-full" />
</button>
</CheckedIdolCard>
</div>
);
})}
</div>
</div>

<div className="w-full max-w-[1200px] border-b border-gray-700 my-6"></div>

<h2 className="text-white text-[16px] tablet:text-[20px] pc:text-[24px] font-pretendard font-bold self-start mt-6">
<h2 className="text-white text-[16px] tablet:text-[20px] pc:text-[24px] font-bold self-start mt-6">
관심 있는 아이돌을 추가해보세요.
</h2>

{/* 이전 버튼 */}
<div className="relative w-full max-w-[1200px] mt-[20px]">
<button
onClick={prevPage}
disabled={currentPage === 0}
className="absolute left-[1%] md:left-[-6%] lg:left-[-4%] top-1/2 transform -translate-y-1/2
w-[29px] h-[135px] rounded-[4px]
bg-[rgba(27,27,27,0.8)]
hover:bg-[rgba(27,27,27,1)] transition-all
flex items-center justify-center"
>
<img src={prevIcon} alt="Previous" className="w-4 h-4" />
</button>

{/* 아이돌 리스트 */}
<div className="grid grid-cols-3 md:grid-cols-4 lg:grid-cols-8 gap-3 mt-4 mx-auto min-h-[300px]">
{idols
.slice(
currentPage * itemsPerPage,
(currentPage + 1) * itemsPerPage
)
.map((idol) => (
</div>

<div className="relative w-full max-w-[1200px] mt-[10px]">

<button
onClick={prevPage}
disabled={currentPage === 0}
className="absolute left-[1%] tablet:left-[1.5%] pc:left-[-4.5%] top-1/2 transform -translate-y-1/2
bg-[rgba(27,27,27,0.8)] hover:bg-[rgba(27,27,27,1)] transition-all w-[29px] h-[135px]
rounded-[4px] flex items-center justify-center"
>
<img src={prevIcon}
alt="Previous"
className="w-[6px] h-[12px] object-contain"
/>
</button>

{/* 아이돌 리스트 */}
<div className="grid grid-cols-3 tablet:grid-cols-4 pc:grid-cols-8 gap-3.5
px-[8px] mt-0 mx-auto ">
{idols.slice(currentPage * itemsPerPage, (currentPage + 1) * itemsPerPage).map((idol) => {
const isDisabled = favoriteIdols.includes(idol.id);

return (
<div key={idol.id} className={`relative transition-opacity duration-300 ${isDisabled ? 'opacity-50' : ''}`}>
<CheckedIdolCard
key={idol.id}
idol={idol}
isSelectable={true}
isSelectable={!isDisabled}
isSelected={selectedIdols.includes(idol.id)}
onClick={() => handleToggle(idol.id)}
isDisabled={isDisabled}
onClick={(e) => {
if (isDisabled) {
e.preventDefault();
return;
}
handleToggle(idol.id);
}}
/>
))}
</div>

{/* 다음 버튼 (반응형 위치 조정) */}
<button
onClick={nextPage}
disabled={(currentPage + 1) * itemsPerPage >= idols.length}
className="absolute right-[1%] md:right-[-6%] lg:right-[-4%] top-1/2 transform -translate-y-1/2
w-[29px] h-[135px] rounded-[4px]
bg-[rgba(27,27,27,0.8)]
hover:bg-[rgba(27,27,27,1)] transition-all
flex items-center justify-center"
>
<img src={nextIcon} alt="Next" className="w-4 h-4" />
</button>
</div>
);
})}
</div>


<button
onClick={nextPage}
disabled={(currentPage + 1) * itemsPerPage >= idols.length}
className="absolute right-[1%] tablet:right-[1.5%] pc:right-[-4.5%] top-1/2 transform -translate-y-1/2
bg-[rgba(27,27,27,0.8)] hover:bg-[rgba(27,27,27,1)] transition-all w-[29px] h-[135px]
rounded-[4px] flex items-center justify-center"
>
<img
src={nextIcon}
alt="Next"
className="w-[6px] h-[12px] object-contain"
/>
</button>
</div>

<PrimaryButton
onClickFunc={handleAddToFavorites}
className="w-[255px] h-[48px] mt-10 text-white rounded-full font-pretendard font-bold text-[16px]"

<PrimaryButton
onClickFunc={handleAddToFavorites}
className="w-[255px] h-[48px] mt-10 text-white rounded-full font-bold
bg-gradient-to-r from-pink-500 to-red-500 hover:opacity-90"
>
+ 추가하기
</PrimaryButton>
Expand Down