From 8c1f06222ae8a474c86a80ce2b78aa32727bdbeb Mon Sep 17 00:00:00 2001 From: martha-555 <112080638+martha-555@users.noreply.github.com> Date: Sat, 23 May 2026 22:07:49 +0300 Subject: [PATCH] add task solution --- .github/workflows/test.yml-template | 29 +++ package-lock.json | 170 +-------------- package.json | 2 +- readme.md | 12 +- src/index.html | 320 +++++++++++++++++++++++++++- src/main.js | 1 + src/styles/card.scss | 106 +++++++++ src/styles/catalog.scss | 21 ++ src/styles/header.scss | 65 ++++++ src/styles/index.scss | 34 +++ src/styles/stars.scss | 40 ++++ src/styles/variables.scss | 15 ++ 12 files changed, 639 insertions(+), 176 deletions(-) create mode 100644 .github/workflows/test.yml-template create mode 100644 src/main.js create mode 100644 src/styles/card.scss create mode 100644 src/styles/catalog.scss create mode 100644 src/styles/header.scss create mode 100644 src/styles/stars.scss create mode 100644 src/styles/variables.scss diff --git a/.github/workflows/test.yml-template b/.github/workflows/test.yml-template new file mode 100644 index 0000000000..8b5743ecb4 --- /dev/null +++ b/.github/workflows/test.yml-template @@ -0,0 +1,29 @@ +name: Test + +on: + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test + - name: Upload HTML report(backstop data) + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: report + path: backstop_data diff --git a/package-lock.json b/package-lock.json index 6dd164c6e0..a1c3f92dc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@mate-academy/backstop-config": "latest", "@mate-academy/bemlint": "latest", "@mate-academy/linthtml-config": "latest", - "@mate-academy/scripts": "^1.8.6", + "@mate-academy/scripts": "^2.1.3", "@mate-academy/stylelint-config": "latest", "@parcel/transformer-sass": "^2.12.0", "backstopjs": "6.3.23", @@ -1212,10 +1212,11 @@ "dev": true }, "node_modules/@mate-academy/scripts": { - "version": "1.8.6", - "resolved": "https://registry.npmjs.org/@mate-academy/scripts/-/scripts-1.8.6.tgz", - "integrity": "sha512-b4om/whj4G9emyi84ORE3FRZzCRwRIesr8tJHXa8EvJdOaAPDpzcJ8A0sFfMsWH9NUOVmOwkBtOXDu5eZZ00Ig==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@mate-academy/scripts/-/scripts-2.1.3.tgz", + "integrity": "sha512-a07wHTj/1QUK2Aac5zHad+sGw4rIvcNl5lJmJpAD7OxeSbnCdyI6RXUHwXhjF5MaVo9YHrJ0xVahyERS2IIyBQ==", "dev": true, + "license": "MIT", "dependencies": { "@octokit/rest": "^17.11.2", "@types/get-port": "^4.2.0", @@ -5471,87 +5472,6 @@ "node": ">=12 || >=16" } }, - "node_modules/css-select": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", - "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^6.1.0", - "domhandler": "^5.0.2", - "domutils": "^3.0.1", - "nth-check": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/css-select/node_modules/dom-serializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", - "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/css-select/node_modules/domhandler": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", - "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/css-select/node_modules/domutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", - "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, - "node_modules/css-select/node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, - "optional": true, - "peer": true, - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/css-tree": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", @@ -5589,45 +5509,6 @@ "node": ">=4" } }, - "node_modules/csso": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/csso/-/csso-5.0.5.tgz", - "integrity": "sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "css-tree": "~2.2.0" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/csso/node_modules/css-tree": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.2.1.tgz", - "integrity": "sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "mdn-data": "2.0.28", - "source-map-js": "^1.0.1" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/csso/node_modules/mdn-data": { - "version": "2.0.28", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", - "integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==", - "dev": true, - "optional": true, - "peer": true - }, "node_modules/data-uri-to-buffer": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", @@ -10757,20 +10638,6 @@ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, - "node_modules/srcset": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/srcset/-/srcset-5.0.1.tgz", - "integrity": "sha512-/P1UYbGfJVlxZag7aABNRrulEXAwCSDo7fklafOQrantuPTDmYgijJMks2zusPCVzgW9+4P69mq7w6pYuZpgxw==", - "dev": true, - "optional": true, - "peer": true, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/stable": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", @@ -11176,33 +11043,6 @@ "integrity": "sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==", "dev": true }, - "node_modules/svgo": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-3.3.2.tgz", - "integrity": "sha512-OoohrmuUlBs8B8o6MB2Aevn+pRIH9zDALSR+6hhqVfa6fRwG/Qw9VUMSMW9VNg2CFc/MTIfabtdOVl9ODIJjpw==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "@trysound/sax": "0.2.0", - "commander": "^7.2.0", - "css-select": "^5.1.0", - "css-tree": "^2.3.1", - "css-what": "^6.1.0", - "csso": "^5.0.5", - "picocolors": "^1.0.0" - }, - "bin": { - "svgo": "bin/svgo" - }, - "engines": { - "node": ">=14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/svgo" - } - }, "node_modules/table": { "version": "6.8.2", "resolved": "https://registry.npmjs.org/table/-/table-6.8.2.tgz", diff --git a/package.json b/package.json index 34398805fa..f538e623d5 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@mate-academy/backstop-config": "latest", "@mate-academy/bemlint": "latest", "@mate-academy/linthtml-config": "latest", - "@mate-academy/scripts": "^1.8.6", + "@mate-academy/scripts": "^2.1.3", "@mate-academy/stylelint-config": "latest", "@parcel/transformer-sass": "^2.12.0", "backstopjs": "6.3.23", diff --git a/readme.md b/readme.md index acd5174814..db54753a1c 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Frontend practice with catalog page -Create an HTML page with a catalog. Develop semantic page structure as shown on [the mockup](https://www.figma.com/file/ojkArVazq7vsX0nbpn9CxZ/Moyo-%2F-Catalog-(ENG)?node-id=32249%3A354). +Create an HTML page with a catalog. Develop semantic page structure as shown on [the mockup](). - use `Header`, `Stars` and `Card` blocks from previous tasks but rewrite them using BEM and SCSS - remove old `data-qa` attributes @@ -9,7 +9,7 @@ Create an HTML page with a catalog. Develop semantic page structure as shown on - add `data-qa="card-hover"` (not just `hover`) to the link `Buy` inside the first card - nav links color is not `black` anymore (nav links should have `#060b35` color) - add the class `is-active` to the first link (`Apple`) in the navigation -- use `
` tag for cards container +- use `
` tag for cards container - use the grid for cards with different numbers of columns: - 1 for the smaller screens - 2 starting at `488px` @@ -20,6 +20,7 @@ Create an HTML page with a catalog. Develop semantic page structure as shown on - cards container(catalog) have fixed paddings (`50px` vertically and `40px` horizontally) Make all the changes smooth on hover (during 300ms): + - increase the card by 20 percent (neighboring cards **should not be** affected) - change the card title text color to `#34568b` when the card is hovered (`.card:hover .card__title`) - change navigation link text color to `#00acdc` @@ -27,14 +28,15 @@ Make all the changes smooth on hover (during 300ms): > Here are the [Layout Tasks Instructions](https://mate-academy.github.io/layout_task-guideline) -*Important note*: In this task, you are allowed to link `*.scss` files directly in HTML `` tags using `href` attribute. +_Important note_: In this task, you are allowed to link `*.scss` files directly in HTML `` tags using `href` attribute. This is possible because [we use the Parcel library](https://en.parceljs.org/scss.html) to bundle your solution's source code. ## Checklist ❗️ Replace `` with your GitHub username and copy the links to the `Pull Request` description: -- [DEMO LINK](https://.github.io/layout_catalog/) -- [TEST REPORT LINK](https://.github.io/layout_catalog/report/html_report/) + +- [DEMO LINK](https://martha-555.github.io/layout_catalog/) +- [TEST REPORT LINK](https://martha-555.github.io/layout_catalog/report/html_report/) ❗️ Copy this `Checklist` to the `Pull Request` description after links, and put `- [x]` before each point after you checked it. diff --git a/src/index.html b/src/index.html index 9cff78eeb7..a3ce254ff2 100644 --- a/src/index.html +++ b/src/index.html @@ -6,22 +6,332 @@ name="viewport" content="width=device-width, initial-scale=1.0" /> - Catalog + + Product cards - -

