Skip to content
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
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ Display a calendar in the middle of the screen (both horizontally and vertically
- Set 31 days by default in your HTML

On hovering over a cell:

- cursor should become pointer
- The hovered cell has to become pink (use `#FFBFCB`)
- Move the hovered cell up by `20px` (use `transform`)
- All changes should be animated with the duration of 0.5s

> Here are the [Layout Tasks Instructions](https://mate-academy.github.io/layout_task-guideline)

*Important note*: In this task, you are allowed to link `*.scss` files directly in HTML `<link>` tags using `href` attribute.
_Important note_: In this task, you are allowed to link `*.scss` files directly in HTML `<link>` tags using `href` attribute.
This is possible because [we use the Parcel library](https://en.parceljs.org/scss.html) to bundle your solution's source code.

![reference image](reference.png).
Expand All @@ -36,13 +37,13 @@ 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://damian-k-dev.github.io/layout_calendar/)
- [TEST REPORT LINK](https://damian-k-dev.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.

- [ ] Changing 'month-lengh' and 'start-day' modifier in the code element
reflects in changing calendar layout
- [ ] Each day has no modifiers, only class (eg. calendar__day)
- [ ] All `Typical Mistakes` from `BEM` lesson theory are checked.
- [ ] Code follows all the [Code Style Rules ❗️](https://mate-academy.github.io/layout_task-guideline/html-css-code-style-rules)
- [x] Changing 'month-lengh' and 'start-day' modifier in the code element
reflects in changing calendar layout
- [x] Each day has no modifiers, only class (eg. calendar\_\_day)
- [x] All `Typical Mistakes` from `BEM` lesson theory are checked.
- [x] Code follows all the [Code Style Rules ❗️](https://mate-academy.github.io/layout_task-guideline/html-css-code-style-rules)
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>
76 changes: 76 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,79 @@
$black: #000;
$grey: #eee;
$pink: #ffbfcb;
$calendar-size: 706px;
$field-size: calc(($calendar-size - 6px) / 7);

* {
box-sizing: border-box;
}

body {
height: 100vh;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
}

.calendar {
width: $calendar-size;
height: $calendar-size;

Choose a reason for hiding this comment

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

You've set a fixed height for the calendar, making it a square. This doesn't adapt to the content, which can have a varying number of rows (e.g., 5 or 6) depending on the month's start day. A fixed height can create unnecessary empty space inside the calendar block. The height should be determined by its content.

display: flex;
flex-wrap: wrap;
align-content: center;
gap: 1px;

&__day {
flex-basis: $field-size;
height: $field-size;
padding: 10px;
border: 1px solid $black;
display: flex;
align-items: center;
justify-content: center;
background-color: $grey;
transition:
background-color 0.5s,
transform 2s;
&:hover {
background-color: $pink;
transform: translateY(-20px);
cursor: pointer;
}
}

@for $index from 1 through 31 {
&__day:nth-child(#{$index})::before {
content: '#{$index}';
font-family: Arial, sans-serif;
font-size: 30px;
}
}

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

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

Choose a reason for hiding this comment

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

This calculation will likely fail during Sass compilation. You are trying to add a unitless number ($index) to a pixel value ($index * $field-size), which is not allowed. To fix this, you need to ensure the units are compatible. You should add the total width of the gaps, which can be calculated as $index * 1px.

}
}
}

@for $length from 28 through 31 {
&--month-length-#{$length} {
.calendar__day:nth-child(n + #{$length + 1}) {
display: none;
}
}
}
}