Skip to content

Commit

Permalink
made calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
SaXoNG committed Dec 16, 2024
1 parent f12c803 commit a7b0dd4
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 5 deletions.
38 changes: 36 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- #region head -->
<!doctype html>
<html lang="en">
<head>
Expand All @@ -9,10 +10,43 @@
<title>Calendar</title>
<link
rel="stylesheet"
href="styles/index.scss"
href="styles/main.scss"
/>
</head>
<!-- #endregion -->
<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>
46 changes: 46 additions & 0 deletions src/styles/blocks/calendar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.calendar {
font-size: 30px;
$square-paddings: 10px;
display: flex;
flex-wrap: wrap;
gap: $square-spacing;
width: $calendar-width;

&__day {
@include square($square-size);

background-color: $background-color;
text-align: center;
line-height: $square-size;
cursor: pointer;
border: 1px solid black;
transition:
transform 500ms,
background-color 500ms;

&:hover {
background-color: $background-color-hover;
transform: translateY(-20px);
}

@for $i from 1 through 31 {
&:nth-child(#{$i})::before {
content: '#{$i}';
}
}
}

&--month-length {
@for $i from 28 through 31 {
&--#{$i} :nth-child(n + #{$i + 1}) {
display: none;
}
}
}

@each $day, $count in $start-days {
&--start-day--#{$day} :first-child {
margin-left: #{$count};
}
}
}
3 changes: 0 additions & 3 deletions src/styles/index.scss

This file was deleted.

6 changes: 6 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import './utils/reset';
@import './utils/normalize';
@import './utils/variables';
@import './utils/colors';
@import './utils/mixins';
@import './blocks/calendar';
2 changes: 2 additions & 0 deletions src/styles/utils/_colors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$background-color: #eee;
$background-color-hover: #ffbfcb;
4 changes: 4 additions & 0 deletions src/styles/utils/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@mixin square($size) {
width: $size;
height: $size;
}
3 changes: 3 additions & 0 deletions src/styles/utils/_normalize.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html {
font-family: Arial, Helvetica, sans-serif;
}
7 changes: 7 additions & 0 deletions src/styles/utils/_reset.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* {
box-sizing: border-box;
}

body {
margin: 0;
}
13 changes: 13 additions & 0 deletions src/styles/utils/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$square-size: 100px;
$square-paddings: 10px;
$square-spacing: 1px;
$calendar-width: $square-size * 7 + $square-paddings * 2 + $square-spacing * 8;
$one-day-margin: $square-size + $square-spacing;
$start-days: // stylelint-disable-line scss/dollar-variable-colon-space-after
'mon' 0,
'tue' $one-day-margin,
'wed' $one-day-margin * 2,
'thu' $one-day-margin * 3,
'fri' $one-day-margin * 4,
'sat' $one-day-margin * 5,
'sun' $one-day-margin * 6;

0 comments on commit a7b0dd4

Please sign in to comment.