<template>
  <div
    class="flex middle-xs center-xs center-middle-fixed full-width full-height"
    :class="[{'overlay-black-6': overlay}]"
    style="z-index:1000">

    <div
      :class="[`vue-modal-${size}`, {'full-height': fullHeight}]"
      class="flex flex-column flex-nowrap background-white shadow-large full-width hidden-overflow border-radius-small">
      <header v-if="$slots.header || title" class="full-width header-modal">
        <slot name="header">
          <div v-if="title && size !== 'small'" class="flex flex-row flex-nowrap middle-xs full-width text-center">
            <div v-if="$slots.aside">
              <base-button
                size="large"
                square
                apperance="white"
                @click.native="onClickAside">
                <template #icon>
                  <i class="fas fa-bars"></i>
                </template>
              </base-button>
            </div>
            <span
              class="flex-1 text-medium text-dark text-bold text-ellipsis vertical-padding-medium right-padding-medium title-modal"
              :class="[{'left-padding-medium': !$slots.aside}]">
              {{title}}
            </span>
            <div class="close">
              <button
                class="background-white text-dark"
                @click="$emit('close')">
                  <i class="fas fa-times" />
              </button>
            </div>
          </div>

          <div v-if="title && size === 'small'" class="flex flex-row flex-nowrap between-xs middle-xs horizontal-padding-medium top-padding-medium">
            <span class="text-medium text-dark text-bold text-ellipsis title-modal">{{title}}</span>
            <div class="close">
              <button
                class="background-white text-dark"
                @click="$emit('close')">
                  <i class="fas fa-times" />
              </button>
            </div>
          </div>
        </slot>
      </header>

      <div v-if="$slots.default" class="flex flex-row flex-nowrap flex-1 full-width auto-overflow rel">
        <aside
          v-if="$slots.aside"
          v-show="showAside"
          class="flex flex-column flex-nowrap flex-start background-white right-border-gray"
        >
          <div v-if="$slots.asideHeader" class="full-width">
            <slot name="asideHeader"></slot>
          </div>
          <div class="flex-1 full-width auto-overflow">
            <slot name="aside"></slot>
          </div>
          <div v-if="$slots.asideFooter" class="full-width">
            <slot name="asideFooter"></slot>
          </div>
        </aside>

        <div class="flex-1 full-width" :class="{'hidden-overflow': !slotDefaultOverflowAuto}">
          <slot></slot>
        </div>
      </div>

      <footer v-if="$slots.footer" class="full-width">
        <slot name="footer"></slot>
      </footer>
    </div>

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

<style src="../../identity.css"></style>
<style scoped src="./styles.css" /></style>

<script src="./scripts.js"></script>