Nikki Yong khronoz commited on
Commit
719d697
·
unverified ·
1 Parent(s): 7d9d30d

added loading spinner (#17)

Browse files

* added loading spinner

Added a spinner component whenever waiting for a query response, so that users know something is still happening

* Updated loading spinner to use native svg/tailwinds & moved it in 'send' button

---------

Co-authored-by: Yee Kit <yeek3063@gmail.com>

frontend/app/components/ui/chat/chat-actions.tsx CHANGED
@@ -1,7 +1,7 @@
1
  import { PauseCircle, RefreshCw } from "lucide-react";
2
 
3
- import { Button } from "../button";
4
- import { ChatHandler } from "./chat.interface";
5
 
6
  export default function ChatActions(
7
  props: Pick<ChatHandler, "stop" | "reload"> & {
 
1
  import { PauseCircle, RefreshCw } from "lucide-react";
2
 
3
+ import { Button } from "@/app/components/ui/button";
4
+ import { ChatHandler } from "@/app/components/ui/chat/chat.interface";
5
 
6
  export default function ChatActions(
7
  props: Pick<ChatHandler, "stop" | "reload"> & {
frontend/app/components/ui/chat/chat-input.tsx CHANGED
@@ -1,6 +1,7 @@
1
  import { Button } from "@/app/components/ui/button";
2
  import { Input } from "@/app/components/ui/input";
3
  import { ChatHandler } from "@/app/components/ui/chat/chat.interface";
 
4
  import { Send } from "lucide-react";
5
 
6
  export default function ChatInput(
@@ -23,12 +24,23 @@ export default function ChatInput(
23
  value={props.input}
24
  onChange={props.handleInputChange}
25
  />
26
- <Button type="submit" disabled={props.isLoading} className="hidden md:flex items-center transition duration-300 ease-in-out transform hover:scale-110">
27
- <span className="pr-2">Send</span>
28
- <Send className="h-5 w-5" />
 
 
 
 
 
 
 
29
  </Button>
30
- <Button type="submit" disabled={props.isLoading} className="md:hidden"> {/* Hide on larger screens */}
31
- <Send className="h-5 w-5" />
 
 
 
 
32
  </Button>
33
  </form>
34
  );
 
1
  import { Button } from "@/app/components/ui/button";
2
  import { Input } from "@/app/components/ui/input";
3
  import { ChatHandler } from "@/app/components/ui/chat/chat.interface";
4
+ import { IconSpinner } from "@/app/components/ui/icons";
5
  import { Send } from "lucide-react";
6
 
7
  export default function ChatInput(
 
24
  value={props.input}
25
  onChange={props.handleInputChange}
26
  />
27
+ <Button type="submit" disabled={props.isLoading} className="hidden md:flex items-center transition duration-300 ease-in-out transform hover:scale-110 z-10">
28
+ {props.isLoading ? (
29
+ <IconSpinner className="animate-spin" />
30
+ ) : (
31
+ // Fragment to avoid wrapping the text in a button
32
+ <>
33
+ <span className="pr-2">Send</span>
34
+ <Send className="h-5 w-5" />
35
+ </>
36
+ )}
37
  </Button>
38
+ <Button type="submit" disabled={props.isLoading} className="md:hidden z-10"> {/* Hide on larger screens */}
39
+ {props.isLoading ? (
40
+ <IconSpinner className="animate-spin" />
41
+ ) : (
42
+ <Send className="h-5 w-5" />
43
+ )}
44
  </Button>
45
  </form>
46
  );
frontend/app/components/ui/chat/chat-message.tsx CHANGED
@@ -1,10 +1,10 @@
1
  import { Check, Copy } from "lucide-react";
2
 
3
- import { Button } from "../button";
4
- import ChatAvatar from "./chat-avatar";
5
- import { Message } from "./chat.interface";
6
- import Markdown from "./markdown";
7
- import { useCopyToClipboard } from "./use-copy-to-clipboard";
8
  import { ToastContainer } from 'react-toastify';
9
  import 'react-toastify/dist/ReactToastify.css';
10
 
 
1
  import { Check, Copy } from "lucide-react";
2
 
3
+ import { Button } from "@/app/components/ui/button";
4
+ import ChatAvatar from "@/app/components/ui/chat/chat-avatar";
5
+ import { Message } from "@/app/components/ui/chat/chat.interface";
6
+ import Markdown from "@/app/components/ui/chat/markdown";
7
+ import { useCopyToClipboard } from "@/app/components/ui/chat/use-copy-to-clipboard";
8
  import { ToastContainer } from 'react-toastify';
9
  import 'react-toastify/dist/ReactToastify.css';
10
 
frontend/app/components/ui/chat/chat-messages.tsx CHANGED
@@ -1,8 +1,8 @@
1
  import { useEffect, useRef } from "react";
2
 
3
- import ChatActions from "./chat-actions";
4
- import ChatMessage from "./chat-message";
5
- import { ChatHandler } from "./chat.interface";
6
 
7
  export default function ChatMessages(
8
  props: Pick<ChatHandler, "messages" | "isLoading" | "reload" | "stop">,
 
1
  import { useEffect, useRef } from "react";
2
 
3
+ import ChatActions from "@/app/components/ui/chat/chat-actions";
4
+ import ChatMessage from "@/app/components/ui/chat/chat-message";
5
+ import { ChatHandler } from "@/app/components/ui/chat/chat.interface";
6
 
7
  export default function ChatMessages(
8
  props: Pick<ChatHandler, "messages" | "isLoading" | "reload" | "stop">,