-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #382 from l3vels/feat/chat-widget
Feat/chat widget
- Loading branch information
Showing
13 changed files
with
308 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Route as Router, Routes, BrowserRouter } from 'react-router-dom' | ||
|
||
import styled, { ThemeProvider } from 'styled-components' | ||
import { lightTheme } from 'styles/theme' | ||
import ChatWindow from './ChatWindow' | ||
import { useState } from 'react' | ||
|
||
import Close from 'share-ui/components/Icon/Icons/components/Close' | ||
import Robot from 'share-ui/components/Icon/Icons/components/Robot' | ||
import useApollo from 'hooks/useApollo' | ||
import { ApolloProvider } from '@apollo/client' | ||
|
||
const ChatWidget = () => { | ||
const client = useApollo() | ||
|
||
const [showChat, setShowChat] = useState(false) | ||
|
||
return ( | ||
<ApolloProvider client={client}> | ||
<ThemeProvider theme={lightTheme}> | ||
<StyledRoot> | ||
<BrowserRouter> | ||
{showChat && ( | ||
<Routes> | ||
<Router element={<ChatWindow />} path='/' /> | ||
</Routes> | ||
)} | ||
</BrowserRouter> | ||
|
||
<StyledChatWidget onClick={() => setShowChat(!showChat)}> | ||
{showChat ? <Close size={40} /> : <Robot size={40} />} | ||
</StyledChatWidget> | ||
</StyledRoot> | ||
</ThemeProvider> | ||
</ApolloProvider> | ||
) | ||
} | ||
|
||
export default ChatWidget | ||
|
||
const StyledRoot = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-end; | ||
gap: 10px; | ||
` | ||
|
||
const StyledChatWidget = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 100px; | ||
background: #ca7af7; | ||
cursor: pointer; | ||
width: 50px; | ||
height: 50px; | ||
transition: all 0.3s ease; /* Add transition for smooth animation */ | ||
/* &:hover { | ||
width: 60px; | ||
height: 60px; | ||
} */ | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import ChatV2 from 'modals/AIChatModal/components/ChatV2' | ||
import { ChatContextProvider } from 'modals/AIChatModal/context/ChatContext' | ||
import styled from 'styled-components' | ||
|
||
const ChatWindow = () => { | ||
return ( | ||
<StyledChatWindow> | ||
<ChatContextProvider> | ||
<ChatV2 chatSessionId='11af2cae-3423-42f6-a5d5-29a555dac424' /> | ||
</ChatContextProvider> | ||
</StyledChatWindow> | ||
) | ||
} | ||
|
||
export default ChatWindow | ||
|
||
const StyledChatWindow = styled.div` | ||
width: calc(100vw - 30px); | ||
max-width: 450px; | ||
height: calc(75vh); | ||
border-radius: 10px; | ||
background-color: #fff; | ||
/* border: 1px solid #000; */ | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.4); | ||
padding: 0 10px; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './ChatWidget' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#test { | ||
position: fixed; | ||
bottom: 20px; | ||
right: 20px; | ||
|
||
z-index: 1000000000; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import ReactDOM from 'react-dom' | ||
|
||
import './TestComp.css' | ||
import ChatWidget from 'ChatWidget' | ||
|
||
const renderTestComp = () => { | ||
ReactDOM.render(<ChatWidget />, document.getElementById('test')) | ||
} | ||
|
||
renderTestComp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.