All files / components RightSide.vue

0% Statements 0/4
0% Branches 0/2
0% Functions 0/1
0% Lines 0/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                                                                                                         
<template>
  <div
    class="menu h-100vh w-100 position-fixed d-flex justify-content-end"
    :class="isOpen && 'open'"
    v-on:click.self="isOpen = false"
  >
    <Cart
      v-if="component === 'cart'"
      v-on:close="isOpen = false"
      :isOpen="isOpen"
    />
    <Search
      v-if="component === 'search'"
      v-on:close="isOpen = false"
      :isOpen="isOpen"
    />
  </div>
</template>

<script>
import Cart from "@/components/Cart";
import Search from "@/components/Search";
 
export default {
  name: "RightSide",
  components: { Cart, Search },
  data: () => ({ isOpen: false, component: "cart" }),
  created() {
    this.$nuxt.$on("rightSide", (val) => {
      this.component = val ? val : "cart";
      setTimeout(() => (this.isOpen = !this.isOpen), 0);
    });
  },
};
</script>
 
<style scoped>
.menu {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  opacity: 0;
  background: rgba(0, 0, 0, 0.9);
  transition: all 1s ease-in-out;
}
 
.menu.open {
  z-index: 5;
  opacity: 1;
}
</style>