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';
|
type?: 'success' | 'error' | 'info';
|
||||||
duration?: number;
|
duration?: number;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
'data-testid'?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Toast({
|
export function Toast({
|
||||||
message,
|
message,
|
||||||
type = 'success',
|
type = 'success',
|
||||||
duration = 3000,
|
duration = 3000,
|
||||||
onClose
|
onClose,
|
||||||
|
'data-testid': dataTestId
|
||||||
}: ToastProps) {
|
}: ToastProps) {
|
||||||
const [isVisible, setIsVisible] = useState(true);
|
const [isVisible, setIsVisible] = useState(true);
|
||||||
|
|
||||||
@@ -41,6 +43,8 @@ export function Toast({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<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 ${
|
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'
|
isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-2'
|
||||||
} ${bgColors[type]}`}
|
} ${bgColors[type]}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user