850 B29 lines
Blame
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
8import {useAtomValue} from 'jotai';
9import {AnimatedReorderGroup} from './AnimatedReorderGroup';
10import {hideToast, toastQueueAtom} from './toast';
11
12import 'isl-components/Tooltip.css';
13import './TopLevelToast.css';
14
15export 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