Skip to content

Commit b1a9f55

Browse files
add color scheme
1 parent d77b2c4 commit b1a9f55

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

integrations/front/src/script.raw.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,17 @@
55
s = d.createElement('script');
66
s.src = 'https://chat-assets.frontapp.com/v1/chat.bundle.js';
77
s.async = 1;
8+
d.getElementsByTagName('head')[0].appendChild(s);
89

910
s.onload = function () {
1011
if (window.FrontChat) {
11-
window.FrontChat('init', { chatId: chatId, useDefaultLauncher: true });
12+
window.FrontChat('init', {
13+
chatId: chatId,
14+
useDefaultLauncher: true,
15+
colorScheme: 'light dark',
16+
});
1217
}
13-
14-
// Workaround for Front's color-scheme bug
15-
// Front's widget uses color-scheme: normal which doesn't respect page color schemes
16-
// This override allows proper light/dark mode support
17-
const styleOverride = d.createElement('style');
18-
styleOverride.textContent = `
19-
[data-front-chat-container],
20-
[data-front-chat-container] iframe,
21-
#front-chat-container,
22-
#front-chat-container iframe {
23-
color-scheme: light dark !important;
24-
}
25-
`;
26-
d.head.appendChild(styleOverride);
2718
};
2819

29-
// Append to body (just before closing </body> tag) as per Front's documentation
30-
d.getElementsByTagName('body')[0].appendChild(s);
20+
d.getElementsByTagName('head')[0].appendChild(s);
3121
})(window, document);

0 commit comments

Comments
 (0)