v0.0.01b
This commit is contained in:
17
src/components/Toast.tsx
Normal file
17
src/components/Toast.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { createPortal } from 'react-dom';
|
||||
import { useToastStore } from '../store/useToast';
|
||||
|
||||
export function Toast() {
|
||||
const toasts = useToastStore((s) => s.toasts);
|
||||
if (toasts.length === 0) return null;
|
||||
return createPortal(
|
||||
<div aria-live="polite" role="status">
|
||||
{toasts.map((t) => (
|
||||
<div key={t.id} className="toast is-show">
|
||||
{t.message}
|
||||
</div>
|
||||
))}
|
||||
</div>,
|
||||
document.body,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user