front-hub/src/pages/Support/Chat/Message.tsx

78 lines
2.7 KiB
TypeScript
Raw Normal View History

2022-11-25 18:52:46 +00:00
import { Box, Typography, useMediaQuery, useTheme } from "@mui/material";
2022-11-23 11:46:04 +00:00
interface Props {
isSelf: boolean;
text: string;
time: string;
}
export default function Message({ isSelf, text, time }: Props) {
2022-11-24 18:08:51 +00:00
const theme = useTheme();
2022-11-25 18:52:46 +00:00
const upMd = useMediaQuery(theme.breakpoints.up("md"));
2022-11-23 11:46:04 +00:00
return (
<Box
sx={{
display: "flex",
alignSelf: isSelf ? "end" : "start",
gap: "9px",
pl: isSelf ? undefined : "8px",
pr: isSelf ? "8px" : undefined,
}}
>
<Typography
sx={{
alignSelf: "end",
fontWeight: 400,
fontSize: "14px",
lineHeight: "17px",
order: isSelf ? 1 : 2,
2022-11-24 19:22:30 +00:00
color: theme.palette.grey2.main,
2022-11-23 11:46:04 +00:00
mb: "-4px",
}}
>{time}</Typography>
<Box
sx={{
2022-11-24 19:22:30 +00:00
backgroundColor: isSelf ? "white" : theme.palette.grey2.main,
border: `1px solid ${theme.palette.grey2.main}`,
2022-11-23 11:46:04 +00:00
order: isSelf ? 2 : 1,
2022-11-25 18:52:46 +00:00
p: upMd ? "18px" : "12px",
2022-11-23 11:46:04 +00:00
borderRadius: "8px",
maxWidth: "464px",
2022-11-24 19:22:30 +00:00
color: isSelf ? theme.palette.grey3.main : "white",
2022-11-23 11:46:04 +00:00
position: "relative",
}}
>
<svg
style={{
position: "absolute",
top: "-1px",
right: isSelf ? "-8px" : undefined,
left: isSelf ? undefined : "-8px",
transform: isSelf ? undefined : "scale(-1, 1)",
}}
xmlns="http://www.w3.org/2000/svg"
width="16"
height="8"
viewBox="0 0 16 8"
fill="none"
>
<path d="M0.5 0.5L15.5 0.500007
C10 0.500006 7.5 8 7.5 7.5H7.5H0.5V0.5Z"
2022-11-24 19:22:30 +00:00
fill={isSelf ? "white" : theme.palette.grey2.main}
stroke={theme.palette.grey2.main}
2022-11-23 11:46:04 +00:00
/>
2022-11-24 19:22:30 +00:00
<rect y="1" width="8" height="8" fill={isSelf ? "white" : theme.palette.grey2.main} />
2022-11-23 11:46:04 +00:00
</svg>
2022-11-25 18:52:46 +00:00
<Typography
sx={{
fontWeight: 400,
fontSize: "16px",
lineHeight: "19px",
}}
>{text}</Typography>
2022-11-23 11:46:04 +00:00
</Box>
2022-11-25 18:52:46 +00:00
</Box >
2022-11-23 11:46:04 +00:00
);
}