2024-02-09 14:04:38 +00:00
|
|
|
import { Box, Fab, useTheme, useMediaQuery } from "@mui/material";
|
2024-02-06 14:39:02 +00:00
|
|
|
import { useState } from "react";
|
2024-02-09 14:04:38 +00:00
|
|
|
import CircleDoubleDown from "./QuestionIcon";
|
|
|
|
|
2024-02-06 14:39:02 +00:00
|
|
|
import Chat from "./Chat";
|
|
|
|
|
2024-02-09 14:04:38 +00:00
|
|
|
const animation = {
|
|
|
|
"@keyframes runningStripe": {
|
|
|
|
"0%": { left: "10%", backgroundColor: "transparent" },
|
|
|
|
"10%": { backgroundColor: "#ffffff" },
|
|
|
|
"50%": { backgroundColor: "#ffffff", transform: "translate(400px, 0)" },
|
|
|
|
"80%": { backgroundColor: "#ffffff" },
|
|
|
|
"100%": { backgroundColor: "transparent", boxShadow: "none", left: "100%" },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-02-06 14:39:02 +00:00
|
|
|
export default function FloatingSupportChat() {
|
|
|
|
const [isChatOpened, setIsChatOpened] = useState<boolean>(false);
|
2024-02-09 14:04:38 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(800));
|
2024-02-06 14:39:02 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
position: "fixed",
|
|
|
|
right: "20px",
|
2024-02-09 17:35:16 +00:00
|
|
|
bottom: "100px",
|
2024-02-06 14:39:02 +00:00
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column",
|
|
|
|
gap: "8px",
|
|
|
|
width: "clamp(200px, 100% - 40px, 454px)",
|
|
|
|
zIndex: 10,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{isChatOpened && (
|
2024-02-09 14:04:38 +00:00
|
|
|
<Chat sx={{ alignSelf: "start", width: "clamp(200px, 100%, 400px)" }} />
|
2024-02-06 14:39:02 +00:00
|
|
|
)}
|
|
|
|
<Fab
|
|
|
|
disableRipple
|
|
|
|
sx={{
|
|
|
|
position: "relative",
|
|
|
|
backgroundColor: "rgba(255, 255, 255, 0.7)",
|
2024-02-09 14:04:38 +00:00
|
|
|
borderRadius: "50%",
|
2024-02-06 14:39:02 +00:00
|
|
|
alignSelf: "end",
|
2024-02-09 14:04:38 +00:00
|
|
|
padding: "0px",
|
2024-02-06 14:39:02 +00:00
|
|
|
overflow: "hidden",
|
2024-02-09 14:04:38 +00:00
|
|
|
height: "54px",
|
|
|
|
width: "54px",
|
|
|
|
transform: !isMobile ? "scale(1.2)" : null,
|
2024-02-06 14:39:02 +00:00
|
|
|
"&:hover": {
|
|
|
|
background: "rgba(255, 255, 255, 0.7)",
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
variant={"extended"}
|
|
|
|
onClick={() => setIsChatOpened((prev) => !prev)}
|
|
|
|
>
|
|
|
|
{!isChatOpened && (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
position: "absolute",
|
|
|
|
bgcolor: "#FFFFFF",
|
|
|
|
height: "100px",
|
|
|
|
width: "25px",
|
|
|
|
animation: "runningStripe linear 3s infinite",
|
|
|
|
transform:
|
|
|
|
" skew(-10deg) rotate(70deg) skewX(20deg) skewY(10deg)",
|
|
|
|
boxShadow: "0px 3px 12px rgba(126, 42, 234, 0.1)",
|
|
|
|
opacity: "0.4",
|
|
|
|
...animation,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)}
|
2024-02-09 14:04:38 +00:00
|
|
|
<CircleDoubleDown />
|
2024-02-06 14:39:02 +00:00
|
|
|
</Fab>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|