Skip to content

Commit

Permalink
Chat Block 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
eastshine94 committed Oct 9, 2020
1 parent c610532 commit 35ab6ec
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions client/src/components/chattingRoom/ChatBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {UserResponseDto} from '~/types/user';
import { BASE_IMG_URL } from '~/constants';
import { SeparationBlock } from './InfoBlock';

const Chat = styled.div`
const ChatWrapper = styled.div`
position: relative;
display: inline-block;
padding: 7px 8px;
Expand All @@ -21,7 +21,7 @@ const RightBlock = styled.div`
margin-left: 10px;
margin-right: 10px;
& ${Chat}{
& ${ChatWrapper}{
background-color: #ffec42;
text-align: left;
& span{
Expand Down Expand Up @@ -49,7 +49,7 @@ const LeftBlock = styled.div`
margin-left: 10px;
margin-right: 10px;
padding-left: 50px;
& ${Chat}{
& ${ChatWrapper}{
background-color: #fff;
& span{
position: absolute;
Expand Down Expand Up @@ -99,51 +99,52 @@ interface FriendChatProps {
onImgClick():void;
}

export const MyChat:React.FC<ChatProps> = ({msg, localeTime, content, notRead}) => {

export const Chat: React.FC<ChatProps> = ({msg, localeTime, notRead}) => {
return(
<ChatWrapper>
{msg}
<span className="time">{localeTime}</span>
<span className="not-read">{notRead > 0 ? notRead : ""}</span>
</ChatWrapper>
);
}


export const MyChat:React.FC<ChatProps> = (props) => {
const { content } = props;
return(
<React.Fragment>
{content? <SeparationBlock content={content}/> : null}
<RightBlock>
<div>
<Chat>
{msg}
<span className="time">{localeTime}</span>
<span className="not-read">{notRead > 0 ? notRead : ""}</span>
</Chat>
<Chat {...props} />
</div>
</RightBlock>
</React.Fragment>
)
}

export const FriendChat:React.FC<ChatProps> = ({msg, localeTime, notRead}) => {
export const FriendChat:React.FC<ChatProps> = (props) => {
return (
<LeftBlock>
<div>
<Chat>
{msg}
<span className="time">{localeTime}</span>
<span className="not-read">{notRead > 0 ? notRead : ""}</span>
</Chat>
<Chat {...props} />
</div>
</LeftBlock>
)
}

export const FriendChatWithThumbnail: React.FC<FriendChatProps> = (props) => {
const {user, msg, localeTime, content, notRead, onImgClick} = props
const {user, content, onImgClick} = props
return(
<React.Fragment>
{content? <SeparationBlock content={content}/> : null}
<LeftBlock>
<img src={ user.profile_img_url || BASE_IMG_URL } alt="thumbnail" onClick={onImgClick}/>
<NameBlock>{user.name}</NameBlock>
<div>
<Chat>
{msg}
<span className="time">{localeTime}</span>
<span className="not-read">{notRead > 0 ? notRead : ""}</span>
</Chat>
<Chat {...props} />
</div>
</LeftBlock>
</React.Fragment>
Expand Down

0 comments on commit 35ab6ec

Please sign in to comment.