index.js 6.6 KB

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