feat: add data-testid and data-type support to Toast component

This commit is contained in:
张翔
2026-03-06 17:49:27 +08:00
parent 3da8ef7072
commit badce55606
+5 -1
View File
@@ -8,13 +8,15 @@ interface ToastProps {
type?: 'success' | 'error' | 'info';
duration?: number;
onClose: () => void;
'data-testid'?: string;
}
export function Toast({
message,
type = 'success',
duration = 3000,
onClose
onClose,
'data-testid': dataTestId
}: ToastProps) {
const [isVisible, setIsVisible] = useState(true);
@@ -41,6 +43,8 @@ export function Toast({
return (
<div
data-testid={dataTestId}
data-type={type}
className={`fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 bg-white rounded-lg shadow-lg border transition-all duration-300 ${
isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-2'
} ${bgColors[type]}`}