From 14a6c5a03f1646baca8a951faa7183aa2e6f0816 Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Wed, 28 Sep 2022 23:31:19 +0530 Subject: [PATCH] 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 Co-authored-by: Peer Richelsen --- packages/config/tailwind-preset.js | 15 ++++++++++++ packages/ui/v2/core/notifications.tsx | 33 ++++++++++++++++++++------- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/packages/config/tailwind-preset.js b/packages/config/tailwind-preset.js index 8e62c7a63b..2f514c4b68 100644 --- a/packages/config/tailwind-preset.js +++ b/packages/config/tailwind-preset.js @@ -154,6 +154,21 @@ module.exports = { 900: "#f3f4f6", }, }, + keyframes: { + "fade-in-up": { + "0%": { + opacity: 0.75, + transform: "translateY(20px)", + }, + "100%": { + opacity: 1, + transform: "translateY(0)", + }, + }, + }, + animation: { + "fade-in-up": "fade-in-up 0.35s cubic-bezier(.21,1.02,.73,1)", + }, boxShadow: { dropdown: "0px 2px 6px -1px rgba(0, 0, 0, 0.08)", }, diff --git a/packages/ui/v2/core/notifications.tsx b/packages/ui/v2/core/notifications.tsx index 428b316d62..6b78b63586 100644 --- a/packages/ui/v2/core/notifications.tsx +++ b/packages/ui/v2/core/notifications.tsx @@ -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( - () => ( -
+ (t) => ( +

{message}

@@ -16,8 +21,12 @@ export default function showToast(message: string, variant: "success" | "warning break; case "error": toast.custom( - () => ( -
+ (t) => ( +

{message}

@@ -27,8 +36,12 @@ export default function showToast(message: string, variant: "success" | "warning break; case "warning": toast.custom( - () => ( -
+ (t) => ( +

{message}

@@ -38,8 +51,12 @@ export default function showToast(message: string, variant: "success" | "warning break; default: toast.custom( - () => ( -
+ (t) => ( +

{message}