Skip to content

Commit 1a2518c

Browse files
authored
Merge pull request #110 from iceljc/features/refine-chat-window
Features/refine chat window
2 parents b09631d + 737d95b commit 1a2518c

File tree

5 files changed

+40
-17
lines changed

5 files changed

+40
-17
lines changed

src/lib/scss/custom/pages/_chat.scss

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
button {
227227
min-width: 50px;
228228
text-align: left;
229+
border-radius: 10px;
229230
}
230231
}
231232

@@ -236,20 +237,27 @@
236237
margin-top: 10px;
237238

238239
.card-element {
239-
flex: 1 1 fit-content;
240+
flex: 1 1 50%;
240241
border-radius: 10px;
241242
border-width: 2px;
242243
max-width: 45%;
243244
margin-bottom: 0px;
244245

246+
@media (max-width: 620px) {
247+
width: 100%;
248+
max-width: 100%;
249+
}
250+
245251
.card-element-title {
246-
font-size: 1.1rem;
252+
font-size: 0.8rem;
247253
font-weight: 700;
254+
height: 30%;
248255
}
249256

250257
.card-element-subtitle {
251-
font-size: 0.8rem;
258+
font-size: 0.7rem;
252259
font-weight: 500;
260+
height: 8%;
253261
}
254262

255263
.card-option-group {
@@ -259,6 +267,7 @@
259267
display: block;
260268
margin-left: 0px !important;
261269
text-align: left;
270+
border-radius: 10px;
262271
}
263272
}
264273
}

