frontend-mentor/product-preview-card-component/README.md

86 lines
2.4 KiB
Markdown
Raw Normal View History

2023-05-28 17:49:23 -07:00
# Frontend Mentor - Product preview card component solution
This is a solution to
the [Product preview card component challenge on Frontend Mentor](https://www.frontendmentor.io/challenges/product-preview-card-component-GO7UmttRfa).
Frontend Mentor challenges help you improve your coding skills by building realistic projects.
2023-05-28 17:49:23 -07:00
## Table of contents
- [Overview](#overview)
- [The challenge](#the-challenge)
- [Screenshot](#screenshot)
- [Links](#links)
2023-05-28 17:49:23 -07:00
- [My process](#my-process)
- [Built with](#built-with)
- [What I learned](#what-i-learned)
- [Useful resources](#useful-resources)
2023-05-28 17:49:23 -07:00
- [Author](#author)
## 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.png)
2023-05-28 17:49:23 -07:00
### Links
- [Solution URL](https://www.frontendmentor.io/solutions/product-preview-card-vanilla-csshtml-w-vite-tOKhLeMFut)
- [Live Site URL](https://product-preview-card-component-zeta-teal.vercel.app/)
2023-05-28 17:49:23 -07:00
## My process
### Built with
2023-05-28 18:47:30 -07:00
- CSS/HTML
- Vite.js
2023-05-28 17:49:23 -07:00
### What I learned
2023-05-29 11:55:21 -07:00
How to use a `<picture>` element and set images differently based on media queries:
2023-05-28 17:49:23 -07:00
```html
2023-05-29 11:55:21 -07:00
<picture>
<source media="(max-width: 999px)" srcset="images/image-product-mobile.jpg">
<source media="(min-width: 1000px)" srcset="images/image-product-desktop.jpg">
<!-- <img> is required! Src is set to fallback img -->
<img
src="images/image-product-desktop.jpg"
alt="Gabrielle Essence perfume bottle"
class="ProductCard-picture"
>
</picture>
2023-05-28 17:49:23 -07:00
```
2023-05-29 11:55:21 -07:00
Additionally, <picture> does not automatically shrink-wrap to its <img>, so CSS is required to keep
<picture> from creating extra spacing:
```css
.ProductCard-picture {
height: 100%;
2023-05-28 17:49:23 -07:00
}
```
### Useful resources
2023-05-29 11:55:21 -07:00
[SUIT CSS](https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md)
2023-05-28 17:49:23 -07:00
2023-05-29 11:55:21 -07:00
I've known about BEM for a long time, and more recently came across SUIT CSS. For a while I've used
a sort of hybrid, as I liked the spacing of BEM's syntax (block__elem vs block-elem), but prefer
SUIT's seperation of modifier & state. For this project though, I decided to try conforming fully
to SUIT and found I actually really liked it.
2023-05-28 17:49:23 -07:00
## Author
2023-05-28 18:47:30 -07:00
- Website - [Marley Rae](https://www.punkfairie.net)
- Frontend Mentor - [@punkfairie](https://www.frontendmentor.io/profile/punkfairie)
2023-05-28 17:49:23 -07:00
**Note: Delete this note and add/remove/edit lines above based on what links you'd like to share.**