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 solution #5191

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
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://VadimKudrenko.github.io/layout_product-cards/)
- [TEST REPORT LINK](https://VadimKudrenko.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)
62 changes: 61 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,72 @@
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:[email protected]&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="./styles/index.scss"
/>
</head>
<body>
<h1>Product cards</h1>
<main>
<div
class="card"
data-qa="card"
>
<div class="card__image-wrapper">
<img
class="card__image"
src="./images/imac.jpeg"
alt="card image"
/>
</div>
<div class="card__title-wrapper">
<h2 class="card__title">
APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A)
</h2>
</div>
<div class="card__product-code-wrapper">
<p class="card__product-code">Product code: 195434</p>
</div>
<div class="card__reviews-wrapper">
<div class="reviews">
<div class="reviews__stars">
<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>
<p class="reviews__counter">Reviews: 5</p>
</div>
</div>
<div class="card__price-wrapper">
<div class="card__price">
<p class="card__price-title">Price:</p>
<p class="card__price-amount">$2,199</p>
</div>
</div>
<a
class="card__buy-btn"
href="#"
data-qa="hover"
>
Buy
</a>
</div>
</main>
</body>
</html>
113 changes: 113 additions & 0 deletions src/styles/blocks/card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
.card {
box-sizing: border-box;
border: 1px solid #f3f3f3;
border-radius: 5px;
width: 200px;
padding: 32px 16px 16px;
margin: 0 auto;

display: flex;
flex-direction: column;
}

.card__image-wrapper {
height: 134px;
display: flex;
justify-content: center;
margin-bottom: 40px;
}

.card__image {
width: 160px;
height: 134px;
}

.card__title-wrapper {
margin-bottom: 4px;
}

.card__title {
font-weight: 500;
font-size: 12px;
line-height: 18px;
color: $card-title-main-color;
}

.card__product-code-wrapper {
margin-bottom: 16px;
}

.card__product-code {
font-weight: 400;
font-size: 10px;
line-height: 14px;
color: $card-subtitle-color;
}

.card__reviews-wrapper {
margin-bottom: 24px;
}

.reviews {
display: flex;
justify-content: space-between;
align-items: center;
}

.reviews__counter {
display: flex;
align-items: center;
height: 16px;
font-weight: 400;
font-size: 10px;
color: $card-title-main-color;
}

.card__price-wrapper {
margin-bottom: 16px;
}

.card__price {
display: flex;
justify-content: space-between;
}

.card__price-title {
font-weight: 400;
font-size: 12px;
line-height: 18px;
color: $card-subtitle-color;
}

.card__price-amount {
font-weight: 700;
font-size: 16px;
line-height: 18px;
color: $card-title-main-color;
}

.card__buy-btn {
display: flex;
justify-content: center;
align-items: center;

background-color: $card-buy-btn-color;
border-radius: 5px;
border: 1px solid $card-buy-btn-color;
box-sizing: border-box;
height: $card-buy-btn-height;
width: 100%;

font-weight: 700;
font-size: 14px;
text-decoration: none;
text-transform: uppercase;
text-align: center;
color: #fff;

&:hover {
cursor: pointer;
background-color: transparent;
color: $card-buy-btn-color;
}
}
21 changes: 21 additions & 0 deletions src/styles/blocks/stars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.stars {
display: flex;
}

.stars__star {
height: 16px;
width: 16px;
background-image: url(../images/star.svg);
background-position: center;
background-repeat: no-repeat;
}

.stars__star:nth-child(n + 2) {
margin-left: 4px;
}

@for $i from 0 through 5 {
.stars--#{$i} > .stars__star:nth-child(-n + #{$i}) {
background-image: url(../images/star-active.svg);
}
}
12 changes: 11 additions & 1 deletion src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
body {
@import './utils/variables';
@import './blocks/card';
@import './blocks/stars';

html {
font-family: Roboto, serif;
}

body,
p,
h2 {
margin: 0;
}
4 changes: 4 additions & 0 deletions src/styles/utils/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$card-title-main-color: #060b35;
$card-subtitle-color: #616070;
$card-buy-btn-color: #00acdc;
$card-buy-btn-height: 40px;
Loading