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

Open
wants to merge 5 commits 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
14 changes: 7 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ This is possible because [we use the Parcel library](https://en.parceljs.org/scs

❗️ 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://serhiy23471.github.io/layout_product-cards/)
- [TEST REPORT LINK](https://serhiy23471.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.

- [ ] there 2 BEM blocks `card` and `stars` each in their own file
- [ ] SCSS Nesting is used for `elements`, `modifiers` and `pseudo-classes`
- [ ] SCSS Variables are used for main values and placed in a **separate file**
- [ ] all `stars--N` modifiers work as expected (Highlight first `N` stars)
- [ ] Code follows all the [Code Style Rules ❗️](https://mate-academy.github.io/layout_task-guideline/html-css-code-style-rules)
- [x] there 2 BEM blocks `card` and `stars` each in their own file
- [x] SCSS Nesting is used for `elements`, `modifiers` and `pseudo-classes`
- [x] SCSS Variables are used for main values and placed in a **separate file**
- [x] all `stars--N` modifiers work as expected (Highlight first `N` stars)
- [x] Code follows all the [Code Style Rules ❗️](https://mate-academy.github.io/layout_task-guideline/html-css-code-style-rules)
54 changes: 53 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,64 @@
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:wdth,[email protected],100..900&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="./styles/index.scss"

Choose a reason for hiding this comment

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

The href attribute is linking to an SCSS file (index.scss). Ensure that your build process (e.g., Parcel) is correctly configured to handle SCSS files and compile them into CSS. If not, this link might not apply the styles as expected in the browser.

Choose a reason for hiding this comment

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

The task requires separating BEM blocks into individual SCSS files. Currently, the index.scss file is linked here, which suggests that both card and stars blocks might be in the same file. Please ensure that these blocks are separated into their respective SCSS files as per the task requirements.

/>
</head>
<body>
<h1>Product cards</h1>
<div
class="card"
data-qa="card"
>
<img
class="card__img"
src="../src/images/imac.jpeg"
alt="iMac"
/>

<h2 class="card__name">
APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A)
</h2>

<p class="card__code">Product code: 195434</p>

<div class="card__review">
<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>

<p>Reviews: 5</p>
</div>

<div class="card__price">
<p class="card__price-label">Price:</p>
<p class="card__price-value">$2,199</p>
</div>

<a
class="button"
data-qa="hover"
>
BUY
</a>
</div>
</body>
</html>

85 changes: 85 additions & 0 deletions src/styles/blocks/card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
.card {
width: 200px;

padding: 0 16px;
border-radius: 5px;
border: 1px solid #f3f3f3;
Comment on lines +2 to +6

Choose a reason for hiding this comment

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

Consider using SCSS variables for main values like width, padding, border-radius, and border color. This will make your styles more maintainable and consistent.

}

.card__img {
display: block;
margin: 32px auto 40px;
width: 160px;
height: 134px;
}

.card__name {
font-weight: 500;
font-size: 12px;
line-height: 18px;
color: #060b35;
margin-bottom: 4px;
}

.card__code {
font-weight: 400;
font-size: 10px;
line-height: 14px;
color: #616070;
}

.card__review {
display: flex;

font-size: 10px;
font-weight: 400;

align-items: center;
justify-content: space-between;
margin: 16px 0 0;
}

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

.card__price-label {
font-weight: 400;
font-size: 12px;
line-height: 18px;
color: #616070;
}

.card__price-value {
font-weight: 700;
font-size: 16px;
line-height: 18px;
color: #060b35;
}

.button {
display: block;
height: 40px;
align-items: center;
text-align: center;
background-color: #00acdc;
border-radius: 5px;
border: 1px solid transparent;
padding: 12px 0;
margin: 16px 0;

color: #fff;
font-weight: 700;
font-size: 14px;
line-height: 16px;
text-transform: uppercase;
}

.button:hover {
border-radius: 5px;
border: 1px solid #00acdc;
background-color: #fff;
color: #00acdc;
Comment on lines +67 to +84

Choose a reason for hiding this comment

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

Using SCSS variables for colors and other repeated values can help maintain consistency and make future changes easier.

}
7 changes: 7 additions & 0 deletions src/styles/blocks/reset.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
body,
div,
p,
h2,
a {
margin: 0;
}
29 changes: 29 additions & 0 deletions src/styles/blocks/stars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.stars {
display: flex;
align-items: center;
}

.stars__star {
height: 16px;
width: 16px;
margin: 0 2px;
background-repeat: no-repeat;
background-position: center;
background-image: url(../images/star.svg);
Comment on lines +7 to +12

Choose a reason for hiding this comment

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

Consider using SCSS variables for repeated values such as height, width, and image paths. This will make your styles more maintainable and consistent.

}

.stars__star:last-child {
margin-right: 0;
}

.stars__star:first-child {
margin-left: 0;
}

.stars--5 > .stars__star,
.stars--1 > .stars__star:nth-child(1),
.stars--2 > .stars__star:nth-child(-n + 2),
.stars--3 > .stars__star:nth-child(-n + 3),
.stars--4 > .stars__star:nth-child(-n + 4) {
background-image: url(../images/star-active.svg);
}
9 changes: 9 additions & 0 deletions src/styles/blocks/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* {
box-sizing: border-box;
}

html {
font-family: Roboto, sans-serif;
font-size: 12px;
font-weight: 500;
Comment on lines +6 to +8

Choose a reason for hiding this comment

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

Consider using SCSS variables for font properties like font-family, font-size, and font-weight. This will help maintain consistency and make it easier to update these values across your styles.

}
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 'blocks/card';
@import 'blocks/stars';
@import 'blocks/style';
@import 'blocks/reset';