<template>
  <transition name="modal">
    <div class="modal-mask">
      <div class="modal-wrapper">
        <div class="modal-container">
          <div
            v-if="icon"
            class="modal-icon"
          />
          <div class="modal-header">
            <slot name="header" />
          </div>
          <div class="modal-body">
            <slot name="body" />
          </div>
          <div class="modal-footer">
            <slot name="footer" />
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>
<script>
export default {
  name: 'CuModal',
  props: {
    'icon': {
      type: Boolean,
      default: false
    }
  }
}
</script>
<style lang="scss" scoped>
@import "../styles/colors.scss";

.modal-mask {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, .3);
  display: table;
  transition: opacity .1s ease-out;
}

.modal-wrapper {
  display: table-cell;
  vertical-align: middle;
}

.modal-container {
  width: 80%;
  max-width: 740px;
  margin: 0px auto;
  padding: 24px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
  transition: all .1s ease-out;
}

.modal-icon {
  height: 4rem;
  background-image: url("../assets/icon-check.svg");
  background-size: 4rem 4rem;
  background-position: center center;
  background-repeat: no-repeat;
  margin-bottom: 16px;
  transition: all .1s ease-out;
}

.modal-header h3 {
  margin-top: 0;
  color: $black;
  text-align: center;
  font-size: 1.6rem;
}

.modal-body {
  margin: 24px 0;
  text-align: center;
  font-size: 1.6rem;
}

.modal-footer {
  text-align: center;
  display: flex;
  justify-content: space-between;

  button:nth-child(2) {
    margin-left: 8px;
  }
}

.modal-enter {
  opacity: 0;
}

.modal-leave-active {
  opacity: 0;
}

.modal-enter .modal-container,
.modal-leave-active .modal-container {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}

hr {
  border: 0;
  border-top: 1px solid $border-gray;
  margin: 24px 0;
}

.cancel {
  background-color: $gray;
}

.ok {
  background-color: $carrot;
}
</style>
