index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  8. var _cssinjs = require("../../_util/cssinjs");
  9. var _internal = require("../../theme/internal");
  10. var _style = require("../../style");
  11. // deps-lint-skip-all
  12. const genMessageStyle = token => {
  13. const {
  14. componentCls,
  15. iconCls,
  16. boxShadowSecondary,
  17. colorBgElevated,
  18. colorSuccess,
  19. colorError,
  20. colorWarning,
  21. colorInfo,
  22. fontSizeLG,
  23. motionEaseInOutCirc,
  24. motionDurationSlow,
  25. marginXS,
  26. paddingXS,
  27. borderRadiusLG,
  28. zIndexPopup,
  29. // Custom token
  30. messageNoticeContentPadding
  31. } = token;
  32. const messageMoveIn = new _cssinjs.Keyframes('MessageMoveIn', {
  33. '0%': {
  34. padding: 0,
  35. transform: 'translateY(-100%)',
  36. opacity: 0
  37. },
  38. '100%': {
  39. padding: paddingXS,
  40. transform: 'translateY(0)',
  41. opacity: 1
  42. }
  43. });
  44. const messageMoveOut = new _cssinjs.Keyframes('MessageMoveOut', {
  45. '0%': {
  46. maxHeight: token.height,
  47. padding: paddingXS,
  48. opacity: 1
  49. },
  50. '100%': {
  51. maxHeight: 0,
  52. padding: 0,
  53. opacity: 0
  54. }
  55. });
  56. return [
  57. // ============================ Holder ============================
  58. {
  59. [componentCls]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
  60. position: 'fixed',
  61. top: marginXS,
  62. left: '50%',
  63. transform: 'translateX(-50%)',
  64. width: '100%',
  65. pointerEvents: 'none',
  66. zIndex: zIndexPopup,
  67. [`${componentCls}-move-up`]: {
  68. animationFillMode: 'forwards'
  69. },
  70. [`
  71. ${componentCls}-move-up-appear,
  72. ${componentCls}-move-up-enter
  73. `]: {
  74. animationName: messageMoveIn,
  75. animationDuration: motionDurationSlow,
  76. animationPlayState: 'paused',
  77. animationTimingFunction: motionEaseInOutCirc
  78. },
  79. [`
  80. ${componentCls}-move-up-appear${componentCls}-move-up-appear-active,
  81. ${componentCls}-move-up-enter${componentCls}-move-up-enter-active
  82. `]: {
  83. animationPlayState: 'running'
  84. },
  85. [`${componentCls}-move-up-leave`]: {
  86. animationName: messageMoveOut,
  87. animationDuration: motionDurationSlow,
  88. animationPlayState: 'paused',
  89. animationTimingFunction: motionEaseInOutCirc
  90. },
  91. [`${componentCls}-move-up-leave${componentCls}-move-up-leave-active`]: {
  92. animationPlayState: 'running'
  93. },
  94. '&-rtl': {
  95. direction: 'rtl',
  96. span: {
  97. direction: 'rtl'
  98. }
  99. }
  100. })
  101. },
  102. // ============================ Notice ============================
  103. {
  104. [`${componentCls}-notice`]: {
  105. padding: paddingXS,
  106. textAlign: 'center',
  107. [iconCls]: {
  108. verticalAlign: 'text-bottom',
  109. marginInlineEnd: marginXS,
  110. fontSize: fontSizeLG
  111. },
  112. [`${componentCls}-notice-content`]: {
  113. display: 'inline-block',
  114. padding: messageNoticeContentPadding,
  115. background: colorBgElevated,
  116. borderRadius: borderRadiusLG,
  117. boxShadow: boxShadowSecondary,
  118. pointerEvents: 'all'
  119. },
  120. [`${componentCls}-success ${iconCls}`]: {
  121. color: colorSuccess
  122. },
  123. [`${componentCls}-error ${iconCls}`]: {
  124. color: colorError
  125. },
  126. [`${componentCls}-warning ${iconCls}`]: {
  127. color: colorWarning
  128. },
  129. [`
  130. ${componentCls}-info ${iconCls},
  131. ${componentCls}-loading ${iconCls}`]: {
  132. color: colorInfo
  133. }
  134. }
  135. },
  136. // ============================= Pure =============================
  137. {
  138. [`${componentCls}-notice-pure-panel`]: {
  139. padding: 0,
  140. textAlign: 'start'
  141. }
  142. }];
  143. };
  144. // ============================== Export ==============================
  145. var _default = exports.default = (0, _internal.genComponentStyleHook)('Message', token => {
  146. // Gen-style functions here
  147. const combinedToken = (0, _internal.mergeToken)(token, {
  148. messageNoticeContentPadding: `${(token.controlHeightLG - token.fontSize * token.lineHeight) / 2}px ${token.paddingSM}px`
  149. });
  150. return [genMessageStyle(combinedToken)];
  151. }, token => ({
  152. height: 150,
  153. zIndexPopup: token.zIndexPopupBase + 10
  154. }));