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 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 @@ -9,10 +9,42 @@
<title>Calendar</title>
<link
rel="stylesheet"
href="styles/index.scss"
href="./styles/blocks/index.scss"

Choose a reason for hiding this comment

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

The stylesheet link references an .scss file. Browsers cannot directly interpret SCSS files. Ensure that this file is compiled to CSS and link the resulting CSS file instead.

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

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. Otherwise, this calculation will not 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 assumes that $col-count, $cell-width, and $gap are defined and have valid values. Verify these variables are correctly set in the imported file.

}

@each $day, $number in $days-of-week {
@if $day == $current-day {

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 populated correctly. Otherwise, this conditional logic will not function as intended.

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

Choose a reason for hiding this comment

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

Verify that $month-length is defined and correctly represents the number of days in the current month. This loop hides days beyond the month's length.

&: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';
Loading