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 #3923

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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ This is possible because [we use the Parcel library](https://en.parceljs.org/scs

❗️ Replace `<your_account>` with your Github username and copy the links to `Pull Request` description:

- [DEMO LINK](https://<your_account>.github.io/layout_calendar/)
- [TEST REPORT LINK](https://<your_account>.github.io/layout_calendar/report/html_report/)
- [DEMO LINK](https://leraMeleshchenko.github.io/layout_calendar/)
- [TEST REPORT LINK](https://leraMeleshchenko.github.io/layout_calendar/report/html_report/)

❗️ Copy this `Checklist` to the `Pull Request` description after links, and put `- [x]` before each point after you checked it.

Expand Down
34 changes: 33 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,38 @@
/>
</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>
63 changes: 63 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

$day-size: 100px;
$gap: 1px;

.calendar {
max-width: calc($day-size * 7 + $gap * 6);
display: flex;
flex-wrap: wrap;
gap: $gap;
padding: 10px;
&__day {
background-color: #eee;
position: relative;
box-sizing: border-box;
width: $day-size;
height: $day-size;
border: 1px solid black;
display: flex;
justify-content: center;
align-items: center;

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

@for $i from 1 to 32 {
.calendar :nth-child(#{$i}):after {
content: '#{$i}';
font-family: Arial, Helvetica, sans-serif;
font-size: 30px;
}

Choose a reason for hiding this comment

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

The selector .calendar :nth-child(#{$i}):after may not work as intended because the space before :nth-child makes it a descendant combinator. This means it will select any element that is the nth child of its parent, not necessarily the direct children of .calendar. Consider removing the space to target direct children.

}

$days: (
mon: 0,
tue: 1,
wed: 2,
thu: 3,
fri: 4,
sat: 5,
sun: 6,
);

@each $day, $index in $days {
.calendar--start-day-#{$day} :first-child {
margin-left: ($day-size + $gap) * $index;
}

Choose a reason for hiding this comment

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

The selector .calendar--start-day-#{$day} :first-child may not work as intended due to the space before :first-child, which makes it a descendant combinator. This will select any first child of any element within .calendar--start-day-#{$day}. Consider removing the space to target the first child of .calendar--start-day-#{$day} directly.

}

@for $i from 28 to 31 {
.calendar--month-length-#{$i} :nth-child(n + #{$i + 1}) {
display: none;
}
}
Loading