Skip to content

Commit

Permalink
feat: jubi chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyuweitarek committed Jul 17, 2024
1 parent 31cf620 commit 817934f
Show file tree
Hide file tree
Showing 8 changed files with 471 additions and 3 deletions.
13 changes: 12 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const config: Config = {
locales: ["en"],
},
customFields: {
chatbot:{
socket_server: process.env.SOCKET_SERVER,
}
// newsletter: {
// action:
// "https://dev.us14.list-manage.com/subscribe/post?u=4ed0fd1909674fddee53ac3e7&id=dfdcae99f5&f_id=004887e0f0",
Expand Down Expand Up @@ -120,10 +123,18 @@ const config: Config = {
hideable: true,
},
},
announcementBar: {
id: 'support_us',
content:
'🐧 Jubi has just been born! Say hi to him~ 🎉</a> ',
backgroundColor: '#040D12',
textColor: '#78D6C6',
isCloseable: true,
},
// announcementBar: {
// id: 'support_us',
// content:
// '🐧 <a target="_blank" rel="noopener noreferrer" href="#">Send Me to Antarctica!</a> 🐧',
// '🐧 <a target="_blank" rel="noopener noreferrer" href="#">Jubi has just been born!</a> 🐧',
// backgroundColor: '#040D12',
// textColor: '#78D6C6',
// isCloseable: true,
Expand Down
82 changes: 81 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"react-native-vector-icons": "^10.1.0",
"rehype-katex": "^7.0.0",
"remark-math": "^6.0.0",
"sass": "^1.70.0"
"sass": "^1.70.0",
"socket.io-client": "^4.7.5"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.1.1",
Expand Down
219 changes: 219 additions & 0 deletions src/components/chatbot/ChatBot.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
@import "../../css/mixins";

.chatbotContainer {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
}

.chatIcon {
width: 60px;
height: 60px;
border-radius: 30px;
background-color: #2c3e50;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
overflow: hidden;

&:hover {
transform: scale(1.1);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
}

.chatIconImage {
width: 100%;
height: 100%;
object-fit: cover;
}

.chatWindow {
position: absolute;
bottom: 80px;
right: 0;
width: 320px;
height: 500px;
background-color: rgb(from var(--ifm-background-color) r g b / 80%);
border-radius: 10px;
overflow: hidden;
display: flex;
flex-direction: column;
box-shadow: 0 5px 30px rgba(0, 0, 0, 0.2);
}

.chatHeader {
background-color: rgba(0, 0, 0, 0.2);
color: var(--ifm-font-color);
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;

h3 {
margin: 0;
font-size: 16px;
}

button {
background: none;
border: none;
color: var(--ifm-font-color);
font-size: 20px;
cursor: pointer;
}
}

.chatMessages {
flex-grow: 1;
overflow-y: auto;
padding: 20px;
display: flex;
flex-direction: column;

// Custom scrollbar styles
&::-webkit-scrollbar {
width: 6px;
}

&::-webkit-scrollbar-track {
background: #f1f1f1;
}

&::-webkit-scrollbar-thumb {
background: #888;
border-radius: 3px;
}

&::-webkit-scrollbar-thumb:hover {
background: #555;
}
}

.messageContainer {
display: flex;
margin-bottom: 15px;
width: 100%;
}

.messageContent {
display: flex;
flex-direction: column;
max-width: 80%;
}

.message {
padding: 10px 15px;
border-radius: 20px;
font-size: 14px;
line-height: 1.4;
overflow-wrap: anywhere;
}

.user {
.messageContent {
align-items: flex-end;
margin-right: 5px;
}

.avatarWrapper {
order: 1;
}

.message {
background: linear-gradient(to left, #4bc9ff 0%, #09ffb9 100%);
color: rgba(0, 0, 0, 0.8);
}

.messageTime {
text-align: right;
}
}

.user.messageContainer {
justify-content: flex-end;
}

.bot {
.avatarWrapper {
margin-right: 5px;
}

.message {
background: rgb(from var(--ifm-color-primary) r g b / 20%);
color: var(--ifm-font-color);
}
}

.bot.messageContainer {
justify-content: flex-start;
}

.messageTime {
font-size: 12px;
color: #7f8c8d;
margin-top: 5px;
}

.avatarWrapper {
width: 30px;
height: 30px;
border-radius: 50% !important;
overflow: hidden;
flex-shrink: 0;
}

.chatAvatar {
width: 100%;
height: 100%;
object-fit: cover;
}

.inputArea {
display: flex;
padding: 10px;
background-color: rgba(0, 0, 0, 0.2);
}

.inputArea input {
flex-grow: 1;
padding: 10px;
border: none;
border-radius: 20px;
font-size: 14px;
background-color: rgb(from var(--ifm-background-color) r g b / 80%);
margin-right: 10px;
}

.inputArea button {
padding: 10px 15px;
background: linear-gradient(to left, #4bc9ff 0%, #09ffb9 100%);
color: rgb(4, 30, 30);
border: none;
border-radius: 20px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s ease;

&:hover {
background: linear-gradient(to left, #43b5e6 0%, #08e6a7 100%);
}
}

.mCSB_scrollTools {
margin: 1px -3px 1px 0;
opacity: 0;
}

.mCSB_inside > .mCSB_container {
margin-right: 0px;
padding: 0 10px;
}

.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {
background-color: rgba(0, 0, 0, 0.5)!important;
}
Loading

0 comments on commit 817934f

Please sign in to comment.