index.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 _internal = require("../../theme/internal");
  9. var _style = require("../../style");
  10. const genTimelineStyle = token => {
  11. const {
  12. componentCls
  13. } = token;
  14. return {
  15. [componentCls]: (0, _extends2.default)((0, _extends2.default)({}, (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.timeLineItemPaddingBottom,
  23. fontSize: token.fontSize,
  24. listStyle: 'none',
  25. '&-tail': {
  26. position: 'absolute',
  27. insetBlockStart: token.timeLineItemHeadSize,
  28. insetInlineStart: (token.timeLineItemHeadSize - token.timeLineItemTailWidth) / 2,
  29. height: `calc(100% - ${token.timeLineItemHeadSize}px)`,
  30. borderInlineStart: `${token.timeLineItemTailWidth}px ${token.lineType} ${token.colorSplit}`
  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.timeLineItemHeadSize,
  44. height: token.timeLineItemHeadSize,
  45. backgroundColor: token.colorBgContainer,
  46. border: `${token.timeLineHeadBorderWidth}px ${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: token.timeLineItemHeadSize / 2,
  68. insetInlineStart: token.timeLineItemHeadSize / 2,
  69. width: 'auto',
  70. height: 'auto',
  71. marginBlockStart: 0,
  72. paddingBlock: token.timeLineItemCustomHeadPaddingVertical,
  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: -(token.fontSize * token.lineHeight - token.fontSize) + token.lineWidth,
  82. marginInlineStart: token.margin + token.timeLineItemHeadSize,
  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: token.controlHeightLG * 1.2
  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: `-${token.marginXXS}px`,
  106. '&-custom': {
  107. marginInlineStart: token.timeLineItemTailWidth / 2
  108. }
  109. },
  110. '&-left': {
  111. [`${componentCls}-item-content`]: {
  112. insetInlineStart: `calc(50% - ${token.marginXXS}px)`,
  113. width: `calc(50% - ${token.marginSM}px)`,
  114. textAlign: 'start'
  115. }
  116. },
  117. '&-right': {
  118. [`${componentCls}-item-content`]: {
  119. width: `calc(50% - ${token.marginSM}px)`,
  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% - ${(token.timeLineItemHeadSize + token.timeLineItemTailWidth) / 2}px)`
  132. },
  133. [`${componentCls}-item-content`]: {
  134. width: `calc(100% - ${token.timeLineItemHeadSize + token.marginXS}px)`
  135. }
  136. }
  137. },
  138. [`&${componentCls}-pending
  139. ${componentCls}-item-last
  140. ${componentCls}-item-tail`]: {
  141. display: 'block',
  142. height: `calc(100% - ${token.margin}px)`,
  143. borderInlineStart: `${token.timeLineItemTailWidth}px dotted ${token.colorSplit}`
  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% - ${token.margin}px)`,
  155. borderInlineStart: `${token.timeLineItemTailWidth}px dotted ${token.colorSplit}`
  156. },
  157. [`${componentCls}-item-content`]: {
  158. minHeight: token.controlHeightLG * 1.2
  159. }
  160. },
  161. [`&${componentCls}-label`]: {
  162. [`${componentCls}-item-label`]: {
  163. position: 'absolute',
  164. insetBlockStart: -(token.fontSize * token.lineHeight - token.fontSize) + token.timeLineItemTailWidth,
  165. width: `calc(50% - ${token.marginSM}px)`,
  166. textAlign: 'end'
  167. },
  168. [`${componentCls}-item-right`]: {
  169. [`${componentCls}-item-label`]: {
  170. insetInlineStart: `calc(50% + ${token.marginSM}px)`,
  171. width: `calc(50% - ${token.marginSM}px)`,
  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. var _default = exports.default = (0, _internal.genComponentStyleHook)('Timeline', token => {
  188. const timeLineToken = (0, _internal.mergeToken)(token, {
  189. timeLineItemPaddingBottom: token.padding * 1.25,
  190. timeLineItemHeadSize: 10,
  191. timeLineItemCustomHeadPaddingVertical: token.paddingXXS,
  192. timeLinePaddingInlineEnd: 2,
  193. timeLineItemTailWidth: token.lineWidthBold,
  194. timeLineHeadBorderWidth: token.wireframe ? token.lineWidthBold : token.lineWidth * 3
  195. });
  196. return [genTimelineStyle(timeLineToken)];
  197. });