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 | 80x 80x 80x 6x 6x | import { Box, SxProps } from "@mui/material";
import { AvatarSizesProps, GiveAvatarProps } from "./GiveAvatar.types";
import GiveAvatar from "./GiveAvatar";
import GiveText from "@shared/Text/GiveText";
import { styled, useAppTheme } from "@theme/v2/Provider";
import { CustomTheme } from "@theme/v2/palette.interface";
interface Props extends GiveAvatarProps {
fallbackString?: string;
fallbackSx?: SxProps;
bgcolor?: string;
}
export default function GiveAvatarWithFallback({
imageUrl,
fallbackString,
fallbackSx,
size,
bgcolor,
...avatarProps
}: Props) {
const { palette } = useAppTheme();
Eif (imageUrl)
return <GiveAvatar imageUrl={imageUrl} size={size} {...avatarProps} />;
return (
<Box bgcolor={bgcolor || palette.surface?.primary} borderRadius="50%">
<FallbackContainer bg={bgcolor} sx={fallbackSx} size={size}>
<GiveText variant="bodyM">{fallbackString}</GiveText>
</FallbackContainer>
</Box>
);
}
interface FallbackContainerProps {
size?: AvatarSizesProps;
bg?: string;
}
const FallbackContainer = styled(Box, {
shouldForwardProp: (prop) => prop !== "bg" && prop !== "size",
})<FallbackContainerProps>(
({ theme, bg, size }: { theme: CustomTheme } & FallbackContainerProps) => ({
backgroundColor: bg || theme.palette.primitive?.transparent["darken-5"],
width: size || "28px",
height: size || "28px",
display: "flex",
justifyContent: "center",
alignItems: "center",
borderRadius: theme.customs?.radius.large,
}),
);
|