Notification.js 784 B

1234567891011121314151617181920212223
  1. import { Icon, Notification as _Notification } from "tiny-ui";
  2. const Notification = ({ type, ...props }) => {
  3. let payload = { ...props, placement: "bottomRight" };
  4. if (type && ["info", "success", "warning", "error"].includes(type)) {
  5. _Notification[type](payload);
  6. } else if (type && ["loader", "loading"].includes(type)) {
  7. payload.duration = 1500;
  8. payload.icon = (
  9. <Icon name="loader" size={32} style={{ marginRight: "1rem" }} spin />
  10. );
  11. _Notification.open(payload);
  12. } else if (type && ["announce", "announcement"].includes(type)) {
  13. payload.icon = (
  14. <Icon name="broadcast" size={32} style={{ marginRight: "1rem" }} />
  15. );
  16. _Notification.open(payload);
  17. } else {
  18. _Notification.open(payload);
  19. }
  20. };
  21. export default Notification;