progress-dot.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const genStepsProgressDotStyle = token => {
  2. const {
  3. componentCls,
  4. descriptionWidth,
  5. lineHeight,
  6. stepsCurrentDotSize,
  7. stepsDotSize,
  8. motionDurationSlow
  9. } = token;
  10. return {
  11. [`&${componentCls}-dot, &${componentCls}-dot${componentCls}-small`]: {
  12. [`${componentCls}-item`]: {
  13. '&-title': {
  14. lineHeight
  15. },
  16. '&-tail': {
  17. top: Math.floor((token.stepsDotSize - token.lineWidth * 3) / 2),
  18. width: '100%',
  19. marginTop: 0,
  20. marginBottom: 0,
  21. marginInline: `${descriptionWidth / 2}px 0`,
  22. padding: 0,
  23. '&::after': {
  24. width: `calc(100% - ${token.marginSM * 2}px)`,
  25. height: token.lineWidth * 3,
  26. marginInlineStart: token.marginSM
  27. }
  28. },
  29. '&-icon': {
  30. width: stepsDotSize,
  31. height: stepsDotSize,
  32. marginInlineStart: (token.descriptionWidth - stepsDotSize) / 2,
  33. paddingInlineEnd: 0,
  34. lineHeight: `${stepsDotSize}px`,
  35. background: 'transparent',
  36. border: 0,
  37. [`${componentCls}-icon-dot`]: {
  38. position: 'relative',
  39. float: 'left',
  40. width: '100%',
  41. height: '100%',
  42. borderRadius: 100,
  43. transition: `all ${motionDurationSlow}`,
  44. /* expand hover area */
  45. '&::after': {
  46. position: 'absolute',
  47. top: -token.marginSM,
  48. insetInlineStart: (stepsDotSize - token.controlHeightLG * 1.5) / 2,
  49. width: token.controlHeightLG * 1.5,
  50. height: token.controlHeight,
  51. background: 'transparent',
  52. content: '""'
  53. }
  54. }
  55. },
  56. '&-content': {
  57. width: descriptionWidth
  58. },
  59. [`&-process ${componentCls}-item-icon`]: {
  60. position: 'relative',
  61. top: (stepsDotSize - stepsCurrentDotSize) / 2,
  62. width: stepsCurrentDotSize,
  63. height: stepsCurrentDotSize,
  64. lineHeight: `${stepsCurrentDotSize}px`,
  65. background: 'none',
  66. marginInlineStart: (token.descriptionWidth - stepsCurrentDotSize) / 2
  67. },
  68. [`&-process ${componentCls}-icon`]: {
  69. [`&:first-child ${componentCls}-icon-dot`]: {
  70. insetInlineStart: 0
  71. }
  72. }
  73. }
  74. },
  75. [`&${componentCls}-vertical${componentCls}-dot`]: {
  76. [`${componentCls}-item-icon`]: {
  77. marginTop: (token.controlHeight - stepsDotSize) / 2,
  78. marginInlineStart: 0,
  79. background: 'none'
  80. },
  81. [`${componentCls}-item-process ${componentCls}-item-icon`]: {
  82. marginTop: (token.controlHeight - stepsCurrentDotSize) / 2,
  83. top: 0,
  84. insetInlineStart: (stepsDotSize - stepsCurrentDotSize) / 2,
  85. marginInlineStart: 0
  86. },
  87. // https://github.com/ant-design/ant-design/issues/18354
  88. [`${componentCls}-item > ${componentCls}-item-container > ${componentCls}-item-tail`]: {
  89. top: (token.controlHeight - stepsDotSize) / 2,
  90. insetInlineStart: 0,
  91. margin: 0,
  92. padding: `${stepsDotSize + token.paddingXS}px 0 ${token.paddingXS}px`,
  93. '&::after': {
  94. marginInlineStart: (stepsDotSize - token.lineWidth) / 2
  95. }
  96. },
  97. [`&${componentCls}-small`]: {
  98. [`${componentCls}-item-icon`]: {
  99. marginTop: (token.controlHeightSM - stepsDotSize) / 2
  100. },
  101. [`${componentCls}-item-process ${componentCls}-item-icon`]: {
  102. marginTop: (token.controlHeightSM - stepsCurrentDotSize) / 2
  103. },
  104. [`${componentCls}-item > ${componentCls}-item-container > ${componentCls}-item-tail`]: {
  105. top: (token.controlHeightSM - stepsDotSize) / 2
  106. }
  107. },
  108. [`${componentCls}-item:first-child ${componentCls}-icon-dot`]: {
  109. insetInlineStart: 0
  110. },
  111. [`${componentCls}-item-content`]: {
  112. width: 'inherit'
  113. }
  114. }
  115. };
  116. };
  117. export default genStepsProgressDotStyle;