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

calendar added #1070

Open
wants to merge 1 commit into
base: main
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
Binary file added assets/image/download.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,15 @@ <h3 class="card-heading">Othello Game</h3>
</div>
</a>
<!--============================== End =========================================== -->
<a href="projects/calander/index.html" class="card" target="_blank">
<div class="card-cover counter-cover-colour">
<img src="./assets/image/download.jpg" alt="Othello Game" style="width: 10rem; height: auto;">
</div>
<div class="card-content">
<h3 class="card-heading">Calender</h3>
<p class="card-description">A calendar is a tool that helps organize days so we can keep track of important dates and plan events easily. </p>
</div>
</a>



Expand Down
81 changes: 81 additions & 0 deletions projects/calander/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<title>Calendar</title>
</head>
<body>
<section>
<h1 class="heading">My Calendar</h1>
</section>
<section>
<div class="container">
<div class="calendar">
<div class="month">
<i class="fas fa-angle-left prev"></i>
<div class="date">
<h1></h1>
<p></p>
</div>
<i class="fas fa-angle-right next"></i>
</div>
<div class="week">
<div class="Sun">Sun</div>
<div class="Mon">Mon</div>
<div class="Tue">Tue</div>
<div class="Wed">Wed</div>
<div class="Thu">Thu</div>
<div class="Fri">Fri</div>
<div class="Sat">Sat</div>
</div>
<div class="days">
<div class="prev-date">28</div>
<div class="prev-date">29</div>
<div class="prev-date">30</div>
<div class="prev-date">31</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div class="today">21</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div class="next-date">1</div>
<div class="next-date">2</div>
<div class="next-date">3</div>
<div class="next-date">4</div>
</div>

</div>
</div>
</section>
<script src="index.js"></script>
</body>
</html>
74 changes: 74 additions & 0 deletions projects/calander/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const date = new Date();
const renderCalender = () => {
const monthDays = document.querySelector(".days");
const lastDay = new Date(
date.getFullYear(),
date.getMonth() + 1,
0
).getDate();
const firstDay = new Date(date.getFullYear(), date.getMonth()).getDay();
const prevLastDay = new Date(
date.getFullYear(),
date.getMonth(),
0
).getDate();
console.log(prevLastDay)
console.log(firstDay)
const lastDayIndex = new Date(
date.getFullYear(),
date.getMonth() + 1,
0
).getDay();
const nextDay = 7 - lastDayIndex - 1;

let months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];

document.querySelector(".date h1").innerHTML = months[date.getMonth()];

document.querySelector(".date p").innerHTML = date.toDateString();

let days = "";

for (let x = firstDay; x > 0; x--) {
days += `<div class="prev-date"> ${prevLastDay - x +1 } </div>`;
}

for (let i = 1; i <= lastDay; i++) {
if (
i === new Date().getDate() &&
date.getMonth() === new Date().getMonth()
) {
days += `<div class="today">${i}</div>`;
} else {
days += `<div> ${i} </div>`;
monthDays.innerHTML = days;
}
}

for (let j = 1; j <= nextDay; j++) {
days += `<div class="next-date"> ${j} </div>`;
monthDays.innerHTML = days;
}
};
document.querySelector(".prev").addEventListener("click", () => {
date.setMonth(date.getMonth() - 1);
renderCalender();
});
document.querySelector(".next").addEventListener("click", () => {
date.setMonth(date.getMonth() + 1);
renderCalender();
});
renderCalender();
108 changes: 108 additions & 0 deletions projects/calander/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
:root{
--primary: #FFEFBA;
--secondary: #FFFFFF;

}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;

}
html{
font-size: 10px;
}
.heading{
font-size: 70px;
align-items: center;
text-align: center;
font-style: italic;
padding-top: 10px;
}
.container{
width: 100%;
height: 500px;
background: linear-gradient(100deg,var(--primary),var(--tertiary));
color: white;
display: flex;
justify-content: center;
align-items: center;

}
.calendar{
width: 400px;
background-color: rgb(14, 71, 69);
box-shadow: 0 0.5rem 3rem rgb(0, 0, 0);
}
.month{
width: 100%;
background-color: rgb(42, 207, 202);
display: flex;
align-items: center;
justify-content: space-between;
text-align: center;
padding: 15px 10px;
}
.month i{
cursor: pointer;
font-size: large;
font-weight: bolder;

}
.date h1{
font-weight: 800px;
text-transform: uppercase;
}
.date p{
font-size: large;
margin: 3px;
}
.week{
width: 100%;
display: flex;
align-items: center;
padding: 10px 0px;
}
.week div{
justify-content: space-around;
font-weight: 700;
width: calc(100%/7);
display: flex;
align-items: center;
justify-content: center;
font-size: larger;

}
.days{
display: flex;
align-items: center;
flex-wrap: wrap;
font-weight: 700;
font-size: larger;
}
.days div{
width: calc(72%/7);
align-items: center;
justify-content: center;
display: flex;
padding: 9px ;
margin: 2%;
}
.days div:hover:not(.today){
background-color: rgb(184, 244, 224);
color: black;
cursor: pointer;
border-radius: 50%;
}
.next-date{
opacity: 0.5;
}
.prev-date{
opacity: 0.5;
}
.today{
background-color: aquamarine;
border-radius: 100%;
cursor: pointer;
}