index.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.prepareComponentToken = exports.default = void 0;
  6. var _cssinjs = require("@ant-design/cssinjs");
  7. var _style = require("../../style");
  8. var _internal = require("../../theme/internal");
  9. const antSpinMove = new _cssinjs.Keyframes('antSpinMove', {
  10. to: {
  11. opacity: 1
  12. }
  13. });
  14. const antRotate = new _cssinjs.Keyframes('antRotate', {
  15. to: {
  16. transform: 'rotate(405deg)'
  17. }
  18. });
  19. const genSpinStyle = token => {
  20. const {
  21. componentCls,
  22. calc
  23. } = token;
  24. return {
  25. [componentCls]: Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
  26. position: 'absolute',
  27. display: 'none',
  28. color: token.colorPrimary,
  29. fontSize: 0,
  30. textAlign: 'center',
  31. verticalAlign: 'middle',
  32. opacity: 0,
  33. transition: `transform ${token.motionDurationSlow} ${token.motionEaseInOutCirc}`,
  34. '&-spinning': {
  35. position: 'relative',
  36. display: 'inline-block',
  37. opacity: 1
  38. },
  39. [`${componentCls}-text`]: {
  40. fontSize: token.fontSize,
  41. paddingTop: calc(calc(token.dotSize).sub(token.fontSize)).div(2).add(2).equal()
  42. },
  43. '&-fullscreen': {
  44. position: 'fixed',
  45. width: '100vw',
  46. height: '100vh',
  47. backgroundColor: token.colorBgMask,
  48. zIndex: token.zIndexPopupBase,
  49. inset: 0,
  50. display: 'flex',
  51. alignItems: 'center',
  52. flexDirection: 'column',
  53. justifyContent: 'center',
  54. opacity: 0,
  55. visibility: 'hidden',
  56. transition: `all ${token.motionDurationMid}`,
  57. '&-show': {
  58. opacity: 1,
  59. visibility: 'visible'
  60. },
  61. [componentCls]: {
  62. [`${componentCls}-dot-holder`]: {
  63. color: token.colorWhite
  64. },
  65. [`${componentCls}-text`]: {
  66. color: token.colorTextLightSolid
  67. }
  68. }
  69. },
  70. '&-nested-loading': {
  71. position: 'relative',
  72. [`> div > ${componentCls}`]: {
  73. position: 'absolute',
  74. top: 0,
  75. insetInlineStart: 0,
  76. zIndex: 4,
  77. display: 'block',
  78. width: '100%',
  79. height: '100%',
  80. maxHeight: token.contentHeight,
  81. [`${componentCls}-dot`]: {
  82. position: 'absolute',
  83. top: '50%',
  84. insetInlineStart: '50%',
  85. margin: calc(token.dotSize).mul(-1).div(2).equal()
  86. },
  87. [`${componentCls}-text`]: {
  88. position: 'absolute',
  89. top: '50%',
  90. width: '100%',
  91. textShadow: `0 1px 2px ${token.colorBgContainer}` // FIXME: shadow
  92. },
  93. [`&${componentCls}-show-text ${componentCls}-dot`]: {
  94. marginTop: calc(token.dotSize).div(2).mul(-1).sub(10).equal()
  95. },
  96. '&-sm': {
  97. [`${componentCls}-dot`]: {
  98. margin: calc(token.dotSizeSM).mul(-1).div(2).equal()
  99. },
  100. [`${componentCls}-text`]: {
  101. paddingTop: calc(calc(token.dotSizeSM).sub(token.fontSize)).div(2).add(2).equal()
  102. },
  103. [`&${componentCls}-show-text ${componentCls}-dot`]: {
  104. marginTop: calc(token.dotSizeSM).div(2).mul(-1).sub(10).equal()
  105. }
  106. },
  107. '&-lg': {
  108. [`${componentCls}-dot`]: {
  109. margin: calc(token.dotSizeLG).mul(-1).div(2).equal()
  110. },
  111. [`${componentCls}-text`]: {
  112. paddingTop: calc(calc(token.dotSizeLG).sub(token.fontSize)).div(2).add(2).equal()
  113. },
  114. [`&${componentCls}-show-text ${componentCls}-dot`]: {
  115. marginTop: calc(token.dotSizeLG).div(2).mul(-1).sub(10).equal()
  116. }
  117. }
  118. },
  119. [`${componentCls}-container`]: {
  120. position: 'relative',
  121. transition: `opacity ${token.motionDurationSlow}`,
  122. '&::after': {
  123. position: 'absolute',
  124. top: 0,
  125. insetInlineEnd: 0,
  126. bottom: 0,
  127. insetInlineStart: 0,
  128. zIndex: 10,
  129. width: '100%',
  130. height: '100%',
  131. background: token.colorBgContainer,
  132. opacity: 0,
  133. transition: `all ${token.motionDurationSlow}`,
  134. content: '""',
  135. pointerEvents: 'none'
  136. }
  137. },
  138. [`${componentCls}-blur`]: {
  139. clear: 'both',
  140. opacity: 0.5,
  141. userSelect: 'none',
  142. pointerEvents: 'none',
  143. '&::after': {
  144. opacity: 0.4,
  145. pointerEvents: 'auto'
  146. }
  147. }
  148. },
  149. // tip
  150. // ------------------------------
  151. '&-tip': {
  152. color: token.spinDotDefault
  153. },
  154. // holder
  155. // ------------------------------
  156. [`${componentCls}-dot-holder`]: {
  157. width: '1em',
  158. height: '1em',
  159. fontSize: token.dotSize,
  160. display: 'inline-block',
  161. transition: `transform ${token.motionDurationSlow} ease, opacity ${token.motionDurationSlow} ease`,
  162. transformOrigin: '50% 50%',
  163. lineHeight: 1,
  164. color: token.colorPrimary,
  165. '&-hidden': {
  166. transform: 'scale(0.3)',
  167. opacity: 0
  168. }
  169. },
  170. // progress
  171. // ------------------------------
  172. [`${componentCls}-dot-progress`]: {
  173. position: 'absolute',
  174. inset: 0
  175. },
  176. // dots
  177. // ------------------------------
  178. [`${componentCls}-dot`]: {
  179. position: 'relative',
  180. display: 'inline-block',
  181. fontSize: token.dotSize,
  182. width: '1em',
  183. height: '1em',
  184. '&-item': {
  185. position: 'absolute',
  186. display: 'block',
  187. width: calc(token.dotSize).sub(calc(token.marginXXS).div(2)).div(2).equal(),
  188. height: calc(token.dotSize).sub(calc(token.marginXXS).div(2)).div(2).equal(),
  189. background: 'currentColor',
  190. borderRadius: '100%',
  191. transform: 'scale(0.75)',
  192. transformOrigin: '50% 50%',
  193. opacity: 0.3,
  194. animationName: antSpinMove,
  195. animationDuration: '1s',
  196. animationIterationCount: 'infinite',
  197. animationTimingFunction: 'linear',
  198. animationDirection: 'alternate',
  199. '&:nth-child(1)': {
  200. top: 0,
  201. insetInlineStart: 0,
  202. animationDelay: '0s'
  203. },
  204. '&:nth-child(2)': {
  205. top: 0,
  206. insetInlineEnd: 0,
  207. animationDelay: '0.4s'
  208. },
  209. '&:nth-child(3)': {
  210. insetInlineEnd: 0,
  211. bottom: 0,
  212. animationDelay: '0.8s'
  213. },
  214. '&:nth-child(4)': {
  215. bottom: 0,
  216. insetInlineStart: 0,
  217. animationDelay: '1.2s'
  218. }
  219. },
  220. '&-spin': {
  221. transform: 'rotate(45deg)',
  222. animationName: antRotate,
  223. animationDuration: '1.2s',
  224. animationIterationCount: 'infinite',
  225. animationTimingFunction: 'linear'
  226. },
  227. '&-circle': {
  228. strokeLinecap: 'round',
  229. transition: ['stroke-dashoffset', 'stroke-dasharray', 'stroke', 'stroke-width', 'opacity'].map(item => `${item} ${token.motionDurationSlow} ease`).join(','),
  230. fillOpacity: 0,
  231. stroke: 'currentcolor'
  232. },
  233. '&-circle-bg': {
  234. stroke: token.colorFillSecondary
  235. }
  236. },
  237. // small
  238. [`&-sm ${componentCls}-dot`]: {
  239. '&, &-holder': {
  240. fontSize: token.dotSizeSM
  241. }
  242. },
  243. [`&-sm ${componentCls}-dot-holder`]: {
  244. i: {
  245. width: calc(calc(token.dotSizeSM).sub(calc(token.marginXXS).div(2))).div(2).equal(),
  246. height: calc(calc(token.dotSizeSM).sub(calc(token.marginXXS).div(2))).div(2).equal()
  247. }
  248. },
  249. // large
  250. [`&-lg ${componentCls}-dot`]: {
  251. '&, &-holder': {
  252. fontSize: token.dotSizeLG
  253. }
  254. },
  255. [`&-lg ${componentCls}-dot-holder`]: {
  256. i: {
  257. width: calc(calc(token.dotSizeLG).sub(token.marginXXS)).div(2).equal(),
  258. height: calc(calc(token.dotSizeLG).sub(token.marginXXS)).div(2).equal()
  259. }
  260. },
  261. [`&${componentCls}-show-text ${componentCls}-text`]: {
  262. display: 'block'
  263. }
  264. })
  265. };
  266. };
  267. const prepareComponentToken = token => {
  268. const {
  269. controlHeightLG,
  270. controlHeight
  271. } = token;
  272. return {
  273. contentHeight: 400,
  274. dotSize: controlHeightLG / 2,
  275. dotSizeSM: controlHeightLG * 0.35,
  276. dotSizeLG: controlHeight
  277. };
  278. };
  279. // ============================== Export ==============================
  280. exports.prepareComponentToken = prepareComponentToken;
  281. var _default = exports.default = (0, _internal.genStyleHooks)('Spin', token => {
  282. const spinToken = (0, _internal.mergeToken)(token, {
  283. spinDotDefault: token.colorTextDescription
  284. });
  285. return genSpinStyle(spinToken);
  286. }, prepareComponentToken);