feat: add transition in toasts (#4658)
* feat: add transition in toasts * feat: toast animation improved * fix: type check in toast Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
2 files changed
+40
-8
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import classNames from "classnames";
|
||||
import { Check, Info } from "react-feather";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
@@ -5,8 +6,12 @@ export default function showToast(message: string, variant: "success" | "warning
|
||||
switch (variant) {
|
||||
case "success":
|
||||
toast.custom(
|
||||
() => (
|
||||
<div className="data-testid-toast-success bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
|
||||
(t) => (
|
||||
<div
|
||||
className={classNames(
|
||||
"data-testid-toast-success bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md",
|
||||
t.visible && "animate-fade-in-up"
|
||||
)}>
|
||||
<Check className="h-4 w-4" />
|
||||
<p>{message}</p>
|
||||
</div>
|
||||
@@ -16,8 +21,12 @@ export default function showToast(message: string, variant: "success" | "warning
|
||||
break;
|
||||
case "error":
|
||||
toast.custom(
|
||||
() => (
|
||||
<div className="mb-2 flex h-9 items-center space-x-2 rounded-md bg-red-100 p-3 text-sm font-semibold text-red-900 shadow-md">
|
||||
(t) => (
|
||||
<div
|
||||
className={classNames(
|
||||
"animate-fade-in-up mb-2 flex h-9 items-center space-x-2 rounded-md bg-red-100 p-3 text-sm font-semibold text-red-900 shadow-md",
|
||||
t.visible && "animate-fade-in-up"
|
||||
)}>
|
||||
<Info className="h-4 w-4" />
|
||||
<p>{message}</p>
|
||||
</div>
|
||||
@@ -27,8 +36,12 @@ export default function showToast(message: string, variant: "success" | "warning
|
||||
break;
|
||||
case "warning":
|
||||
toast.custom(
|
||||
() => (
|
||||
<div className="bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
|
||||
(t) => (
|
||||
<div
|
||||
className={classNames(
|
||||
"animate-fade-in-up bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md",
|
||||
t.visible && "animate-fade-in-up"
|
||||
)}>
|
||||
<Info className="h-4 w-4" />
|
||||
<p>{message}</p>
|
||||
</div>
|
||||
@@ -38,8 +51,12 @@ export default function showToast(message: string, variant: "success" | "warning
|
||||
break;
|
||||
default:
|
||||
toast.custom(
|
||||
() => (
|
||||
<div className="bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
|
||||
(t) => (
|
||||
<div
|
||||
className={classNames(
|
||||
"animate-fade-in-up bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md",
|
||||
t.visible && "animate-fade-in-up"
|
||||
)}>
|
||||
<Check className="h-4 w-4" />
|
||||
<p>{message}</p>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user