Skip to content

Commit 8927635

Browse files
committed
💄(frontend) hide Crisp when mobile and modal
The Crisp button was hidding buttons on mobile when a modal was open. This commit hides the Crisp button when a modal is open on mobile.
1 parent 76bce43 commit 8927635

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

src/frontend/apps/impress/src/core/config/ConfigProvider.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PropsWithChildren, useEffect } from 'react';
33

44
import { Box } from '@/components';
55
import { useCunninghamTheme } from '@/cunningham';
6-
import { PostHogProvider, configureCrispSession } from '@/services';
6+
import { CrispProvider, PostHogProvider } from '@/services';
77
import { useSentryStore } from '@/stores/useSentryStore';
88

99
import { useConfig } from './api/useConfig';
@@ -29,14 +29,6 @@ export const ConfigProvider = ({ children }: PropsWithChildren) => {
2929
setTheme(conf.FRONTEND_THEME);
3030
}, [conf?.FRONTEND_THEME, setTheme]);
3131

32-
useEffect(() => {
33-
if (!conf?.CRISP_WEBSITE_ID) {
34-
return;
35-
}
36-
37-
configureCrispSession(conf.CRISP_WEBSITE_ID);
38-
}, [conf?.CRISP_WEBSITE_ID]);
39-
4032
if (!conf) {
4133
return (
4234
<Box $height="100vh" $width="100vw" $align="center" $justify="center">
@@ -45,5 +37,11 @@ export const ConfigProvider = ({ children }: PropsWithChildren) => {
4537
);
4638
}
4739

48-
return <PostHogProvider conf={conf.POSTHOG_KEY}>{children}</PostHogProvider>;
40+
return (
41+
<PostHogProvider conf={conf.POSTHOG_KEY}>
42+
<CrispProvider websiteId={conf?.CRISP_WEBSITE_ID}>
43+
{children}
44+
</CrispProvider>
45+
</PostHogProvider>
46+
);
4947
};

src/frontend/apps/impress/src/services/Crisp.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,23 @@
33
*/
44

55
import { Crisp } from 'crisp-sdk-web';
6+
import { PropsWithChildren, useEffect, useState } from 'react';
7+
import { createGlobalStyle } from 'styled-components';
68

79
import { User } from '@/features/auth';
810

11+
const CrispStyle = createGlobalStyle`
12+
#crisp-chatbox a{
13+
zoom: 0.8;
14+
}
15+
16+
@media screen and (width <= 1024px) {
17+
.c__modals--opened #crisp-chatbox {
18+
display: none!important;
19+
}
20+
}
21+
`;
22+
923
export const initializeCrispSession = (user: User) => {
1024
if (!Crisp.isCrispInjected()) {
1125
return;
@@ -29,3 +43,30 @@ export const terminateCrispSession = () => {
2943
Crisp.setTokenId();
3044
Crisp.session.reset();
3145
};
46+
47+
interface CrispProviderProps {
48+
websiteId?: string;
49+
}
50+
51+
export const CrispProvider = ({
52+
children,
53+
websiteId,
54+
}: PropsWithChildren<CrispProviderProps>) => {
55+
const [isConfigured, setIsConfigured] = useState(false);
56+
57+
useEffect(() => {
58+
if (!websiteId) {
59+
return;
60+
}
61+
62+
setIsConfigured(true);
63+
configureCrispSession(websiteId);
64+
}, [websiteId]);
65+
66+
return (
67+
<>
68+
{isConfigured && <CrispStyle />}
69+
{children}
70+
</>
71+
);
72+
};

0 commit comments

Comments
 (0)