From e133c29b2c1f67e6cd0ce90b217d774be12dbd21 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 9 Nov 2024 18:46:31 +0000 Subject: [PATCH 01/11] feat: widget bounciness --- .../src/components/DocsGPTWidget.tsx | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/extensions/react-widget/src/components/DocsGPTWidget.tsx b/extensions/react-widget/src/components/DocsGPTWidget.tsx index 699803598..6588ccc5c 100644 --- a/extensions/react-widget/src/components/DocsGPTWidget.tsx +++ b/extensions/react-widget/src/components/DocsGPTWidget.tsx @@ -99,7 +99,7 @@ const WidgetContainer = styled.div<{ modal?: boolean, isOpen?: boolean }>` transform: scale(1.02); } 100% { - transform: scale(0); + transform: scale(0.45); } } `; @@ -127,7 +127,7 @@ const StyledContainer = styled.div` overflow: auto; } `; -const FloatingButton = styled.div<{ bgcolor: string, hidden: boolean }>` +const FloatingButton = styled.div<{ bgcolor: string, hidden: boolean, isAnimatingButton: boolean }>` position: fixed; display: ${props => props.hidden ? "none" : "flex"}; z-index: 500; @@ -144,9 +144,22 @@ const FloatingButton = styled.div<{ bgcolor: string, hidden: boolean }>` background: ${props => props.bgcolor}; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); cursor: pointer; + animation: ${props => props.isAnimatingButton ? 'scaleAnimation 200ms forwards' : 'none'}; &:hover { - transform: scale(1.1); - transition: transform 0.2s ease-in-out; + transform: scale(1.1); + transition: transform 0.2s ease-in-out; + } + &:not(:hover) { + transition: transform 0.2s ease-in-out; + } + + @keyframes scaleAnimation { + from { + transform: scale(1.2); + } + to { + transform: scale(1); + } } `; const CancelButton = styled.button` @@ -433,6 +446,8 @@ export const DocsGPTWidget = ({ const [conversationId, setConversationId] = React.useState(null) const [open, setOpen] = React.useState(deafultOpen) const [eventInterrupt, setEventInterrupt] = React.useState(false); //click or scroll by user while autoScrolling + const [isAnimatingButton, setIsAnimatingButton] = React.useState(false); + const [isFloatingButtonVisible, setIsFloatingButtonVisible] = React.useState(true); const isBubbleHovered = useRef(false) const widgetRef = useRef(null) const endMessageRef = React.useRef(null); @@ -549,14 +564,17 @@ export const DocsGPTWidget = ({ const handleClose = () => { setOpen(false); size !== "large" ? setTimeout(() => { - if (widgetRef.current) - widgetRef.current.style.display = "none" + if (widgetRef.current) widgetRef.current.style.display = "none"; + setIsFloatingButtonVisible(true); + setIsAnimatingButton(true); + setTimeout(() => setIsAnimatingButton(false), 200); }, 250) : widgetRef.current && (widgetRef.current.style.display = "none") }; const handleOpen = () => { setOpen(true); + setIsFloatingButtonVisible(false); if (widgetRef.current) widgetRef.current.style.display = 'block' } @@ -570,7 +588,7 @@ export const DocsGPTWidget = ({ {open && size === 'large' && } - - { + {
From ba1c0ab6fb93658b2575388b1b76fe90bcba19c1 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 10 Nov 2024 16:36:14 +0000 Subject: [PATCH 03/11] fix: large closing --- extensions/react-widget/src/components/DocsGPTWidget.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/react-widget/src/components/DocsGPTWidget.tsx b/extensions/react-widget/src/components/DocsGPTWidget.tsx index e3cf72245..c74d658f6 100644 --- a/extensions/react-widget/src/components/DocsGPTWidget.tsx +++ b/extensions/react-widget/src/components/DocsGPTWidget.tsx @@ -577,7 +577,7 @@ export const DocsGPTWidget = ({ setTimeout(() => setIsAnimatingButton(false), 200); }, 250) : - widgetRef.current && (widgetRef.current.style.display = "none") + widgetRef.current && (widgetRef.current.style.display = "none") && setIsFloatingButtonVisible(true); }; const handleOpen = () => { setOpen(true); From d4b409e166ac42f5bc3f144e88686aa04fca6346 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 10 Nov 2024 18:46:26 +0000 Subject: [PATCH 04/11] fix: align buttons --- frontend/src/conversation/Conversation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index a8326da71..1754e6800 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -218,7 +218,7 @@ export default function Conversation() { {conversationId && queries.length > 0 && (
{' '} -
+
{isMobile && queries.length > 0 && (