From f9bbfb324316a53fecd3c7bbe054fd420182e8fe Mon Sep 17 00:00:00 2001 From: Krajcik Ondrej Date: Thu, 4 Nov 2021 12:57:45 +0100 Subject: [PATCH] support for no launcher --- README.md | 2 +- src/components/Widget/index.tsx | 2 +- src/components/Widget/layout.tsx | 33 +++++++++++++++++--------------- src/index.tsx | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b8f9aa7fc..5c7af7615 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ export default App; |**showCloseButton**|boolean|NO|false|Show or hide the close button in full screen mode| |**fullScreenMode**|boolean|NO|false|Allow the use of full screen in full desktop mode| |**autofocus**|boolean|NO|true|Autofocus or not the user input| -|**launcher**|(handleToggle) => ElementType|NO||Custom Launcher component to use instead of the default| +|**launcher**|(handleToggle) => ElementType|NO|Custom Launcher component to use instead of the default|Use null for no launcher |**handleQuickButtonClicked**|(...args: any[]) => any|NO||Function to handle the user clicking a quick button, will receive the 'value' when clicked.| |**showTimeStamp**|boolean|NO|true|Show time stamp on messages| |**chatId**|string|NO|'rcw-chat-container'|Chat container id for a11y| diff --git a/src/components/Widget/index.tsx b/src/components/Widget/index.tsx index cb9714c2e..59239f89a 100644 --- a/src/components/Widget/index.tsx +++ b/src/components/Widget/index.tsx @@ -16,7 +16,7 @@ type Props = { showCloseButton: boolean; fullScreenMode: boolean; autofocus: boolean; - customLauncher?: AnyFunction; + customLauncher?: AnyFunction|null; handleNewUserMessage: AnyFunction; handleQuickButtonClicked?: AnyFunction; handleTextInputChange?: (event: any) => void; diff --git a/src/components/Widget/layout.tsx b/src/components/Widget/layout.tsx index 982fcecee..7314f8347 100644 --- a/src/components/Widget/layout.tsx +++ b/src/components/Widget/layout.tsx @@ -25,7 +25,7 @@ type Props = { showCloseButton: boolean; fullScreenMode: boolean; autofocus: boolean; - customLauncher?: AnyFunction; + customLauncher?: AnyFunction|null; onTextInputChange?: (event: any) => void; chatId: string; launcherOpenLabel: string; @@ -86,7 +86,7 @@ function WidgetLayout({ messageRef.current = null; } }, [showChat]) - + const eventHandle = evt => { if(evt.target && evt.target.className === 'rcw-message-img') { const { src, alt, naturalWidth, naturalHeight } = (evt.target as HTMLImageElement); @@ -118,6 +118,21 @@ function WidgetLayout({ document.body.setAttribute('style', `overflow: ${visible || fullScreenMode ? 'hidden' : 'auto'}`) }, [fullScreenMode, visible]) + const renderLauncher = () => { + return (customLauncher ? + customLauncher(onToggleConversation) : + !fullScreenMode && + ) + }; + return (
} - {customLauncher ? - customLauncher(onToggleConversation) : - !fullScreenMode && - - } + {customLauncher !== null && renderLauncher()} { imagePreview && } diff --git a/src/index.tsx b/src/index.tsx index 758e5088c..a72a94f69 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -18,7 +18,7 @@ type Props = { autofocus?: boolean; profileAvatar?: string; profileClientAvatar?: string; - launcher?: AnyFunction; + launcher?: AnyFunction|null; handleTextInputChange?: (event: any) => void; chatId?: string; handleToggle?: AnyFunction;