| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | import {useAtomValue} from 'jotai'; |
| 9 | import {AnimatedReorderGroup} from './AnimatedReorderGroup'; |
| 10 | import {hideToast, toastQueueAtom} from './toast'; |
| 11 | |
| 12 | import 'isl-components/Tooltip.css'; |
| 13 | import './TopLevelToast.css'; |
| 14 | |
| 15 | export function TopLevelToast() { |
| 16 | const toastQueue = useAtomValue(toastQueueAtom); |
| 17 | |
| 18 | const toastDivs = toastQueue.toArray().map(t => { |
| 19 | const handleClick = () => hideToast([t.key]); |
| 20 | return ( |
| 21 | <div className="toast tooltip" key={t.key} data-reorder-id={t.key} onClick={handleClick}> |
| 22 | {t.message} |
| 23 | </div> |
| 24 | ); |
| 25 | }); |
| 26 | |
| 27 | return <AnimatedReorderGroup className="toast-container">{toastDivs}</AnimatedReorderGroup>; |
| 28 | } |
| 29 | |