Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for no launcher #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion src/components/Widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
33 changes: 18 additions & 15 deletions src/components/Widget/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -118,6 +118,21 @@ function WidgetLayout({
document.body.setAttribute('style', `overflow: ${visible || fullScreenMode ? 'hidden' : 'auto'}`)
}, [fullScreenMode, visible])

const renderLauncher = () => {
return (customLauncher ?
customLauncher(onToggleConversation) :
!fullScreenMode &&
<Launcher
toggle={onToggleConversation}
chatId={chatId}
openLabel={launcherOpenLabel}
closeLabel={launcherCloseLabel}
closeImg={launcherCloseImg}
openImg={launcherOpenImg}
showBadge={showBadge}
/>)
};

return (
<div
className={cn('rcw-widget-container', {
Expand Down Expand Up @@ -149,19 +164,7 @@ function WidgetLayout({
emojis={emojis}
/>
}
{customLauncher ?
customLauncher(onToggleConversation) :
!fullScreenMode &&
<Launcher
toggle={onToggleConversation}
chatId={chatId}
openLabel={launcherOpenLabel}
closeLabel={launcherCloseLabel}
closeImg={launcherCloseImg}
openImg={launcherOpenImg}
showBadge={showBadge}
/>
}
{customLauncher !== null && renderLauncher()}
{
imagePreview && <FullScreenPreview fullScreenMode={fullScreenMode} zoomStep={zoomStep} />
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down