All files / components/nav-icons bag-icon.vue

0% Statements 0/2
100% Branches 0/0
0% Functions 0/2
0% Lines 0/2

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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75                                                                                                                                                     
<template>
  <li class="dropdown">
    <nuxt-link class="navbar-link d-flex align-items-start position-relative" :to="'/verify-cart'">
      <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="gray" class="bi bi-bag icon"
           viewBox="0 0 16 16" aria-labelledby="bagIcon">
        <title id="bagIcon">Shopping cart icon</title>
        <path
          d="M8 1a2.5 2.5 0 0 1 2.5 2.5V4h-5v-.5A2.5 2.5 0 0 1 8 1zm3.5 3v-.5a3.5 3.5 0 1 0-7 0V4H1v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4h-3.5zM2 5h12v9a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5z"/>
      </svg>
      <span class="d-inline-flex justify-content-center text-center position-absolute">{{ this.cartItemsLength }}</span>
    </nuxt-link>
  </li>
</template>
 
<script>
import {mapGetters} from 'vuex';
 
export default {
  computed: {
    ...mapGetters(['cartItems']),
    /**
     * Get how many items are in the cart
     * @see cartItemsLength
     * @returns number
     */
    cartItemsLength() {
      return this.cartItems.reduce((total, curr) => total + curr.cantitate, 0);
    }
  }
}
</script>
 
<style lang="scss" scoped>
span {
  width: 0.8rem;
  height: 0.8rem;
  background-color: rgb(154, 117, 63);
  border-radius: 100%;
  color: white;
  text-decoration: none;
  bottom: -0.2rem;
  font-size: 0.6rem;
  right: -0.2rem;
}
 
@include media-breakpoint-down(lg) {
  span {
    width: 1rem;
    height: 1rem;
    font-size: .8rem;
    right: 0;
  }
}
 
@include media-breakpoint-down(sm) {
  span {
    width: .7rem;
    height: .7rem;
    font-size: .5rem;
    right: 0;
  }
}
 
@media screen and #{$ipad-pro-landscape-breakpoint},
screen and #{$ipad-pro-portrait-breakpoint},
screen and #{$ipad-landscape-breakpoint} {
  span {
    width: 1.6rem;
    height: 1.6rem;
    font-size: 1.1rem;
    right: 0;
  }
}
</style>