Skip to content

Commit 4b953f0

Browse files
authored
Merge pull request #467 from leviceccato/custom-intercom-icon
Allow using a custom icon for Intercom
2 parents 4cad22a + e656ea9 commit 4b953f0

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Made by the team at [♠ Calibre](https://calibreapp.com/), your performance com
1616
1717
Since introducing `react-live-chat-loader` in 2019 we've welcomed the addition of several chat provider tools, with thanks to numerous contributors. As a group the Calibre team have taken this library as far as we can, and we're looking for someone to take the reigns. If you, your buddies or team can help, please create a new issue to start discussion. 💬
1818

19-
2019
## 🖇️ Table of Contents
2120

2221
1. [How it Works](#-how-it-works)
@@ -203,6 +202,7 @@ You can customise the Intercom placeholder icon by passing the following props t
203202

204203
- `color`: The background color of the placeholder widget
205204
- `containerClass`: Class to be added to the placeholder element, defaults to `live-chat-loader-placeholder`
205+
- `icon`: Override the default Intercom icon, can be any JSX element.
206206

207207
[Messenger Settings](https://developers.intercom.com/installing-intercom/docs/javascript-api-attributes-objects#messenger-attributes), User context and Company context settings can be set using `window.intercomSettings`. See the [official Intercom documentation](https://developers.intercom.com/installing-intercom/docs/javascript-api-attributes-objects#section-data-attributes) for more details.
208208

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, CSSProperties } 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)