-
+ {
+ !isEmbeddedBox && {
@@ -308,9 +309,14 @@ export const Chatbot = ({ isOpen, setIsOpen , isIframeBox }) => {
{labels.close || "Close"}
+ }
{
@@ -327,7 +334,8 @@ export const Chatbot = ({ isOpen, setIsOpen , isIframeBox }) => {
textAlign: headerAlignment === "left" ? "left" : "center",
}}
>
- {logo ? (
+ {isEmbeddedBox? null :
+ logo ? (
{
) : (
<>
-
{botName}
-
{description}
- >
+
{botName}
+
{description}
+ >
)}
diff --git a/src/components/embeddedChatBox/EmbeddedChat.jsx b/src/components/embeddedChatBox/EmbeddedChat.jsx
index 9f8fc35..b6390b8 100644
--- a/src/components/embeddedChatBox/EmbeddedChat.jsx
+++ b/src/components/embeddedChatBox/EmbeddedChat.jsx
@@ -41,7 +41,7 @@ const EmbeddedChat = () => {
isOpen ?
-
+
: null
diff --git a/src/components/embeddedChatBox/embeddedChat.css b/src/components/embeddedChatBox/embeddedChat.css
index ea54727..465abd3 100644
--- a/src/components/embeddedChatBox/embeddedChat.css
+++ b/src/components/embeddedChatBox/embeddedChat.css
@@ -5,11 +5,11 @@
}
.iframe-box{
- border: 1px solid rgb(221 213 213);
position: relative;
- width: 800px;
+ width: 80%;
height: 500px;
box-sizing: border-box;
+ margin: auto;
}
#root {
@@ -31,7 +31,6 @@
.docsbot-wrapper {
width: 100%;
opacity: 1;
- box-shadow: rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgba(0, 0, 0, 0.15) 0px 5px 30px 0px, rgba(0, 0, 0, 0.05) 0px 3px 3px 0px;
display: block;
z-index: 999999;
height: 100%;
@@ -44,9 +43,9 @@
}
.docsbot-chat-container {
+ border-radius: 10px;
background-color: rgb(249, 250, 250);
height: 100%;
- animation: fadeIn 0.5s;
width: 100%;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
From cbb853427e1ced81e69b8d1c744c8889bbc7f4e4 Mon Sep 17 00:00:00 2001
From: Yuvraj Singh
Date: Thu, 7 Sep 2023 16:35:49 +0530
Subject: [PATCH 08/17] fixed bugs and added feature to remove float button if
embedded
---
public/index.html | 3 ++-
src/components/embeddableWidget/EmbeddableWidget.jsx | 4 ++--
src/components/embeddedChatBox/EmbeddedChat.jsx | 11 +++++++++--
src/components/embeddedChatBox/index.js | 9 ---------
src/main.js | 11 +++++++++++
webpack.config.js | 2 +-
6 files changed, 25 insertions(+), 15 deletions(-)
delete mode 100644 src/components/embeddedChatBox/index.js
create mode 100644 src/main.js
diff --git a/public/index.html b/public/index.html
index 7720903..cea365a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -99,7 +99,8 @@ Embeddable Widget Demo
quis, accumsan porttitor, facilisis luctus, metus
-
+
+
HTML Ipsum Presents
diff --git a/src/components/embeddableWidget/EmbeddableWidget.jsx b/src/components/embeddableWidget/EmbeddableWidget.jsx
index 8bb37cc..eb8ff6c 100644
--- a/src/components/embeddableWidget/EmbeddableWidget.jsx
+++ b/src/components/embeddableWidget/EmbeddableWidget.jsx
@@ -38,11 +38,11 @@ export default class EmbeddableWidget {
}
const el = document.createElement("div");
el.id = "docsbotai-root";
-
+ const parentRootElement = document.getElementById('parent-root')
if (parentElement) {
document.querySelector(parentElement).appendChild(el);
} else {
- document.body.appendChild(el);
+ parentRootElement.appendChild(el)
}
const root = ReactDOM.createRoot(el);
diff --git a/src/components/embeddedChatBox/EmbeddedChat.jsx b/src/components/embeddedChatBox/EmbeddedChat.jsx
index b6390b8..79516d2 100644
--- a/src/components/embeddedChatBox/EmbeddedChat.jsx
+++ b/src/components/embeddedChatBox/EmbeddedChat.jsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react'
+import React, { useEffect, useState } from 'react'
import { Chatbot } from '../chatbot/Chatbot';
import { ChatbotProvider } from '../chatbotContext/ChatbotContext';
import { ConfigProvider } from '../configContext/ConfigContext';
@@ -19,11 +19,18 @@ const EmbeddedChat = () => {
const handleOpenEmbeddedBox = () => {
const floatChatBox = document.getElementById('docsbotai-root')
if (floatChatBox) {
- // window?.DocsBotAI.unmount()
+ window?.DocsBotAI.unmount()
}
setIsOpen(true)
}
+ useEffect(() => {
+ const reinitBtn = document.getElementById("reinit-btn");
+ reinitBtn.addEventListener("click", () => {
+ setIsOpen(false)
+ })
+ }, [])
+
return (
diff --git a/src/components/embeddedChatBox/index.js b/src/components/embeddedChatBox/index.js
deleted file mode 100644
index 712ee58..0000000
--- a/src/components/embeddedChatBox/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from "react";
-import ReactDOM from "react-dom/client";
-import EmbeddedChat from './EmbeddedChat'
-
-const root = ReactDOM.createRoot(document.getElementById('docsbot-widget-embed'))
-
-root.render(
-
-)
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
new file mode 100644
index 0000000..9cb982b
--- /dev/null
+++ b/src/main.js
@@ -0,0 +1,11 @@
+import React from "react";
+import ReactDOM from "react-dom/client";
+import EmbeddedChat from './components/embeddedChatBox/EmbeddedChat'
+
+const root = ReactDOM.createRoot(document.getElementById('parent-root'))
+
+root.render(
+ <>
+
+ >
+)
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
index 4146399..fe1b145 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -6,8 +6,8 @@ const TerserPlugin = require("terser-webpack-plugin");
module.exports = (_, { mode }) => {
return {
entry: {
+ main: "./src/main.js",
chat: "./src/components/embeddableWidget/EmbeddableWidget.jsx",
- embeddedChat: "./src/components/embeddedChatBox/index.js"
},
output: {
path: path.resolve(__dirname, "build"),
From b05619fb3928456ceba16ed930f8a7b458658d7f Mon Sep 17 00:00:00 2001
From: Yuvraj Singh
Date: Thu, 7 Sep 2023 18:04:52 +0530
Subject: [PATCH 09/17] file name update and button text change in embedded
---
src/components/embeddedChatBox/EmbeddedChat.jsx | 10 +++++++---
src/{main.js => index.js} | 0
webpack.config.js | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)
rename src/{main.js => index.js} (100%)
diff --git a/src/components/embeddedChatBox/EmbeddedChat.jsx b/src/components/embeddedChatBox/EmbeddedChat.jsx
index 79516d2..ade24aa 100644
--- a/src/components/embeddedChatBox/EmbeddedChat.jsx
+++ b/src/components/embeddedChatBox/EmbeddedChat.jsx
@@ -26,9 +26,13 @@ const EmbeddedChat = () => {
useEffect(() => {
const reinitBtn = document.getElementById("reinit-btn");
- reinitBtn.addEventListener("click", () => {
+ const reinitBtnEventListener = reinitBtn.addEventListener("click", () => {
setIsOpen(false)
})
+
+ return ()=>{
+ removeEventListener(reinitBtnEventListener)
+ }
}, [])
return (
@@ -41,8 +45,8 @@ const EmbeddedChat = () => {
-
-
+
+
{
isOpen ?
diff --git a/src/main.js b/src/index.js
similarity index 100%
rename from src/main.js
rename to src/index.js
diff --git a/webpack.config.js b/webpack.config.js
index fe1b145..9b78573 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -6,7 +6,7 @@ const TerserPlugin = require("terser-webpack-plugin");
module.exports = (_, { mode }) => {
return {
entry: {
- main: "./src/main.js",
+ main: "./src/index.js",
chat: "./src/components/embeddableWidget/EmbeddableWidget.jsx",
},
output: {
From 00be543a1583d2af5d590c493b7849cb959a6ae9 Mon Sep 17 00:00:00 2001
From: Yuvraj Singh
Date: Thu, 7 Sep 2023 18:08:40 +0530
Subject: [PATCH 10/17] removed input ref focus for embedded chat
---
src/components/chatbot/Chatbot.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/chatbot/Chatbot.jsx b/src/components/chatbot/Chatbot.jsx
index ef9364c..8f4d2fd 100644
--- a/src/components/chatbot/Chatbot.jsx
+++ b/src/components/chatbot/Chatbot.jsx
@@ -106,7 +106,7 @@ export const Chatbot = ({ isOpen, setIsOpen , isEmbeddedBox }) => {
}
//only focus on input if not mobile
- if (mediaMatch.matches) {
+ if (mediaMatch.matches && !isEmbeddedBox) {
inputRef.current.focus();
}
};
From da5b05077f9048a8fde96e6bcba11e94698f7c56 Mon Sep 17 00:00:00 2001
From: Yuvraj Singh
Date: Fri, 8 Sep 2023 10:45:32 +0530
Subject: [PATCH 11/17] fixed embedded chatbox width and height
---
.../embeddedChatBox/embeddedChat.css | 22 ++++++++++++++-----
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/components/embeddedChatBox/embeddedChat.css b/src/components/embeddedChatBox/embeddedChat.css
index 465abd3..ecf84da 100644
--- a/src/components/embeddedChatBox/embeddedChat.css
+++ b/src/components/embeddedChatBox/embeddedChat.css
@@ -6,10 +6,12 @@
.iframe-box{
position: relative;
- width: 80%;
- height: 500px;
+ width: 600px;
+ height: 450px;
box-sizing: border-box;
margin: auto;
+ border-radius: 10px;
+ border: 2px solid #ded4d4;
}
#root {
@@ -55,8 +57,19 @@
margin-left: 0;
}
+ @media (max-width: 650px){
+ .iframe-box{
+ width: 450px;
+ height: 350px;
+ }
+ }
+
/* on mobile make the chat window full screen */
@media (max-width: 480px) {
+ .iframe-box{
+ width: 100%;
+ height: 300px;
+ }
.docsbot-wrapper {
width: 100%;
right: 0;
@@ -71,9 +84,6 @@
left: 0;
right: unset;
}
- .docsbot-chat-container {
- border-radius: 0;
- }
.floating-button.is-open {
display: none;
}
@@ -82,7 +92,7 @@
}
.docsbot-chat-inner-container {
height: 100%;
- border-radius: 0;
+ /* border-radius: 0; */
}
}
\ No newline at end of file
From 78314c6eef582b4d676850ddbddd87b1ca5da689 Mon Sep 17 00:00:00 2001
From: Yuvraj Singh
Date: Sat, 9 Sep 2023 12:58:09 +0530
Subject: [PATCH 12/17] changed id name and entry points
---
public/index.html | 2 +-
src/components/embeddableWidget/EmbeddableWidget.jsx | 4 +---
src/index.js | 2 +-
webpack.config.js | 7 ++-----
4 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/public/index.html b/public/index.html
index cea365a..608a822 100644
--- a/public/index.html
+++ b/public/index.html
@@ -99,7 +99,7 @@ Embeddable Widget Demo
quis, accumsan porttitor, facilisis luctus, metus
-
+
HTML Ipsum Presents
diff --git a/src/components/embeddableWidget/EmbeddableWidget.jsx b/src/components/embeddableWidget/EmbeddableWidget.jsx
index eb8ff6c..1ece9ab 100644
--- a/src/components/embeddableWidget/EmbeddableWidget.jsx
+++ b/src/components/embeddableWidget/EmbeddableWidget.jsx
@@ -38,13 +38,11 @@ export default class EmbeddableWidget {
}
const el = document.createElement("div");
el.id = "docsbotai-root";
- const parentRootElement = document.getElementById('parent-root')
if (parentElement) {
document.querySelector(parentElement).appendChild(el);
} else {
- parentRootElement.appendChild(el)
+ document.body.appendChild(el);
}
-
const root = ReactDOM.createRoot(el);
root.render(component);
diff --git a/src/index.js b/src/index.js
index 9cb982b..8f99d52 100644
--- a/src/index.js
+++ b/src/index.js
@@ -2,7 +2,7 @@ import React from "react";
import ReactDOM from "react-dom/client";
import EmbeddedChat from './components/embeddedChatBox/EmbeddedChat'
-const root = ReactDOM.createRoot(document.getElementById('parent-root'))
+const root = ReactDOM.createRoot(document.getElementById('docsbot-widget-embed'))
root.render(
<>
diff --git a/webpack.config.js b/webpack.config.js
index 9b78573..65ee5a7 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -5,14 +5,11 @@ const TerserPlugin = require("terser-webpack-plugin");
module.exports = (_, { mode }) => {
return {
- entry: {
- main: "./src/index.js",
- chat: "./src/components/embeddableWidget/EmbeddableWidget.jsx",
- },
+ entry: ["./src/index.js", "./src/components/embeddableWidget/EmbeddableWidget.jsx"],
output: {
path: path.resolve(__dirname, "build"),
publicPath: "/",
- filename: "[name].js",
+ filename: "chat.js",
library: "DocsBotAI",
libraryExport: "default",
libraryTarget: "window",
From a390543fbea7befcb86ab20151692ce17558ff6e Mon Sep 17 00:00:00 2001
From: Aaron Edwards
Date: Mon, 11 Sep 2023 17:10:56 -0500
Subject: [PATCH 13/17] Minor css changes
---
public/index.html | 2 +-
src/components/embeddedChatBox/EmbeddedChat.jsx | 2 +-
src/components/embeddedChatBox/embeddedChat.css | 12 ++++++------
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/public/index.html b/public/index.html
index 608a822..d0797b6 100644
--- a/public/index.html
+++ b/public/index.html
@@ -99,7 +99,7 @@ Embeddable Widget Demo
quis, accumsan porttitor, facilisis luctus, metus
-
{
- isOpen ?
+ isOpen ?
diff --git a/src/components/embeddedChatBox/embeddedChat.css b/src/components/embeddedChatBox/embeddedChat.css
index ecf84da..b220b5a 100644
--- a/src/components/embeddedChatBox/embeddedChat.css
+++ b/src/components/embeddedChatBox/embeddedChat.css
@@ -4,14 +4,14 @@
margin-bottom: 10px;
}
-.iframe-box{
+.docsbot-iframe-box{
position: relative;
- width: 600px;
- height: 450px;
+ width: 100%;
+ height: 100%;
box-sizing: border-box;
margin: auto;
border-radius: 10px;
- border: 2px solid #ded4d4;
+ border: 1px solid #ded4d4;
}
#root {
@@ -58,7 +58,7 @@
}
@media (max-width: 650px){
- .iframe-box{
+ .docsbot-iframe-box{
width: 450px;
height: 350px;
}
@@ -66,7 +66,7 @@
/* on mobile make the chat window full screen */
@media (max-width: 480px) {
- .iframe-box{
+ .docsbot-iframe-box{
width: 100%;
height: 300px;
}
From fa45973da798af5af75a339840415a56cf52b7f9 Mon Sep 17 00:00:00 2001
From: Yuvraj Singh
Date: Tue, 12 Sep 2023 14:45:15 +0530
Subject: [PATCH 14/17] handled case if no embedded div found in dom and
removed button
---
src/components/embeddedChatBox/EmbeddedChat.jsx | 15 ++++-----------
src/index.js | 15 ++++++++++++++-
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/components/embeddedChatBox/EmbeddedChat.jsx b/src/components/embeddedChatBox/EmbeddedChat.jsx
index abe37b8..38c7892 100644
--- a/src/components/embeddedChatBox/EmbeddedChat.jsx
+++ b/src/components/embeddedChatBox/EmbeddedChat.jsx
@@ -30,33 +30,26 @@ const EmbeddedChat = () => {
setIsOpen(false)
})
- return ()=>{
+ return () => {
removeEventListener(reinitBtnEventListener)
}
}, [])
return (
-
+
-
-
-
-
-
- {
- isOpen ?
)
}
diff --git a/src/index.js b/src/index.js
index 8f99d52..a6e1c3c 100644
--- a/src/index.js
+++ b/src/index.js
@@ -2,7 +2,20 @@ import React from "react";
import ReactDOM from "react-dom/client";
import EmbeddedChat from './components/embeddedChatBox/EmbeddedChat'
-const root = ReactDOM.createRoot(document.getElementById('docsbot-widget-embed'))
+let el = null;
+const embeddedElement = document.getElementById('docsbot-widget-embed')
+if (embeddedElement) {
+ el = embeddedElement
+}
+else {
+ const embeddedElement = document.createElement("div");
+ embeddedElement.id = "docsbot-widget-embed";
+ embeddedElement.style = "width:600px;height:450px;margin:auto 20px;"
+ document.body.appendChild(embeddedElement)
+ el = embeddedElement
+}
+
+const root = ReactDOM.createRoot(el)
root.render(
<>
From 33f2eee6694e8b79788ed74a3411ef7aab1333a5 Mon Sep 17 00:00:00 2001
From: Yuvraj Singh
Date: Wed, 13 Sep 2023 12:27:28 +0530
Subject: [PATCH 15/17] added dynamic rendering of embedded chat and widget ,
reduced code size
---
.../embeddableWidget/EmbeddableWidget.jsx | 31 ++++++++++------
.../embeddedChatBox/EmbeddedChat.jsx | 36 +++----------------
src/index.js | 24 -------------
webpack.config.js | 2 +-
4 files changed, 27 insertions(+), 66 deletions(-)
delete mode 100644 src/index.js
diff --git a/src/components/embeddableWidget/EmbeddableWidget.jsx b/src/components/embeddableWidget/EmbeddableWidget.jsx
index 1ece9ab..1f79eba 100644
--- a/src/components/embeddableWidget/EmbeddableWidget.jsx
+++ b/src/components/embeddableWidget/EmbeddableWidget.jsx
@@ -3,7 +3,7 @@ import ReactDOM from "react-dom/client";
import App from "../app/App";
import { ConfigProvider } from "../configContext/ConfigContext";
import { Emitter } from "../../utils/event-emitter";
-
+import EmbeddedChat from '../embeddedChatBox/EmbeddedChat'
export default class EmbeddableWidget {
static _root;
static el;
@@ -26,24 +26,35 @@ export default class EmbeddableWidget {
}
static mount({ parentElement = null, ...props } = {}) {
+ const embeddedChatElement = document.getElementById('docsbot-widget-embed')
const component = (
-
+ {
+ embeddedChatElement ? :
+ }
);
const doRender = () => {
if (EmbeddableWidget.el) {
- throw new Error("EmbeddableWidget is already mounted, unmount first");
+ console.warn("EmbeddableWidget is already mounted, unmount first");
+ return false
+ }
+ let el = null
+ let root = null
+ if (embeddedChatElement) {
+ el = embeddedChatElement
}
- const el = document.createElement("div");
- el.id = "docsbotai-root";
- if (parentElement) {
- document.querySelector(parentElement).appendChild(el);
- } else {
- document.body.appendChild(el);
+ else {
+ el = document.createElement("div");
+ el.id = "docsbotai-root";
+ if (parentElement) {
+ document.querySelector(parentElement).appendChild(el);
+ } else {
+ document.body.appendChild(el);
+ }
}
- const root = ReactDOM.createRoot(el);
+ root = ReactDOM.createRoot(el);
root.render(component);
this._root = root;
diff --git a/src/components/embeddedChatBox/EmbeddedChat.jsx b/src/components/embeddedChatBox/EmbeddedChat.jsx
index 38c7892..e612d92 100644
--- a/src/components/embeddedChatBox/EmbeddedChat.jsx
+++ b/src/components/embeddedChatBox/EmbeddedChat.jsx
@@ -1,7 +1,6 @@
-import React, { useEffect, useState } from 'react'
+import React from 'react'
import { Chatbot } from '../chatbot/Chatbot';
import { ChatbotProvider } from '../chatbotContext/ChatbotContext';
-import { ConfigProvider } from '../configContext/ConfigContext';
import fontAwesomeStyles from "!raw-loader!@fortawesome/fontawesome-svg-core/styles.css";
import reactChatbotStyles from "!raw-loader!../../chatbot.css";
@@ -11,29 +10,6 @@ import linkListStyles from "!raw-loader!../linkList/LinkList.css";
import embeddedChatStyles from "!raw-loader!./embeddedChat.css"
const EmbeddedChat = () => {
- const [isOpen, setIsOpen] = useState(false)
- const [config] = useState({
- id: "ZrbLG98bbxZ9EFqiPvyl/UaRQtd7AOTaMXeRQGQRl",
- })
-
- const handleOpenEmbeddedBox = () => {
- const floatChatBox = document.getElementById('docsbotai-root')
- if (floatChatBox) {
- window?.DocsBotAI.unmount()
- }
- setIsOpen(true)
- }
-
- useEffect(() => {
- const reinitBtn = document.getElementById("reinit-btn");
- const reinitBtnEventListener = reinitBtn.addEventListener("click", () => {
- setIsOpen(false)
- })
-
- return () => {
- removeEventListener(reinitBtnEventListener)
- }
- }, [])
return (
@@ -44,12 +20,10 @@ const EmbeddedChat = () => {
-
-
-
-
-
-
+
+
+
+
)
}
diff --git a/src/index.js b/src/index.js
deleted file mode 100644
index a6e1c3c..0000000
--- a/src/index.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import React from "react";
-import ReactDOM from "react-dom/client";
-import EmbeddedChat from './components/embeddedChatBox/EmbeddedChat'
-
-let el = null;
-const embeddedElement = document.getElementById('docsbot-widget-embed')
-if (embeddedElement) {
- el = embeddedElement
-}
-else {
- const embeddedElement = document.createElement("div");
- embeddedElement.id = "docsbot-widget-embed";
- embeddedElement.style = "width:600px;height:450px;margin:auto 20px;"
- document.body.appendChild(embeddedElement)
- el = embeddedElement
-}
-
-const root = ReactDOM.createRoot(el)
-
-root.render(
- <>
-
- >
-)
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
index 65ee5a7..f4678e2 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -5,7 +5,7 @@ const TerserPlugin = require("terser-webpack-plugin");
module.exports = (_, { mode }) => {
return {
- entry: ["./src/index.js", "./src/components/embeddableWidget/EmbeddableWidget.jsx"],
+ entry: "./src/components/embeddableWidget/EmbeddableWidget.jsx",
output: {
path: path.resolve(__dirname, "build"),
publicPath: "/",
From 3adba7882d5bd7d2c373cafabb12a308baa59e6c Mon Sep 17 00:00:00 2001
From: Aaron Edwards
Date: Thu, 14 Sep 2023 15:52:31 -0500
Subject: [PATCH 16/17] Add optional header removal Fix mobile view
---
public/index.html | 7 +-
src/components/chatbot/Chatbot.jsx | 117 +++++++++---------
.../embeddedChatBox/embeddedChat.css | 14 +--
3 files changed, 67 insertions(+), 71 deletions(-)
diff --git a/public/index.html b/public/index.html
index d0797b6..05fc41a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -38,7 +38,7 @@ Embeddable Widget Demo
},
//signature: 'hmachash:expiry',
options: {
- alignment: 'right',
+ alignment: 'left',
horizontalMargin: 20,
verticalMargin: 20,
//hideSources: true,
@@ -48,6 +48,7 @@ Embeddable Widget Demo
logo: "https://docsbot.ai/branding/docsbot-logo-white.png",
//headerAlignment: "left",
//logo: "https://docsbot.ai/branding/docsbot-logo-lg.png",
+ //hideHeader: true,
}
}).then(() => {
// Script is safely loaded, you can do whatever you want from here with bot
@@ -99,8 +100,8 @@ Embeddable Widget Demo
quis, accumsan porttitor, facilisis luctus, metus
-
-
+
+
HTML Ipsum Presents
diff --git a/src/components/chatbot/Chatbot.jsx b/src/components/chatbot/Chatbot.jsx
index 8f4d2fd..9ebaf16 100644
--- a/src/components/chatbot/Chatbot.jsx
+++ b/src/components/chatbot/Chatbot.jsx
@@ -18,7 +18,7 @@ import clsx from "clsx";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faXmark, faRefresh } from "@fortawesome/free-solid-svg-icons";
-export const Chatbot = ({ isOpen, setIsOpen , isEmbeddedBox }) => {
+export const Chatbot = ({ isOpen, setIsOpen, isEmbeddedBox }) => {
const [chatInput, setChatInput] = useState("");
const [refreshChat, setRefreshChat] = useState(false);
const { dispatch, state } = useChatbot();
@@ -38,6 +38,7 @@ export const Chatbot = ({ isOpen, setIsOpen , isEmbeddedBox }) => {
verticalMargin,
logo,
headerAlignment,
+ hideHeader,
} = useConfig();
const ref = useRef();
const inputRef = useRef();
@@ -58,7 +59,7 @@ export const Chatbot = ({ isOpen, setIsOpen , isEmbeddedBox }) => {
id: uuidv4(),
variant: "chatbot",
message: parsedMessage,
- timestamp: Date.now()
+ timestamp: Date.now(),
},
});
}
@@ -71,19 +72,17 @@ export const Chatbot = ({ isOpen, setIsOpen , isEmbeddedBox }) => {
const savedConversation = JSON.parse(
localStorage.getItem("docsbot_chat_history")
);
- const currentTime = Date.now()
- let lastMsgTimeStamp = 0
- if(savedConversation){
- Object.values(savedConversation)?.map(message=>{
- if(message?.timestamp > lastMsgTimeStamp){
- lastMsgTimeStamp = message?.timestamp
+ const currentTime = Date.now();
+ let lastMsgTimeStamp = 0;
+ if (savedConversation) {
+ Object.values(savedConversation)?.map((message) => {
+ if (message?.timestamp > lastMsgTimeStamp) {
+ lastMsgTimeStamp = message?.timestamp;
}
- })
- if(currentTime - lastMsgTimeStamp > 12 * 60 * 60 * 1000){
- setRefreshChat(true)
- }
- else
- {
+ });
+ if (currentTime - lastMsgTimeStamp > 12 * 60 * 60 * 1000) {
+ setRefreshChat(true);
+ } else {
dispatch({
type: "load_conversation",
payload: { savedConversation: savedConversation },
@@ -114,14 +113,11 @@ export const Chatbot = ({ isOpen, setIsOpen , isEmbeddedBox }) => {
fetchData();
}, [labels.firstMessage]);
-
-
useEffect(() => {
localStorage.setItem(
"docsbot_chat_history",
JSON.stringify(state.messages)
);
-
}, [state.messages]);
function fetchAnswer(question) {
@@ -134,7 +130,7 @@ export const Chatbot = ({ isOpen, setIsOpen , isEmbeddedBox }) => {
variant: "chatbot",
message: null,
loading: true,
- timestamp: Date.now()
+ timestamp: Date.now(),
},
});
ref.current.scrollTop = ref.current.scrollHeight;
@@ -293,68 +289,73 @@ export const Chatbot = ({ isOpen, setIsOpen , isEmbeddedBox }) => {
part="wrapper"
>
-
- {
- !isEmbeddedBox &&
{
- e.preventDefault();
- setIsOpen(false);
- }}
- sr-label="Close chat"
- >
-
-
- {labels.close || "Close"}
-
-
- }
+
+ {!isEmbeddedBox && (
+
{
+ e.preventDefault();
+ setIsOpen(false);
+ }}
+ sr-label="Close chat"
+ >
+
+
+ {labels.close || "Close"}
+
+
+ )}
-
- {isEmbeddedBox? null :
- logo ? (
-
) : (
<>
-
{botName}
-
{description}
- >
+
{botName}
+
{description}
+ >
)}
diff --git a/src/components/embeddedChatBox/embeddedChat.css b/src/components/embeddedChatBox/embeddedChat.css
index b220b5a..7bfe6c8 100644
--- a/src/components/embeddedChatBox/embeddedChat.css
+++ b/src/components/embeddedChatBox/embeddedChat.css
@@ -10,7 +10,7 @@
height: 100%;
box-sizing: border-box;
margin: auto;
- border-radius: 10px;
+ border-radius: 15px;
border: 1px solid #ded4d4;
}
@@ -45,7 +45,7 @@
}
.docsbot-chat-container {
- border-radius: 10px;
+ border-radius: 15px;
background-color: rgb(249, 250, 250);
height: 100%;
width: 100%;
@@ -56,19 +56,13 @@
width: auto;
margin-left: 0;
}
-
- @media (max-width: 650px){
- .docsbot-iframe-box{
- width: 450px;
- height: 350px;
- }
- }
/* on mobile make the chat window full screen */
@media (max-width: 480px) {
.docsbot-iframe-box{
width: 100%;
- height: 300px;
+ height: 100%;
+ max-height: calc(100vh - 120px);
}
.docsbot-wrapper {
width: 100%;
From 0a778aa4ac5301653285eb16979f15f3bdf6a4b2 Mon Sep 17 00:00:00 2001
From: Yuvraj Singh
Date: Wed, 11 Oct 2023 10:38:09 +0530
Subject: [PATCH 17/17] use of reset lable
---
src/components/chatbot/Chatbot.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/chatbot/Chatbot.jsx b/src/components/chatbot/Chatbot.jsx
index 2eb7498..2633c14 100644
--- a/src/components/chatbot/Chatbot.jsx
+++ b/src/components/chatbot/Chatbot.jsx
@@ -346,7 +346,7 @@ export const Chatbot = ({ isOpen, setIsOpen, isEmbeddedBox }) => {