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

add task solution #4847

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Create a pages with product card using `flexbox`, `BEM` and `SCSS` based on [thi

❗️ Replace `<your_account>` with your Github username and copy the links to `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://mrsBlackA.github.io/layout_product-cards/)
- [TEST REPORT LINK](https://mrsBlackA.github.io/layout_product-cards/report/html_report/)

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

Expand Down
76 changes: 73 additions & 3 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,88 @@
<!doctype html>
<html lang="en">
<html
lang="en"
class="page"
>
<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=Roboto:wght@400;500;700&display=swap"
rel="stylesheet"
/>

<link
rel="shortcut icon"
href="/src/images/star-active.svg"
type="image/x-icon"
/>

<link
rel="stylesheet"
href="./styles/index.scss"
/>
<link
rel="stylesheet"
href="./styles/index.scss"
/>
Comment on lines 39 to 42

Choose a reason for hiding this comment

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

You have two identical links to the index.scss file. Please, remove one of them.

</head>
<body>
<h1>Product cards</h1>

<body class="page__body">
<div
class="product-card"
data-qa="card"
>
<div class="product-card__image">
<img
src="images/imac.jpeg"
alt="APPLE A1419 iMac 27"
/>
</div>

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

<div class="product-card__reviews">
<div class="product-card__stars">
<div class="product-card__star"></div>
<div class="product-card__star"></div>
<div class="product-card__star"></div>
<div class="product-card__star"></div>
<div class="product-card__star"></div>
</div>
<span class="product-card__count">Reviews: 5</span>
</div>

<div class="product-card__price">
<span class="product-card__label">Price:</span>
<span class="product-card__value">$2,199</span>
</div>

<button
class="product-card__button product-card__button--hover"
data-qa="hover"
>
Buy
</button>
</div>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions src/styles/blocks/font.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.roboto-regular {
font-family: Roboto, sans-serif;
font-weight: 400;
font-style: normal;
}

.roboto-medium {
font-family: Roboto, sans-serif;
font-weight: 500;
font-style: normal;
}

.roboto-bold {
font-family: Roboto, sans-serif;
font-weight: 700;
font-style: normal;
}
13 changes: 13 additions & 0 deletions src/styles/blocks/page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.page {
font-family: Roboto, Arial, sans-serif;
font-weight: 400;

&__body {
margin: 0;
height: 100vh;

display: flex;
align-items: center;
justify-content: center;
}
}
113 changes: 113 additions & 0 deletions src/styles/blocks/product-card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
.product-card {
width: 200px;
height: 408px;
padding: 32px 16px 16px;

border-radius: 5px;
border: 1px solid rgba(243, 243, 243, 1);
box-sizing: border-box;

Choose a reason for hiding this comment

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

You have specified box-sizing: border-box; for this class. While this is not inherently wrong, it is a good practice to apply this property to all elements at once in your general or reset stylesheet. This helps to ensure consistent sizing of all elements in your project.


display: flex;
flex-direction: column;
justify-content: space-between;

&__image {
padding-inline: 3px;

& img {
width: 100%;
height: 134px;

Choose a reason for hiding this comment

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

It's not recommended to set the height of the image. This can lead to distortion if the aspect ratio of the original image is not the same as the one you've set. It's better to set only the width and let the height be set automatically to maintain the aspect ratio of the image.

}
}

&__title {
margin: 0;
font-family: inherit;
font-size: 12px;
font-weight: 500;
line-height: 18px;
color: $color-main;
}

&__code {
margin: 4px 0 16px;
font-family: inherit;
font-size: 10px;
line-height: 14px;
color: rgba(97, 96, 112, 1);
}

&__reviews {
display: flex;
justify-content: space-between;
}

&__stars {
display: flex;
}

&__star {
background-image: url(/src/images/star.svg);
background-position: center;
background-repeat: no-repeat;
width: 16px;
height: 16px;
margin-right: 4px;

Choose a reason for hiding this comment

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

The margin-right: 4px; style will be applied to the last star as well, which could potentially cause alignment issues. A common solution is to use margin-left: 4px; and then offset the first child with &:first-child { margin-left: 0; }.

}

&__star:nth-child(-n + 4) {
background-image: url('/src/images/star-active.svg');

Choose a reason for hiding this comment

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

This selector &__star:nth-child(-n + 4) will always select the first 4 stars, regardless of the rating. The number of active stars should be determined dynamically, based on the rating data. You might need to adjust your HTML structure and/or CSS to achieve this.

}

&__count {
font-family: inherit;
font-weight: 400;
font-size: 10px;
line-height: 14px;
align-self: end;
color: $color-main;
}

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

&__label {
font-family: inherit;
font-size: 12px;
line-height: 18px;
color: rgba(97, 96, 112, 1);
}

&__value {
font-family: inherit;
font-weight: 700;
font-size: 16px;
line-height: 18px;
color: $color-main;
}

&__button {
height: 40px;
width: 100%;
border: none;

Choose a reason for hiding this comment

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

Setting the width to 100% could cause layout issues if the parent container's padding, border, or margin is not accounted for. It might be better to use width: auto; and control the button's width with padding.

border-radius: 5px;
background-color: $color-button;
cursor: pointer;

font-family: inherit;
font-weight: 700;
font-size: 14px;
line-height: 16px;
text-transform: uppercase;
color: rgba(255, 255, 255, 1);

&:hover {
background-color: #fff;
border: 1px solid $color-button;
color: $color-button;
}

Choose a reason for hiding this comment

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

On hover, the button text color changes to $color-button, which is the same color as the border. This could potentially reduce the readability of the text. Consider choosing a color that contrasts with the border color.

}
}
16 changes: 16 additions & 0 deletions src/styles/blocks/stars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.stars {
display: flex;

&__star {
background-image: url(/src/images/star.svg);
background-position: center;
background-repeat: no-repeat;
width: 16px;
height: 16px;
margin-right: 4px;
}

&__star:nth-child(-n + 4) {

Choose a reason for hiding this comment

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

This code will always make the first 4 stars active, no matter how many stars you want to be active. You should add a modifier to the stars block, like 'stars--4', and then use it in combination with the nth-child selector to select the appropriate number of active stars. For example, '.stars--4 &__star:nth-child(-n + 4)'.

background-image: url('/src/images/star-active.svg');
}
}
5 changes: 5 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
body {
margin: 0;
}

@import './utils/variables';
@import './blocks/font';
@import './blocks/page';
@import './blocks/product-card';
2 changes: 2 additions & 0 deletions src/styles/utils/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$color-main: rgba(6, 11, 53, 1);
$color-button: rgba(0, 172, 220, 1);
Loading