Catalog

+
+ + + + +
+
+
+
+

+ APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A) +

+

Product code: 195434

+
+
+
+
+
+
+
+
+

Reviews: 5

+
+
+

Price:

+

$2,199

+
+ + BUY + +
+
+
+

+ APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A) +

+

Product code: 195434

+
+
+
+
+
+
+
+
+

Reviews: 5

+
+
+

Price:

+

$2,199

+
+ + BUY + +
+
+
+

+ APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A) +

+

Product code: 195434

+
+
+
+
+
+
+
+
+

Reviews: 5

+
+
+

Price:

+

$2,199

+
+ + BUY + +
+
+
+

+ APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A) +

+

Product code: 195434

+
+
+
+
+
+
+
+
+ +

Reviews: 5

+
+
+

Price:

+

$2,199

+
+ + BUY + +
+
+
+

+ APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A) +

+

Product code: 195434

+
+
+
+
+
+
+
+
+ +

Reviews: 5

+
+
+

Price:

+

$2,199

+
+ + BUY + +
+
+
+

+ APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A) +

+

Product code: 195434

+
+
+
+
+
+
+
+
+ +

Reviews: 5

+
+
+

Price:

+

$2,199

+
+ + BUY + +
+
+
+

+ APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A) +

+

