style(DropdownMenu): add box-shadow style

This commit is contained in:
chenjiahan
2020-04-19 15:37:50 +08:00
parent 2364c4f526
commit 7db7449095
5 changed files with 145 additions and 73 deletions

View File

@@ -1,6 +1,5 @@
// Utils
import { createNamespace } from '../utils';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { createNamespace, isDef } from '../utils';
import { getScroller } from '../utils/dom/scroll';
// Mixins
@@ -49,15 +48,27 @@ export default createComponent({
scroller() {
return getScroller(this.$el);
},
opened() {
return this.children.some((item) => item.showWrapper);
},
barStyle() {
if (this.opened && isDef(this.zIndex)) {
return {
zIndex: 1 + this.zIndex,
};
}
},
},
methods: {
updateOffset() {
if (!this.$refs.menu) {
if (!this.$refs.bar) {
return;
}
const rect = this.$refs.menu.getBoundingClientRect();
const rect = this.$refs.bar.getBoundingClientRect();
if (this.direction === 'down') {
this.offset = rect.bottom;
@@ -113,8 +124,14 @@ export default createComponent({
));
return (
<div ref="menu" class={[bem(), BORDER_TOP_BOTTOM]}>
{Titles}
<div class={bem()}>
<div
ref="bar"
style={this.barStyle}
class={bem('bar', { opened: this.opened })}
>
{Titles}
</div>
{this.slots('default')}
</div>
);