Skip to content

Commit 0f420eb

Browse files
committed
moved scroll fixes to into list shadcn component, fixed input and send button formatting
1 parent 8952360 commit 0f420eb

File tree

3 files changed

+10
-44
lines changed

3 files changed

+10
-44
lines changed

app/classrooms/[classroomId]/chat/MessageBox.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ export default function MessageBox({
6565
}
6666

6767
return (
68-
<div className="flex h-[600px] w-11/12 flex-col place-self-center rounded border p-4 text-gray-800 shadow dark:text-white">
68+
<div className="flex h-[80vh] min-h-[400px] w-11/12 flex-col place-self-center rounded border p-4 text-gray-800 shadow dark:text-white">
6969
<Logo
70-
className={"size-24 place-self-center stroke-black stroke-[10px]"}
70+
className={"size-[4vmin] place-self-center stroke-black stroke-[10px]"}
7171
/>
72-
73-
<AutoScroll messages={messages}>
72+
<div className="flex-1 overflow-auto">
7473
<ChatMessageList smooth>
7574
{messages.map((msg, index) => (
7675
<ChatBubble
7776
key={index}
7877
variant={msg.role === "assistant" ? "received" : "sent"}
78+
className="max-w-[80%]"
7979
>
8080
{msg.role === "assistant" ? (
8181
<ChatBubbleAvatar fallback="AI" />
@@ -97,20 +97,16 @@ export default function MessageBox({
9797
</ChatBubble>
9898
)}
9999
</ChatMessageList>
100-
</AutoScroll>
101-
102-
<div className="relative mt-4">
100+
</div>
101+
<div className="flex w-full items-center justify-between gap-2 rounded-lg border bg-background p-1">
103102
<ChatInput
104103
value={value}
105104
onChange={(e) => setValue(e.target.value)}
106105
placeholder="Type your message..."
107106
onEnter={handleSend}
107+
className="focus-visible:ringof min-h-10 resize-none border-0 bg-background shadow-none focus-visible:ring-0"
108108
/>
109-
<Button
110-
onClick={handleSend}
111-
size="default"
112-
className="absolute right-2 top-1/2 -translate-y-1/2"
113-
>
109+
<Button onClick={handleSend} size="sm" className="ml-auto mr-3">
114110
Send <SendIcon />
115111
</Button>
116112
</div>

app/classrooms/[classroomId]/chat/auto-scroll.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

shared/components/ui/chat/hooks/useAutoScroll.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function useAutoScroll(options: UseAutoScrollOptions = {}) {
6767
setScrollState(() => ({
6868
isAtBottom: atBottom,
6969
// Re-enable auto-scroll if at the bottom
70-
autoScrollEnabled: true//atBottom ? true : prev.autoScrollEnabled,
70+
autoScrollEnabled: true, //atBottom ? true : prev.autoScrollEnabled,
7171
}));
7272
}, [checkIsAtBottom]);
7373

@@ -120,7 +120,7 @@ export function useAutoScroll(options: UseAutoScrollOptions = {}) {
120120
userHasScrolled.current = true;
121121
setScrollState((prev) => ({
122122
...prev,
123-
autoScrollEnabled: true//false,
123+
autoScrollEnabled: true, //false,
124124
}));
125125
}
126126
}, [checkIsAtBottom]);

0 commit comments

Comments
 (0)