addons/isl/src/TopLevelToast.tsxblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import {useAtomValue} from 'jotai';
b69ab319import {AnimatedReorderGroup} from './AnimatedReorderGroup';
b69ab3110import {hideToast, toastQueueAtom} from './toast';
b69ab3111
b69ab3112import 'isl-components/Tooltip.css';
b69ab3113import './TopLevelToast.css';
b69ab3114
b69ab3115export function TopLevelToast() {
b69ab3116 const toastQueue = useAtomValue(toastQueueAtom);
b69ab3117
b69ab3118 const toastDivs = toastQueue.toArray().map(t => {
b69ab3119 const handleClick = () => hideToast([t.key]);
b69ab3120 return (
b69ab3121 <div className="toast tooltip" key={t.key} data-reorder-id={t.key} onClick={handleClick}>
b69ab3122 {t.message}
b69ab3123 </div>
b69ab3124 );
b69ab3125 });
b69ab3126
b69ab3127 return <AnimatedReorderGroup className="toast-container">{toastDivs}</AnimatedReorderGroup>;
b69ab3128}