Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

product card 24.12.2024 #5114

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Product cards

Create a page with product card using `flexbox`, `BEM` and `SCSS` based on [this mockup](https://www.figma.com/file/ojkArVazq7vsX0nbpn9CxZ/Moyo-%2F-Catalog-(ENG)?node-id=11325%3A2287&mode=dev).
Create a page with product card using `flexbox`, `BEM` and `SCSS` based on [this mockup](<https://www.figma.com/file/ojkArVazq7vsX0nbpn9CxZ/Moyo-%2F-Catalog-(ENG)?node-id=11325%3A2287&mode=dev>).

> Here are the [Layout Tasks Instructions](https://mate-academy.github.io/layout_task-guideline)

Expand All @@ -16,15 +16,15 @@ Create a page with product card using `flexbox`, `BEM` and `SCSS` based on [this
- Rewrite the `stars` block from the [Stars task](https://github.com/mate-academy/layout_stars) with SCSS and use it
- Find the required font on [google fonts](https://fonts.google.com/) and use.

*Important note*: In this task, you are allowed to link `*.scss` files directly in HTML `<link>` tags using `href` attribute.
_Important note_: In this task, you are allowed to link `*.scss` files directly in HTML `<link>` tags using `href` attribute.
This is possible because [we use the Parcel library](https://en.parceljs.org/scss.html) to bundle your solution's source code.

## Checklist

❗️ Replace `<your_account>` with your GitHub username and copy the links to the `Pull Request` description:

- [DEMO LINK](https://<your_account>.github.io/layout_product-cards/)
- [TEST REPORT LINK](https://<your_account>.github.io/layout_product-cards/report/html_report/)
- [DEMO LINK](https://YriKm.github.io/layout_product-cards/)
- [TEST REPORT LINK](https://YriKm.github.io/layout_product-cards/report/html_report/)
YriKm marked this conversation as resolved.
Show resolved Hide resolved

❗️ Copy this `Checklist` to the `Pull Request` description after links, and put `- [x]` before each point after you checked it.

Expand Down
102 changes: 101 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,118 @@
<!doctype html>
<html lang="en">
<!-- #region head -->
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Product cards</title>
<link
rel="preconnect"
href="https://fonts.googleapis.com"
/>
<link
rel="preconnect"
href="https://fonts.gstatic.com"
/>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="./styles/index.scss"
/>
Comment on lines 23 to 26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the Parcel bundler is set up to handle SCSS files correctly, as you are linking to an SCSS file directly. This is allowed, but make sure the setup is correct to avoid runtime issues.

</head>
<!-- #endregion -->
<body>
<h1>Product cards</h1>
<div
class="card"
data-qa="card"
>
<div class="card__cord-image">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this wrapper for image?

Suggested change
<div class="card__cord-image">

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it I couldn't center the image.

<img
src="/src/images/imac.jpeg"
alt="APPLE A1419 iMac 27” Retina 5K Monoblock"
class="card__image"
/>
</div>

<div class="card__info-product">
<h3 class="card__title-product">
APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A)
</h3>

<span class="card__article-product">Product code: 195434</span>
</div>

<div class="card__rating">
<div class="card__rating-stars star">
<div class="star__line star__line--0">
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
</div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix classes and implement the modifier logic

Suggested change
<div class="star__line star__line--0">
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
</div>
<div class="stars stars--4">
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
<div class="stars__star"></div>
</div>


<div class="star__line star__line--1">
<div class="star__style star__style--active"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
</div>

<div class="star__line star__line--2">
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
</div>

<div class="star__line star__line--3">
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
<div class="star__style star__style--passive"></div>
<div class="star__style star__style--passive"></div>
</div>

<div class="star__line star__line--4">
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove other blocks

<div class="star__style star__style--passive"></div>
</div>

<div class="star__line star__line--5">
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
<div class="star__style star__style--active"></div>
</div>
</div>

<span class="card__reviews">Reviews: 5</span>
</div>

<div class="card__price">
<span class="card__price-text">Price:</span>

<span class="card__price-numbers">2,199</span>
YriKm marked this conversation as resolved.
Show resolved Hide resolved
</div>

<button
class="card__buy-button button"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class="card__buy-button button"
class="card__button"

data-qa="hover"
>
Buy
</button>
</div>
</body>
</html>
15 changes: 15 additions & 0 deletions src/styles/button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.button {
box-sizing: border-box;
border: none;
border-radius: 5px;
background-color: #00acdc;
padding-block: 12px;

font-size: 14px;
font-weight: 700;
text-transform: uppercase;
line-height: 16px;
text-align: center;
text-decoration: none;
color: #fff;
}
7 changes: 4 additions & 3 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
body {
margin: 0;
}
@import './variables';
@import './product-card';
@import './star';
@import './button';
114 changes: 114 additions & 0 deletions src/styles/product-card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
body {
margin: 0;
font-family: Roboto, Helvetica, sans-serif;
color: $font-color;
}

.card {
font-size: $font-size-card;
width: $width-product-card;

display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
padding: 32px 16px 16px;
border: 1px solid rgba(243, 243, 243, 1);
border-radius: 5px;
background-color: #fff;

&__cord-image {
display: flex;
justify-content: center;
}

&__image {
display: inline-block;
width: 160px;
height: 134px;
}

&__info-product {
margin-top: 40px;
display: flex;
flex-direction: column;
gap: 4px;
}

&__title-product {
margin: 0;
font-size: 1.2em;
font-weight: 500;
line-height: 18px;
}

&__article-product {
font-size: 1em;
font-weight: 400;
line-height: 14px;
color: $articl-font-color;
}

&__rating {
display: flex;
justify-content: space-between;
margin-top: 18px;
}

&__rating-stars {
position: relative;
top: -2px;

.star__line--0,
.star__line--1,
.star__line--2,
.star__line--3,
.star__line--4,
.star__line--5 {
opacity: 0;
}

.star__line--#{$quantities-stars} {
opacity: 1;
}
}

&__reviews {
font-size: 1em;
font-weight: 400;
line-height: 14px;
}

&__price {
display: flex;
justify-content: space-between;
margin-top: 24px;
}

&__price-text {
font-size: 1.2em;
font-weight: 400;
line-height: 18px;
color: #616070;
}

&__price-numbers {
font-size: 1.6em;
font-weight: 700;
line-height: 18px;

&::before {
content: '$';
}
}

&__buy-button {
margin-top: 16px;

&:hover {
background-color: #fff;
border: 1px solid #00acdc;
color: #00acdc;
}
}
}
26 changes: 26 additions & 0 deletions src/styles/star.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.star {
&__line {
display: flex;
position: absolute;
}

&__line :last-child {
margin-right: 0;
}

&__style {
width: 16px;
height: 16px;
margin-right: 4px;
background-repeat: no-repeat;
background-position: center;

&--active {
background-image: url(/src/images/star-active.svg);
}

&--passive {
background-image: url(/src/images/star.svg);
}
}
}
5 changes: 5 additions & 0 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$width-product-card: 200px;
$font-size-card: 10px;
$font-color: #060b35;
$articl-font-color: #616070;
$quantities-stars: 4;
Loading