Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
osidanych committed Dec 17, 2024
1 parent 7f98364 commit 57c3f17
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,38 @@
/>
</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>
72 changes: 72 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,75 @@
$cell-size: 100px;
$gap: 1px;
$days: (
'mon': 0,
'tue': 1,
'wed': 2,
'thu': 3,
'fri': 4,
'sat': 5,
'sun': 6,
);

html {
font-family: Arial, Helvetica, sans-serif;
font-size: 30px;
}

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

.calendar {
display: flex;
flex-wrap: wrap;
gap: 1px;
padding: 10px;
width: calc($cell-size * 7 + $gap * 6);

&__day {
box-sizing: border-box;
display: flex;
width: 100px;
height: 100px;
border: 1px solid black;
background-color: #eee;
justify-content: center;
align-items: center;
transition-duration: 0.5s;
&:hover {
cursor: pointer;
background-color: #ffbfcb;
transform: translateY(-20px);
}
}
}

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

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

@each $day, $i in $days {
.calendar--start-day-#{$day} .calendar__day:first-child {
margin-left: calc(#{$i} * $cell-size + #{$i * $gap});
}
}

@each $day, $i in $days {
.calendar--start-day-#{$day} {
.calendar__day:first-child {
margin-left: ($cell-size + $gap) * $i;
}
}
}

0 comments on commit 57c3f17

Please sign in to comment.