placement.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { Keyframes } from '../../_util/cssinjs';
  2. const genNotificationPlacementStyle = token => {
  3. const {
  4. componentCls,
  5. width,
  6. notificationMarginEdge
  7. } = token;
  8. const notificationTopFadeIn = new Keyframes('antNotificationTopFadeIn', {
  9. '0%': {
  10. marginTop: '-100%',
  11. opacity: 0
  12. },
  13. '100%': {
  14. marginTop: 0,
  15. opacity: 1
  16. }
  17. });
  18. const notificationBottomFadeIn = new Keyframes('antNotificationBottomFadeIn', {
  19. '0%': {
  20. marginBottom: '-100%',
  21. opacity: 0
  22. },
  23. '100%': {
  24. marginBottom: 0,
  25. opacity: 1
  26. }
  27. });
  28. const notificationLeftFadeIn = new Keyframes('antNotificationLeftFadeIn', {
  29. '0%': {
  30. right: {
  31. _skip_check_: true,
  32. value: width
  33. },
  34. opacity: 0
  35. },
  36. '100%': {
  37. right: {
  38. _skip_check_: true,
  39. value: 0
  40. },
  41. opacity: 1
  42. }
  43. });
  44. return {
  45. [`&${componentCls}-top, &${componentCls}-bottom`]: {
  46. marginInline: 0
  47. },
  48. [`&${componentCls}-top`]: {
  49. [`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]: {
  50. animationName: notificationTopFadeIn
  51. }
  52. },
  53. [`&${componentCls}-bottom`]: {
  54. [`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]: {
  55. animationName: notificationBottomFadeIn
  56. }
  57. },
  58. [`&${componentCls}-topLeft, &${componentCls}-bottomLeft`]: {
  59. marginInlineEnd: 0,
  60. marginInlineStart: notificationMarginEdge,
  61. [`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]: {
  62. animationName: notificationLeftFadeIn
  63. }
  64. }
  65. };
  66. };
  67. export default genNotificationPlacementStyle;