Skip to content

Commit 3f006cd

Browse files
committed
Use ProductImage
1 parent a0ed5b4 commit 3f006cd

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
<template>
2-
<img
3-
id="product-image"
4-
class="h-auto p-8 transition duration-500 ease-in-out transform xl:p-2 md:p-2 lg:p-2 hover:shadow-lg hover:scale-95"
5-
:alt="alt"
6-
:src="displayedImage"
7-
/>
2+
<img id="product-image"
3+
class="h-auto p-8 transition duration-500 ease-in-out transform md:p-0 hover:shadow-lg hover:scale-95" :alt="alt"
4+
:src="displayedImage" :width="width" :height="height" />
85
</template>
96

107
<script setup>
118
import { computed } from "vue";
129
1310
const props = defineProps({
14-
alt: { type: String, required: true },
15-
src: { type: String, required: true },
11+
alt: { type: String, required: true },
12+
src: { type: String, required: true },
13+
width: { type: String, required: false },
14+
height: { type: String, required: false },
1615
});
1716
1817
const config = useRuntimeConfig();
1918
2019
const displayedImage = computed(() => {
21-
return props.src || config.placeholderImage;
20+
return props.src || config.placeholderImage;
2221
});
2322
</script>

components/Products/ProductsShowAll.vue

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717
query: { id: product.databaseId },
1818
}"
1919
>
20-
<img
21-
id="product-image"
22-
class="p-8 border mx-auto w-4/5 border-gray-200 rounded drop-shadow-lg transition duration-500 ease-in-out transform cursor-pointer lg:ml-0 lg:w-full lg:p-2 hover:scale-95"
23-
:alt="product.name"
24-
:src="productImage(product)"
25-
/>
20+
<ProductImage :alt="product.name" :src="productImage(product)" />
21+
2622
<div class="flex justify-center pt-3">
2723
<p class="text-2xl font-bold text-center cursor-pointer">
2824
{{ product.name }}
@@ -69,12 +65,8 @@
6965
query: { id: product.databaseId },
7066
}"
7167
>
72-
<img
73-
id="product-image"
74-
class="p-8 border mx-auto w-4/5 border-gray-200 rounded drop-shadow-lg transition duration-500 ease-in-out transform cursor-pointer lg:ml-0 lg:w-full lg:p-2 hover:scale-95"
75-
:alt="product.name"
76-
:src="productImage(product)"
77-
/>
68+
<ProductImage :alt="product.name" :src="productImage(product)" />
69+
7870
<div class="flex justify-center pt-3">
7971
<p class="text-2xl font-bold text-center cursor-pointer">
8072
{{ product.name }}
@@ -111,6 +103,8 @@
111103
import FETCH_ALL_PRODUCTS_QUERY from "@/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql";
112104
import GET_PRODUCTS_FROM_CATEGORY_QUERY from "@/apollo/queries/GET_PRODUCTS_FROM_CATEGORY_QUERY.gql";
113105
106+
import ProductImage from "@/components/Products/ProductImage.vue";
107+
114108
import { filteredVariantPrice } from "@/utils/functions";
115109
116110
const props = defineProps({

0 commit comments

Comments
 (0)