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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | 492x 14x 14x 492x 492x 14x 14x 9x 3x 2x 492x 14x | import { Box, Stack, SxProps } from "@mui/material";
import {
ArrowLineDownIcon,
CheckIcon,
UploadSimpleIcon,
WarningIcon,
XIcon,
ArrowsClockwiseIcon,
PaperPlaneTiltIcon,
TrashIcon,
InfoIcon,
} from "@phosphor-icons/react";
import { useAppTheme } from "@theme/v2/Provider";
import React from "react";
import SnackbarLinearProgress from "shared/Snackbar/SnackbarLinearProgress";
import GiveText from "../Text/GiveText";
import { SnackbarIconsType } from "./GiveSnackbarTypes";
import { DEFAULT_ICON_SIZE } from "../constants";
import GiveTruncateText from "../Text/GiveTruncateText";
import { FONT_PRIMARY } from "@theme/v2/const";
import { SwitchAccountToastIcon } from "@assets/icons/SwitchAccountToastIcon";
interface Props {
type: SnackbarIconsType;
title: string;
description: React.ReactNode;
progress?: number;
rightContent?: React.ReactNode;
lineClamp?: number;
isMobile: boolean;
showTitle?: boolean;
containerSx?: SxProps;
}
const GiveSnackbar = ({
type = "success",
title,
description,
progress,
rightContent,
lineClamp = 1,
isMobile,
showTitle = true,
containerSx,
}: Props) => {
const { palette } = useAppTheme();
return (
<Stack
direction="row"
gap="12px"
sx={{
maxWidth: isMobile ? "100%" : "320px",
width: isMobile ? "100%" : "fit-content",
minWidth: type === "upload" ? "320px" : "163px",
padding: "10px",
borderRadius: "12px",
backgroundColor: palette["surface-inverted"]?.primary,
height: "fit-content",
alignItems: "center",
...containerSx,
}}
>
<Stack direction="column" gap="8px" width="100%">
<Stack
direction="row"
gap="12px"
sx={{
height: "fit-content",
alignItems: "center",
}}
>
<Icon type={type} />
<Stack direction="column" gap="2px">
{showTitle && title && (
<GiveTruncateText
lineClamp={lineClamp}
variant="bodyS"
sx={{
color: palette["text-inverted"]?.primary,
fontFamily: FONT_PRIMARY,
}}
>
{title}
</GiveTruncateText>
)}
<GiveText
variant="bodyXS"
sx={{
color: palette["text-inverted"]?.secondary,
fontFamily: FONT_PRIMARY,
}}
>
{description}
</GiveText>
</Stack>
</Stack>
{typeof progress === "number" && (
<SnackbarLinearProgress progress={progress} />
)}
</Stack>
{rightContent}
</Stack>
);
};
export default GiveSnackbar;
const ICON_SIZE = DEFAULT_ICON_SIZE;
const Icon = ({ type }: { type: SnackbarIconsType }): React.ReactElement => {
const { palette } = useAppTheme();
// deleting
switch (type) {
case "download":
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<ArrowLineDownIcon
size={ICON_SIZE}
color={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
case "deleting":
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<TrashIcon
size={ICON_SIZE}
color={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
case "deleted":
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<TrashIcon
size={ICON_SIZE}
color={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
case "upload":
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<UploadSimpleIcon
size={ICON_SIZE}
color={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
case "success":
return (
<IconBox backgroundColor={palette.primitive?.["success-inverted"][25]}>
<CheckIcon
size={ICON_SIZE}
color={palette.primitive?.["success-inverted"][100]}
/>
</IconBox>
);
case "warning":
return (
<IconBox backgroundColor={palette.primitive?.["warning-inverted"][10]}>
<WarningIcon
size={ICON_SIZE}
color={palette.primitive?.["warning-inverted"][100]}
/>
</IconBox>
);
case "error":
return (
<IconBox backgroundColor={palette.primitive?.["error-inverted"][25]}>
<XIcon
size={ICON_SIZE}
color={palette.primitive?.["error-inverted"][100]}
/>
</IconBox>
);
case "process":
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<ArrowsClockwiseIcon
size={ICON_SIZE}
color={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
case "invitation":
return (
<IconBox backgroundColor={palette.primitive?.["success-inverted"][25]}>
<PaperPlaneTiltIcon
size={ICON_SIZE}
color={palette.primitive?.["success-inverted"][100]}
/>
</IconBox>
);
case "info":
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<InfoIcon
size={ICON_SIZE}
color={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
case "switch":
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<SwitchAccountToastIcon
fill={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
case "sending-invitation":
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<PaperPlaneTiltIcon
size={ICON_SIZE}
color={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
default:
return (
<IconBox backgroundColor={palette["surface-inverted"]?.tertiary}>
<CheckIcon
size={ICON_SIZE}
color={palette["icon-inverted"]?.["icon-primary"]}
/>
</IconBox>
);
}
};
const IconBox = ({
backgroundColor,
children,
}: {
backgroundColor?: string;
children: React.ReactNode;
}): React.ReactElement => {
return (
<Box
sx={{
backgroundColor,
borderRadius: "50%",
height: "30px",
width: "30px",
flex: "none",
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
{children}
</Box>
);
};
|