Skip to content

Commit 694207f

Browse files
[ChatQnA] Show spinner after query to improve user experience (#1003) (#1628)
Signed-off-by: Wang,Le3 <le3.wang@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 555e240 commit 694207f

2 files changed

Lines changed: 77 additions & 2 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!--
2+
Copyright (c) 2024 Intel Corporation
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<script lang="ts">
18+
export let color = '#3498db';
19+
</script>
20+
21+
<div class="spinner" style="width: 28px; height: 28px;">
22+
<svg viewBox="0 0 50 50">
23+
<circle
24+
class="path"
25+
cx="25"
26+
cy="25"
27+
r="20"
28+
fill="none"
29+
stroke={color}
30+
stroke-width="6"
31+
/>
32+
</svg>
33+
</div>
34+
35+
<style>
36+
.spinner {
37+
display: inline-block;
38+
animation: rotate 1.4s linear infinite;
39+
}
40+
41+
.path {
42+
stroke-dasharray: 1, 200;
43+
stroke-dashoffset: 0;
44+
animation: dash 1.5s ease-in-out infinite;
45+
stroke-linecap: round;
46+
}
47+
48+
@keyframes rotate {
49+
100% {
50+
transform: rotate(360deg);
51+
}
52+
}
53+
54+
@keyframes dash {
55+
0% {
56+
stroke-dasharray: 1, 200;
57+
stroke-dashoffset: 0;
58+
}
59+
50% {
60+
stroke-dasharray: 89, 200;
61+
stroke-dashoffset: -35px;
62+
}
63+
100% {
64+
stroke-dasharray: 89, 200;
65+
stroke-dashoffset: -124px;
66+
}
67+
}
68+
</style>

ChatQnA/ui/svelte/src/routes/+page.svelte

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import ChatMessage from "$lib/modules/chat/ChatMessage.svelte";
4040
import { fetchAllFile } from "$lib/network/upload/Network.js";
4141
import { getNotificationsContext } from "svelte-notifications";
42+
import Spinner from "$lib/shared/components/loading/Spinner.svelte";
43+
4244
4345
let query: string = "";
4446
let loading: boolean = false;
@@ -241,8 +243,13 @@
241243
type="submit"
242244
id="send"
243245
class="absolute bottom-2.5 end-2.5 px-4 py-2 text-sm font-medium text-white dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
244-
><PaperAirplane /></button
245-
>
246+
>
247+
{#if loading}
248+
<Spinner />
249+
{:else}
250+
<PaperAirplane />
251+
{/if}
252+
</button>
246253
</div>
247254
</div>
248255
</div>

0 commit comments

Comments
 (0)