-
Notifications
You must be signed in to change notification settings - Fork 5k
solution: layout calendar #5461
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?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| .calendar { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| gap: $calendar-space-size; | ||
| width: $calendar-week-size; | ||
| padding: $calendar-padding-size; | ||
|
|
||
| @each $day, $index in $weekdays { | ||
| &--start-day-#{$day} &__day:first-child { | ||
| margin-left: ($index - 1) * ($calendar-day-size + $calendar-space-size); | ||
| } | ||
| } | ||
|
|
||
| @for $length from 28 through 31 { | ||
| &--month-length-#{$length} &__day:nth-child(n + #{$length + 1}) { | ||
| display: none; | ||
| } | ||
| } | ||
|
|
||
| &__day { | ||
| @include flex-center; | ||
|
|
||
| width: $calendar-day-size; | ||
| height: $calendar-day-size; | ||
| border: 1px solid $color-black; | ||
| background-color: $color-gray; | ||
| cursor: default; | ||
| transition: | ||
| transform $transition-duration, | ||
| background-color $transition-duration; | ||
| box-sizing: border-box; | ||
| font-family: $font-arial; | ||
|
|
||
| @for $day from 1 through 31 { | ||
| &:nth-child(#{$day}) { | ||
| &::before { | ||
| content: '#{$day}'; | ||
| font-size: $calendar-font-size; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| &:hover { | ||
| cursor: pointer; | ||
| background-color: $color-day-hover; | ||
| transform: translateY(-$translate-size-y); | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| @import './utils/variables'; | ||
| @import './utils/mixin'; | ||
| @import './blocks/calendar'; | ||
|
|
||
| html, | ||
| body { | ||
| box-sizing: border-box; | ||
| padding: 0; | ||
| margin: 0; | ||
| } | ||
|
|
||
| .main { | ||
| @include flex-center; | ||
|
|
||
| width: 100%; | ||
| min-height: 100vh; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @mixin flex-center { | ||
|
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 import path |
||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // colors | ||
| $color-gray: #eee; | ||
| $color-black: #000; | ||
| $color-day-hover: #ffbfcb; | ||
|
|
||
| // fonts | ||
| $font-arial: 'Arial', sans-serif; | ||
|
|
||
| // options transform | ||
| $translate-size-y: 20px; | ||
| $transition-duration: 0.5s; | ||
|
|
||
| // options calendar | ||
| $calendar-day-size: 100px; | ||
| $calendar-space-size: 1px; | ||
| $calendar-week-size: calc( | ||
| ($calendar-day-size * 7) + ($calendar-space-size * 6) | ||
| ); | ||
| $calendar-padding-size: 10px; | ||
| $calendar-font-size: 30px; | ||
| $weekdays: ( | ||
| 'mon': 1, | ||
| 'tue': 2, | ||
| 'wed': 3, | ||
| 'thu': 4, | ||
| 'fri': 5, | ||
| 'sat': 6, | ||
| 'sun': 7, | ||
| ); |
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.
The current
$weekdaysmap ('mon': 0, 'tue': 1, ..., 'sun': 6) makes Monday start at column 0 instead of column 1, so forcalendar--start-day-monthe first day is not rendered in the 2nd column as required (“The month should start at the correct column (Monday is the 1st, Friday is the 5th)”). Adjust the indices so that the visual columns match the required positions.