Skip to content

Commit 2170b16

Browse files
committed
Hover animation
1 parent 779db89 commit 2170b16

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/components/Product/SingleProduct.component.tsx

+18-14
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const SingleProduct = ({ product }: IProductRootObject) => {
4242
if (process.browser) {
4343
DESCRIPTION_WITHOUT_HTML = new DOMParser().parseFromString(
4444
description,
45-
'text/html'
45+
'text/html',
4646
).body.textContent;
4747
}
4848

@@ -58,17 +58,19 @@ const SingleProduct = ({ product }: IProductRootObject) => {
5858
<div className="container mx-auto px-4 py-8">
5959
<div className="flex flex-col md:grid md:grid-cols-2 md:gap-8">
6060
{/* Image Container */}
61-
<div className="mb-6 md:mb-0">
62-
<img
63-
id="product-image"
64-
src={
65-
image?.sourceUrl ||
66-
process.env.NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL ||
67-
placeholderFallBack
68-
}
69-
alt={name}
70-
className="w-full h-auto object-cover transition duration-500 ease-in-out transform md:hover:scale-105"
71-
/>
61+
<div className="mb-6 md:mb-0 group">
62+
<div className="max-w-xl mx-auto aspect-[3/4] relative overflow-hidden bg-gray-100">
63+
<img
64+
id="product-image"
65+
src={
66+
image?.sourceUrl ||
67+
process.env.NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL ||
68+
placeholderFallBack
69+
}
70+
alt={name}
71+
className="w-full h-full object-cover object-center transition duration-300 group-hover:scale-105"
72+
/>
73+
</div>
7274
</div>
7375

7476
{/* Product Details Container */}
@@ -126,14 +128,16 @@ const SingleProduct = ({ product }: IProductRootObject) => {
126128
id="variant"
127129
name="variant"
128130
className="w-full px-4 py-2 bg-white border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
129-
onChange={(e) => setSelectedVariation(Number(e.target.value))}
131+
onChange={(e) =>
132+
setSelectedVariation(Number(e.target.value))
133+
}
130134
>
131135
{product.variations.nodes.map(
132136
({ id, name, databaseId, stockQuantity }) => (
133137
<option key={id} value={databaseId}>
134138
{name.split('- ').pop()} - ({stockQuantity} på lager)
135139
</option>
136-
)
140+
),
137141
)}
138142
</select>
139143
</div>

0 commit comments

Comments
 (0)