<template>
  <header class="header">
    <div
      :class="{
        'container': boxed,
        'header__container': boxed,
        'container-fluid': !boxed,
        'header__container-fluid': !boxed,
      }"
    >
      <div class="row header__row">
        <section class="col-6 header__button-box">
          <button
            class="menu-toggle"
            :class="{ 'menu-toggle--open': value }"
            @click.stop.prevent="$emit('input', !value)"
            :aria-pressed="value"
            :aria-expanded="value"
          >
            <div class="menu-toggle__line"></div>
            <div class="menu-toggle__line"></div>
            <div class="menu-toggle__line"></div>
          </button>
          <transition name="fade">
            <nav class="navigation" v-if="value">
              <div class="container navigation__container">
                <div class="row navigation__row">
                  <header class="col-12 navigation__header">
                    <h1 class="navigation__title">
                      <slot name="title"></slot>
                    </h1>
                  </header>
                </div>
                <ul class="col-12 navigation__list">
                  <slot name="links"></slot>
                </ul>
              </div>
            </nav>
          </transition>
        </section>
        <section class="col-6 header__avatar">
          <slot name="avatar"></slot>
        </section>
      </div>
    </div>
  </header>
</template>

<script>
export default {
  name: 'navigation',
  props: {
    value: {
      type: Boolean,
      required: true,
    },
    boxed: {
      type: Boolean,
      required: false,
      default: false,
    }
  },
}
</script>

<style lang="scss" scoped>
.header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: z-index(navigation);
  width: 100%;
  width: 100vw;
  &__container, &__container-fluid {
    background-color: $white;
    box-shadow: box-shadow(tertiary);
  }
  &__row {
    height: 80px;
    height: 8rem;
  }
  &__button-box {
    display: flex;
    align-items: center;
  }
  &__avatar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
}
.menu-toggle {
  position: relative;
  height: 16px;
  height: 1.6rem;
  width: 25px;
  width: 2.5rem;
  perspective: 800px;
  z-index: z-index(modal);
  &__line {
    position: absolute;
    height: 2px;
    background-color: $black;
    width: 17px;
    width: 1.7rem;
    opacity: 1;
    transition: all transition(fast);
    &:not(:last-child) {
      width: 25px;
      width: 2.5rem;
    }
    &:first-child {
      top: 0;
    }
    &:nth-child(2) {
      top: 7px;
    }
    &:last-child {
      top: 14px;
    }
  }
  &--open {
    .menu-toggle__line {
      &:first-child {
        top: 7px;
        transform: rotate3d(0, 0, 1, 45deg);
      }
      &:nth-child(2) {
        top: 7px;
        opacity: 0;
      }
      &:last-child {
        top: 7px;
        width: 15px;
        width: 2.5rem;
        transform: rotate3d(0, 0, 1, -45deg);
      }
    }
  }
}
.navigation {
  position: fixed;
  z-index: z-index(navigation);
  top: 0;
  left: 0;
  background-color: $white;
  width: 100%;
  width: 100vw;
  height: 100%;
  height: 100vh;
  padding: 100px 0px 100px 0px;
  padding: 10rem 0rem 10rem 0rem;
  &__title {
    @include body-small;
    margin-bottom: 50px;
    margin-bottom: 5rem;
    svg {
      margin-right: 1.5rem;
    }
  }
  &__list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
    perspective: 800px;
  }
  &__link {
    position: relative;
    display: block;
    transition: all transition(fast);
    &:hover, &:focus {
      transform: translate3d(5px, 0, 0);
      transform: translate3d(.5rem, 0, 0);
      color: $color-primary;
    }
  }
}
</style>

