<template>
<Teleport to="body">
<Transition name="modal">
<div v-if="src" class="modal a-show" @click.self="close">
<div class="modal-backdrop" @click="close" />
<div class="modal-panel lightbox-panel" role="dialog" aria-modal="true">
<header class="modal-header">
<h4 class="modal-title">Photo</h4>
<button class="btn-icon modal-close" type="button" aria-label="Close" @click="close">✕</button>
</header>
<div class="modal-body lightbox-body">
<img :src="src" class="lightbox-img" />
</div>
</div>
</div>
</Transition>
</Teleport>
</template>
<script setup>
import { watch, onUnmounted } from 'vue'
import { useLightbox } from '@/composables/useLightbox.js'
const { src, close } = useLightbox()
watch(src, (val) => {
document.body.style.overflow = val ? 'hidden' : ''
})
onUnmounted(() => {
document.body.style.overflow = ''
})
</script>
<style scoped>
.lightbox-panel {
max-width: 90vw;
min-height: unset;
width: fit-content;
cursor: default;
}
.lightbox-body {
display: flex;
align-items: center;
justify-content: center;
padding: 0;
max-height: calc(90vh - 60px);
overflow: hidden;
}
.lightbox-img {
display: block;
max-width: 100%;
max-height: calc(90vh - 60px);
object-fit: contain;
}
</style>