Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
West-u committed Dec 1, 2024
1 parent f94d7dd commit ff98282
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,38 @@
/>
</head>
<body>
<h1>Calendar</h1>
</body>
<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>
68 changes: 68 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
$day__size: 100px;
$calendar__padding: 10px;
$day__gap: 1px;
$color__grey: #eee;

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
margin: 0;
padding: 0;
box-sizing: border-box;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}

.calendar {
display: flex;
flex-wrap: wrap;
gap: $day__gap;
padding: $calendar__padding;
width: calc(7 * $day__size + 6 * $day__gap + 2 * $calendar__padding);
&__day {
display: flex;
justify-content: center;
align-items: center;
height: $day__size;
width: $day__size;
border: 1px solid black;
background-color: $color__grey;
font-size: 30px;
font-family: Arial, sans-serif;
text-align: center;
transition: 0.5s;
color: black;

&:hover {
cursor: pointer;
background-color: #ffbfcb;
transform: translateY(-20px);
}

&::before {
content: '';
}
}

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

@each $day, $offset in (mon: 0, tue: 1, wed: 2, thu: 3, fri: 4, sat: 5, sun: 6)
{
.calendar--start-day-#{$day} .calendar__day:first-child {
margin-left: calc($offset * ($day__size + $day__gap));
}
}

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

0 comments on commit ff98282

Please sign in to comment.