Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add task solution #3961

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,39 @@
href="styles/index.scss"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The href attribute is linking to a .scss file. Typically, .scss files are not directly used in HTML as they need to be compiled into .css files. Ensure that the Sass file is compiled into a CSS file and link the resulting CSS file here.

/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HTML file is linking to a .scss file. You should compile your SCSS into a CSS file and link to that CSS file instead. This is crucial for the stylesheet to be applied correctly.

</head>
<body>
<h1>Calendar</h1>
<body class="page">
<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>
61 changes: 60 additions & 1 deletion src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
$daySize: 100px;
$countDays: 31;
$gapValue: 1px;
$calendarWidth: $daySize * 7 + 10;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calculation for $calendarWidth does not account for the gaps between the days. Since there are 6 gaps in a 7-day week, consider updating the calculation to $calendarWidth: $daySize * 7 + $gapValue * 6; to ensure the width includes these gaps.

$daysOfWeek: ('mon' 1, 'tue' 2, 'wed' 3, 'thu' 4, 'fri' 5, 'sat' 6, 'sun' 7);
$startDay: 'sun';

body {
margin: 0;
display: flex;
justify-content: center;
margin-top: 82px;
font-family: Arial, Helvetica, sans-serif;
font-size: 30px;
}

.calendar {
display: flex;
flex-wrap: wrap;
padding-inline: 10px;
gap: $gapValue;
max-width: $calendarWidth;
}

.calendar__day {
display: flex;
box-sizing: border-box;
justify-content: center;
align-items: center;
background-color: #eee;
border: 1px solid black;
height: $daySize;
width: $daySize;
}

.calendar__day:hover {
cursor: pointer;
background-color: #ffbfcb;
transition-duration: 0.5s;
transform: translateY(-20px);
}

@for $dayNumber from 1 through 31 {
@if $dayNumber <= $countDays {
.calendar__day:nth-child(#{$dayNumber})::before {
content: '#{$dayNumber}';
}
}

@if $dayNumber > $countDays {
.calendar__day:nth-child(#{$dayNumber}) {
display: none;
}
}
}

@each $name, $value in $daysOfWeek {
@if $startDay == $name {
.calendar--start-day-sun .calendar__day:first-child {
margin-left: ($value * ($daySize + $gapValue)) - ($daySize + $gapValue);
}
}
}
Loading