Skip to content

Commit

Permalink
add solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihakurochkin committed Nov 28, 2024
1 parent f12c803 commit 8469d0c
Show file tree
Hide file tree
Showing 4 changed files with 109 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/blocks/index.scss"
/>
</head>
<body>
<h1>Calendar</h1>
<div class="calendar">
<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>
59 changes: 59 additions & 0 deletions src/styles/blocks/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@import '../utils/variables';

body {
margin: 0;
padding-top: 25px;
}

.calendar {
display: flex;
gap: $gap;
flex-wrap: wrap;
width: $col-count * $cell-width + $gap * $col-count;
margin: 0 auto;

&__day {
display: flex;
font-family: Arial, Helvetica, sans-serif;
justify-content: center;
align-items: center;
font-size: 30px;
line-height: 100%;
box-sizing: border-box;
background-color: #eee;
width: $cell-width;
height: $cell-height;
border: 1px solid black;

&:first-child {
margin-left: ($col-count - 1) * $cell-width + $gap * ($col-count - 1);
}

@each $day, $number in $days-of-week {
@if $day == $current-day {
&:first-child {
margin-left: $number * $cell-width + $gap * $number;
}
}
}

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

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

@for $i from $month-length + 1 through 32 {
&:nth-child(#{$i}) {
display: none;
}
}
}
}
3 changes: 0 additions & 3 deletions src/styles/index.scss

This file was deleted.

16 changes: 16 additions & 0 deletions src/styles/utils/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$col-count: 7;
$gap: 1;
$cell-width: 100;
$cell-height: 100;
/* stylelint-disable */
$days-of-week:
'mon' 0,
'tue' 1,
'wed' 2,
'thu' 3,
'fri' 4,
'sat' 5,
'sun' 6;
/* stylelint-enable */
$month-length: 31;
$current-day: 'sun';

0 comments on commit 8469d0c

Please sign in to comment.