<template>
  <div v-if="show" class="dialog">
    <div class="dialog-container">
      <div class="close" v-if="close"><Close @click="closeDialog" /></div>
      <header>
        <slot name="header"></slot>
      </header>

      <main>
        <slot></slot>
      </main>

      <footer>
        <slot name="footer"></slot>
      </footer>
    </div>
  </div>
</template>

<script setup>
import { useViewerStore } from '@/stores/modules/viewer'

const { show, dialogName, close } = defineProps(['show', 'dialogName', 'close'])

const useViewer = useViewerStore()

const closeDialog = () => {
  useViewer.closeElement(dialogName)
}
</script>

<style lang="scss">
.dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 72;
}

.dialog-container {
  background-color: var(--c-header-bg);
  padding: 20px;
  margin: 0 10px;
  border-radius: 4px;
  .close {
    margin-top: -6px;
    margin-bottom: 2px;
    text-align: right;
    line-height: 0;
    font-size: 0;
    svg {
      cursor: pointer;
    }
  }
  header {
    font-family: Helvetica;
    font-size: 16px;
    font-weight: 700;
    line-height: 24px;
  }
  main {
    margin-top: 8px;
    margin-bottom: 16px;
  }
  footer {
    display: flex;
    justify-content: flex-end;
    .rect-button {
      width: 120px;
      height: 40px;
    }
  }
}
</style>
