index.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. const antProgressActive = new _cssinjs.Keyframes('antProgressActive', {
  12. '0%': {
  13. transform: 'translateX(-100%) scaleX(0)',
  14. opacity: 0.1
  15. },
  16. '20%': {
  17. transform: 'translateX(-100%) scaleX(0)',
  18. opacity: 0.5
  19. },
  20. to: {
  21. transform: 'translateX(0) scaleX(1)',
  22. opacity: 0
  23. }
  24. });
  25. const genBaseStyle = token => {
  26. const {
  27. componentCls: progressCls,
  28. iconCls: iconPrefixCls
  29. } = token;
  30. return {
  31. [progressCls]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
  32. display: 'inline-block',
  33. '&-rtl': {
  34. direction: 'rtl'
  35. },
  36. '&-line': {
  37. position: 'relative',
  38. width: '100%',
  39. fontSize: token.fontSize,
  40. marginInlineEnd: token.marginXS,
  41. marginBottom: token.marginXS
  42. },
  43. [`${progressCls}-outer`]: {
  44. display: 'inline-block',
  45. width: '100%'
  46. },
  47. [`&${progressCls}-show-info`]: {
  48. [`${progressCls}-outer`]: {
  49. marginInlineEnd: `calc(-2em - ${token.marginXS}px)`,
  50. paddingInlineEnd: `calc(2em + ${token.paddingXS}px)`
  51. }
  52. },
  53. [`${progressCls}-inner`]: {
  54. position: 'relative',
  55. display: 'inline-block',
  56. width: '100%',
  57. overflow: 'hidden',
  58. verticalAlign: 'middle',
  59. backgroundColor: token.progressRemainingColor,
  60. borderRadius: token.progressLineRadius
  61. },
  62. [`${progressCls}-inner:not(${progressCls}-circle-gradient)`]: {
  63. [`${progressCls}-circle-path`]: {
  64. stroke: token.colorInfo
  65. }
  66. },
  67. [`${progressCls}-success-bg, ${progressCls}-bg`]: {
  68. position: 'relative',
  69. backgroundColor: token.colorInfo,
  70. borderRadius: token.progressLineRadius,
  71. transition: `all ${token.motionDurationSlow} ${token.motionEaseInOutCirc}`
  72. },
  73. [`${progressCls}-success-bg`]: {
  74. position: 'absolute',
  75. insetBlockStart: 0,
  76. insetInlineStart: 0,
  77. backgroundColor: token.colorSuccess
  78. },
  79. [`${progressCls}-text`]: {
  80. display: 'inline-block',
  81. width: '2em',
  82. marginInlineStart: token.marginXS,
  83. color: token.progressInfoTextColor,
  84. lineHeight: 1,
  85. whiteSpace: 'nowrap',
  86. textAlign: 'start',
  87. verticalAlign: 'middle',
  88. wordBreak: 'normal',
  89. [iconPrefixCls]: {
  90. fontSize: token.fontSize
  91. }
  92. },
  93. [`&${progressCls}-status-active`]: {
  94. [`${progressCls}-bg::before`]: {
  95. position: 'absolute',
  96. inset: 0,
  97. backgroundColor: token.colorBgContainer,
  98. borderRadius: token.progressLineRadius,
  99. opacity: 0,
  100. animationName: antProgressActive,
  101. animationDuration: token.progressActiveMotionDuration,
  102. animationTimingFunction: token.motionEaseOutQuint,
  103. animationIterationCount: 'infinite',
  104. content: '""'
  105. }
  106. },
  107. [`&${progressCls}-status-exception`]: {
  108. [`${progressCls}-bg`]: {
  109. backgroundColor: token.colorError
  110. },
  111. [`${progressCls}-text`]: {
  112. color: token.colorError
  113. }
  114. },
  115. [`&${progressCls}-status-exception ${progressCls}-inner:not(${progressCls}-circle-gradient)`]: {
  116. [`${progressCls}-circle-path`]: {
  117. stroke: token.colorError
  118. }
  119. },
  120. [`&${progressCls}-status-success`]: {
  121. [`${progressCls}-bg`]: {
  122. backgroundColor: token.colorSuccess
  123. },
  124. [`${progressCls}-text`]: {
  125. color: token.colorSuccess
  126. }
  127. },
  128. [`&${progressCls}-status-success ${progressCls}-inner:not(${progressCls}-circle-gradient)`]: {
  129. [`${progressCls}-circle-path`]: {
  130. stroke: token.colorSuccess
  131. }
  132. }
  133. })
  134. };
  135. };
  136. const genCircleStyle = token => {
  137. const {
  138. componentCls: progressCls,
  139. iconCls: iconPrefixCls
  140. } = token;
  141. return {
  142. [progressCls]: {
  143. [`${progressCls}-circle-trail`]: {
  144. stroke: token.progressRemainingColor
  145. },
  146. [`&${progressCls}-circle ${progressCls}-inner`]: {
  147. position: 'relative',
  148. lineHeight: 1,
  149. backgroundColor: 'transparent'
  150. },
  151. [`&${progressCls}-circle ${progressCls}-text`]: {
  152. position: 'absolute',
  153. insetBlockStart: '50%',
  154. insetInlineStart: 0,
  155. width: '100%',
  156. margin: 0,
  157. padding: 0,
  158. color: token.colorText,
  159. lineHeight: 1,
  160. whiteSpace: 'normal',
  161. textAlign: 'center',
  162. transform: 'translateY(-50%)',
  163. [iconPrefixCls]: {
  164. fontSize: `${token.fontSize / token.fontSizeSM}em`
  165. }
  166. },
  167. [`${progressCls}-circle&-status-exception`]: {
  168. [`${progressCls}-text`]: {
  169. color: token.colorError
  170. }
  171. },
  172. [`${progressCls}-circle&-status-success`]: {
  173. [`${progressCls}-text`]: {
  174. color: token.colorSuccess
  175. }
  176. }
  177. },
  178. [`${progressCls}-inline-circle`]: {
  179. lineHeight: 1,
  180. [`${progressCls}-inner`]: {
  181. verticalAlign: 'bottom'
  182. }
  183. }
  184. };
  185. };
  186. const genStepStyle = token => {
  187. const {
  188. componentCls: progressCls
  189. } = token;
  190. return {
  191. [progressCls]: {
  192. [`${progressCls}-steps`]: {
  193. display: 'inline-block',
  194. '&-outer': {
  195. display: 'flex',
  196. flexDirection: 'row',
  197. alignItems: 'center'
  198. },
  199. '&-item': {
  200. flexShrink: 0,
  201. minWidth: token.progressStepMinWidth,
  202. marginInlineEnd: token.progressStepMarginInlineEnd,
  203. backgroundColor: token.progressRemainingColor,
  204. transition: `all ${token.motionDurationSlow}`,
  205. '&-active': {
  206. backgroundColor: token.colorInfo
  207. }
  208. }
  209. }
  210. }
  211. };
  212. };
  213. const genSmallLine = token => {
  214. const {
  215. componentCls: progressCls,
  216. iconCls: iconPrefixCls
  217. } = token;
  218. return {
  219. [progressCls]: {
  220. [`${progressCls}-small&-line, ${progressCls}-small&-line ${progressCls}-text ${iconPrefixCls}`]: {
  221. fontSize: token.fontSizeSM
  222. }
  223. }
  224. };
  225. };
  226. var _default = exports.default = (0, _internal.genComponentStyleHook)('Progress', token => {
  227. const progressStepMarginInlineEnd = token.marginXXS / 2;
  228. const progressToken = (0, _internal.mergeToken)(token, {
  229. progressLineRadius: 100,
  230. progressInfoTextColor: token.colorText,
  231. progressDefaultColor: token.colorInfo,
  232. progressRemainingColor: token.colorFillSecondary,
  233. progressStepMarginInlineEnd,
  234. progressStepMinWidth: progressStepMarginInlineEnd,
  235. progressActiveMotionDuration: '2.4s'
  236. });
  237. return [genBaseStyle(progressToken), genCircleStyle(progressToken), genStepStyle(progressToken), genSmallLine(progressToken)];
  238. });