Skip to content

Commit

Permalink
refactor: remove webchat prefix from input panel and chat area
Browse files Browse the repository at this point in the history
  • Loading branch information
vanbasten17 committed Oct 3, 2024
1 parent 1339085 commit 9e6852f
Show file tree
Hide file tree
Showing 12 changed files with 413 additions and 997 deletions.
1,384 changes: 400 additions & 984 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { BotonicContainerId } from '../constants'
import { useWebchatDimensions } from '../hooks'
import { WebchatMessageList } from '../message-list'
import { WebchatReplies } from '../replies'
import { StyledWebchatChatArea } from './styles'
import { StyledChatArea } from './styles'

export const WebchatChatArea = () => {
export const ChatArea = () => {
const {
webchatState: { replies },
chatAreaRef,
Expand All @@ -21,7 +21,7 @@ export const WebchatChatArea = () => {
}, [])

return (
<StyledWebchatChatArea
<StyledChatArea
id={BotonicContainerId.ChatArea}
ref={chatAreaRef}
height={chatAreaHeight}
Expand All @@ -30,6 +30,6 @@ export const WebchatChatArea = () => {
{replies && Object.keys(replies).length > 0 && (
<WebchatReplies replies={replies} />
)}
</StyledWebchatChatArea>
</StyledChatArea>
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components'

export const StyledWebchatChatArea = styled.div<{ height: number }>`
export const StyledChatArea = styled.div<{ height: number }>`
display: inherit;
flex-direction: inherit;
height: ${props => props.height}px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SendButton } from './send-button'
import { UserInputContainer } from './styles'
import { Textarea } from './textarea'

interface WebchatInputPanelProps {
interface InputPanelProps {
persistentMenu: any
enableEmojiPicker: boolean
enableAttachments: boolean
Expand All @@ -24,15 +24,15 @@ interface WebchatInputPanelProps {
onUserInput?: (event: any) => Promise<void>
}

export const WebchatInputPanel = ({
export const InputPanel = ({
persistentMenu,
enableEmojiPicker,
enableAttachments,
handleAttachment,
textareaRef,
host,
onUserInput,
}: WebchatInputPanelProps) => {
}: InputPanelProps) => {
const {
getThemeProperty,
sendText,
Expand Down
10 changes: 5 additions & 5 deletions packages/botonic-react/src/webchat/webchat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
initSession,
shouldKeepSessionOnReload,
} from '../util/webchat'
import { ChatArea } from './chat-area'
import { OpenedPersistentMenu } from './components/opened-persistent-menu'
import { BotonicContainerId } from './constants'
import { WebchatHeader } from './header'
Expand All @@ -51,11 +52,10 @@ import {
useTyping,
useWebchat,
} from './hooks'
import { InputPanel } from './input-panel'
import { TriggerButton } from './trigger-button'
import { useStorageState } from './use-storage-state-hook'
import { getParsedAction } from './utils'
import { WebchatChatArea } from './webchat-chat-area'
import { WebchatInputPanel } from './webchat-input-panel'
import { WebviewContainer } from './webview'

const StyledWebchat = styled.div`
Expand Down Expand Up @@ -727,7 +727,7 @@ export const Webchat = forwardRef((props, ref) => {
<StyledWebchat
id={BotonicContainerId.Webchat}
ref={webchatRef}
// TODO: Distinguis between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
// TODO: Distinguish between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
role={ROLES.WEBCHAT}
width={webchatState.width}
height={webchatState.height}
Expand All @@ -748,13 +748,13 @@ export const Webchat = forwardRef((props, ref) => {
<ErrorMessage>{webchatState.error.message}</ErrorMessage>
</ErrorMessageContainer>
)}
<WebchatChatArea />
<ChatArea />

{webchatState.isPersistentMenuOpen && (
<DarkenBackground component={persistentMenu()} />
)}
{!webchatState.handoff && userInputEnabled && (
<WebchatInputPanel
<InputPanel
persistentMenu={props.persistentMenu}
enableEmojiPicker={props.enableEmojiPicker}
enableAttachments={props.enableAttachments}
Expand Down

0 comments on commit 9e6852f

Please sign in to comment.