Skip to content

Commit

Permalink
feat(react): coverComponentProps
Browse files Browse the repository at this point in the history
  • Loading branch information
Aina Vendrell authored and Aina Vendrell committed Sep 29, 2020
1 parent 4da5529 commit 18419c5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/botonic-react/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export const WEBCHAT = {
blockInputs: 'userInput.blockInputs',
scrollbar: 'scrollbar',
markdownStyle: 'markdownStyle',
coverComponent: 'coverComponent',
coverComponent: 'coverComponent.component',
coverComponentProps: 'coverComponent.props',
mobileBreakpoint: 'mobileBreakpoint',
mobileStyle: 'mobileStyle',
enableCarouselArrows: 'carousel.enableArrows',
Expand Down
24 changes: 19 additions & 5 deletions packages/botonic-react/src/webchat/webchat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,14 @@ export const Webchat = forwardRef((props, ref) => {
)
}

const CoverComponent = getThemeProperty(
'coverComponent',
props.coverComponent
)
const getCoverComponent = () => {
return getThemeProperty(
WEBCHAT.CUSTOM_PROPERTIES.coverComponent,
props.coverComponent &&
(props.coverComponent.component || props.coverComponent)
)
}
const CoverComponent = getCoverComponent()

const closeCoverComponent = () => {
toggleCoverComponent(false)
Expand All @@ -430,8 +434,18 @@ export const Webchat = forwardRef((props, ref) => {
}, [])

const coverComponent = () => {
const coverComponentProps = getThemeProperty(
WEBCHAT.CUSTOM_PROPERTIES.coverComponentProps,
props.coverComponent && props.coverComponent.props
)

if (CoverComponent && webchatState.isCoverComponentOpen)
return <CoverComponent closeComponent={closeCoverComponent} />
return (
<CoverComponent
closeComponent={closeCoverComponent}
{...coverComponentProps}
/>
)
return null
}

Expand Down

0 comments on commit 18419c5

Please sign in to comment.