From b752595554977ce48e0591a68c2905d603c6f72f Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Thu, 9 Nov 2023 21:43:12 +0700 Subject: [PATCH] Add loader buble chat --- uikit/src/button/styles.scss | 2 +- .../BasicPromptAccessories/index.tsx | 26 ---- web/components/BasicPromptInput/index.tsx | 95 ------------ .../ConfirmDeleteConversationModal/index.tsx | 99 ------------- web/components/ConfirmationModal/index.tsx | 93 ------------ web/components/HistoryItem/index.tsx | 101 ------------- web/components/HistoryList/index.tsx | 54 ------- web/components/InputToolbar/index.tsx | 112 --------------- web/components/LoadingIndicator.tsx | 13 -- web/components/MainHeader/index.tsx | 35 ----- web/components/ModalNoActiveModel/index.tsx | 75 ---------- web/components/SendButton/index.tsx | 24 ---- web/components/SidebarEmptyHistory/index.tsx | 63 -------- .../SwitchingModelConfirmationModal/index.tsx | 135 ------------------ web/components/TextAreaWithTitle/index.tsx | 46 ------ web/containers/Layout/BottomBar/index.tsx | 3 +- web/containers/Loader/Bubble.tsx | 9 ++ .../ProgressBar/index.tsx | 0 web/containers/Providers/index.tsx | 4 +- web/helpers/atoms/Modal.atom.ts | 5 - web/models/ChatMessage.ts | 3 +- web/package.json | 1 + web/screens/Chat/ChatItem/index.tsx | 1 + web/screens/Chat/HistoryList/index.tsx | 6 +- web/screens/Chat/SimpleTextMessage/index.tsx | 48 ++++--- web/screens/Chat/index.tsx | 18 +-- .../ExploreModels/ExploreModelList/index.tsx | 4 +- web/styles/components/code-block.scss | 2 - web/styles/components/loader.scss | 64 +++++++++ web/styles/components/message.scss | 34 +++++ 30 files changed, 154 insertions(+), 1021 deletions(-) delete mode 100644 web/components/BasicPromptAccessories/index.tsx delete mode 100644 web/components/BasicPromptInput/index.tsx delete mode 100644 web/components/ConfirmDeleteConversationModal/index.tsx delete mode 100644 web/components/ConfirmationModal/index.tsx delete mode 100644 web/components/HistoryItem/index.tsx delete mode 100644 web/components/HistoryList/index.tsx delete mode 100644 web/components/InputToolbar/index.tsx delete mode 100644 web/components/LoadingIndicator.tsx delete mode 100644 web/components/MainHeader/index.tsx delete mode 100644 web/components/ModalNoActiveModel/index.tsx delete mode 100644 web/components/SendButton/index.tsx delete mode 100644 web/components/SidebarEmptyHistory/index.tsx delete mode 100644 web/components/SwitchingModelConfirmationModal/index.tsx delete mode 100644 web/components/TextAreaWithTitle/index.tsx create mode 100644 web/containers/Loader/Bubble.tsx rename web/{components => containers}/ProgressBar/index.tsx (100%) diff --git a/uikit/src/button/styles.scss b/uikit/src/button/styles.scss index 17df7381f..69d8e522e 100644 --- a/uikit/src/button/styles.scss +++ b/uikit/src/button/styles.scss @@ -12,7 +12,7 @@ } &-outline { - @apply border-input hover:bg-primary hover:text-primary-foreground border bg-transparent; + @apply border-input border bg-transparent; } &-secondary { diff --git a/web/components/BasicPromptAccessories/index.tsx b/web/components/BasicPromptAccessories/index.tsx deleted file mode 100644 index 2f082ef44..000000000 --- a/web/components/BasicPromptAccessories/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -'use client' - -import SendButton from '../SendButton' - -const BasicPromptAccessories: React.FC = () => { - return ( -
- {/* Add future accessories here, e.g upload a file */} -
-
- {/* */} -
-
-
- -
-
- ) -} - -export default BasicPromptAccessories diff --git a/web/components/BasicPromptInput/index.tsx b/web/components/BasicPromptInput/index.tsx deleted file mode 100644 index df03e45d1..000000000 --- a/web/components/BasicPromptInput/index.tsx +++ /dev/null @@ -1,95 +0,0 @@ -'use client' - -import { ChangeEvent, useEffect, useRef } from 'react' - -import { useAtom, useAtomValue } from 'jotai' - -import { currentPromptAtom } from '@/containers/Providers/Jotai' - -import { useCreateConversation } from '@/hooks/useCreateConversation' - -import useSendChatMessage from '@/hooks/useSendChatMessage' - -import { getActiveConvoIdAtom } from '@/helpers/atoms/Conversation.atom' -import { selectedModelAtom } from '@/helpers/atoms/Model.atom' - -const BasicPromptInput: React.FC = () => { - const activeConversationId = useAtomValue(getActiveConvoIdAtom) - const selectedModel = useAtomValue(selectedModelAtom) - const [currentPrompt, setCurrentPrompt] = useAtom(currentPromptAtom) - const { sendChatMessage } = useSendChatMessage() - const { requestCreateConvo } = useCreateConversation() - - const textareaRef = useRef(null) - - const handleKeyDown = async ( - event: React.KeyboardEvent - ) => { - if (event.key === 'Enter') { - if (!event.shiftKey) { - if (activeConversationId) { - event.preventDefault() - sendChatMessage() - } else { - if (!selectedModel) { - console.log('No model selected') - return - } - await requestCreateConvo(selectedModel) - sendChatMessage() - } - } - } - } - - useEffect(() => { - adjustTextareaHeight() - }, [currentPrompt]) - - const handleMessageChange = (event: ChangeEvent) => { - setCurrentPrompt(event.target.value) - } - - // Auto adjust textarea height based on content - const MAX_ROWS = 30 - - const adjustTextareaHeight = () => { - if (textareaRef.current) { - textareaRef.current.style.height = 'auto' // 1 row - const scrollHeight = textareaRef.current.scrollHeight - const maxScrollHeight = - parseInt(window.getComputedStyle(textareaRef.current).lineHeight, 10) * - MAX_ROWS - textareaRef.current.style.height = `${Math.min( - scrollHeight, - maxScrollHeight - )}px` - } - } - - return ( -
-