Skip to content

Commit a60f4a1

Browse files
authored
Merge pull request #215 from calibreapp/213-bug-overlapping-images-in-intercom-widget
Intercom: update placeholder appearance to match real icon
2 parents 0ab7252 + 78112e2 commit a60f4a1

1 file changed

Lines changed: 87 additions & 119 deletions

File tree

src/components/Intercom/index.tsx

Lines changed: 87 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,57 @@ import { ProviderProps, ClassNames } from '../../types'
55

66
const styles: {
77
wrapper: CSSProperties
8-
region: CSSProperties
98
launcher: CSSProperties
9+
icon: CSSProperties
1010
logo: CSSProperties
1111
close: CSSProperties
1212
} = {
1313
wrapper: {
14-
zIndex: 2147483004, // 1 more than the actual widget
15-
position: 'fixed',
16-
bottom: '20px',
17-
display: 'block',
18-
right: '20px',
19-
width: '60px',
20-
height: '60px',
21-
borderRadius: '50%',
22-
boxShadow:
23-
'rgba(0, 0, 0, 0.0588235) 0px 1px 6px 0px, rgba(0, 0, 0, 0.156863) 0px 2px 32px 0px'
24-
},
25-
region: {
2614
fontFamily:
27-
"intercom-font, 'Helvetica Neue', 'Apple Color Emoji', Helvetica, Arial, sans-serif",
28-
fontSize: '100%',
29-
fontStyle: 'normal',
30-
letterSpacing: 'normal',
31-
fontStretch: 'normal',
32-
fontVariantLigatures: 'normal',
33-
fontVariantCaps: 'normal',
34-
fontVariantEastAsian: 'normal',
35-
fontVariantPosition: 'normal',
36-
fontWeight: 'normal',
37-
textAlign: 'left',
38-
textDecorationLine: 'none',
39-
textDecorationStyle: 'initial',
40-
textDecorationColor: 'initial',
41-
textDecoration: 'none',
42-
textIndent: '0px',
43-
textShadow: 'none',
44-
textTransform: 'none',
45-
boxSizing: 'content-box',
46-
WebkitTextEmphasisStyle: 'none',
47-
WebkitTextEmphasisColor: 'initial',
48-
WebkitFontSmoothing: 'antialiased',
49-
lineHeight: 1
15+
'intercom-font, "Helvetica Neue", "Apple Color Emoji", Helvetica, Arial, sans-serif',
16+
color: 'white',
17+
fontSize: '16px',
18+
lineHeight: 1.5,
19+
WebkitTextSizeAdjust: '100%',
20+
WebkitFontSmoothing: 'antialiased'
5021
},
5122
launcher: {
52-
position: 'absolute',
53-
top: '0px',
54-
left: '0px',
55-
width: '60px',
56-
height: '60px',
23+
position: 'fixed',
24+
// z-index is 1 more than Intercom's actual launcher as when the real widget loads
25+
// it might not initially reflect the fake icon's current state (open/closed)
26+
zIndex: 2147483004,
27+
padding: '0 !important',
28+
margin: '0 !important',
29+
border: 'none',
30+
bottom: '20px',
31+
right: '20px',
32+
maxWidth: '48px',
33+
width: '48px',
34+
maxHeight: '48px',
35+
height: '48px',
5736
borderRadius: '50%',
5837
cursor: 'pointer',
59-
transformOrigin: 'center',
60-
overflowX: 'hidden',
61-
overflowY: 'hidden',
62-
WebkitBackfaceVisibility: 'hidden',
63-
WebkitFontSmoothing: 'antialiased'
38+
boxShadow:
39+
'0 1px 6px 0 rgba(0, 0, 0, 0.06), 0 2px 32px 0 rgba(0, 0, 0, 0.16)',
40+
transition: 'transform 167ms cubic-bezier(0.33, 0.00, 0.00, 1.00)',
41+
boxSizing: 'content-box'
6442
},
65-
logo: {
43+
icon: {
6644
display: 'flex',
67-
WebkitBoxAlign: 'center',
6845
alignItems: 'center',
69-
WebkitBoxPack: 'center',
7046
justifyContent: 'center',
7147
position: 'absolute',
72-
top: '0px',
73-
bottom: '0px',
74-
width: '100%',
75-
transform: 'rotate(0deg) scale(1)',
76-
transition: 'transform 0.16s linear 0s, opacity 0.08s linear 0s'
48+
top: '0',
49+
left: '0',
50+
width: '48px',
51+
height: '48px',
52+
transition: 'transform 100ms linear, opacity 80ms linear'
53+
},
54+
logo: {
55+
transform: 'rotate(0deg) scale(1)'
7756
},
7857
close: {
79-
display: 'flex',
80-
WebkitBoxAlign: 'center',
81-
alignItems: 'center',
82-
WebkitBoxPack: 'center',
83-
justifyContent: 'center',
84-
position: 'absolute',
85-
top: '0px',
86-
bottom: '0px',
87-
width: '100%',
88-
transition: 'transform 0.16s linear 0s, opacity 0.08s linear 0s'
58+
transform: 'rotate(-60deg) scale(0)'
8959
}
9060
}
9161

@@ -94,7 +64,7 @@ interface Props extends ProviderProps {
9464
}
9565

9666
const Intercom = ({
97-
color,
67+
color = '#333333',
9868
containerClass = ClassNames.container
9969
}: Props): JSX.Element | null => {
10070
const [state, loadChat] = useChat({ loadWhenIdle: true })
@@ -107,70 +77,68 @@ const Intercom = ({
10777
<div
10878
className={containerClass}
10979
style={{
110-
...styles.wrapper,
111-
background: color
80+
...styles.wrapper
11281
}}
11382
>
114-
<div style={styles.region}>
83+
<div
84+
role="button"
85+
aria-label="Load Chat"
86+
aria-busy="true"
87+
aria-live="polite"
88+
onClick={() => loadChat({ open: true })}
89+
onMouseEnter={() => loadChat({ open: false })}
90+
style={{
91+
...styles.launcher,
92+
background: color
93+
}}
94+
>
11595
<div
116-
role="button"
117-
aria-label="Load Chat"
118-
aria-busy="true"
119-
aria-live="polite"
120-
onClick={() => loadChat({ open: true })}
121-
onMouseEnter={() => loadChat({ open: false })}
122-
style={styles.launcher}
96+
style={{
97+
...styles.icon,
98+
...styles.logo,
99+
opacity: state === 'initial' ? 1 : 0
100+
}}
123101
>
124-
<div
125-
style={{
126-
...styles.logo,
127-
opacity: state === 'initial' ? 1 : 0
128-
}}
102+
<svg
103+
height="24px"
104+
width="24px"
105+
focusable="false"
106+
aria-hidden="true"
107+
viewBox="0 0 28 32"
129108
>
130-
<svg
131-
height="32px"
132-
width="28px"
133-
focusable="false"
134-
aria-hidden="true"
135-
viewBox="0 0 28 32"
136-
>
137-
<path
138-
fill="rgb(255, 255, 255)"
139-
d="M28,32 C28,32 23.2863266,30.1450667 19.4727818,28.6592 L3.43749107,28.6592 C1.53921989,28.6592 0,27.0272 0,25.0144 L0,3.6448 C0,1.632 1.53921989,0 3.43749107,0 L24.5615088,0 C26.45978,0 27.9989999,1.632 27.9989999,3.6448 L27.9989999,22.0490667 L28,22.0490667 L28,32 Z M23.8614088,20.0181333 C23.5309223,19.6105242 22.9540812,19.5633836 22.5692242,19.9125333 C22.5392199,19.9392 19.5537934,22.5941333 13.9989999,22.5941333 C8.51321617,22.5941333 5.48178311,19.9584 5.4277754,19.9104 C5.04295119,19.5629428 4.46760991,19.6105095 4.13759108,20.0170667 C3.97913051,20.2124916 3.9004494,20.4673395 3.91904357,20.7249415 C3.93763774,20.9825435 4.05196575,21.2215447 4.23660523,21.3888 C4.37862552,21.5168 7.77411059,24.5386667 13.9989999,24.5386667 C20.2248893,24.5386667 23.6203743,21.5168 23.7623946,21.3888 C23.9467342,21.2215726 24.0608642,20.9827905 24.0794539,20.7254507 C24.0980436,20.4681109 24.0195551,20.2135019 23.8614088,20.0181333 Z"
140-
/>
141-
</svg>
142-
</div>
143-
<div
144-
style={{
145-
...styles.close,
146-
opacity: state === 'initial' ? 0 : 1,
147-
transform: state === 'initial' ? 'rotate(-30deg)' : 'rotate(0deg)'
148-
}}
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>
114+
</div>
115+
<div
116+
style={{
117+
...styles.icon,
118+
...styles.close,
119+
opacity: state === 'initial' ? 0 : 1,
120+
transform: state === 'initial' ? 'rotate(-30deg)' : 'rotate(0deg)'
121+
}}
122+
>
123+
<svg
124+
focusable="false"
125+
width="24"
126+
height="24"
127+
viewBox="0 0 24 24"
128+
fill="none"
129+
xmlns="http://www.w3.org/2000/svg"
149130
>
150-
<svg
151-
focusable="false"
152-
width="24"
153-
height="24"
154-
viewBox="0 0 24 24"
155-
fill="none"
156-
xmlns="http://www.w3.org/2000/svg"
157-
>
158-
<path
159-
fillRule="evenodd"
160-
clipRule="evenodd"
161-
d="M18.601 8.39897C18.269 8.06702 17.7309 8.06702 17.3989 8.39897L12 13.7979L6.60099 8.39897C6.26904 8.06702 5.73086 8.06702 5.39891 8.39897C5.06696 8.73091 5.06696 9.2691 5.39891 9.60105L11.3989 15.601C11.7309 15.933 12.269 15.933 12.601 15.601L18.601 9.60105C18.9329 9.2691 18.9329 8.73091 18.601 8.39897Z"
162-
fill="white"
163-
></path>
164-
</svg>
165-
</div>
131+
<path
132+
fillRule="evenodd"
133+
clipRule="evenodd"
134+
d="M18.601 8.39897C18.269 8.06702 17.7309 8.06702 17.3989 8.39897L12 13.7979L6.60099 8.39897C6.26904 8.06702 5.73086 8.06702 5.39891 8.39897C5.06696 8.73091 5.06696 9.2691 5.39891 9.60105L11.3989 15.601C11.7309 15.933 12.269 15.933 12.601 15.601L18.601 9.60105C18.9329 9.2691 18.9329 8.73091 18.601 8.39897Z"
135+
fill="white"
136+
></path>
137+
</svg>
166138
</div>
167139
</div>
168140
</div>
169141
)
170142
}
171143

172-
Intercom.defaultProps = {
173-
color: '#333333'
174-
}
175-
176144
export default Intercom

0 commit comments

Comments
 (0)