index.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 genTimelineStyle = token => {
  10. const {
  11. componentCls,
  12. calc
  13. } = token;
  14. return {
  15. [componentCls]: Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
  16. margin: 0,
  17. padding: 0,
  18. listStyle: 'none',
  19. [`${componentCls}-item`]: {
  20. position: 'relative',
  21. margin: 0,
  22. paddingBottom: token.itemPaddingBottom,
  23. fontSize: token.fontSize,
  24. listStyle: 'none',
  25. '&-tail': {
  26. position: 'absolute',
  27. insetBlockStart: token.itemHeadSize,
  28. insetInlineStart: calc(calc(token.itemHeadSize).sub(token.tailWidth)).div(2).equal(),
  29. height: `calc(100% - ${(0, _cssinjs.unit)(token.itemHeadSize)})`,
  30. borderInlineStart: `${(0, _cssinjs.unit)(token.tailWidth)} ${token.lineType} ${token.tailColor}`
  31. },
  32. '&-pending': {
  33. [`${componentCls}-item-head`]: {
  34. fontSize: token.fontSizeSM,
  35. backgroundColor: 'transparent'
  36. },
  37. [`${componentCls}-item-tail`]: {
  38. display: 'none'
  39. }
  40. },
  41. '&-head': {
  42. position: 'absolute',
  43. width: token.itemHeadSize,
  44. height: token.itemHeadSize,
  45. backgroundColor: token.dotBg,
  46. border: `${(0, _cssinjs.unit)(token.dotBorderWidth)} ${token.lineType} transparent`,
  47. borderRadius: '50%',
  48. '&-blue': {
  49. color: token.colorPrimary,
  50. borderColor: token.colorPrimary
  51. },
  52. '&-red': {
  53. color: token.colorError,
  54. borderColor: token.colorError
  55. },
  56. '&-green': {
  57. color: token.colorSuccess,
  58. borderColor: token.colorSuccess
  59. },
  60. '&-gray': {
  61. color: token.colorTextDisabled,
  62. borderColor: token.colorTextDisabled
  63. }
  64. },
  65. '&-head-custom': {
  66. position: 'absolute',
  67. insetBlockStart: calc(token.itemHeadSize).div(2).equal(),
  68. insetInlineStart: calc(token.itemHeadSize).div(2).equal(),
  69. width: 'auto',
  70. height: 'auto',
  71. marginBlockStart: 0,
  72. paddingBlock: token.customHeadPaddingVertical,
  73. lineHeight: 1,
  74. textAlign: 'center',
  75. border: 0,
  76. borderRadius: 0,
  77. transform: 'translate(-50%, -50%)'
  78. },
  79. '&-content': {
  80. position: 'relative',
  81. insetBlockStart: calc(calc(token.fontSize).mul(token.lineHeight).sub(token.fontSize)).mul(-1).add(token.lineWidth).equal(),
  82. marginInlineStart: calc(token.margin).add(token.itemHeadSize).equal(),
  83. marginInlineEnd: 0,
  84. marginBlockStart: 0,
  85. marginBlockEnd: 0,
  86. wordBreak: 'break-word'
  87. },
  88. '&-last': {
  89. [`> ${componentCls}-item-tail`]: {
  90. display: 'none'
  91. },
  92. [`> ${componentCls}-item-content`]: {
  93. minHeight: calc(token.controlHeightLG).mul(1.2).equal()
  94. }
  95. }
  96. },
  97. [`&${componentCls}-alternate,
  98. &${componentCls}-right,
  99. &${componentCls}-label`]: {
  100. [`${componentCls}-item`]: {
  101. '&-tail, &-head, &-head-custom': {
  102. insetInlineStart: '50%'
  103. },
  104. '&-head': {
  105. marginInlineStart: calc(token.marginXXS).mul(-1).equal(),
  106. '&-custom': {
  107. marginInlineStart: calc(token.tailWidth).div(2).equal()
  108. }
  109. },
  110. '&-left': {
  111. [`${componentCls}-item-content`]: {
  112. insetInlineStart: `calc(50% - ${(0, _cssinjs.unit)(token.marginXXS)})`,
  113. width: `calc(50% - ${(0, _cssinjs.unit)(token.marginSM)})`,
  114. textAlign: 'start'
  115. }
  116. },
  117. '&-right': {
  118. [`${componentCls}-item-content`]: {
  119. width: `calc(50% - ${(0, _cssinjs.unit)(token.marginSM)})`,
  120. margin: 0,
  121. textAlign: 'end'
  122. }
  123. }
  124. }
  125. },
  126. [`&${componentCls}-right`]: {
  127. [`${componentCls}-item-right`]: {
  128. [`${componentCls}-item-tail,
  129. ${componentCls}-item-head,
  130. ${componentCls}-item-head-custom`]: {
  131. insetInlineStart: `calc(100% - ${(0, _cssinjs.unit)(calc(calc(token.itemHeadSize).add(token.tailWidth)).div(2).equal())})`
  132. },
  133. [`${componentCls}-item-content`]: {
  134. width: `calc(100% - ${(0, _cssinjs.unit)(calc(token.itemHeadSize).add(token.marginXS).equal())})`
  135. }
  136. }
  137. },
  138. [`&${componentCls}-pending
  139. ${componentCls}-item-last
  140. ${componentCls}-item-tail`]: {
  141. display: 'block',
  142. height: `calc(100% - ${(0, _cssinjs.unit)(token.margin)})`,
  143. borderInlineStart: `${(0, _cssinjs.unit)(token.tailWidth)} dotted ${token.tailColor}`
  144. },
  145. [`&${componentCls}-reverse
  146. ${componentCls}-item-last
  147. ${componentCls}-item-tail`]: {
  148. display: 'none'
  149. },
  150. [`&${componentCls}-reverse ${componentCls}-item-pending`]: {
  151. [`${componentCls}-item-tail`]: {
  152. insetBlockStart: token.margin,
  153. display: 'block',
  154. height: `calc(100% - ${(0, _cssinjs.unit)(token.margin)})`,
  155. borderInlineStart: `${(0, _cssinjs.unit)(token.tailWidth)} dotted ${token.tailColor}`
  156. },
  157. [`${componentCls}-item-content`]: {
  158. minHeight: calc(token.controlHeightLG).mul(1.2).equal()
  159. }
  160. },
  161. [`&${componentCls}-label`]: {
  162. [`${componentCls}-item-label`]: {
  163. position: 'absolute',
  164. insetBlockStart: calc(calc(token.fontSize).mul(token.lineHeight).sub(token.fontSize)).mul(-1).add(token.tailWidth).equal(),
  165. width: `calc(50% - ${(0, _cssinjs.unit)(token.marginSM)})`,
  166. textAlign: 'end'
  167. },
  168. [`${componentCls}-item-right`]: {
  169. [`${componentCls}-item-label`]: {
  170. insetInlineStart: `calc(50% + ${(0, _cssinjs.unit)(token.marginSM)})`,
  171. width: `calc(50% - ${(0, _cssinjs.unit)(token.marginSM)})`,
  172. textAlign: 'start'
  173. }
  174. }
  175. },
  176. // ====================== RTL =======================
  177. '&-rtl': {
  178. direction: 'rtl',
  179. [`${componentCls}-item-head-custom`]: {
  180. transform: `translate(50%, -50%)`
  181. }
  182. }
  183. })
  184. };
  185. };
  186. // ============================== Export ==============================
  187. const prepareComponentToken = token => ({
  188. tailColor: token.colorSplit,
  189. tailWidth: token.lineWidthBold,
  190. dotBorderWidth: token.wireframe ? token.lineWidthBold : token.lineWidth * 3,
  191. dotBg: token.colorBgContainer,
  192. itemPaddingBottom: token.padding * 1.25
  193. });
  194. exports.prepareComponentToken = prepareComponentToken;
  195. var _default = exports.default = (0, _internal.genStyleHooks)('Timeline', token => {
  196. const timeLineToken = (0, _internal.mergeToken)(token, {
  197. itemHeadSize: 10,
  198. customHeadPaddingVertical: token.paddingXXS,
  199. paddingInlineEnd: 2
  200. });
  201. return genTimelineStyle(timeLineToken);
  202. }, prepareComponentToken);