<template>
  <header class="boxed-header">
    <div class="container boxed-header__container">
      <div class="row boxed-header__row">
        <section class="col-6 boxed-header__button-box">
          <button
            class="menu-toggle"
            :class="{ 'menu-toggle--open': menuOpen }"
            @click.stop.prevent="toggleMenu"
            :aria-pressed="menuOpen"
            :aria-expanded="menuOpen"
          >
            <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="menuOpen">
              <div class="container navigation__container">
                <div class="row navigation__row">
                  <header class="col-12 navigation__header">
                    <h1 class="navigation__title">
                      <eli5-black></eli5-black>
                      Design system
                    </h1>
                  </header>
                </div>
                <ul class="col-12 navigation__list">
                  <li class="navigation__item"><router-link class="navigation__link" :to="{ name: 'basic' }">Basics</router-link></li>
                  <li class="navigation__item"><router-link class="navigation__link" :to="{ name: 'buttons' }">Buttons</router-link></li>
                  <li class="navigation__item"><router-link class="navigation__link" :to="{ name: 'elements' }">Elements</router-link></li>
                  <li class="navigation__item"><router-link class="navigation__link" :to="{ name: 'cards' }">Cards</router-link></li>
                  <li class="navigation__item"><router-link class="navigation__link" :to="{ name: 'components' }">Components</router-link></li>
                  <li class="navigation__item"><router-link class="navigation__link" :to="{ name: 'icons' }">Icons</router-link></li>
                </ul>
              </div>
            </nav>
          </transition>
        </section>
        <section class="col-6 boxed-header__logo-box">
          <h1 class="boxed-header__title">
            <eli5-black></eli5-black>
            Design system
          </h1>
        </section>
      </div>
    </div>
  </header>
</template>

<script>
import { mapActions, mapGetters } from 'vuex';

export default {
  name: 'boxed-navigation',
  components: {
    Eli5Black: () => import('@/components/logos/Eli5Black.vue'),
  },
  computed: {
    ...mapGetters(['menuOpen']),
  },
  methods: {
    ...mapActions(['toggleMenu']),
  }
}
</script>

<style lang="scss" scoped>
.boxed-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: z-index(navigation);
  background-color: $white;
  width: 100%;
  width: 100vw;
  box-shadow: box-shadow(tertiary);
  &__row {
    height: 80px;
    height: 8rem;
  }
  &__button-box {
    display: flex;
    align-items: center;
  }
  &__logo-box {
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
  &__title {
    @include body-small;
    svg {
      margin-right: 1.5rem;
    }
  }
}
.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>


