Skip to content

Commit

Permalink
support Chatwoot expanded bubble
Browse files Browse the repository at this point in the history
  • Loading branch information
billykwok committed Mar 2, 2022
1 parent 3068167 commit f8139dd
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions src/components/Chatwoot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import useChat from '../../hooks/useChat'
const styles: {
button: CSSProperties
img: CSSProperties
expandedButton: CSSProperties
expandedImg: CSSProperties
launcherTitle: CSSProperties
close: CSSProperties
} = {
button: {
Expand All @@ -24,6 +27,27 @@ const styles: {
margin: '20px',
width: '24px'
},
expandedButton: {
display: 'flex',
bottom: '24px',
height: '48px',
width: 'auto'
},
expandedImg: {
height: '20px',
margin: '14px 8px 14px 16px',
width: '20px'
},
launcherTitle: {
display: 'flex',
color: '#fff',
alignItems: 'center',
paddingRight: '20px',
fontFamily:
'system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, Arial, sans-serif',
fontSize: '16px',
fontWeight: 500
},
close: {
backgroundColor: '#fff',
height: '24px',
Expand All @@ -36,9 +60,10 @@ const styles: {

interface Props {
color?: string
launcherTitle?: string
}

const Provider = ({ color }: Props): JSX.Element | null => {
const Provider = ({ color, launcherTitle }: Props): JSX.Element | null => {
const [state, loadChat] = useChat({ loadWhenIdle: true })

if (state === 'complete') return null
Expand All @@ -54,15 +79,24 @@ const Provider = ({ color }: Props): JSX.Element | null => {
onMouseEnter={() => loadChat({ open: false })}
style={{
...styles.button,
...(launcherTitle && styles.expandedButton),
backgroundColor: color
}}
>
{state === 'initial' ? (
<img
style={styles.img}
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAUVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////8IN+deAAAAGnRSTlMAAwgJEBk0TVheY2R5eo+ut8jb5OXs8fX2+cjRDTIAAADsSURBVHgBldZbkoMgFIThRgQv8SKKgGf/C51UnJqaRI30/9zfe+NQUQ3TvG7bOk9DVeCmshmj/CuOTYnrdBfkUOg0zlOtl9OWVuEk4+QyZ3DIevmSt/ioTvK1VH/s5bY3YdM9SBZ/mUUyWgx+U06ycgp7D8msxSvtc4HXL9BLdj2elSEfhBJAI0QNgJEBI1BEBsQClVBVGDgwYOLAhJkDM1YOrNg4sLFAsLJgZsHEgoEFFQt0JAFGFjQsKAMJ0LFAexKgZYFyJIDxJIBNJEDNAtSJBLCeBDCOBFAPzwFA94ED+zmhwDO9358r8ANtIsMXi7qVAwAAAABJRU5ErkJggg=="
alt="bubble-icon"
/>
<>
<img
style={{
...styles.img,
...(launcherTitle && styles.expandedImg)
}}
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAUVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////8IN+deAAAAGnRSTlMAAwgJEBk0TVheY2R5eo+ut8jb5OXs8fX2+cjRDTIAAADsSURBVHgBldZbkoMgFIThRgQv8SKKgGf/C51UnJqaRI30/9zfe+NQUQ3TvG7bOk9DVeCmshmj/CuOTYnrdBfkUOg0zlOtl9OWVuEk4+QyZ3DIevmSt/ioTvK1VH/s5bY3YdM9SBZ/mUUyWgx+U06ycgp7D8msxSvtc4HXL9BLdj2elSEfhBJAI0QNgJEBI1BEBsQClVBVGDgwYOLAhJkDM1YOrNg4sLFAsLJgZsHEgoEFFQt0JAFGFjQsKAMJ0LFAexKgZYFyJIDxJIBNJEDNAtSJBLCeBDCOBFAPzwFA94ED+zmhwDO9358r8ANtIsMXi7qVAwAAAABJRU5ErkJggg=="
alt="bubble-icon"
/>
{launcherTitle ? (
<div style={styles.launcherTitle}>{launcherTitle}</div>
) : null}
</>
) : (
<>
<div style={{ ...styles.close, transform: 'rotate(45deg)' }} />
Expand Down

0 comments on commit f8139dd

Please sign in to comment.