Skip to content

Commit cd80dbd

Browse files
committed
style: fix tawk.to chat widget positioning
1 parent e8ba56c commit cd80dbd

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

components/chat/TawkToChat.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import { useEffect } from 'react'
22

33
const TawkToChat = () => {
44
useEffect(() => {
5-
// Initialize Tawk.to API
65
const Tawk_API: any = window.Tawk_API || {}
76
const Tawk_LoadStart = new Date()
87

9-
// Create and append the script
108
const s1 = document.createElement('script')
119
const s0 = document.getElementsByTagName('script')[0]
1210

@@ -17,23 +15,28 @@ const TawkToChat = () => {
1715

1816
s0.parentNode?.insertBefore(s1, s0)
1917

20-
// Add custom CSS to position the widget
2118
const style = document.createElement('style')
2219
style.textContent = `
23-
#tawkto-container {
24-
right: 80px !important;
20+
body #tawkto-container,
21+
body #tawkto-container iframe,
22+
body .tawk-minimized,
23+
body .tawk-button,
24+
body .tawk-button-container,
25+
body .tawk-chat-container,
26+
body .tawk-chat-iframe {
27+
right: 150px !important;
28+
margin-right: 150px !important;
2529
}
2630
`
2731
document.head.appendChild(style)
2832

29-
// Cleanup function to remove the script and style when component unmounts
3033
return () => {
3134
s1.remove()
3235
style.remove()
3336
}
34-
}, []) // Empty dependency array means this effect runs once on mount
37+
}, [])
3538

36-
return null // This component doesn't render anything
39+
return null
3740
}
3841

3942
export default TawkToChat

0 commit comments

Comments
 (0)