Skip to content

Commit

Permalink
(#72) πŸš€ feat: 챗봇 μ±„νŒ…μ°½ μ˜μ—­ 뿐만 μ•„λ‹ˆλΌ 전체 μœˆλ„μš° μ˜μ—­λ„ 슀크둀 μ•„λž˜λ‘œ 내렀가도둝 μžλ™ 슀크둀 이벀트 μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
inaemon committed Nov 27, 2024
1 parent bd658c2 commit 88a9c57
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/pages/Chatbot/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ const Chatbot = () => {
// 챗봇 첫 인사 λ Œλ”λ§ κ΄€λ ¨
useEffect(() => {
// 챗봇 νŽ˜μ΄μ§€ λ“€μ–΄μ˜¨ ν›„ 초기 λ©”μ‹œμ§€ ν‘œμ‹œ
const timer = setTimeout(() => {
setShowInitialMessages(true);
}, );

return () => clearTimeout(timer);
setShowInitialMessages(true);
}, []);


Expand Down Expand Up @@ -104,10 +100,20 @@ const Chatbot = () => {
);
}

// μžλ™ 슀크둀 κΈ°λŠ₯

// μŠ€ν¬λ‘€μ„ μ‘°μž‘ν•  μ˜μ—­(μ±„νŒ…μ°½ div) 지정
const chatContainerRef = useRef<HTMLDivElement>(null);

// μžλ™ 슀크둀 κΈ°λŠ₯
// μ±„νŒ…μ΄ 좔가될 λ•Œ 슀크둀 맨 μ•„λž˜λ‘œ 이동
const scrollToBottom = () => {
// μ±„νŒ… μ˜μ—­μ„ λ„˜μ–΄μ„œ 전체 νŽ˜μ΄μ§€λ₯Ό 맨 μ•„λž˜λ‘œ 슀크둀
window.scrollTo({
top: document.documentElement.scrollHeight,
behavior: 'smooth', // λΆ€λ“œλŸ¬μš΄ 슀크둀
});

// μ±„νŒ… μ˜μ—­ 맨 μ•„λž˜λ‘œ 슀크둀
if (chatContainerRef.current) {
chatContainerRef.current.scrollTop = chatContainerRef.current.scrollHeight;
}
Expand Down Expand Up @@ -139,12 +145,12 @@ const Chatbot = () => {
<BackLogoBar />
</div>

<div className="flex justify-center items-center min-h-screen bg-grayscale-50 mt-[55px] pb-[60px]">
<div className="flex justify-center items-center h-full min-h-screen bg-grayscale-10 mt-[55px] pb-14">
<div className="flex flex-col h-full max-w-[500px] w-full bg-grayscale-10">
{/* μ±„νŒ… μ˜μ—­ */}
<div
ref={chatContainerRef}
className="flex-1 p-4 overflow-y-auto mb-10"
className="flex-1 px-3 py-4 h-full overflow-y-auto mb-10"
>

{/* 2. 였늘 λ‚ μ§œ */}
Expand Down Expand Up @@ -228,11 +234,11 @@ const Chatbot = () => {
</div>
</div>

</div>
</div>

{/* 4. μ±„νŒ… μž…λ ₯μ°½ */}
<ChatbotInputField isStadiumSelected={isStadiumSelected} onSelect={handleCategorySelect} />
</div>
</div>
</>
);
};
Expand Down

0 comments on commit 88a9c57

Please sign in to comment.