feat: render product images with hover-zoom in ProductCard

This commit is contained in:
belviskhoremk
2026-08-03 22:53:28 +00:00
parent 12beaa990e
commit 8be76f77a4
3 changed files with 15 additions and 0 deletions

View File

@@ -31,3 +31,16 @@
background: #b7ada3;
cursor: not-allowed;
}
.image {
width: 100%;
aspect-ratio: 4 / 3;
object-fit: cover;
border-radius: 3px;
margin-bottom: var(--space-sm);
transition: transform 0.3s ease;
}
.card:hover .image {
transform: scale(1.05);
}

View File

@@ -15,6 +15,7 @@ describe('ProductCard', () => {
render(<ProductCard product={product} onInquire={onInquire} />)
expect(screen.getByText('Silk Edge Control')).toBeInTheDocument()
expect(screen.getByText('$12')).toBeInTheDocument()
expect(screen.getByRole('img', { name: 'Silk Edge Control' })).toHaveAttribute('src', '/x.jpg')
await userEvent.click(screen.getByRole('button', { name: /ask about this/i }))
expect(onInquire).toHaveBeenCalledWith(product)
})

View File

@@ -9,6 +9,7 @@ interface ProductCardProps {
function ProductCard({ product, onInquire }: ProductCardProps) {
return (
<div className={styles.card}>
<img src={product.image} alt={product.name} className={styles.image} />
<h3>{product.name}</h3>
<p>${product.price}</p>
<p>{product.description}</p>