nav.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import { unit } from '@ant-design/cssinjs';
  2. import { textEllipsis } from '../../style';
  3. const genStepsNavStyle = token => {
  4. const {
  5. componentCls,
  6. navContentMaxWidth,
  7. navArrowColor,
  8. stepsNavActiveColor,
  9. motionDurationSlow
  10. } = token;
  11. return {
  12. [`&${componentCls}-navigation`]: {
  13. paddingTop: token.paddingSM,
  14. [`&${componentCls}-small`]: {
  15. [`${componentCls}-item`]: {
  16. '&-container': {
  17. marginInlineStart: token.calc(token.marginSM).mul(-1).equal()
  18. }
  19. }
  20. },
  21. [`${componentCls}-item`]: {
  22. overflow: 'visible',
  23. textAlign: 'center',
  24. '&-container': {
  25. display: 'inline-block',
  26. height: '100%',
  27. marginInlineStart: token.calc(token.margin).mul(-1).equal(),
  28. paddingBottom: token.paddingSM,
  29. textAlign: 'start',
  30. transition: `opacity ${motionDurationSlow}`,
  31. [`${componentCls}-item-content`]: {
  32. maxWidth: navContentMaxWidth
  33. },
  34. [`${componentCls}-item-title`]: Object.assign(Object.assign({
  35. maxWidth: '100%',
  36. paddingInlineEnd: 0
  37. }, textEllipsis), {
  38. '&::after': {
  39. display: 'none'
  40. }
  41. })
  42. },
  43. [`&:not(${componentCls}-item-active)`]: {
  44. [`${componentCls}-item-container[role='button']`]: {
  45. cursor: 'pointer',
  46. '&:hover': {
  47. opacity: 0.85
  48. }
  49. }
  50. },
  51. '&:last-child': {
  52. flex: 1,
  53. '&::after': {
  54. display: 'none'
  55. }
  56. },
  57. '&::after': {
  58. position: 'absolute',
  59. top: `calc(50% - ${unit(token.calc(token.paddingSM).div(2).equal())})`,
  60. insetInlineStart: '100%',
  61. display: 'inline-block',
  62. width: token.fontSizeIcon,
  63. height: token.fontSizeIcon,
  64. borderTop: `${unit(token.lineWidth)} ${token.lineType} ${navArrowColor}`,
  65. borderBottom: 'none',
  66. borderInlineStart: 'none',
  67. borderInlineEnd: `${unit(token.lineWidth)} ${token.lineType} ${navArrowColor}`,
  68. transform: 'translateY(-50%) translateX(-50%) rotate(45deg)',
  69. content: '""'
  70. },
  71. '&::before': {
  72. position: 'absolute',
  73. bottom: 0,
  74. insetInlineStart: '50%',
  75. display: 'inline-block',
  76. width: 0,
  77. height: token.lineWidthBold,
  78. backgroundColor: stepsNavActiveColor,
  79. transition: `width ${motionDurationSlow}, inset-inline-start ${motionDurationSlow}`,
  80. transitionTimingFunction: 'ease-out',
  81. content: '""'
  82. }
  83. },
  84. [`${componentCls}-item${componentCls}-item-active::before`]: {
  85. insetInlineStart: 0,
  86. width: '100%'
  87. }
  88. },
  89. [`&${componentCls}-navigation${componentCls}-vertical`]: {
  90. [`> ${componentCls}-item`]: {
  91. marginInlineEnd: 0,
  92. '&::before': {
  93. display: 'none'
  94. },
  95. [`&${componentCls}-item-active::before`]: {
  96. top: 0,
  97. insetInlineEnd: 0,
  98. insetInlineStart: 'unset',
  99. display: 'block',
  100. width: token.calc(token.lineWidth).mul(3).equal(),
  101. height: `calc(100% - ${unit(token.marginLG)})`
  102. },
  103. '&::after': {
  104. position: 'relative',
  105. insetInlineStart: '50%',
  106. display: 'block',
  107. width: token.calc(token.controlHeight).mul(0.25).equal(),
  108. height: token.calc(token.controlHeight).mul(0.25).equal(),
  109. marginBottom: token.marginXS,
  110. textAlign: 'center',
  111. transform: 'translateY(-50%) translateX(-50%) rotate(135deg)'
  112. },
  113. '&:last-child': {
  114. '&::after': {
  115. display: 'none'
  116. }
  117. },
  118. [`> ${componentCls}-item-container > ${componentCls}-item-tail`]: {
  119. visibility: 'hidden'
  120. }
  121. }
  122. },
  123. [`&${componentCls}-navigation${componentCls}-horizontal`]: {
  124. [`> ${componentCls}-item > ${componentCls}-item-container > ${componentCls}-item-tail`]: {
  125. visibility: 'hidden'
  126. }
  127. }
  128. };
  129. };
  130. export default genStepsNavStyle;