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 solution #3977

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -9,10 +9,42 @@
<title>Calendar</title>
<link
rel="stylesheet"
href="styles/index.scss"
href="./styles/main.scss"

Choose a reason for hiding this comment

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

The HTML file links to a .scss file, which browsers cannot interpret. Please compile your SCSS to CSS and update the link to point to the compiled CSS file.

/>
</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>
3 changes: 0 additions & 3 deletions src/styles/index.scss

This file was deleted.

65 changes: 65 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@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;

Choose a reason for hiding this comment

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

Ensure that the variables $col-count, $cell-width, and $gap are defined in the imported variables file. This line uses these variables for calculating the width, and they must be correctly set for the layout to work as expected.

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);

Choose a reason for hiding this comment

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

The calculation for margin-left in &:first-child seems to be incorrect. It should account for the starting day of the week. Verify that the logic aligns with the intended layout.

}

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

Choose a reason for hiding this comment

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

Ensure that $days-of-week and $current-day are defined and correctly used. This logic is intended to adjust the margin based on the current day, and it must be accurate for the calendar to display correctly.

}
}
}

&: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 {

Choose a reason for hiding this comment

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

The loop for hiding days beyond the $month-length should be verified. Ensure that $month-length is set correctly to reflect the actual number of days in the month.

&:nth-child(#{$i}) {
display: none;
}
}

@for $i from 28 through 31 {
.calendar--month-length-#{$i} .calendar__day:nth-child(n + #{$i + 1}) {
display: none;
}
}
}
}
15 changes: 15 additions & 0 deletions src/styles/utils/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$col-count: 7;
$gap: 1;
$cell-width: 100;
$cell-height: 100;
$days-of-week: (
'mon': 0,
'tue': 1,
'wed': 2,
'thu': 3,
'fri': 4,
'sat': 5,
'sun': 6,
);
$month-length: 31;
$current-day: 'sun';
Loading