From d7f3db1cc480b10058d368ca6c070f7370181dcb Mon Sep 17 00:00:00 2001 From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com> Date: Wed, 26 Aug 2026 14:06:12 +0800 Subject: [PATCH] refactor: replace Toast with Sonner --- frontend/app/app.css | 11 - frontend/app/components/common/Toast.tsx | 34 --- frontend/app/components/ui/sonner.tsx | 44 ++++ frontend/app/components/ui/toast.tsx | 232 ------------------ .../app/features/admin/state/adminStore.ts | 6 +- .../app/features/platform/ScriptWorkspace.tsx | 4 +- .../app/features/platform/ScriptsPage.tsx | 7 +- .../app/features/platform/state/helpers.ts | 6 +- .../app/features/platform/state/uiStore.ts | 15 -- .../features/schedules/SchedulesPageRoute.tsx | 8 +- .../app/features/schedules/state/helpers.ts | 6 +- frontend/app/root.tsx | 2 + frontend/app/routes/platform.tsx | 11 - frontend/app/routes/system-projects.tsx | 8 +- frontend/app/routes/system-roles.tsx | 8 +- frontend/app/routes/system-users.tsx | 8 +- frontend/package.json | 2 + frontend/pnpm-lock.yaml | 34 +++ 18 files changed, 126 insertions(+), 320 deletions(-) delete mode 100644 frontend/app/components/common/Toast.tsx create mode 100644 frontend/app/components/ui/sonner.tsx delete mode 100644 frontend/app/components/ui/toast.tsx diff --git a/frontend/app/app.css b/frontend/app/app.css index 71d6c96..0bcef87 100644 --- a/frontend/app/app.css +++ b/frontend/app/app.css @@ -196,10 +196,6 @@ animation: modal-in 0.18s ease-out; } - .toast-enter { - animation: toast-in 0.2s ease-out; - } - .notebook-md h1, .notebook-md h2, .notebook-md h3, @@ -260,13 +256,6 @@ } } -@keyframes toast-in { - from { - opacity: 0; - transform: translateY(-7px); - } -} - @keyframes spin { to { transform: rotate(360deg); diff --git a/frontend/app/components/common/Toast.tsx b/frontend/app/components/common/Toast.tsx deleted file mode 100644 index f200567..0000000 --- a/frontend/app/components/common/Toast.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import Icon from "./Icon"; - -type ToastState = { - tone: "success" | "error" | "info"; - message: string; -}; - -type ToastProps = { - toast: ToastState | null; -}; - -const toneIconClass: Record = { - success: "bg-[#e6f7f0] text-[#177b55]", - error: "bg-[#fff0f0] text-[#b94a4a]", - info: "bg-[#eaf4fd] text-[#2675bf]", -}; - -export function Toast({ toast }: ToastProps) { - if (!toast) return null; - - return ( -
- - - - {toast.message} -
- ); -} diff --git a/frontend/app/components/ui/sonner.tsx b/frontend/app/components/ui/sonner.tsx new file mode 100644 index 0000000..1919f52 --- /dev/null +++ b/frontend/app/components/ui/sonner.tsx @@ -0,0 +1,44 @@ +import { Toaster as Sonner, type ToasterProps } from "sonner" +import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react" + +const Toaster = ({ ...props }: ToasterProps) => { + return ( + + ), + info: ( + + ), + warning: ( + + ), + error: ( + + ), + loading: ( + + ), + }} + style={ + { + "--normal-bg": "var(--popover)", + "--normal-text": "var(--popover-foreground)", + "--normal-border": "var(--border)", + "--border-radius": "var(--radius)", + } as React.CSSProperties + } + toastOptions={{ + classNames: { + toast: "cn-toast", + }, + }} + {...props} + /> + ) +} + +export { Toaster } diff --git a/frontend/app/components/ui/toast.tsx b/frontend/app/components/ui/toast.tsx deleted file mode 100644 index a294f83..0000000 --- a/frontend/app/components/ui/toast.tsx +++ /dev/null @@ -1,232 +0,0 @@ -import * as React from "react" -import { Toast as ToastPrimitive } from "@base-ui/react/toast" - -import { cn } from "~/lib/utils" -import { Button } from "~/components/ui/button" -import { XIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react" - -const toast = ToastPrimitive.createToastManager() - -function ToastProvider({ ...props }: ToastPrimitive.Provider.Props) { - return -} - -function ToastPortal({ ...props }: ToastPrimitive.Portal.Props) { - return -} - -function ToastViewport({ className, ...props }: ToastPrimitive.Viewport.Props) { - return ( - - ) -} - -function Toast({ className, ...props }: ToastPrimitive.Root.Props) { - return ( - - ) -} - -function ToastContent({ className, ...props }: ToastPrimitive.Content.Props) { - return ( - - ) -} - -function ToastTitle({ className, ...props }: ToastPrimitive.Title.Props) { - return ( - - ) -} - -function ToastDescription({ - className, - ...props -}: ToastPrimitive.Description.Props) { - return ( - - ) -} - -function ToastAction({ - className, - render =