You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lightweight, responsive calendar widget built with vanilla JavaScript. This project demonstrates DOM manipulation, Date object handling, and local state management without external libraries.
3
+
A lightweight, responsive calendar widget built with **vanilla JavaScript**.
4
+
This project demonstrates **DOM manipulation**, **Date object handling**, and **local state management** without external libraries.
5
+
6
+
---
4
7
5
8
## 🚀 Features
6
9
7
10
-**Dynamic Rendering:** Automatically generates the correct grid for any month and year.
8
11
-**Navigation:** Browse through past and future months.
9
-
-**Current Date Highlighting:**visual indicator for today's date.
12
+
-**Current Date Highlighting:**Visual indicator for today's date.
10
13
-**Event Management (Bonus):** Click any date to add, view, or delete notes.
11
14
-**Data Persistence:** Events are saved to the browser's `localStorage`, so they remain after refreshing the page.
12
15
-**Responsive Design:** Built with CSS Grid to adapt to different screen sizes.
13
16
17
+
---
18
+
14
19
## 🛠️ Technologies Used
15
20
16
-
-**HTML5:** Semantic structure.
17
-
-**CSS3:** Flexbox and Grid layout; CSS Variables for theming.
18
-
-**JavaScript (ES6+):** Logic for date calculation and event handling.
21
+
-**HTML5:** Semantic structure
22
+
-**CSS3:** Flexbox and Grid layout, CSS Variables for theming
23
+
-**JavaScript (ES6+):** Date calculation and event handling logic
24
+
25
+
---
19
26
20
27
## 📂 Project Structure
21
28
22
29
```text
23
30
interactive-calendar/
24
31
├── index.html # Main HTML structure
25
32
├── style.css # Styling and Grid layout
26
-
├── script.js # Calendar logic and Event handling
33
+
├── script.js # Calendar logic and event handling
27
34
└── README.md # Project documentation
35
+
```
36
+
37
+
---
38
+
39
+
## 💡 How It Works
28
40
29
-
##💡 How It Works
30
-
1. Date Calculation
31
-
The calendar grid is calculated using the native Date object:
41
+
### 1. Date Calculation
32
42
33
-
Start Day: new Date(year, month, 1).getDay() determines which day of the week the month starts on (0=Sunday, 1=Monday).
43
+
The calendar grid is calculated using the native `Date` object:
34
44
35
-
Total Days: new Date(year, month + 1, 0).getDate() retrieves the exact number of days in the current month.
45
+
-**Start Day:**
46
+
`new Date(year, month, 1).getDay()`
47
+
Determines which day of the week the month starts on
48
+
`(0 = Sunday, 1 = Monday, ...)`
36
49
37
-
2. Rendering the Grid
38
-
We use a loop to generate <div> elements.
50
+
-**Total Days:**
51
+
`new Date(year, month + 1, 0).getDate()`
52
+
Retrieves the exact number of days in the current month
39
53
40
-
First, we insert empty placeholder divs to align the 1st of the month with the correct weekday column.
54
+
---
41
55
42
-
Then, we generate the actual numbered days.
56
+
### 2. Rendering the Grid
43
57
44
-
3. State Management
45
-
Events are stored in a simple JSON object and saved to LocalStorage:
58
+
- A loop generates `<div>` elements for the calendar.
59
+
- Empty placeholder divs are inserted to align the first day of the month correctly.
60
+
- Numbered day cells are then rendered dynamically.
46
61
47
-
JavaScript
62
+
---
63
+
64
+
### 3. State Management
65
+
66
+
Events are stored in a simple JSON object and persisted using `localStorage`.
0 commit comments