Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added loading spinner #17

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/app/components/ui/chat/chat-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PauseCircle, RefreshCw } from "lucide-react";

import { Button } from "../button";
import { ChatHandler } from "./chat.interface";
import { Button } from "@/app/components/ui/button";
import { ChatHandler } from "@/app/components/ui/chat/chat.interface";

export default function ChatActions(
props: Pick<ChatHandler, "stop" | "reload"> & {
Expand Down
22 changes: 17 additions & 5 deletions frontend/app/components/ui/chat/chat-input.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button } from "@/app/components/ui/button";
import { Input } from "@/app/components/ui/input";
import { ChatHandler } from "@/app/components/ui/chat/chat.interface";
import { IconSpinner } from "@/app/components/ui/icons";
import { Send } from "lucide-react";

export default function ChatInput(
Expand All @@ -23,12 +24,23 @@ export default function ChatInput(
value={props.input}
onChange={props.handleInputChange}
/>
<Button type="submit" disabled={props.isLoading} className="hidden md:flex items-center transition duration-300 ease-in-out transform hover:scale-110">
<span className="pr-2">Send</span>
<Send className="h-5 w-5" />
<Button type="submit" disabled={props.isLoading} className="hidden md:flex items-center transition duration-300 ease-in-out transform hover:scale-110 z-10">
{props.isLoading ? (
<IconSpinner className="animate-spin" />
) : (
// Fragment to avoid wrapping the text in a button
<>
<span className="pr-2">Send</span>
<Send className="h-5 w-5" />
</>
)}
</Button>
<Button type="submit" disabled={props.isLoading} className="md:hidden"> {/* Hide on larger screens */}
<Send className="h-5 w-5" />
<Button type="submit" disabled={props.isLoading} className="md:hidden z-10"> {/* Hide on larger screens */}
{props.isLoading ? (
<IconSpinner className="animate-spin" />
) : (
<Send className="h-5 w-5" />
)}
</Button>
</form>
);
Expand Down
10 changes: 5 additions & 5 deletions frontend/app/components/ui/chat/chat-message.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Check, Copy } from "lucide-react";

import { Button } from "../button";
import ChatAvatar from "./chat-avatar";
import { Message } from "./chat.interface";
import Markdown from "./markdown";
import { useCopyToClipboard } from "./use-copy-to-clipboard";
import { Button } from "@/app/components/ui/button";
import ChatAvatar from "@/app/components/ui/chat/chat-avatar";
import { Message } from "@/app/components/ui/chat/chat.interface";
import Markdown from "@/app/components/ui/chat/markdown";
import { useCopyToClipboard } from "@/app/components/ui/chat/use-copy-to-clipboard";
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

Expand Down
6 changes: 3 additions & 3 deletions frontend/app/components/ui/chat/chat-messages.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useRef } from "react";

import ChatActions from "./chat-actions";
import ChatMessage from "./chat-message";
import { ChatHandler } from "./chat.interface";
import ChatActions from "@/app/components/ui/chat/chat-actions";
import ChatMessage from "@/app/components/ui/chat/chat-message";
import { ChatHandler } from "@/app/components/ui/chat/chat.interface";

export default function ChatMessages(
props: Pick<ChatHandler, "messages" | "isLoading" | "reload" | "stop">,
Expand Down
Loading