diff --git a/src/index.html b/src/index.html index c10199d38..e0615db44 100644 --- a/src/index.html +++ b/src/index.html @@ -9,10 +9,43 @@ Calendar

Calendar

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/styles/main.scss b/src/styles/main.scss new file mode 100644 index 000000000..0a536637a --- /dev/null +++ b/src/styles/main.scss @@ -0,0 +1,61 @@ +@import './utils/variables'; + +body { + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + margin: 0; +} + +.calendar { + font-family: Arial, sans-serif; + font-size: 30px; + display: flex; + flex-wrap: wrap; + gap: 1px; + width: $width-calendar; + margin: auto; + + @each $name, $number in $week-day { + &--start-day-#{$name} > :first-child { + margin-left: (($number - 1) * $width-square) + ($number - 1); + } + } + + &--month-length-28 > :nth-last-child(-n + 3) { + display: none; + } + + &--month-length-29 > :nth-last-child(-n + 2) { + display: none; + } + + &--month-length-30 > :nth-last-child { + display: none; + } + + &__day { + background-color: #eee; + width: $width-square; + height: $width-square; + border: 1px solid black; + box-sizing: border-box; + + text-align: center; + line-height: $width-square; + + @for $i from 1 through $month-length { + &:nth-child(#{$i})::before { + content: '#{$i}'; + } + } + + &:hover { + cursor: pointer; + background-color: #ffbfcb; + transform: translateY(-20px); + transition-duration: 0.5s; + } + } +} diff --git a/src/styles/utils/mixins.scss b/src/styles/utils/mixins.scss new file mode 100644 index 000000000..a7dbcca7c --- /dev/null +++ b/src/styles/utils/mixins.scss @@ -0,0 +1,7 @@ +.calendar { + @each $name, $number in $week-day { + &--start-day--#{name} { + margin-left: (($number - 1) * $width-square) + ($number - 1); + } + } +} diff --git a/src/styles/utils/variables.scss b/src/styles/utils/variables.scss new file mode 100644 index 000000000..ce5742456 --- /dev/null +++ b/src/styles/utils/variables.scss @@ -0,0 +1,4 @@ +$width-square: 100px; +$width-calendar: ($width-square * 7) + 10px; +$week-day: ('mon' 1, 'tue' 2, 'wed' 3, 'thu' 4, 'fri' 5, 'sat' 6, 'sun' 7); +$month-length: 31;