UNPKG

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