db-popup.vue 822 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <view v-if="show" class="db-popup-mask" @click="onMask">
  3. <view class="db-popup-panel" :style="panelStyle" @click.stop>
  4. <slot />
  5. </view>
  6. </view>
  7. </template>
  8. <script setup>
  9. import { computed } from 'vue'
  10. const props = defineProps({
  11. show: Boolean,
  12. height: { type: String, default: '70vh' }
  13. })
  14. const emit = defineEmits(['close', 'update:show'])
  15. const panelStyle = computed(() => ({
  16. maxHeight: props.height,
  17. height: props.height
  18. }))
  19. function onMask() {
  20. emit('update:show', false)
  21. emit('close')
  22. }
  23. </script>
  24. <style scoped>
  25. .db-popup-mask {
  26. position: fixed;
  27. inset: 0;
  28. background: rgba(0, 0, 0, 0.55);
  29. z-index: 1000;
  30. display: flex;
  31. align-items: flex-end;
  32. }
  33. .db-popup-panel {
  34. width: 100%;
  35. background: #fff;
  36. border-radius: 16px 16px 0 0;
  37. overflow: hidden;
  38. }
  39. </style>