Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
wiltonmartinsdev committed Dec 19, 2024
1 parent f12c803 commit d827fcb
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 5 deletions.
36 changes: 34 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,42 @@
<title>Calendar</title>
<link
rel="stylesheet"
href="styles/index.scss"
href="./styles/main.scss"
/>
</head>
<body>
<h1>Calendar</h1>
<div class="calendar calendar--month-length-31 calendar--start-day-sun">
<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>
3 changes: 0 additions & 3 deletions src/styles/index.scss

This file was deleted.

98 changes: 98 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

$day-size: 100px;
$border-width: 1px;
$gap-size: 1px;
$padding-size: 10px;
$days-per-row: 7;
$transition-duration: 0.5s;
$hover-offset: 20px;
$start-days: (
mon: 0,
tue: 1,
wed: 2,
thu: 3,
fri: 4,
sat: 5,
sun: 6,
);

body {
display: flex;
justify-content: center;
align-items: center;

height: 100vh;
}

.calendar {
display: flex;
flex-wrap: wrap;
gap: $gap-size;

padding: $padding-size;

width: calc(
#{$day-size * $days-per-row} + #{$gap-size * ($days-per-row - 1)} + #{(
$padding-size * 2
)}
);

&__day {
width: $day-size;
height: $day-size;

background: #eee;

border: $border-width solid black;

position: relative;

cursor: pointer;

transition:
transform $transition-duration,
background-color $transition-duration;

&::before {
content: '';

position: absolute;
top: 50%;
left: 50%;

transform: translate(-50%, -50%);

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

&:hover {
background: #ffbfcb;

transform: translateY(-$hover-offset);
}
}

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

@each $day, $index in $start-days {
&--start-day-#{$day} &__day:first-child {
margin-left: calc(#{($day-size + $gap-size) * $index});
}
}

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

0 comments on commit d827fcb

Please sign in to comment.