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 #4820

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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://OlhaLishenko.github.io/layout_product-cards/)
- [TEST REPORT LINK](https://OlhaLishenko.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
Binary file added src/images/mac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 52 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,60 @@
<title>Product cards</title>
<link
rel="stylesheet"
href="./styles/index.scss"
href="./styles/index.css"
/>
<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:ital,wght@0,400;0,500;0,700;1,400&display=swap"
rel="stylesheet"
/>
</head>
<body>
<h1>Product cards</h1>
<div
class="product-card"
data-qa="card"
>
<div class="product-card__image"></div>

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

Choose a reason for hiding this comment

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

According to the checklist, text content should be wrapped in a paragraph <p> tag, not a <div>. Consider changing <div class="product-name"> to <p class="product-name">.

</div>

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

Choose a reason for hiding this comment

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

For the product code, it is more semantically correct to use a <span> tag since this is a short piece of information within a block. Change <div class="product-code"> to <span class="product-code">.


<div class="product-rating">
<div class="stars">
<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="product-rating__reviews">Reviews: 5</div>
</div>

<div class="product-price">
<div class="product-price__text">Price:</div>
<div class="product-price__value">$2,199</div>

Choose a reason for hiding this comment

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

The price label and value seem to be a part of the same piece of information and should be within the same tag. Consider using a <span> tag for the price label and wrapping both the label and the value inside a <p> tag for better semantic structure.

</div>

<a
href="#"
class="buy-button"
data-qa="hover"

Choose a reason for hiding this comment

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

The data-qa attribute is used for test hooks, but hover is not descriptive of its purpose. It should describe the element or action it's associated with, such as data-qa="buy-button".

>

Choose a reason for hiding this comment

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

Anchor tags representing buttons should include a role="button" attribute to ensure accessibility. Add role="button" to the <a> tag.

Buy
</a>
</div>
</div>
</body>
</html>
124 changes: 124 additions & 0 deletions src/styles/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/styles/index.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 127 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,130 @@
$border-color: #f3f3f3;
$product-card-width: 200px;
$main-fonts: 'Roboto';
$main-text-color: #060b35;
$second-text-color: #616070;
$button-color: #00acdc;
$border-radius: 5px;

body {
margin: 0;
}

.product-card {
display: flex;
flex-direction: column;
box-sizing: border-box;
width: $product-card-width;
border: 1px solid $border-color;
border-radius: $border-radius;
align-items: center;
justify-content: center;

&__image {
background-image: url('../images/imac.jpeg');

Choose a reason for hiding this comment

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

According to the checklist, images should be in the format of .png, .jpg, or .jpeg. The image 'imac.jpeg' should be checked to ensure it is in the correct format and renamed if necessary to adhere to the format guidelines.

background-repeat: no-repeat;
background-size: 100% 100%;
width: 160px;
height: 134px;
margin: 32px 19px 0;
box-sizing: border-box;
}
Comment on lines +23 to +31

Choose a reason for hiding this comment

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

The BEM element '.product-card__image' has a margin with non-zero values, which is not recommended. BEM methodology suggests avoiding external geometry and positioning for BEM blocks and elements, such as margins. Consider refactoring this by utilizing the parent element to control the layout instead.


&__content {
margin: 40px 16px 16px;
font-family: $main-fonts, sans-serif;
}
}

.product-name {
font-weight: 500;
font-size: 12px;
line-height: 18px;
color: $main-text-color;
}

.product-code {
font-weight: 400;
font-size: 10px;
line-height: 14px;
color: $second-text-color;
margin: 4px 0 0;
}

.product-rating {
margin: 16px 0 0;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-end;

&__reviews {
font-weight: 400;
font-size: 10px;
line-height: 14px;
color: $main-text-color;
}
}

.stars {
flex-direction: row;
display: flex;
gap: 4px;

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

&:last-of-type {
background-image: url('../images/star.svg');
}
}
}

.product-price {
display: flex;
flex-direction: row;
justify-content: space-between;
margin: 24px 0 0;

&__text {
line-height: 18px;
font-weight: 400;
font-size: 12px;
color: $second-text-color;
}

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

.buy-button {
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
background-color: $button-color;
text-decoration: none;
color: #ffff;

Choose a reason for hiding this comment

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

The color value should be written in lowercase to maintain consistency as per the code style rules.

font-weight: 700;
font-size: 14px;
line-height: 16px;
margin: 16px 0 0;
border-radius: $border-radius;
border: 1px solid $button-color;
width: 166px;
height: 40px;
text-transform: uppercase;

&:hover {
color: $button-color;
background-color: #ffff;
}
}
Loading