summaryrefslogblamecommitdiff
path: root/iridescence/src/components/ProductDetail.vue
blob: 9802d84f3deca06c3ff44e6ad85a74aff9a57c57 (plain) (tree)
1
2
3
4
5
6
7
8
9

                          

                                                                 




                                                  




                                            






                                    
                                  







                                                 
                                       



                  
                                                                     






                        
             




                                                        
             
                                       

                               
                                                             


               
                                                          

            


                                                                            

                







                                                                                



         
<template>
  <div id="productDetail">
    <div v-if="product" class="modal is-active">
      <div @click="clearDetailId" class="modal-background"></div>
      <div class="modal-content">
        <div class="card">
          <div class="card-image">
            <figure class="image ">
              <a target="_blank" :href="fullsize">
                <img
                  :src="base"
                  :alt="product.name"
                  title="Click for fullsize"
                />
              </a>
            </figure>
          </div>

          <div class="card-content">
            <div class="content">
              <p class="title">
                {{ product.name }}
              </p>
              <p class="subtitle">
                {{ dollars }}
              </p>
              <p class="subtitle">{{ stock }}</p>
            </div>

            <div class="content">
              {{ product.description }}
            </div>
          </div>
        </div>
      </div>
      <div @click="clearDetailId" class="modal-close is-large"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: "ProductDetail",
  computed: {
    product() {
      return this.$store.getters.products.find(
        p => p.id == this.$store.getters.productDetailId
      );
    },
    stock() {
      if (this.product.quantity == 0) {
        return "Made to order";
      } else {
        return [this.product.quantity, "in stock"].join(" ");
      }
    },
    dollars() {
      return "$ " + (this.product.cents / 100).toFixed(2);
    },
    base() {
      return [process.env.VUE_APP_IMAGE_ROOT, this.product.photo_base].join(
        "/"
      );
    },
    fullsize() {
      return [process.env.VUE_APP_IMAGE_ROOT, this.product.photo_fullsize].join(
        "/"
      );
    }
  },
  methods: {
    clearDetailId() {
      this.$store.commit("productDetailId", 0);
    }
  }
};
</script>