progress-dot.js 4.4 KB

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