Product code: 195434

+
+
+
+
+
+
+
+
+ +

Reviews: 5

+
+
+

Price:

+

$2,199

+
+ + BUY + +
+
+
+

+ APPLE A1419 iMac 27" Retina 5K Monoblock (MNED2UA/A) +

+

Product code: 195434

+
+
+
+
+
+
+
+
+ +

Reviews: 5

+
+
+

Price:

+

$2,199

+
+ + BUY + +
+
diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000000..ad9a93a7c1 --- /dev/null +++ b/src/main.js @@ -0,0 +1 @@ +'use strict'; diff --git a/src/styles/card.scss b/src/styles/card.scss new file mode 100644 index 0000000000..f7b10c4443 --- /dev/null +++ b/src/styles/card.scss @@ -0,0 +1,106 @@ +@use './variables' as *; + +.card { + position: relative; + box-sizing: border-box; + display: flex; + flex-direction: column; + width: $card-width; + padding: 32px 16px 16px; + border: 1px solid $container-color; + border-radius: 5px; + background-color: $white; + transition: transform $transition-duration; + + &:hover { + z-index: 1; + transform: scale(1.2); + } + + &__image { + box-sizing: border-box; + background-image: url(../images/imac.jpeg); + background-position: 50%; + background-repeat: no-repeat; + background-size: 100% 100%; + width: 160px; + height: 134px; + margin: 0 auto 40px; + } + + &__title { + width: 166px; + margin: 0; + font-size: 12px; + font-weight: 500; + line-height: 18px; + color: $main-color; + transition: color $transition-duration; + } + + &:hover &__title { + color: $title-hover-color; + } + + &__code { + color: $secondary-color; + font-weight: 400; + font-size: 10px; + line-height: 14px; + margin-top: 4px; + margin-bottom: 16px; + } + + &__price-block { + display: flex; + justify-content: space-between; + margin-bottom: 16px; + } + + &__price-label { + font-size: 12px; + font-weight: 400; + line-height: 18px; + color: $secondary-color; + } + + &__price { + font-size: 16px; + font-weight: 700; + line-height: 18px; + } + + &__buy { + display: flex; + justify-content: center; + align-items: center; + + box-sizing: border-box; + width: 166px; + height: 40px; + margin: 0 auto; + + border: 1px solid transparent; + border-radius: 5px; + + background: $blue-accent; + color: $white; + + font-family: Roboto, sans-serif; + font-size: 14px; + font-weight: 700; + + text-decoration: none; + + transition: + background-color $transition-duration, + color $transition-duration, + border-color $transition-duration; + + &:hover { + border-color: $blue-accent; + background: $white; + color: $blue-accent; + } + } +} diff --git a/src/styles/catalog.scss b/src/styles/catalog.scss new file mode 100644 index 0000000000..8658641494 --- /dev/null +++ b/src/styles/catalog.scss @@ -0,0 +1,21 @@ +@use './variables' as *; + +.catalog { + display: grid; + grid-template-columns: repeat(1, $card-width); + gap: $catalog-row-gap $catalog-column-gap; + padding: $catalog-padding-vertical $catalog-padding-horizontal; + justify-content: center; + + @media (min-width: $breakpoint-2-columns) { + grid-template-columns: repeat(2, $card-width); + } + + @media (min-width: $breakpoint-3-columns) { + grid-template-columns: repeat(3, $card-width); + } + + @media (min-width: $breakpoint-4-columns) { + grid-template-columns: repeat(4, $card-width); + } +} diff --git a/src/styles/header.scss b/src/styles/header.scss new file mode 100644 index 0000000000..ba22150913 --- /dev/null +++ b/src/styles/header.scss @@ -0,0 +1,65 @@ +@use './variables' as *; + +.header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 50px; + font-size: 12px; + box-shadow: 0 2px 4px 0 #0000000d; + + &__logo { + width: 40px; + height: 40px; + } + + &__list { + display: flex; + align-items: center; + list-style: none; + text-transform: uppercase; + height: 100%; + margin: 0; + padding: 0; + } + + &__nav { + height: 60px; + } + + &__item:not(:last-child) { + margin-right: 20px; + } + + &__link { + position: relative; + display: flex; + align-items: center; + height: 100%; + line-height: 15px; + color: $main-color; + text-decoration: none; + transition: color $transition-duration; + + &:hover { + color: $blue-accent; + } + + &.is-active { + color: $blue-accent; + + &::after { + content: ''; + position: absolute; + left: 0; + display: block; + width: 100%; + height: 4px; + border-radius: 8px; + background: $blue-accent; + bottom: 0; + line-height: 100%; + } + } + } +} diff --git a/src/styles/index.scss b/src/styles/index.scss index 293d3b1f13..486e6a5ab0 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -1,3 +1,37 @@ +@use './variables' as *; +@use './header'; +@use './catalog'; +@use './card'; +@use './stars'; + +* { + box-sizing: border-box; +} + +html { + box-sizing: border-box; + font-family: Roboto, sans-serif; + font-weight: 500; + font-style: normal; +} + body { margin: 0; + padding: 0; +} + +p { + margin: 0; +} + +button { + padding: 0; +} + +img { + display: block; +} + +li { + height: 100%; } diff --git a/src/styles/stars.scss b/src/styles/stars.scss new file mode 100644 index 0000000000..98df779502 --- /dev/null +++ b/src/styles/stars.scss @@ -0,0 +1,40 @@ +@use './variables' as *; + +.rating { + display: flex; + width: 100%; + justify-content: space-between; + margin-bottom: 24px; + + &__stars { + display: flex; + } + + &__star { + width: 16px; + height: 16px; + margin-right: 4px; + background-image: url('../images/star.svg'); + background-repeat: no-repeat; + background-position: center; + + &:last-child { + margin-right: 0; + } + } + + &__stars--1 .rating__star:nth-child(-n + 1), + &__stars--2 .rating__star:nth-child(-n + 2), + &__stars--3 .rating__star:nth-child(-n + 3), + &__stars--4 .rating__star:nth-child(-n + 4), + &__stars--5 .rating__star:nth-child(-n + 5) { + background-image: url('../images/star-active.svg'); + } + + &__info { + font-weight: 400; + font-size: 10px; + line-height: 14px; + color: $main-color; + } +} diff --git a/src/styles/variables.scss b/src/styles/variables.scss new file mode 100644 index 0000000000..d548ff5897 --- /dev/null +++ b/src/styles/variables.scss @@ -0,0 +1,15 @@ +$main-color: #060b35; +$secondary-color: #616070; +$blue-accent: #00acdc; +$title-hover-color: #34568b; +$white: #fff; +$container-color: #f3f3f3; +$card-width: 200px; +$catalog-column-gap: 48px; +$catalog-row-gap: 46px; +$catalog-padding-vertical: 50px; +$catalog-padding-horizontal: 40px; +$transition-duration: 300ms; +$breakpoint-2-columns: 488px; +$breakpoint-3-columns: 768px; +$breakpoint-4-columns: 1024px;