index.less 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. @import '../../style/themes/index';
  2. @import '../../style/mixins/index';
  3. @import './status';
  4. @dropdown-prefix-cls: ~'@{ant-prefix}-dropdown';
  5. .@{dropdown-prefix-cls} {
  6. .reset-component();
  7. position: absolute;
  8. top: -9999px;
  9. left: -9999px;
  10. z-index: @zindex-dropdown;
  11. display: block;
  12. &::before {
  13. position: absolute;
  14. top: -@popover-distance + @popover-arrow-width;
  15. right: 0;
  16. bottom: -@popover-distance + @popover-arrow-width;
  17. left: -7px;
  18. z-index: -9999;
  19. opacity: 0.0001;
  20. content: ' ';
  21. }
  22. &-wrap {
  23. position: relative;
  24. .@{ant-prefix}-btn > .@{iconfont-css-prefix}-down {
  25. font-size: 10px;
  26. }
  27. .@{iconfont-css-prefix}-down::before {
  28. transition: transform @animation-duration-base;
  29. }
  30. }
  31. &-wrap-open {
  32. .@{iconfont-css-prefix}-down::before {
  33. transform: rotate(180deg);
  34. }
  35. }
  36. &-hidden,
  37. &-menu-hidden,
  38. &-menu-submenu-hidden {
  39. display: none;
  40. }
  41. // Offset the popover to account for the dropdown arrow
  42. &-show-arrow&-placement-topLeft,
  43. &-show-arrow&-placement-top,
  44. &-show-arrow&-placement-topRight {
  45. padding-bottom: @popover-distance;
  46. }
  47. &-show-arrow&-placement-bottomLeft,
  48. &-show-arrow&-placement-bottom,
  49. &-show-arrow&-placement-bottomRight {
  50. padding-top: @popover-distance;
  51. }
  52. // Arrows
  53. // .popover-arrow is outer, .popover-arrow:after is inner
  54. &-arrow {
  55. position: absolute;
  56. z-index: 1; // lift it up so the menu wouldn't cask shadow on it
  57. display: block;
  58. width: @popover-arrow-width;
  59. height: @popover-arrow-width;
  60. .roundedArrow(@popover-arrow-width, 5px, @popover-bg);
  61. }
  62. &-placement-top > &-arrow,
  63. &-placement-topLeft > &-arrow,
  64. &-placement-topRight > &-arrow {
  65. bottom: @popover-arrow-width * sqrt((1 / 2)) + 2px;
  66. box-shadow: 3px 3px 7px -3px fade(@black, 10%);
  67. transform: rotate(45deg);
  68. }
  69. &-placement-top > &-arrow {
  70. left: 50%;
  71. transform: translateX(-50%) rotate(45deg);
  72. }
  73. &-placement-topLeft > &-arrow {
  74. left: 16px;
  75. }
  76. &-placement-topRight > &-arrow {
  77. right: 16px;
  78. }
  79. &-placement-bottom > &-arrow,
  80. &-placement-bottomLeft > &-arrow,
  81. &-placement-bottomRight > &-arrow {
  82. top: (@popover-arrow-width + 2px) * sqrt((1 / 2));
  83. box-shadow: 2px 2px 5px -2px fade(@black, 10%);
  84. transform: rotate(-135deg) translateY(-0.5px);
  85. }
  86. &-placement-bottom > &-arrow {
  87. left: 50%;
  88. transform: translateX(-50%) rotate(-135deg) translateY(-0.5px);
  89. }
  90. &-placement-bottomLeft > &-arrow {
  91. left: 16px;
  92. }
  93. &-placement-bottomRight > &-arrow {
  94. right: 16px;
  95. }
  96. &-menu {
  97. position: relative;
  98. margin: 0;
  99. padding: @dropdown-edge-child-vertical-padding 0;
  100. text-align: left;
  101. list-style-type: none;
  102. background-color: @dropdown-menu-bg;
  103. background-clip: padding-box;
  104. border-radius: @border-radius-base;
  105. outline: none;
  106. box-shadow: @box-shadow-base;
  107. &-item-group-title {
  108. padding: 5px @control-padding-horizontal;
  109. color: @text-color-secondary;
  110. transition: all @animation-duration-slow;
  111. }
  112. &-submenu-popup {
  113. position: absolute;
  114. z-index: @zindex-dropdown;
  115. background: transparent;
  116. box-shadow: none;
  117. transform-origin: 0 0;
  118. ul,
  119. li {
  120. list-style: none;
  121. }
  122. ul {
  123. margin-right: 0.3em;
  124. margin-left: 0.3em;
  125. }
  126. }
  127. // ======================= Item Content =======================
  128. &-item {
  129. position: relative;
  130. display: flex;
  131. align-items: center;
  132. }
  133. &-item-icon {
  134. min-width: 12px;
  135. margin-right: 8px;
  136. font-size: @font-size-sm;
  137. }
  138. &-title-content {
  139. flex: auto;
  140. > a {
  141. color: inherit;
  142. transition: all @animation-duration-slow;
  143. &:hover {
  144. color: inherit;
  145. }
  146. &::after {
  147. position: absolute;
  148. top: 0;
  149. right: 0;
  150. bottom: 0;
  151. left: 0;
  152. content: '';
  153. }
  154. }
  155. }
  156. // =========================== Item ===========================
  157. &-item,
  158. &-submenu-title {
  159. clear: both;
  160. margin: 0;
  161. padding: @dropdown-vertical-padding @control-padding-horizontal;
  162. color: @text-color;
  163. font-weight: normal;
  164. font-size: @dropdown-font-size;
  165. line-height: @dropdown-line-height;
  166. cursor: pointer;
  167. transition: all @animation-duration-slow;
  168. &:first-child {
  169. & when (@dropdown-edge-child-vertical-padding = 0) {
  170. border-radius: @border-radius-base @border-radius-base 0 0;
  171. }
  172. }
  173. &:last-child {
  174. & when (@dropdown-edge-child-vertical-padding = 0) {
  175. border-radius: 0 0 @border-radius-base @border-radius-base;
  176. }
  177. }
  178. &-selected {
  179. color: @dropdown-selected-color;
  180. background-color: @dropdown-selected-bg;
  181. }
  182. &:hover,
  183. &&-active {
  184. background-color: @item-hover-bg;
  185. }
  186. &&-disabled {
  187. color: @disabled-color;
  188. cursor: not-allowed;
  189. &:hover {
  190. color: @disabled-color;
  191. background-color: @dropdown-menu-submenu-disabled-bg;
  192. cursor: not-allowed;
  193. }
  194. a {
  195. pointer-events: none;
  196. }
  197. }
  198. &-divider {
  199. height: 1px;
  200. margin: 4px 0;
  201. overflow: hidden;
  202. line-height: 0;
  203. background-color: @border-color-split;
  204. }
  205. .@{dropdown-prefix-cls}-menu-submenu-expand-icon {
  206. position: absolute;
  207. right: @padding-xs;
  208. .@{dropdown-prefix-cls}-menu-submenu-arrow-icon {
  209. margin-right: 0 !important;
  210. color: @text-color-secondary;
  211. font-size: 10px;
  212. font-style: normal;
  213. }
  214. }
  215. }
  216. &-item-group-list {
  217. margin: 0 8px;
  218. padding: 0;
  219. list-style: none;
  220. }
  221. &-submenu-title {
  222. padding-right: @control-padding-horizontal + @font-size-sm;
  223. }
  224. &-submenu-vertical {
  225. position: relative;
  226. }
  227. &-submenu-vertical > & {
  228. position: absolute;
  229. top: 0;
  230. left: 100%;
  231. min-width: 100%;
  232. margin-left: 4px;
  233. transform-origin: 0 0;
  234. }
  235. &-submenu&-submenu-disabled .@{dropdown-prefix-cls}-menu-submenu-title {
  236. &,
  237. .@{dropdown-prefix-cls}-menu-submenu-arrow-icon {
  238. color: @disabled-color;
  239. background-color: @dropdown-menu-submenu-disabled-bg;
  240. cursor: not-allowed;
  241. }
  242. }
  243. // https://github.com/ant-design/ant-design/issues/19264
  244. &-submenu-selected &-submenu-title {
  245. color: @primary-color;
  246. }
  247. }
  248. &.@{ant-prefix}-slide-down-enter.@{ant-prefix}-slide-down-enter-active&-placement-bottomLeft,
  249. &.@{ant-prefix}-slide-down-appear.@{ant-prefix}-slide-down-appear-active&-placement-bottomLeft,
  250. &.@{ant-prefix}-slide-down-enter.@{ant-prefix}-slide-down-enter-active&-placement-bottom,
  251. &.@{ant-prefix}-slide-down-appear.@{ant-prefix}-slide-down-appear-active&-placement-bottom,
  252. &.@{ant-prefix}-slide-down-enter.@{ant-prefix}-slide-down-enter-active&-placement-bottomRight,
  253. &.@{ant-prefix}-slide-down-appear.@{ant-prefix}-slide-down-appear-active&-placement-bottomRight {
  254. animation-name: antSlideUpIn;
  255. }
  256. &.@{ant-prefix}-slide-up-enter.@{ant-prefix}-slide-up-enter-active&-placement-topLeft,
  257. &.@{ant-prefix}-slide-up-appear.@{ant-prefix}-slide-up-appear-active&-placement-topLeft,
  258. &.@{ant-prefix}-slide-up-enter.@{ant-prefix}-slide-up-enter-active&-placement-top,
  259. &.@{ant-prefix}-slide-up-appear.@{ant-prefix}-slide-up-appear-active&-placement-top,
  260. &.@{ant-prefix}-slide-up-enter.@{ant-prefix}-slide-up-enter-active&-placement-topRight,
  261. &.@{ant-prefix}-slide-up-appear.@{ant-prefix}-slide-up-appear-active&-placement-topRight {
  262. animation-name: antSlideDownIn;
  263. }
  264. &.@{ant-prefix}-slide-down-leave.@{ant-prefix}-slide-down-leave-active&-placement-bottomLeft,
  265. &.@{ant-prefix}-slide-down-leave.@{ant-prefix}-slide-down-leave-active&-placement-bottom,
  266. &.@{ant-prefix}-slide-down-leave.@{ant-prefix}-slide-down-leave-active&-placement-bottomRight {
  267. animation-name: antSlideUpOut;
  268. }
  269. &.@{ant-prefix}-slide-up-leave.@{ant-prefix}-slide-up-leave-active&-placement-topLeft,
  270. &.@{ant-prefix}-slide-up-leave.@{ant-prefix}-slide-up-leave-active&-placement-top,
  271. &.@{ant-prefix}-slide-up-leave.@{ant-prefix}-slide-up-leave-active&-placement-topRight {
  272. animation-name: antSlideDownOut;
  273. }
  274. }
  275. .@{dropdown-prefix-cls}-trigger,
  276. .@{dropdown-prefix-cls}-link,
  277. .@{dropdown-prefix-cls}-button {
  278. > .@{iconfont-css-prefix}.@{iconfont-css-prefix}-down {
  279. font-size: 10px;
  280. vertical-align: baseline;
  281. }
  282. }
  283. .@{dropdown-prefix-cls}-button {
  284. white-space: nowrap;
  285. &.@{ant-prefix}-btn-group > .@{ant-prefix}-btn {
  286. &-loading,
  287. &-loading + .@{ant-prefix}-btn {
  288. cursor: default;
  289. pointer-events: none;
  290. }
  291. &-loading + .@{ant-prefix}-btn::before {
  292. display: block;
  293. }
  294. &:last-child:not(:first-child):not(.@{ant-prefix}-btn-icon-only) {
  295. padding-right: @padding-xs;
  296. padding-left: @padding-xs;
  297. }
  298. }
  299. }
  300. // https://github.com/ant-design/ant-design/issues/4903
  301. .@{dropdown-prefix-cls}-menu-dark {
  302. &,
  303. .@{dropdown-prefix-cls}-menu {
  304. background: @menu-dark-bg;
  305. }
  306. .@{dropdown-prefix-cls}-menu-item,
  307. .@{dropdown-prefix-cls}-menu-submenu-title,
  308. .@{dropdown-prefix-cls}-menu-item > a,
  309. .@{dropdown-prefix-cls}-menu-item > .@{iconfont-css-prefix} + span > a {
  310. color: @text-color-secondary-dark;
  311. .@{dropdown-prefix-cls}-menu-submenu-arrow::after {
  312. color: @text-color-secondary-dark;
  313. }
  314. &:hover {
  315. color: @text-color-inverse;
  316. background: transparent;
  317. }
  318. }
  319. .@{dropdown-prefix-cls}-menu-item-selected {
  320. &,
  321. &:hover,
  322. > a {
  323. color: @text-color-inverse;
  324. background: @primary-color;
  325. }
  326. }
  327. }
  328. @import './rtl';