Skip to content

Commit ca6d777

Browse files
committed
Add support for a custom initial Intercom icon
1 parent df385b8 commit ca6d777

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

src/components/Intercom/index.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { CSSProperties } from 'react'
1+
import React, { ReactElement, SSProperties } from 'react'
22

33
import useChat from '../../hooks/useChat'
44
import { ProviderProps, ClassNames } from '../../types'
@@ -61,10 +61,12 @@ const styles: {
6161

6262
interface Props extends ProviderProps {
6363
color?: string
64+
icon?: ReactElement
6465
}
6566

6667
const Intercom = ({
6768
color = '#333333',
69+
icon: Icon,
6870
containerClass = ClassNames.container
6971
}: Props): JSX.Element | null => {
7072
const [state, loadChat] = useChat({ loadWhenIdle: true })
@@ -99,18 +101,21 @@ const Intercom = ({
99101
opacity: state === 'initial' ? 1 : 0
100102
}}
101103
>
102-
<svg
103-
height="24px"
104-
width="24px"
105-
focusable="false"
106-
aria-hidden="true"
107-
viewBox="0 0 28 32"
108-
>
109-
<path
110-
fill="white"
111-
d="M28 32s-4.714-1.855-8.527-3.34H3.437C1.54 28.66 0 27.026 0 25.013V3.644C0 1.633 1.54 0 3.437 0h21.125c1.898 0 3.437 1.632 3.437 3.645v18.404H28V32zm-4.139-11.982a.88.88 0 00-1.292-.105c-.03.026-3.015 2.681-8.57 2.681-5.486 0-8.517-2.636-8.571-2.684a.88.88 0 00-1.29.107 1.01 1.01 0 00-.219.708.992.992 0 00.318.664c.142.128 3.537 3.15 9.762 3.15 6.226 0 9.621-3.022 9.763-3.15a.992.992 0 00.317-.664 1.01 1.01 0 00-.218-.707z"
112-
></path>
113-
</svg>
104+
{
105+
Icon ||
106+
<svg
107+
height="24px"
108+
width="24px"
109+
focusable="false"
110+
aria-hidden="true"
111+
viewBox="0 0 28 32"
112+
>
113+
<path
114+
fill="white"
115+
d="M28 32s-4.714-1.855-8.527-3.34H3.437C1.54 28.66 0 27.026 0 25.013V3.644C0 1.633 1.54 0 3.437 0h21.125c1.898 0 3.437 1.632 3.437 3.645v18.404H28V32zm-4.139-11.982a.88.88 0 00-1.292-.105c-.03.026-3.015 2.681-8.57 2.681-5.486 0-8.517-2.636-8.571-2.684a.88.88 0 00-1.29.107 1.01 1.01 0 00-.219.708.992.992 0 00.318.664c.142.128 3.537 3.15 9.762 3.15 6.226 0 9.621-3.022 9.763-3.15a.992.992 0 00.317-.664 1.01 1.01 0 00-.218-.707z"
116+
></path>
117+
</svg>
118+
}
114119
</div>
115120
<div
116121
style={{

0 commit comments

Comments
 (0)