Hi @devtorrescarlos!
The developed solution looks good! Below are a few suggestions for improvement:
1) "Add to Cart" Button Not Fully Clickable
Currently, the button structure is as follows:
<>
<img src="/images/icon-add-to-cart.svg" alt="cart-icon" />
<button className="..." onClick={...}>Add To Cart</button>
</>
Only the text Add To Cart
is wrapped inside the <button>
, making it clickable. The icon is outside the button, so clicking on it does nothing.
Bad UX: Users expect the entire button (including the cart icon) to be clickable.
β
Wrap Everything Inside <button>
The entire button, including the icon and text, should be inside the <button>
element:
<button className="..." onClick={...}>
<img src="/images/icon-add-to-cart.svg" alt="cart-icon" />
Add To Cart
</button>
Now, clicking anywhere inside the button (text or icon) will trigger the event. This improves usability and user experience (UX).
2) Use Different Images for Different Screen Sizes
You're only rendering the desktop image for all screen sizes, even though separate images are provided for desktop, tablet, and mobile.
Use <picture>
for Responsive Images
The <picture>
element allows you to specify different images for different screen resolutions.
<picture>
<source srcSet="/images/item-mobile.jpg" media="(max-width: 640px)" />
<source srcSet="/images/item-tablet.jpg" media="(max-width: 1024px)" />
<img src="/images/item-desktop.jpg" alt="product-image" />
</picture>
How this works:
- If the screen width is β€ 640px, the mobile image loads.
- If the screen width is β€ 1024px, the tablet image loads.
- Otherwise, the desktop image loads.
Why use <picture>
?
- Optimizes performance by loading only the necessary image.
- Ensures the right image is shown for different devices.
Everything else looks great! Keep up the awesome work! π