From 37720341a08d3bccd6144d96251286ce1d0b42fd Mon Sep 17 00:00:00 2001 From: Sonya Date: Mon, 6 Jul 2026 15:22:20 +0200 Subject: [PATCH] add solution --- .github/workflows/test.yml-template | 29 +++++++++++++++ README.md | 12 +++---- package-lock.json | 9 ++--- package.json | 2 +- src/index.html | 38 ++++++++++++++++++-- src/styles/blocks/calendar.scss | 55 +++++++++++++++++++++++++++++ src/styles/blocks/page.scss | 7 ++++ src/styles/index.scss | 3 -- src/styles/main.scss | 3 ++ src/styles/variables.scss | 5 +++ 10 files changed, 146 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/test.yml-template create mode 100644 src/styles/blocks/calendar.scss create mode 100644 src/styles/blocks/page.scss delete mode 100644 src/styles/index.scss create mode 100644 src/styles/main.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/README.md b/README.md index 6a30283def..113944e8d8 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,13 @@ This is possible because [we use the Parcel library](https://en.parceljs.org/scs ❗️ Replace `` with your Github username and copy the links to `Pull Request` description: -- [DEMO LINK](https://.github.io/layout_calendar/) -- [TEST REPORT LINK](https://.github.io/layout_calendar/report/html_report/) +- [DEMO LINK](https://cuka9955-lang.github.io/layout_calendar/) +- [TEST REPORT LINK](https://cuka9955-lang.github.io/layout_calendar/report/html_report/) ❗️ Copy this `Checklist` to the `Pull Request` description after links, and put `- [x]` before each point after you checked it. -- [ ] Changing 'month-lengh' and 'start-day' modifier in the code element +- [x] Changing 'month-lengh' and 'start-day' modifier in the code element reflects in changing calendar layout -- [ ] Each day has no modifiers, only class (eg. calendar__day) -- [ ] All `Typical Mistakes` from `BEM` lesson theory are checked. -- [ ] Code follows all the [Code Style Rules ❗️](https://mate-academy.github.io/layout_task-guideline/html-css-code-style-rules) +- [x] Each day has no modifiers, only class (eg. calendar__day) +- [x] All `Typical Mistakes` from `BEM` lesson theory are checked. +- [x] Code follows all the [Code Style Rules ❗️](https://mate-academy.github.io/layout_task-guideline/html-css-code-style-rules) diff --git a/package-lock.json b/package-lock.json index 08a8b9f22b..4c0bd76c90 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", diff --git a/package.json b/package.json index 8ba3c05629..93bb0b7c11 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/src/index.html b/src/index.html index c10199d38b..d1b1f321a5 100644 --- a/src/index.html +++ b/src/index.html @@ -9,10 +9,42 @@ Calendar - -

Calendar

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/styles/blocks/calendar.scss b/src/styles/blocks/calendar.scss new file mode 100644 index 0000000000..525bda37ff --- /dev/null +++ b/src/styles/blocks/calendar.scss @@ -0,0 +1,55 @@ +.calendar { + display: flex; + flex-wrap: wrap; + gap: $gap; + padding: $padding; + box-sizing: border-box; + width: ($column * $cell-size) + (($column - 1) * $gap) + (2 * $padding); + + &__day { + display: flex; + align-items: center; + justify-content: center; + background-color: #eee; + width: $cell-size; + height: $cell-size; + border: 1px solid black; + box-sizing: border-box; + font-family: Arial, sans-serif; + font-size: 30px; + transition: + background-color 500ms, + transform 500ms; + + &:hover { + cursor: pointer; + background-color: #ffbfcb; + transform: translateY(-20px); + } + } + + @for $i from 1 through 31 { + &__day:nth-child(#{$i})::before { + content: '#{$i}'; + color: black; + } + } + + @for $length from 28 through 31 { + &--month-length-#{$length} { + .calendar__day:nth-child(n + #{$length + 1}) { + display: none; + } + } + } + + @each $day in $days-of-week { + $index: index($days-of-week, $day); + + &--start-day-#{$day} { + .calendar__day:first-child { + margin-left: ($index - 1) * ($cell-size + $gap); + } + } + } +} diff --git a/src/styles/blocks/page.scss b/src/styles/blocks/page.scss new file mode 100644 index 0000000000..a1bc832159 --- /dev/null +++ b/src/styles/blocks/page.scss @@ -0,0 +1,7 @@ +body { + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + margin: 0; +} diff --git a/src/styles/index.scss b/src/styles/index.scss deleted file mode 100644 index 293d3b1f13..0000000000 --- a/src/styles/index.scss +++ /dev/null @@ -1,3 +0,0 @@ -body { - margin: 0; -} diff --git a/src/styles/main.scss b/src/styles/main.scss new file mode 100644 index 0000000000..4e64eee153 --- /dev/null +++ b/src/styles/main.scss @@ -0,0 +1,3 @@ +@import './variables'; +@import './blocks/calendar'; +@import './blocks/page'; diff --git a/src/styles/variables.scss b/src/styles/variables.scss new file mode 100644 index 0000000000..f3212d3b86 --- /dev/null +++ b/src/styles/variables.scss @@ -0,0 +1,5 @@ +$column: 7; +$cell-size: 100px; +$gap: 1px; +$padding: 10px; +$days-of-week: (mon, tue, wed, thu, fri, sat, sun);