-
Notifications
You must be signed in to change notification settings - Fork 6
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
[CHAT] 사이드바 UI 수정 및 채팅방 컴포넌트 생성 #137
Merged
Merged
Changes from all commits
Commits
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 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,36 @@ | ||
import React, { useCallback } from 'react' | ||
import useChatRoomStore from '../../store/useChatRoomStore' | ||
import { Box, styled } from '@mui/material'; | ||
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos"; | ||
|
||
const ChatRoomSideBar = () => { | ||
const setIsChatRoomShow = useChatRoomStore((state)=> state.setIsChatRoomShow); | ||
const handleChatRoomClose = useCallback(()=>{ | ||
setIsChatRoomShow(false); | ||
},[setIsChatRoomShow]) | ||
|
||
|
||
const DrawerHeader = styled("div")(({ theme }) => ({ | ||
display: "flex", | ||
height: "8rem", | ||
alignItems: "center", | ||
padding: theme.spacing(0, 1), | ||
...theme.mixins.toolbar, | ||
justifyContent: "flex-start", | ||
})); | ||
|
||
return ( | ||
<DrawerHeader > | ||
<ArrowForwardIosIcon | ||
onClick={handleChatRoomClose} | ||
sx={{color:"white"}} | ||
className="cursor-pointer" | ||
/> | ||
<Box> | ||
<div >다이렉트 메세지</div> | ||
</Box> | ||
</DrawerHeader> | ||
) | ||
} | ||
|
||
export default ChatRoomSideBar |
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,28 @@ | ||
import { Box } from '@mui/material' | ||
import React, { useMemo } from 'react' | ||
|
||
interface DropDownProps{ | ||
dropDownItems : string[]; | ||
} | ||
|
||
const DropDown: React.FC<DropDownProps> = ({dropDownItems}) => { | ||
|
||
const dropDownList = useMemo(()=>{ | ||
return dropDownItems.map((item, index)=>{ | ||
return <li className='h-10 leading-10'>{item}</li> | ||
}) | ||
},[dropDownItems]) | ||
|
||
|
||
return ( | ||
<Box className='absolute top-11 right-0 w-32 h-auto z-50 bg-dark text-pink shadow-md'> | ||
<ul className='flex flex-col items-center'> | ||
{ | ||
dropDownList | ||
} | ||
</ul> | ||
</Box> | ||
) | ||
} | ||
|
||
export default DropDown |
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
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,33 @@ | ||
import { List } from "@mui/material"; | ||
import MemberListItem from "./MemberListItem"; | ||
import MemberProfile from "../Profile/MemberProfile"; | ||
import React from "react"; | ||
import { Member } from "../../types/layout"; | ||
|
||
interface MemberListProps{ | ||
memberList: Member[] | ||
} | ||
|
||
// TODO : 오른쪽 사이드바 멤버 리스트 | ||
const MemberList : React.FC<MemberListProps> = ({memberList}) => { | ||
const [openProfile, setOpenProfile] = React.useState(false); | ||
const handleProfileOpen = () => setOpenProfile(true); | ||
const handleProfileClose = () => setOpenProfile(false); | ||
|
||
return ( | ||
<> | ||
<List className="overflow-auto scrollbar-hide"> | ||
{memberList.map(member=>( | ||
<MemberListItem member={member} handleProfileOpen = {handleProfileOpen}/> | ||
))} | ||
</List> | ||
<MemberProfile | ||
openModal={openProfile} | ||
closeModal={handleProfileClose} | ||
></MemberProfile> | ||
</> | ||
|
||
) | ||
} | ||
|
||
export default MemberList |
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,53 @@ | ||
import { Member } from "../../types/layout" | ||
import { | ||
Avatar, | ||
Badge, | ||
ListItem, | ||
ListItemAvatar, | ||
ListItemText, | ||
} from "@mui/material"; | ||
import useChatRoomStore from "../../store/useChatRoomStore"; | ||
import { useCallback } from "react"; | ||
interface MemberListItemProps{ | ||
member: Member; | ||
handleProfileOpen : () => void; | ||
} | ||
|
||
const MemberListItem : React.FC<MemberListItemProps>= ({member, handleProfileOpen}) => { | ||
|
||
const setIsChatRoomShow = useChatRoomStore((state)=> state.setIsChatRoomShow); | ||
const handleChatRoomOpen = useCallback(()=>{ | ||
setIsChatRoomShow(true) | ||
},[setIsChatRoomShow]) | ||
|
||
return ( | ||
<div> | ||
<ListItem sx={{'&:hover': { | ||
backgroundColor: "#FDE2F3", | ||
} | ||
}}> | ||
<ListItemAvatar onClick={handleProfileOpen}> | ||
<Badge | ||
color="success" | ||
variant="dot" | ||
overlap="circular" | ||
sx={{cursor: "pointer"}} | ||
anchorOrigin={{ vertical: "bottom", horizontal: "right" }} | ||
> | ||
<Avatar | ||
alt="user nickname" | ||
src={member.profilePath} | ||
/> | ||
</Badge> | ||
</ListItemAvatar> | ||
<ListItemText | ||
primary={member.userName} | ||
sx={{cursor: "pointer"}} | ||
onClick={handleChatRoomOpen} | ||
/> | ||
</ListItem> | ||
</div> | ||
) | ||
} | ||
|
||
export default MemberListItem |
Oops, something went wrong.
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.
useMemo와 useCallback 둘 다 사용하셔서 둘의 차이점 비교하는데 도움이 되었습니다! 혹시 처음부터 최적화를 미리 고려하셔서 사용하신건가요? 저는 아직 최적화를 고려해서 짜기 보다는 기능 먼저 되면 나중에 리펙토링하는 식으로 코드를 짜는편이라..허헣
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.
아 최적화에 대해서 아직 많이 몰라서 ㅋㅋ... 좀 더 공부해야겠지만 메모이제이션된 값을 쓰면 좋을 것 같다고 개인적으로 판단했을 때 씁니다. 적절하게 사용했는지는 잘 모르겠네요 아래는 지피티 선생님에게 useMemo를 상태 업데이트가 빈번하게 나타나는 경우에 쓰는게 좋은지 여쭈어보았을 때 답입니다