-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/#87/close button #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,21 +16,6 @@ const MyPage = () => { | |
| const [currentPage, setCurrentPage] = useState(0); | ||
| const [itemsPerPage, setItemsPerPage] = useState(16); | ||
|
|
||
| const favoriteIdSet = new Set(favoriteIdols.map(Number)); // 숫자로 변환한 Set 생성 | ||
| const favoriteIdolsArr = idols.filter((idol) => favoriteIdSet.has(idol.id)); | ||
|
|
||
| const handleAddToFavorites = () => { | ||
| if (selectedIdols.length === 0) return; | ||
|
|
||
| setFavoriteIdols((prev) => { | ||
| const updatedFavorites = [...new Set([...prev, ...selectedIdols])]; | ||
| localStorage.setItem(storageKey, updatedFavorites.join(',')); // localStorage 업데이트 | ||
| return updatedFavorites; | ||
| }); | ||
|
|
||
| setSelectedIdols([]); // 선택된 아이돌 초기화 | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| const updateItemsPerPage = () => { | ||
| const width = window.innerWidth; | ||
|
|
@@ -55,9 +40,9 @@ const MyPage = () => { | |
| useEffect(() => { | ||
| const storedFavorites = localStorage.getItem(storageKey); | ||
| if (storedFavorites) { | ||
| setFavoriteIdols(storedFavorites.split(',')); | ||
| setFavoriteIdols(storedFavorites.split(',').map(Number)); | ||
| } | ||
| }, []); // `favoriteIdols` 변경될 때마다 실행 | ||
| }, []); | ||
|
|
||
| const handleToggle = (idolId) => { | ||
| setSelectedIdols((prev) => | ||
|
|
@@ -67,9 +52,21 @@ 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([]); | ||
| }; | ||
|
|
||
| const handleRemoveFavorite = (idolId) => { | ||
| setFavoriteIdols((prev) => { | ||
| const updatedFavorites = prev.filter((id) => id !== idolId.toString()); | ||
| const updatedFavorites = prev.filter((id) => id !== idolId); | ||
| localStorage.setItem(storageKey, updatedFavorites.join(',')); | ||
| return updatedFavorites; | ||
| }); | ||
|
|
@@ -89,75 +86,62 @@ const MyPage = () => { | |
| <div className="w-full min-h-screen bg-midnightBlack flex flex-col items-center font-pretendard"> | ||
| <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"> | ||
| 내가 관심있는 아이돌 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분 피그마에는 '관심있는'으로 되어있는데 '관심 있는'으로 수정하면 좋을 것 같습니다! |
||
| </h1> | ||
|
|
||
| <div className="w-full overflow-x-auto whitespace-nowrap scrollbar-hide"> | ||
| <div className=" flex gap-5 mt-4 mx-auto min-h-[150px]"> | ||
| {favoriteIdolsArr.map((idol) => ( | ||
| <div key={idol.id} className="relative"> | ||
| <CheckedIdolCard | ||
| className="relative" | ||
| idol={idol} | ||
| isSelectable={false} | ||
| sizeClass="w-[100px] h-[100px]" | ||
| > | ||
| {/* 닫기 버튼 */} | ||
| {/* X 버튼 (항상 테두리 상단에 고정) */} | ||
| <button | ||
| onClick={() => handleRemoveFavorite(idol.id)} | ||
| className="absolute top-0 right-0 | ||
| flex items-center justify-center bg-transparent | ||
| transition-opacity z-30 " | ||
| <div className="flex gap-5 mt-4 mx-auto min-h-[150px]"> | ||
| {favoriteIdols.map((idolId) => { | ||
| const idol = idols.find((i) => i.id === idolId); | ||
| if (!idol) return null; | ||
|
|
||
| return ( | ||
| <div key={idol.id} className="relative"> | ||
| <CheckedIdolCard | ||
| idol={idol} | ||
| isSelectable={false} | ||
| sizeClass="w-[100px] h-[100px]" | ||
| > | ||
| <img src={xButton} alt="Remove" className="w-full h-full" /> | ||
| </button> | ||
| </CheckedIdolCard> | ||
| </div> | ||
| ))} | ||
| <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" | ||
| > | ||
| <img | ||
| src={xButton} | ||
| alt="Remove" | ||
| className="w-full h-full" | ||
| /> | ||
| </button> | ||
| </CheckedIdolCard> | ||
| </div> | ||
| ); | ||
| })} | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* 회색 구분선 */} | ||
| <div className="relative w-full max-w-[1200px] mt-4 border-t border-gray-900" /> | ||
|
|
||
| {/* 아이돌 추가하기 섹션 */} | ||
| <h2 className="text-white text-[16px] tablet:text-[20px] pc:text-[24px] font-pretendard 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%] tablet:left-[-6%] pc:left-[-4%] top-1/2 transform -translate-y-1/2 | ||
| 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> | ||
| {/* 이후 버튼 */} | ||
| <button | ||
| onClick={nextPage} | ||
| disabled={(currentPage + 1) * itemsPerPage >= idols.length} | ||
| className="absolute right-[1%] tablet:right-[-6%] pc: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 className="grid grid-cols-3 tablet:grid-cols-4 pc:grid-cols-8 gap-3 mt-4 mx-auto min-h-[300px]"> | ||
|
|
||
| {/* 아이돌 리스트 */} | ||
| <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, | ||
|
|
@@ -173,18 +157,28 @@ const MyPage = () => { | |
| /> | ||
| ))} | ||
| </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> | ||
|
|
||
| {/* 추가하기 버튼 */} | ||
| <div className="flex justify-center w-full"> | ||
| <PrimaryButton | ||
| onClickFunc={handleAddToFavorites} | ||
| className="w-[255px] h-[48px] mt-10 text-white rounded-full font-pretendard font-bold text-[16px]" | ||
| > | ||
| + 추가하기 | ||
| </PrimaryButton> | ||
| </div> | ||
| <PrimaryButton | ||
| onClickFunc={handleAddToFavorites} | ||
| className="w-[255px] h-[48px] mt-10 text-white rounded-full font-pretendard font-bold text-[16px]" | ||
| > | ||
| + 추가하기 | ||
| </PrimaryButton> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tablet, Mobile 화면에서 요소들이 너무 화면 좌우에 딱 붙어있는 것 같습니다. 피그마를 확인해보면 padding이 24px씩 되어있네요.

여기에 px-[24px] 해주면 어떨까 싶습니다.