-
Notifications
You must be signed in to change notification settings - Fork 4.8k
add solution #5204
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
base: master
Are you sure you want to change the base?
add solution #5204
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,42 @@ | |
| <title>Calendar</title> | ||
| <link | ||
| rel="stylesheet" | ||
| href="styles/index.scss" | ||
| href="styles/main.scss" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the requirement: "Write styles in |
||
| /> | ||
| </head> | ||
| <body> | ||
| <h1>Calendar</h1> | ||
| <div class="calendar calendar--start-day-sun calendar--month-length-31"> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| <div class="calendar__day"></div> | ||
| </div> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| .calendar { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| gap: $gap; | ||
| padding: $padding; | ||
| width: calc($cell-size * $columns + $gap * ($columns - 1) + $padding * 2); | ||
| box-sizing: border-box; | ||
|
|
||
| &__day { | ||
| flex: 0 0 $cell-size; | ||
| width: $cell-size; | ||
| height: $cell-size; | ||
| background-color: $bg-color; | ||
| border: 1px solid $color-border-day; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| font-family: $font-family; | ||
| font-size: $font-size; | ||
| transition: | ||
| background-color 0.5s, | ||
| transform 0.5s; | ||
| } | ||
|
|
||
| &__day:hover { | ||
| cursor: pointer; | ||
| background-color: $bg-color-hover; | ||
| transform: translateY(-20px); | ||
| } | ||
|
|
||
| @for $i from 1 through 31 { | ||
| &__day:nth-child(#{$i})::before { | ||
| content: '#{$i}'; | ||
| } | ||
| } | ||
|
|
||
| @for $i from 28 through 30 { | ||
| &--month-length-#{$i} { | ||
| .calendar__day:nth-child(n + #{$i + 1}) { | ||
| display: none; | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+37
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item #1: 'Changing
Comment on lines
+37
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This @for loop only generates |
||
|
|
||
| @each $day, $index in $days { | ||
| &--start-day-#{$day} { | ||
| .calendar__day:first-child { | ||
| margin-left: ($cell-size + $gap) * $index; | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+45
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also violates checklist item #1: although you used
Comment on lines
+45
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| @import './variables'; | ||
| @import './calendar'; | ||
|
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The calendar import is present, but the weekday mapping used by the start-day modifiers is incorrect. In src/styles/variables.scss the $days map sets 'mon': 0 … 'sun': 6, and calendar.scss uses that map to compute margin-left for the first day. That mapping places Monday in the very first column (index 0) instead of the Monday column when the grid starts from Sunday. This causes .calendar--start-day-* modifiers to put the 1st on the wrong column and therefore does not satisfy the requirement that the month starts at the correct column (e.g. Monday should place the 1st under Monday). Suggest remapping so 'sun': 0, 'mon': 1, 'tue': 2, … 'sat': 6. See variables.scss and calendar.scss for the current implementation: . This also means changing the mapping is required so that changing the start-day modifier in the HTML (e.g. calendar--start-day-mon) reflects the correct layout, which is part of the checklist item: "Changing 'month-lengh' and 'start-day' modifier in the code element reflects in changing calendar layout". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. calendar.scss generates month-length modifiers with |
||
|
|
||
| *, | ||
| *::before, | ||
| *::after { | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| body { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| height: $body-height; | ||
| margin: 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| $cell-size: 100px; | ||
| $body-height: 100vh; | ||
| $font-family: Arial, sans-serif; | ||
| $gap: 1px; | ||
| $columns: 7; | ||
| $padding: 10px; | ||
| $bg-color: #eee; | ||
| $bg-color-hover: #ffbfcb; | ||
| $color-border-day: #000; | ||
| $font-size: 30px; | ||
| $days: ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not follow the Code Style requirement to "Use properly named variables to make all the calculations more clear." The name |
||
| 'mon': 0, | ||
| 'tue': 1, | ||
| 'wed': 2, | ||
| 'thu': 3, | ||
| 'fri': 4, | ||
| 'sat': 5, | ||
| 'sun': 6, | ||
|
Comment on lines
+11
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item: "- [ ] Changing 'month-lengh' and 'start-day' modifier in the code element reflects in changing calendar layout" — the $start-day-offsets: ( (Your current map in src/styles/variables.scss is the source of the problem: .) |
||
| ); | ||
|
Comment on lines
+11
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates checklist item #1: 'Changing $start-day-offsets: ( |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates the implementation requirement: "Write styles in src/styles/main.scss instead of src/style.css" — the link href points to "styles/main.scss". Update the stylesheet link to the required path, e.g.
href="src/styles/main.scss", so the project uses the correct SCSS file.