Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Petrychenko authored and Oleksii Petrychenko committed Jan 2, 2025
1 parent 606dc21 commit 666e9f4
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 3 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ 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://Katy4S.github.io/layout_product-cards/)
- [TEST REPORT LINK](https://Katy4S.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
55 changes: 54 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,61 @@
rel="stylesheet"
href="./styles/index.scss"
/>
<link
rel="preconnect"
href="https://fonts.googleapis.com"
/>
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossorigin="anonymous"
/>
<link
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
rel="stylesheet"
/>
</head>
<body>
<h1>Product cards</h1>
<div class="container">
<div
class="card"
data-qa="card"
>
<img
class="card__image"
src="/src/images/imac.jpeg"
alt="iMac"
/>
<div class="card__content">
<span class="card__name">
APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A)
</span>
<div class="card__code">Product code: 195434</div>
<div class="card__rating">
<div class="stars stars--4">
<span class="stars__star"></span>
<span class="stars__star"></span>
<span class="stars__star"></span>
<span class="stars__star"></span>
<span class="stars__star"></span>
</div>
<span class="card__reviews">Reviews: 5</span>
</div>
<div class="card__price">
<span class="card__price-text">Price:</span>
<span class="card__price-value">$2,199</span>
</div>
<div>
<a
href="#"
class="card__buy"
data-qa="hover"
>
buy
</a>
</div>
</div>
</div>
</div>
</body>
</html>
120 changes: 120 additions & 0 deletions src/styles/card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
.card {
box-sizing: border-box;
width: $card-width;
border: 1px solid #f3f3f3;
border-radius: 5px;
padding: 32px 16px 16px;
background: #fff;

&__image {
display: block;
margin: 0 auto 40px;
width: 160px;
height: 134px;
}

&__name {
font-family: Roboto, serif;
font-size: 12px;
font-weight: 500;
line-height: 18px;
text-align: left;
text-underline-position: from-font;
text-decoration-skip-ink: none;
color: $card-main-color;
margin: 0 0 4px;
display: block;
}

&__code {
font-family: Roboto, serif;
font-size: 10px;
font-weight: 400;
line-height: 14px;
text-align: left;
text-underline-position: from-font;
text-decoration-skip-ink: none;
color: $card-secondary-color;
margin-bottom: 16px;
}

&__stars {
display: flex;
justify-content: center;
margin-top: 5px;
line-height: 16px;
}

&__rating {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-bottom: 24px;
}

&__reviews {
font-family: Roboto, serif;
font-size: 10px;
font-weight: 400;
line-height: 14px;
text-align: right;
text-underline-position: from-font;
text-decoration-skip-ink: none;
color: $card-main-color;
}

&__price {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}

&__price-text {
font-family: Roboto, serif;
font-size: 12px;
font-weight: 400;
line-height: 18px;
text-align: left;
text-underline-position: from-font;
text-decoration-skip-ink: none;
color: $card-secondary-color;
}

&__price-value {
font-family: Roboto, serif;
font-size: 16px;
font-weight: 700;
line-height: 18px;
text-align: right;
text-underline-position: from-font;
text-decoration-skip-ink: none;
color: $card-main-color;
}

&__buy {
display: flex;
justify-content: center;
align-items: center;
height: 40px;
background-color: $card-buy-color;
box-sizing: border-box;
text-decoration: none;
border-radius: 5px;
font-family: Roboto, serif;
font-size: 14px;
font-weight: 700;
line-height: 16px;
text-align: center;
text-underline-position: from-font;
text-decoration-skip-ink: none;
color: white;
text-transform: uppercase;

&:hover {
border: 1px solid $card-buy-color;
background-color: rgba(243, 243, 243, 1);
color: $card-buy-color;
}
}
}
5 changes: 5 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@import './variables';
@import './card';
@import './stars';

body {
margin: 0;
font-family: $font-family;
}
25 changes: 25 additions & 0 deletions src/styles/stars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.stars {
display: flex;
}

.stars__star {
width: 16px;
height: 16px;
margin-right: 4px;

background-image: url(/src/images/star.svg);
background-repeat: no-repeat;
background-position: center;
}

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

.stars--1 .stars__star:nth-child(-n + 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),
.stars--5 .stars__star:nth-child(-n + 5) {
background-image: url(/src/images/star-active.svg);
}
9 changes: 9 additions & 0 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$font-family: 'Roboto', sans-serif;
$card-width: 200px;
$card-height: 408px;
$card-border-color: rgba(243, 243, 243, 1);
$star-color: rgba(255, 222, 106, 1);
$star-empty-color: rgba(243, 243, 243, 1);
$card-secondary-color: rgba(97, 96, 112, 1);
$card-main-color: rgba(6, 11, 53, 1);
$card-buy-color: rgba(0, 172, 220, 1);

0 comments on commit 666e9f4

Please sign in to comment.