| 1 | import { useSyncExternalStore } from 'react' |
| 2 | import { getToasts, subscribe } from '../../lib/toast' |
| 3 | |
| 4 | export function Toasts() { |
| 5 | const toasts = useSyncExternalStore(subscribe, getToasts) |
| 6 | return ( |
| 7 | <div |
| 8 | role="status" |
| 9 | className="fixed inset-x-0 bottom-20 z-30 flex flex-col items-center |
| 10 | gap-2 px-4 sm:bottom-6" |
| 11 | > |
| 12 | {toasts.map((t) => ( |
| 13 | <p |
| 14 | key={t.id} |
| 15 | className="rounded-full bg-ink px-4 py-2 text-sm text-paper |
| 16 | shadow-sm motion-safe:animate-drop" |
| 17 | > |
| 18 | {t.text} |
| 19 | </p> |
| 20 | ))} |
| 21 | </div> |
| 22 | ) |
| 23 | } |