All files / src/features/GiveConversation/components FloatingAvatars.tsx

100% Statements 3/3
81.81% Branches 9/11
100% Functions 2/2
100% Lines 2/2

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                                    45x                                                       27x                
import { Box } from "@mui/material";
import GiveAvatarWithFallback from "@shared/Avatar/GiveAvatarWithFallback";
import { styled } from "@theme/v2/Provider";
import { addSizeToImage } from "@utils/image.helpers";
 
interface Props {
  primaryImageURL?: string;
  secondaryImageURL?: string;
  primaryFallbackString?: string;
  secondaryFallbackString?: string;
}
 
export default function FloatingAvatars({
  primaryImageURL,
  secondaryImageURL,
  primaryFallbackString,
  secondaryFallbackString,
}: Props) {
  return (
    <Box position="relative" width="40px" height="40px">
      <GiveAvatarWithFallback
        imageUrl={
          primaryImageURL ? addSizeToImage(primaryImageURL, "thumb") : ""
        }
        fallbackString={primaryFallbackString}
        shape="rounded"
        size={!secondaryImageURL && !secondaryFallbackString ? "40px" : "32px"}
      />
      {(secondaryImageURL || secondaryFallbackString) && (
        <FloatingImageWrapper>
          <GiveAvatarWithFallback
            imageUrl={
              secondaryImageURL
                ? addSizeToImage(secondaryImageURL, "thumb")
                : ""
            }
            fallbackString={secondaryFallbackString}
            shape="rounded"
            size="28px"
          />
        </FloatingImageWrapper>
      )}
    </Box>
  );
}
 
const FloatingImageWrapper = styled(Box)(({ theme }) => ({
  position: "absolute",
  zIndex: 2,
  top: "8px",
  left: "8px",
  borderRadius: "40px",
  border: `1px solid ${theme.palette.surface?.primary}`,
}));