Compare commits

...

1 Commits

Author SHA1 Message Date
Krzysztof Czerwinski
ee3e529964 Dismissable toast 2025-05-19 17:03:00 +02:00
2 changed files with 8 additions and 3 deletions

View File

@@ -13,9 +13,13 @@ import { useToast } from "@/components/ui/use-toast";
export function Toaster() {
const { toasts } = useToast();
const swipeThreshold = toasts.some((toast) => toast.dismissable === false)
? Infinity
: undefined;
return (
<ToastProvider>
{toasts.map(function ({ id, title, description, action, ...props }) {
<ToastProvider swipeThreshold={swipeThreshold}>
{toasts.map(function ({ id, title, description, action, dismissable, ...props }) {
return (
<Toast key={id} {...props}>
<div className="grid gap-1">
@@ -25,7 +29,7 @@ export function Toaster() {
)}
</div>
{action}
<ToastClose />
{dismissable !== false && <ToastClose />}
</Toast>
);
})}

View File

@@ -13,6 +13,7 @@ type ToasterToast = ToastProps & {
title?: React.ReactNode;
description?: React.ReactNode;
action?: ToastActionElement;
dismissable?: boolean;
};
const actionTypes = {