<template>
  <transition name="slide">
    <div
      v-click-outside="close"
      class="navigation-sidebar"
      v-if="sidebar.navigation"
    >
      <content-navigation
        :is-sidebar="true"
        class="navigation-sidebar__main"/>
      <div
        class="navigation-sidebar__close-button"
        @click="close">
        <cross class="navigation-sidebar__close-icon"/>
      </div>
    </div>
  </transition>
</template>

<script>
  import Cross from '@/components/icons/Cross';
  import ContentNavigation from '@/components/book-navigation/ContentNavigation';

  import sidebarMixin from '@/mixins/sidebar';

  import {meQuery} from '@/graphql/queries';

  export default {
    mixins: [sidebarMixin],

    components: {
      ContentNavigation,
      Cross
    },

    data() {
      return {
        me: {}
      };
    },

    methods: {
      close() {
        this.closeSidebar('navigation');
      }
    },

    apollo: {
      me: meQuery
    },
  };
</script>

<style scoped lang="scss">
  @import "@/styles/_variables.scss";
  @import "@/styles/_mixins.scss";

  $desktop-width: 285px;

  .navigation-sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    background-color: white;
    z-index: 20;

    @include desktop {
      box-shadow: 0px 2px 9px rgba(0, 0, 0, 0.12);
    }

    display: grid;

    grid-template-columns: 1fr 50px;
    grid-template-rows: 50px max-content auto 100px;

    grid-template-areas: "m m" "m m" "s s" "s s";

    &--with-subnavigation {
      grid-template-areas: "m m" "m m" "sub sub" "s s";
    }

    height: 100vh;
    overflow-y: auto;

    @include desktop {
      width: $desktop-width;
    }

    &__main {
      padding: $medium-spacing;
      grid-area: m;
    }

    &__main-link {
    }

    &__close-button {
      grid-row: 1;
      grid-column: 2;
      align-self: center;
      justify-self: center;
      cursor: pointer;
    }
  }

  .slide {
    &-enter-active, &-leave-active {
      transition: left 0.2s;
    }

    &-enter, &-leave-to {
      left: -100vw;
      @include desktop {
        left: -$desktop-width;
      }
    }
  }
</style>
