From 2ba630be75c31d0cfd815675b2aa75d29dc52769 Mon Sep 17 00:00:00 2001 From: Jeff7842 Date: Mon, 28 Sep 2026 13:30:13 +0300 Subject: [PATCH] feat: enhance Toast component with gradient styles and improved structure --- stackable-app/components/toast/Toast.tsx | 254 ++++++++++------------- 1 file changed, 107 insertions(+), 147 deletions(-) diff --git a/stackable-app/components/toast/Toast.tsx b/stackable-app/components/toast/Toast.tsx index bfa88ea..61eefb7 100644 --- a/stackable-app/components/toast/Toast.tsx +++ b/stackable-app/components/toast/Toast.tsx @@ -1,5 +1,12 @@ "use client"; +// Gradient design restored from the `main` branch's toast mockup +// (components/toast/sample.tsx) — colour, shadow and icon-badge treatment per +// type, wired to the real showToast() props (id/type/title/description/onClose). +// Sizing is auto-height (not sample.tsx's fixed h-12/h-14) so a longer +// description can wrap without clipping; width is governed by ToastProvider's +// container, same as before. + type ToastType = "error" | "success" | "info" | "warning"; interface ToastProps { @@ -10,160 +17,113 @@ interface ToastProps { onClose: (id: string) => void; } -export default function Toast({ - id, - type, - title, - description, - onClose, -}: ToastProps) { - const styles = { - error: { - icon: "bg-red-50 text-red-600", - ring: "ring-red-100", - accent: "bg-red-500", - description: "text-gray-500", - }, - success: { - icon: "bg-emerald-50 text-emerald-600", - ring: "ring-emerald-100", - accent: "bg-emerald-500", - description: "text-gray-500", - }, - info: { - icon: "bg-sky-50 text-sky-600", - ring: "ring-sky-100", - accent: "bg-sky-500", - description: "text-gray-500", - }, - warning: { - icon: "bg-amber-50 text-amber-600", - ring: "ring-amber-100", - accent: "bg-amber-500", - description: "text-gray-500", - }, - }; +const STYLES: Record< + ToastType, + { + card: string; + shadow: string; + iconBadge: string; + icon: string; + title: string; + description: string; + close: string; + } +> = { + error: { + card: "bg-gradient-to-r from-rose-600 to-red-700", + shadow: "shadow-lg shadow-red-900/40", + iconBadge: "bg-white/15 backdrop-blur-xl", + icon: "text-[#ffbf00]", + title: "text-[#fff200]", + description: "text-red-100/90", + close: "text-red-100/90 hover:text-white hover:bg-white/10", + }, + success: { + card: "bg-gradient-to-r from-[#08bd38] to-emerald-700", + shadow: "shadow-lg shadow-emerald-900/30", + iconBadge: "bg-white/15 backdrop-blur-xl", + icon: "text-yellow-400", + title: "text-white", + description: "text-emerald-100/80", + close: "text-emerald-100/90 hover:text-white hover:bg-white/10", + }, + info: { + card: "bg-gradient-to-r from-sky-600 to-blue-700", + shadow: "shadow-lg shadow-blue-900/30", + iconBadge: "bg-white/15 backdrop-blur-xl", + icon: "text-orange-400", + title: "text-white", + description: "text-blue-100/80", + close: "text-blue-100/90 hover:text-white hover:bg-white/10", + }, + warning: { + card: "bg-gradient-to-r from-amber-500 to-orange-600", + shadow: "shadow-lg shadow-orange-900/40", + iconBadge: "bg-black/20 backdrop-blur-xl", + icon: "text-white", + title: "text-white", + description: "text-amber-100/85", + close: "text-amber-100/90 hover:text-white hover:bg-white/10", + }, +}; - const icons = { - error: ( -
- - - -
- ), - success: ( -
- - - -
- ), - info: ( -
- - - -
- ), - warning: ( -
- - - -
- ), - }; +const icons: Record = { + error: ( + + + + ), + success: ( + + + + ), + // Generic info-circle (sample.tsx used a chat-bubble tied to its "you have a message" example copy; + // this toast carries arbitrary info messages, so it keeps the neutral info glyph instead). + info: ( + + + + ), + warning: ( + + + + ), +}; + +export default function Toast({ id, type, title, description, onClose }: ToastProps) { + const s = STYLES[type]; return (
-
-
- -
-
-
- {icons[type]} -
+
+
+
{icons[type]}
-
-

{title}

- {description ? ( -

- {description} -

- ) : null} -
+
+

{title}

+ {description ?

{description}

: null}
- -
+ +
);