-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from boostcampwm-2024/feature-fe-#209
프로필 수정 기능 추가, useCursor에서 프로필 사용하게 수정
- Loading branch information
Showing
6 changed files
with
335 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import logo from "/logo.png?url"; | ||
|
||
export default function LogoBtn() { | ||
interface LogoBtnProps { | ||
onClick?: () => void; | ||
} | ||
export default function LogoBtn({ onClick }: LogoBtnProps) { | ||
return ( | ||
<div className="h-8 w-8 overflow-clip rounded-md"> | ||
<button className="h-8 w-8 overflow-clip rounded-md" onClick={onClick}> | ||
<img src={logo} /> | ||
</div> | ||
</button> | ||
); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { useEffect, useState } from "react"; | ||
import Button from "../commons/button"; | ||
import { Dialog } from "../commons/dialog"; | ||
import { Compact } from "@uiw/react-color"; | ||
import useUserStore from "@/store/useUserStore"; | ||
|
||
type RemoveNoteModalProps = { | ||
isOpen: boolean; | ||
onConfirm: () => void; | ||
onCloseModal: () => void; | ||
}; | ||
|
||
export default function ProfileModal({ | ||
isOpen, | ||
onConfirm, | ||
onCloseModal, | ||
}: RemoveNoteModalProps) { | ||
const { currentUser, setCurrentUser, provider } = useUserStore(); | ||
const [hex, setHex] = useState(currentUser.color); | ||
const [isColorPickerOpen, setIsColorPickerOpen] = useState(false); | ||
const [nickname, setNickname] = useState(currentUser.clientId); | ||
|
||
useEffect(() => { | ||
setNickname(currentUser.clientId); | ||
setHex(currentUser.color); | ||
}, [currentUser]); | ||
|
||
return ( | ||
<Dialog isOpen={isOpen} onCloseModal={onCloseModal}> | ||
<div className="flex flex-col items-center gap-4"> | ||
<div className="flex flex-col items-center gap-1.5"> | ||
<Dialog.Title>프로필 수정</Dialog.Title> | ||
</div> | ||
<div className="flex flex-row items-center gap-3"> | ||
<button | ||
className="h-12 w-12 rounded-full border-[1px] border-black" | ||
style={{ backgroundColor: hex }} | ||
onClick={() => setIsColorPickerOpen(!isColorPickerOpen)} | ||
/> | ||
|
||
<input | ||
className={ | ||
"h-10 rounded-md border-[1px] border-[#eaeaea] p-2 text-sm text-[#141414] outline-none" | ||
} | ||
placeholder="닉네임을 입력하세요" | ||
value={nickname} | ||
onChange={(e) => setNickname(e.target.value)} | ||
/> | ||
</div> | ||
<div className=""> | ||
{isColorPickerOpen && ( | ||
<Compact color={hex} onChange={(color) => setHex(color.hex)} /> | ||
)} | ||
</div> | ||
|
||
<div className="flex w-full flex-row justify-between gap-2"> | ||
<Button | ||
className="w-full rounded-lg bg-[#171717] text-neutral-100 hover:bg-slate-800" | ||
onClick={() => { | ||
provider.awareness.setLocalStateField("color", hex); | ||
provider.awareness.setLocalStateField("clientId", nickname); | ||
|
||
setCurrentUser({ | ||
...currentUser, | ||
color: hex, | ||
clientId: nickname, | ||
}); | ||
|
||
onConfirm(); | ||
}} | ||
> | ||
확인 | ||
</Button> | ||
<Button | ||
className="w-full rounded-lg bg-[#f4f4f5] text-neutral-700 hover:bg-neutral-200" | ||
onClick={onCloseModal} | ||
> | ||
취소 | ||
</Button> | ||
</div> | ||
</div> | ||
<Dialog.CloseButton onCloseModal={onCloseModal} /> | ||
</Dialog> | ||
); | ||
} |
This file contains 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 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
Oops, something went wrong.