<template>
	<view class="u-drawer " :class="visible ? 'u-drawer-open' : ''">
		<view class="u-drawer-mask" @click="cancel"/>
		<view class="u-drawer-content" >
			<view class="header u-flex">
				<view class="cancel" @click="cancel">取消</view>
				<view v-if="title" class="title">{{title}}</view>
				<view class="u-button" @click="sumbit">完成</view>
			</view>
			 <slot></slot>
		</view>
	</view>
</template>

<script>
	export default {
		name: "u-drawer",
		props: {
			visible: {
				type: Boolean,
				default: false
			},
			title: {
				type: String,
				default: ''
			},
			
		},
		methods: {
			test(e) {
				console.log(e)
			},
			cancel() {
				this.$emit('update:visible', false)
			},
			sumbit() {
				this.$emit('sumbit')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.u-drawer>* {
		transition: transform .3s cubic-bezier(.7, .3, .1, 1), box-shadow .3s cubic-bezier(.7, .3, .1, 1);
	}

	.u-drawer {
		position: fixed;
		z-index: 1000;

		left: 0;
		bottom: 0;
		width: 100%;
		height: 0%;
	}

	.u-drawer-mask {
		position: absolute;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		background-color: rgba(0, 0, 0, .45);
		display: none;
		// pointer-events: none;
	}
	.u-drawer-open {
		height: 100%;
	
		.u-drawer-content,
		.u-drawer-mask {
			display: inherit;
			transform: translateY(0);
		}
	}
	

	.u-drawer-content {
		position: absolute;
		width: 100%;
		bottom: 0;
		// box-shadow: 0 -2px 8px rgb(0 0 0 / 15%);
		padding: 28rpx 32rpx;
		min-height: 100rpx;
		background: #FFFFFF;
		border-radius: 28rpx 28rpx 0px 0px;
		// display: none;
		transform: translateY(1000%);
		// animation: mymove 0.3s;
		// animation-iteration-count: 1;
		
		.header {
			margin-bottom: 50rpx;
		
			.title {
				font-size: 36rpx;
				font-weight: bold;
				color: #333333;
			}
		
			.cancel {
				min-width: 150rpx;
				padding: 12rpx 0;
				font-size: 28rpx;
				font-weight: 400;
				color: #333333;
				cursor: pointer;
			}
		}
	}



</style>
