/Product-preview-card-component

Product preview card component built with Html, Sass, ViteJS (Frontend Mentor)

Primary LanguageSCSS

Netlify Status

Frontend Mentor - Product preview card component solution

This is a solution to the Product preview card component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout depending on their device's screen size
  • See hover and focus states for interactive elements

Screenshot

Screenshot of the app

Links

My process

Built with

  • Semantic HTML5 markup
  • Sass
  • Flexbox
  • Mobile-first workflow
  • ViteJS

What I learned

  • The shopping-cart icon only appeared when using display: inline-flex. I will have to study this further.
  • The <picture> HTML element and the possibility to enter media queries. See code below.
  • Josh Comeau's CSS reset. Josh Comeau's CSS reset
  • To start CSS/Sass color variables with: clr-
  • To start CSS/Sass font-family with: ff-
  • To start CSS/Sass font-weight with: fw-
  • To use a custom data-* attribute to place an svg as an icon. See code below.
  • That the vh unit is not ideal for mobile view. Kevin Powell, The problems with viewport units
  • object-fit: contain; // contain works better on iPad
<picture>
    <source srcset="./assets/images/image-product-desktop.jpg" media="(min-width: 600px)">
    <img src="./assets/images/image-product-mobile.jpg" alt="Chanel Gabrielle">
</picture>
<button type="button" data-icon="shopping-cart">Add to Card</button>

Continued development

Code-wise I am not entirely satisfied.

  • CSS writing style may be improved with the BEM method.
  • On mobile, a part of the site is cut off.
  • On iPad the card stretches vertically and the content gets too much whitespace.

Useful resources

Author