feat: add data-testid and data-type support to Toast component
This commit is contained in:
@@ -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]}`}
|
||||
|
||||
Reference in New Issue
Block a user