<template>
  <transition
    name="dialog-fade"
    @after-enter="afterEnter"
    @after-leave="afterLeave"
  >
    <div
      class="el-dialog__wrapper normal-dialog"
      v-show="visible"
      @click.self="handleWrapperClick"
    >
      <div
        role="dialog"
        aria-modal="true"
        :aria-label="title || 'dialog'"
        class="el-dialog"
        :class="[{ 'is-fullscreen': fullscreen, 'el-dialog--center': center }, customClass]"
        ref="dialog"
        :style="style"
      >
        <div class="el-dialog__header">
          <div class="el-dialog__title">
            <slot name="title">
              <span class="el-dialog__title">{{ title }}</span>
            </slot>
          </div>
          <button
            type="button"
            class="el-dialog__headerbtn"
            aria-label="Close"
            v-if="showClose"
            @click="handleClose"
          >
            <img
              src="@/assets/images/dialog/close_icon.png"
              alt=""
            >
          </button>
        </div>
        <div
          class="el-dialog__body clearfix"
          v-if="rendered"
        >
          <slot></slot>
        </div>
        <div
          class="el-dialog__footer"
          v-if="$slots.footer"
        >
          <slot name="footer"></slot>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
import { Dialog } from 'element-ui';

export default {
  name: 'normal-dialog',
  extends: Dialog,
};
</script>

<style lang="scss">
@import '../../assets/styles/variables.scss';

.el-dialog__wrapper {
  .el-dialog__header {
    box-sizing: border-box;
    position: relative;
    height: 38px;
    background-color: #4e82fb;
    padding: 10px;
    .el-dialog__title {
      margin: 0px auto 0;
      display: flex;
      justify-content: center;
      align-items: center;
      color: #fff;
      line-height: 18px;
      vertical-align: top;
      font-size: 14px;
      img {
        width: 16px;
        height: 16px;
        margin-right: 20px;
      }
    }
  }
  .el-dialog__headerbtn {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 39px;
    height: 39px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .el-dialog__body {
    padding: 20px 40px;
  }
  .el-dialog__footer {
    box-sizing: content-box;
    height: 40px;
    padding: 25px 10px 20px;
    text-align: center;
  }
}
@media screen and (min-width: $bigScreenWidth) {
  .el-dialog__wrapper {
    .el-dialog__header {
      height: 96px;
      padding: 20px 20px 10px;

      .el-dialog__title {
        margin: 14px auto 0;
        font-size: 22px;
        img {
          width: 28px;
          height: 28px;
          margin-right: 20px;
        }
      }
    }
    .el-dialog__headerbtn {
      top: -30px;
      right: -30px;
      width: 65px;
      height: 65px;
    }
    .el-dialog__body {
      padding: 30px 40px;
    }
    .el-dialog__footer {
      padding: 50px 20px 40px;
    }
  }
}
</style>