src/routes/chat/[agentId]/[conversationId]/chat-box.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,18 @@
217217
groupedDialogs = groupDialogs(dialogs);
218218
await tick();
219219
220+
autoScrollToBottom();
221+
}
222+
223+
function autoScrollToBottom() {
220224
// @ts-ignore
221225
scrollbars.forEach(scrollbar => {
222226
setTimeout(() => {
223227
const { viewport } = scrollbar.elements();
224228
viewport.scrollTo({ top: viewport.scrollHeight, behavior: 'smooth' });
225229
}, 200);
226230
});
227-
}
231+
}
228232
229233
/** @param {import('$types').ChatResponseModel[]} dialogs */
230234
function groupDialogs(dialogs) {
@@ -901,6 +905,7 @@
901905
message={message}
902906
displayExtraElements={message.message_id === lastBotMsg?.message_id && !isSendingMsg && !isThinking}
903907
disableOption={isSendingMsg || isThinking}
908+
refresh={autoScrollToBottom}
904909
onConfirm={confirmSelectedOption}
905910
/>
906911
<ChatAttachment

src/routes/chat/[agentId]/[conversationId]/richContent/rc-complex-options.svelte

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { Card, CardBody } from "@sveltestrap/sveltestrap";
33
import { onMount } from "svelte";
44
5-
65
/** @type {boolean} */
76
export let disableOption = false;
87
@@ -12,16 +11,21 @@
1211
/** @type {(args0: string, args1: string) => any} */
1312
export let onConfirm;
1413
14+
/** @type {() => any} */
15+
export let refresh = () => {};
16+
1517
/** @type {any[]} */
1618
let cards = [];
1719
1820
onMount(() => {
19-
cards = collectOptions(options);
21+
reset();
22+
collectOptions(options);
23+
refresh && refresh();
2024
});
2125
2226
/** @param {any[]} options */
2327
function collectOptions(options) {
24-
const res = options?.map(op => {
28+
cards = options?.map(op => {
2529
// @ts-ignore
2630
const options = op.buttons?.filter(op => !!op.title && !!op.payload)?.map(x => {
2731
return {
@@ -36,8 +40,6 @@
3640
options: options
3741
};
3842
}) || [];
39-
40-
return res;
4143
}
4244
4345
/**
@@ -78,7 +80,7 @@
7880
<div class="card-option-group">
7981
{#each card.options as option, i (i)}
8082
<button
81-
class="btn btn-outline-primary btn-rounded btn-sm m-1"
83+
class="btn btn-outline-primary btn-sm m-1"
8284
disabled={disableOption}
8385
on:click={(e) => handleClickOption(e, option)}
8486
>

src/routes/chat/[agentId]/[conversationId]/richContent/rc-plain-options.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
/** @type {(args0: string, args1: string) => any} */
1717
export let onConfirm;
1818
19+
/** @type {() => any} */
20+
export let refresh = () => {};
21+
1922
/** @type {string} */
2023
export let confirmBtnText = 'Continue';
2124
@@ -33,6 +36,7 @@
3336
onMount(() => {
3437
reset();
3538
collectOptions(options);
39+
refresh && refresh();
3640
});
3741
3842
/** @param {any[]} options */
@@ -130,7 +134,7 @@
130134
<div class="button-group-container">
131135
{#each plainOptions as option, index}
132136
<button
133-
class={`btn btn-rounded btn-sm m-1 ${option.is_secondary ? 'btn-outline-secondary': 'btn-outline-primary'}`}
137+
class={`btn btn-sm m-1 ${option.is_secondary ? 'btn-outline-secondary': 'btn-outline-primary'}`}
134138
class:active={!!option.isClicked}
135139
disabled={disableOption}
136140
on:click={(e) => handleClickOption(e, option, index)}
@@ -140,7 +144,7 @@
140144
{/each}
141145
{#if isMultiSelect}
142146
<button
143-
class="btn btn-outline-success btn-rounded btn-sm m-1"
147+
class="btn btn-outline-success btn-sm m-1"
144148
name="confirm"
145149
disabled={disableOption || plainOptions.every(x => !!!x.isClicked)}
146150
on:click={(e) => handleConfirm(e)}

src/routes/chat/[agentId]/[conversationId]/richContent/rich-content.svelte

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
/** @type {(args0: string, args1: string) => any} */
1717
export let onConfirm = () => {};
1818
19+
/** @type {() => any} */
20+
export let refresh = () => {};
21+
1922
/** @type {boolean} */
2023
let isComplexElement = false;
2124
@@ -43,16 +46,16 @@
4346
4447
{#if displayExtraElements}
4548
{#if message?.rich_content?.message?.rich_type === RichType.QuickReply}
46-
<RcPlainOptions options={message?.rich_content?.message?.quick_replies} disableOption={disableOption} onConfirm={handleConfirm} />
49+
<RcPlainOptions options={message?.rich_content?.message?.quick_replies} disableOption={disableOption} onConfirm={handleConfirm} refresh={refresh} />
4750
{:else if message?.rich_content?.message?.rich_type === RichType.Button}
48-
<RcPlainOptions options={message?.rich_content?.message?.buttons} disableOption={disableOption} onConfirm={handleConfirm} />
51+
<RcPlainOptions options={message?.rich_content?.message?.buttons} disableOption={disableOption} onConfirm={handleConfirm} refresh={refresh} />
4952
{:else if message?.rich_content?.message?.rich_type === RichType.MultiSelect}
50-
<RcPlainOptions options={message?.rich_content?.message?.options} isMultiSelect disableOption={disableOption} onConfirm={handleConfirm} />
53+
<RcPlainOptions options={message?.rich_content?.message?.options} isMultiSelect disableOption={disableOption} onConfirm={handleConfirm} refresh={refresh} />
5154
{:else if message?.rich_content?.message?.rich_type === RichType.Generic}
5255
{#if isComplexElement}
53-
<RcComplexOptions options={message?.rich_content?.message?.elements} disableOption={disableOption} onConfirm={handleConfirm} />
56+
<RcComplexOptions options={message?.rich_content?.message?.elements} disableOption={disableOption} onConfirm={handleConfirm} refresh={refresh} />
5457
{:else}
55-
<RcPlainOptions options={message?.rich_content?.message?.elements} disableOption={disableOption} onConfirm={handleConfirm} />
58+
<RcPlainOptions options={message?.rich_content?.message?.elements} disableOption={disableOption} onConfirm={handleConfirm} refresh={refresh} />
5659
{/if}
5760
{/if}
5861
{/if}

0 commit comments

Comments
 (0)