Skip to content

Commit

Permalink
Merge pull request #360 from Appelsiini1/feature-346
Browse files Browse the repository at this point in the history
Add decorators to snackbar
  • Loading branch information
RSaarivuoriLUT authored Dec 13, 2024
2 parents a574b47 + 04c3ee4 commit 59f90bf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "procasma",
"productName": "Procasma",
"version": "1.5.4",
"version": "1.6.1",
"description": "Dynamic Assignment Manager",
"main": ".vite/build/main.js",
"scripts": {
Expand Down
27 changes: 26 additions & 1 deletion src/components/SnackBarComp.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {
CircularProgress,
Snackbar,
SnackbarCloseReason as SnackbarCloseReasonType,
} from "@mui/joy";
import DoneAllIcon from "@mui/icons-material/DoneAll";
import CancelIcon from "@mui/icons-material/Cancel";
import ErrorIcon from "@mui/icons-material/Error";
import { useEffect, useState } from "react";
import texts from "../../resource/texts.json";
import { language } from "../globalsUI";
Expand Down Expand Up @@ -90,10 +94,31 @@ export default function SnackbarComp({
const vertical = "bottom";
const horizontal = "center";

let autoHideDuration = 3000;
let startDecorator: React.JSX.Element = null;
switch (color) {
case "primary":
autoHideDuration = null;
startDecorator = <CircularProgress size="sm" variant="plain" />;
break;
case "neutral":
startDecorator = <CancelIcon />;
break;
case "success":
startDecorator = <DoneAllIcon color="success" />;
break;
case "danger":
startDecorator = <CancelIcon />;
break;
default:
break;
}

return (
<Snackbar
autoHideDuration={color === "primary" ? null : 3000}
autoHideDuration={autoHideDuration}
anchorOrigin={{ vertical, horizontal }}
startDecorator={startDecorator}
open={open}
onClose={(event, reason) => {
if (color === "primary") return;
Expand Down

0 comments on commit 59f90bf

Please sign in to comment.