util.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. export function getPlacementStyle(placement, top, bottom) {
  2. let style;
  3. switch (placement) {
  4. case 'top':
  5. style = {
  6. left: '50%',
  7. transform: 'translateX(-50%)',
  8. right: 'auto',
  9. top,
  10. bottom: 'auto'
  11. };
  12. break;
  13. case 'topLeft':
  14. style = {
  15. left: 0,
  16. top,
  17. bottom: 'auto'
  18. };
  19. break;
  20. case 'topRight':
  21. style = {
  22. right: 0,
  23. top,
  24. bottom: 'auto'
  25. };
  26. break;
  27. case 'bottom':
  28. style = {
  29. left: '50%',
  30. transform: 'translateX(-50%)',
  31. right: 'auto',
  32. top: 'auto',
  33. bottom
  34. };
  35. break;
  36. case 'bottomLeft':
  37. style = {
  38. left: 0,
  39. top: 'auto',
  40. bottom
  41. };
  42. break;
  43. default:
  44. style = {
  45. right: 0,
  46. top: 'auto',
  47. bottom
  48. };
  49. break;
  50. }
  51. return style;
  52. }
  53. export function getMotion(prefixCls) {
  54. return {
  55. motionName: `${prefixCls}-fade`
  56. };
  57. }
  58. export function getCloseIconConfig(closeIcon, notificationConfig, notification) {
  59. if (typeof closeIcon !== 'undefined') {
  60. return closeIcon;
  61. }
  62. if (typeof (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.closeIcon) !== 'undefined') {
  63. return notificationConfig.closeIcon;
  64. }
  65. return notification === null || notification === void 0 ? void 0 : notification.closeIcon;
  66. }