taro-ui-vue3
Version:
Taro UI Rewritten in Vue 3.0
65 lines (64 loc) • 1.59 kB
JavaScript
import {h, defineComponent, computed, mergeProps} from "vue";
import {View} from "@tarojs/components";
const AtCurtain = defineComponent({
name: "AtCurtain",
props: {
isOpened: Boolean,
closeBtnPosition: {
type: String,
default: "bottom"
},
onClose: {
type: Function,
default: () => () => {
}
}
},
setup(props, {attrs, slots}) {
const curtainClass = computed(() => ({
"at-curtain": true,
"at-curtain--closed": !props.isOpened
}));
const btnCloseClass = computed(() => ({
"at-curtain__btn-close": true,
[`at-curtain__btn-close--${props.closeBtnPosition}`]: props.closeBtnPosition
}));
function handleClose(e) {
e.stopPropagation();
props.onClose(e);
}
return () => h(View, mergeProps(attrs, {
class: curtainClass.value,
onTap: (e) => {
e.stopPropagation();
}
}), {
default: () => [
h(View, {
class: "at-curtain__container"
}, {
default: () => [
h(View, {
class: "at-curtain__body"
}, {
default: () => {
var _a;
return [
(_a = slots.default) == null ? void 0 : _a.call(slots),
h(View, {
class: btnCloseClass.value,
onTap: handleClose.bind(this)
})
];
}
})
]
})
]
});
}
});
var curtain_default = AtCurtain;
export {
curtain_default as default
};