indicators.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import styled from '@emotion/styled';
  2. import {AnimatePresence} from 'framer-motion';
  3. import {removeIndicator} from 'sentry/actionCreators/indicator';
  4. import ToastIndicator from 'sentry/components/alerts/toastIndicator';
  5. import IndicatorStore from 'sentry/stores/indicatorStore';
  6. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  7. const Toasts = styled('div')`
  8. position: fixed;
  9. right: 30px;
  10. bottom: 30px;
  11. z-index: ${p => p.theme.zIndex.toast};
  12. `;
  13. type Props = {
  14. className?: string;
  15. };
  16. function Indicators(props: Props) {
  17. const items = useLegacyStore(IndicatorStore);
  18. return (
  19. <Toasts {...props}>
  20. <AnimatePresence>
  21. {items.map((indicator, i) => (
  22. // We purposefully use `i` as key here because of transitions
  23. // Toasts can now queue up, so when we change from [firstToast] -> [secondToast],
  24. // we don't want to animate `firstToast` out and `secondToast` in, rather we want
  25. // to replace `firstToast` with `secondToast`
  26. <ToastIndicator onDismiss={removeIndicator} indicator={indicator} key={i} />
  27. ))}
  28. </AnimatePresence>
  29. </Toasts>
  30. );
  31. }
  32. export default Indicators;