vertical.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { textEllipsis } from '../../style';
  3. const getVerticalInlineStyle = token => {
  4. const {
  5. componentCls,
  6. menuItemHeight,
  7. itemMarginInline,
  8. padding,
  9. menuArrowSize,
  10. marginXS,
  11. marginXXS
  12. } = token;
  13. const paddingWithArrow = padding + menuArrowSize + marginXS;
  14. return {
  15. [`${componentCls}-item`]: {
  16. position: 'relative'
  17. },
  18. [`${componentCls}-item, ${componentCls}-submenu-title`]: {
  19. height: menuItemHeight,
  20. lineHeight: `${menuItemHeight}px`,
  21. paddingInline: padding,
  22. overflow: 'hidden',
  23. textOverflow: 'ellipsis',
  24. marginInline: itemMarginInline,
  25. marginBlock: marginXXS,
  26. width: `calc(100% - ${itemMarginInline * 2}px)`
  27. },
  28. // disable margin collapsed
  29. [`${componentCls}-submenu`]: {
  30. paddingBottom: 0.02
  31. },
  32. [`> ${componentCls}-item,
  33. > ${componentCls}-submenu > ${componentCls}-submenu-title`]: {
  34. height: menuItemHeight,
  35. lineHeight: `${menuItemHeight}px`
  36. },
  37. [`${componentCls}-item-group-list ${componentCls}-submenu-title,
  38. ${componentCls}-submenu-title`]: {
  39. paddingInlineEnd: paddingWithArrow
  40. }
  41. };
  42. };
  43. const getVerticalStyle = token => {
  44. const {
  45. componentCls,
  46. iconCls,
  47. menuItemHeight,
  48. colorTextLightSolid,
  49. dropdownWidth,
  50. controlHeightLG,
  51. motionDurationMid,
  52. motionEaseOut,
  53. paddingXL,
  54. fontSizeSM,
  55. fontSizeLG,
  56. motionDurationSlow,
  57. paddingXS,
  58. boxShadowSecondary
  59. } = token;
  60. const inlineItemStyle = {
  61. height: menuItemHeight,
  62. lineHeight: `${menuItemHeight}px`,
  63. listStylePosition: 'inside',
  64. listStyleType: 'disc'
  65. };
  66. return [{
  67. [componentCls]: {
  68. [`&-inline, &-vertical`]: _extends({
  69. [`&${componentCls}-root`]: {
  70. boxShadow: 'none'
  71. }
  72. }, getVerticalInlineStyle(token))
  73. },
  74. [`${componentCls}-submenu-popup`]: {
  75. [`${componentCls}-vertical`]: _extends(_extends({}, getVerticalInlineStyle(token)), {
  76. boxShadow: boxShadowSecondary
  77. })
  78. }
  79. },
  80. // Vertical only
  81. {
  82. [`${componentCls}-submenu-popup ${componentCls}-vertical${componentCls}-sub`]: {
  83. minWidth: dropdownWidth,
  84. maxHeight: `calc(100vh - ${controlHeightLG * 2.5}px)`,
  85. padding: '0',
  86. overflow: 'hidden',
  87. borderInlineEnd: 0,
  88. // https://github.com/ant-design/ant-design/issues/22244
  89. // https://github.com/ant-design/ant-design/issues/26812
  90. "&:not([class*='-active'])": {
  91. overflowX: 'hidden',
  92. overflowY: 'auto'
  93. }
  94. }
  95. },
  96. // Inline Only
  97. {
  98. [`${componentCls}-inline`]: {
  99. width: '100%',
  100. // Motion enhance for first level
  101. [`&${componentCls}-root`]: {
  102. [`${componentCls}-item, ${componentCls}-submenu-title`]: {
  103. display: 'flex',
  104. alignItems: 'center',
  105. transition: [`border-color ${motionDurationSlow}`, `background ${motionDurationSlow}`, `padding ${motionDurationMid} ${motionEaseOut}`].join(','),
  106. [`> ${componentCls}-title-content`]: {
  107. flex: 'auto',
  108. minWidth: 0,
  109. overflow: 'hidden',
  110. textOverflow: 'ellipsis'
  111. },
  112. '> *': {
  113. flex: 'none'
  114. }
  115. }
  116. },
  117. // >>>>> Sub
  118. [`${componentCls}-sub${componentCls}-inline`]: {
  119. padding: 0,
  120. border: 0,
  121. borderRadius: 0,
  122. boxShadow: 'none',
  123. [`& > ${componentCls}-submenu > ${componentCls}-submenu-title`]: inlineItemStyle,
  124. [`& ${componentCls}-item-group-title`]: {
  125. paddingInlineStart: paddingXL
  126. }
  127. },
  128. // >>>>> Item
  129. [`${componentCls}-item`]: inlineItemStyle
  130. }
  131. },
  132. // Inline Collapse Only
  133. {
  134. [`${componentCls}-inline-collapsed`]: {
  135. width: menuItemHeight * 2,
  136. [`&${componentCls}-root`]: {
  137. [`${componentCls}-item, ${componentCls}-submenu ${componentCls}-submenu-title`]: {
  138. [`> ${componentCls}-inline-collapsed-noicon`]: {
  139. fontSize: fontSizeLG,
  140. textAlign: 'center'
  141. }
  142. }
  143. },
  144. [`> ${componentCls}-item,
  145. > ${componentCls}-item-group > ${componentCls}-item-group-list > ${componentCls}-item,
  146. > ${componentCls}-item-group > ${componentCls}-item-group-list > ${componentCls}-submenu > ${componentCls}-submenu-title,
  147. > ${componentCls}-submenu > ${componentCls}-submenu-title`]: {
  148. insetInlineStart: 0,
  149. paddingInline: `calc(50% - ${fontSizeSM}px)`,
  150. textOverflow: 'clip',
  151. [`
  152. ${componentCls}-submenu-arrow,
  153. ${componentCls}-submenu-expand-icon
  154. `]: {
  155. opacity: 0
  156. },
  157. [`${componentCls}-item-icon, ${iconCls}`]: {
  158. margin: 0,
  159. fontSize: fontSizeLG,
  160. lineHeight: `${menuItemHeight}px`,
  161. '+ span': {
  162. display: 'inline-block',
  163. opacity: 0
  164. }
  165. }
  166. },
  167. [`${componentCls}-item-icon, ${iconCls}`]: {
  168. display: 'inline-block'
  169. },
  170. '&-tooltip': {
  171. pointerEvents: 'none',
  172. [`${componentCls}-item-icon, ${iconCls}`]: {
  173. display: 'none'
  174. },
  175. 'a, a:hover': {
  176. color: colorTextLightSolid
  177. }
  178. },
  179. [`${componentCls}-item-group-title`]: _extends(_extends({}, textEllipsis), {
  180. paddingInline: paddingXS
  181. })
  182. }
  183. }];
  184. };
  185. export default getVerticalStyle;