Skip to content

Commit 38c964f

Browse files
committed
add scroll to bottom button
1 parent 4ab8ecd commit 38c964f

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

src/assets/styles/pages/_chat-interface.scss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,33 @@
9393
background-color: var(--btn-hover-bg-color);
9494
}
9595
}
96+
97+
.scroll-down-btn {
98+
position: absolute;
99+
bottom: 7rem;
100+
left: 50%;
101+
transform: translateX(-50%);
102+
min-width: 0;
103+
width: 2rem;
104+
height: 2rem;
105+
padding: 0;
106+
border: 1px solid var(--border-color);
107+
border-radius: 9999px;
108+
color: var(--text-dark);
109+
background-color: var(--query-editor-bg);
110+
display: flex;
111+
align-items: center;
112+
justify-content: center;
113+
114+
&:hover {
115+
background-color: color-mix(in srgb, var(--theme-base) 10%, var(--query-editor-bg));
116+
}
117+
118+
.material-symbols-outlined {
119+
margin-top: 0.2rem;
120+
font-size: 1.6rem;
121+
}
122+
}
96123
}
97124

98125
.chat-messages {

src/components/ChatInterface.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@
5959
</div>
6060
<div ref="bottomMarker"></div>
6161
</div>
62+
<button
63+
v-if="!isAtBottom"
64+
@click="scrollToBottom({ smooth: true })"
65+
class="btn scroll-down-btn"
66+
title="Scroll to bottom"
67+
>
68+
<span class="material-symbols-outlined">keyboard_arrow_down</span>
69+
</button>
6270
<div class="chat-input-container-container">
6371
<div class="chat-input-container">
6472
<BaseInput
@@ -414,12 +422,19 @@ export default {
414422
}
415423
},
416424
417-
scrollToBottom() {
425+
scrollToBottom(options?: { smooth?: boolean }) {
418426
if (!this.$refs.scrollContainerRef) {
419427
return;
420428
}
421-
this.$refs.scrollContainerRef.scrollTop =
422-
this.$refs.scrollContainerRef.scrollHeight;
429+
if (options?.smooth) {
430+
this.$refs.scrollContainerRef.scrollTo({
431+
top: this.$refs.scrollContainerRef.scrollHeight,
432+
behavior: 'smooth'
433+
});
434+
} else {
435+
this.$refs.scrollContainerRef.scrollTop =
436+
this.$refs.scrollContainerRef.scrollHeight;
437+
}
423438
},
424439
selectModel(model: Model) {
425440
this.setInternal("lastUsedModelId", model.id);

0 commit comments

Comments
 (0)