-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: [FE] 프론트엔드 배포 (#223)
- Loading branch information
Showing
17 changed files
with
147 additions
and
103 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,17 +1,30 @@ | ||
import { memo } from 'react'; | ||
import { MessageData } from '@/types/chatting'; | ||
|
||
interface ChattingMessageProps { | ||
messageData: MessageData; | ||
isMyMessage: boolean; | ||
} | ||
|
||
export default function ChattingMessage({ messageData, isMyMessage }: ChattingMessageProps) { | ||
function ChattingMessage({ messageData, isMyMessage }: ChattingMessageProps) { | ||
const aiMessage = messageData.ai; | ||
const myMessage = !aiMessage && isMyMessage; | ||
|
||
const getMessageColor = () => { | ||
if (aiMessage) return 'bg-point-blue text-white'; | ||
if (myMessage) return 'bg-blue-100'; | ||
|
||
return 'bg-yellow-100'; | ||
}; | ||
|
||
return ( | ||
<div className={`flex flex-col gap-0.5 ${isMyMessage ? 'items-end' : 'items-start'}`}> | ||
<span className="mx-1 text-xs font-light ">{messageData.nickname}</span> | ||
<div className={`px-4 py-2 rounded-lg w-fit ${isMyMessage ? 'bg-blue-100' : 'bg-yellow-100'}`}> | ||
<span>{messageData.message}</span> | ||
<div className={`flex flex-col gap-0.5 ${myMessage ? 'items-end' : 'items-start'}`}> | ||
<span className="mx-1 text-xs font-light">{aiMessage ? '클로바 X' : messageData.nickname}</span> | ||
<div className={`px-4 py-2 rounded-lg w-fit ${getMessageColor()}`}> | ||
<span className="whitespace-pre-wrap">{messageData.message}</span> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default memo(ChattingMessage); |
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
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,14 +1,18 @@ | ||
import { useState } from 'react'; | ||
|
||
export default function useInput(initialValue: string) { | ||
export default function useInput<T extends HTMLInputElement | HTMLTextAreaElement>(initialValue: string) { | ||
const [inputValue, setInputValue] = useState(initialValue); | ||
|
||
const onChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const onChange = (event: React.ChangeEvent<T>) => { | ||
const { | ||
target: { value }, | ||
} = event; | ||
setInputValue(value); | ||
}; | ||
|
||
return { inputValue, onChange }; | ||
const resetInput = () => { | ||
setInputValue(''); | ||
}; | ||
|
||
return { inputValue, onChange, resetInput }; | ||
} |
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,28 @@ | ||
import { useRef, useState } from 'react'; | ||
|
||
let timer: NodeJS.Timeout | null; | ||
|
||
export default function useScroll<T extends HTMLElement>() { | ||
const [scrollRatio, setScrollRatio] = useState(100); | ||
const ref = useRef<T | null>(null); | ||
|
||
const handleScroll = () => { | ||
if (!timer) { | ||
timer = setTimeout(() => { | ||
timer = null; | ||
|
||
if (!ref.current) return; | ||
|
||
const { scrollTop, clientHeight, scrollHeight } = ref.current; | ||
setScrollRatio(((scrollTop + clientHeight) / scrollHeight) * 100); | ||
}, 200); | ||
} | ||
}; | ||
|
||
const moveToBottom = () => { | ||
if (ref.current) ref.current.scrollTop = ref.current.scrollHeight; | ||
setScrollRatio(100); | ||
}; | ||
|
||
return { ref, scrollRatio, handleScroll, moveToBottom }; | ||
} |
Oops, something went wrong.