Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 1037x 1037x 1037x 1037x 1037x 1037x 884x 139x 4559x 884x | import { Box, SxProps } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import { styled, useAppTheme } from "@theme/v2/Provider";
import { ConversationCounterVariant } from "../types";
import { getConversationColors } from "../utils";
interface Props {
count?: number;
variant: ConversationCounterVariant;
size?: number;
capped?: boolean;
displayEmptyDot?: boolean;
testId?: string;
sx?: SxProps;
}
export default function CounterCircle({
count,
variant,
size = 20,
capped,
displayEmptyDot = false,
testId,
sx,
}: Props) {
const { palette } = useAppTheme();
const background = getConversationColors(palette, variant);
//these checks are added to show the UI in a better way and to avoid numbers flowing out of the cirlce
const useCapped = capped && (count || 0) > 99;
const usedCount = useCapped ? "99+" : count || 0;
const usedSize = useCapped && size <= 20 ? size + 4 : size;
if (usedCount === 0 && !displayEmptyDot) return null;
return (
<Circle
backgroundColor={background}
size={`${usedSize}px`}
sx={{
...(useCapped && { width: "28px" }),
...sx,
}}
data-testid={testId || "conversation-counter"}
>
{Boolean(usedCount) && (
<GiveText
variant="bodyXS"
color="default"
component="span"
textAlign="center"
lineHeight="12px"
>
{usedCount}
</GiveText>
)}
</Circle>
);
}
const Circle = styled(Box, {
shouldForwardProp: (prop) => prop !== "backgroundColor" && prop !== "size",
})<{
backgroundColor?: string;
size?: string;
}>(({ backgroundColor, size = "20px" }) => ({
borderRadius: "30px",
height: size,
width: size,
minWidth: size,
minHeight: size,
display: "flex",
alignItems: "center",
justifyContent: "center",
padding: "4px 6px 3px 6px",
backgroundColor,
}));
|