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

Develop #3926

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Develop #3926

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 href attribute is pointing to a SCSS file (styles/main.scss). Browsers cannot directly interpret SCSS files. You need to compile the SCSS into a CSS file and link to that CSS file instead.

/>
</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>
9 changes: 9 additions & 0 deletions src/styles/blocks/page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
body {
justify-content: center;

Choose a reason for hiding this comment

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

Using justify-content on the body element requires the body to be a flex container, which is correctly set on line 7. However, ensure that the body has a defined height or width to see the centering effect.

align-items: center;

Choose a reason for hiding this comment

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

Using align-items on the body element requires the body to be a flex container, which is correctly set on line 7. Ensure that the body has a defined height or width to see the centering effect.

height: 100dvh;
font-family: Arial, sans-serif;
font-size: 30px;
display: flex;
margin: 0;
}
3 changes: 0 additions & 3 deletions src/styles/index.scss

This file was deleted.

12 changes: 12 additions & 0 deletions src/styles/init/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$widthDays: 100px;
$heightDays: 100px;
$gapDays: 1px;
$calendar: 'mon' 0,
'tue' 1,
'wed' 2,
'thu' 3,
'fri' 4,
'sat' 5,
'sun' 6;
$month-length: 31;
$start-day: 'wed';
57 changes: 57 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@import './init/variables';
@import './blocks/page';

.calendar {
flex-wrap: wrap;
gap: 1px;
padding: 10px;
display: flex;
width: ($widthDays + $gapDays) * 7;

Choose a reason for hiding this comment

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

The calculation for the calendar width ($widthDays + $gapDays) * 7 assumes that the gap is included in the width of each day. Ensure that this calculation aligns with your design expectations, as the gap might need to be subtracted if it's not part of the width.


@for $i from 1 through $month-length {
&--month-length-31 :nth-child(#{$i}),
&--month-length-30 :nth-child(#{$i}),
&--month-length-29 :nth-child(#{$i}),
&--month-length-28 :nth-child(#{$i}) {
width: $widthDays;
height: $heightDays;
box-sizing: border-box;
border: 1px solid black;
background-color: #eee;
position: relative;
transition-property: transform, background-color;
transition-duration: 0.5s;
cursor: pointer;
}
}

&--month-length-30 :nth-child(n + 31),
&--month-length-29 :nth-child(n + 30),
&--month-length-28 :nth-child(n + 29) {
visibility: hidden;
}

@for $i from 1 through $month-length {
& :nth-child(#{$i}):before {
content: '#{$i}';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
}
}

&__day:hover {
background-color: #ffbfcb;
transform: translate(0, -20px);
}

@each $day, $i in $calendar {
&--start-day-#{$day} :first-child {
margin-left: ($widthDays + $gapDays) * $i;
}
}
}
Loading