Sure! Below is a complete HTML file that includes HTML, CSS, and JavaScript to create a fully functional and visually appealing Study Planner App. This app allows you to add, edit, delete, and mark tasks as completed. It also stores your tasks in the browser's local storage so that your data persists even after refreshing the page.
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Study Planner App</title>
<style>
/* Reset & Basic Styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
/* Container */
.container {
background-color: #ffffffcc;
backdrop-filter: blur(10px);
border-radius: 15px;
width: 100%;
max-width: 800px;
padding: 30px;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}
/* Header */
.header {
text-align: center;
margin-bottom: 30px;
}
.header h1 {
font-size: 2.5rem;
color: #333;
}
/* Form Styles */
.task-form {
display: flex;
flex-wrap: wrap;
gap: 15px;
margin-bottom: 30px;
}
.task-form input, .task-form textarea, .task-form button {
padding: 10px;
border: none;
border-radius: 8px;
font-size: 1rem;
}
.task-form input, .task-form textarea {
flex: 1 1 200px;
background-color: #f0f0f0;
}
.task-form input:focus, .task-form textarea:focus {
outline: none;
background-color: #e0e0e0;
}
.task-form button {
background-color: #4CAF50;
color: white;
cursor: pointer;
flex: 1 1 100px;
transition: background-color 0.3s ease;
}
.task-form button:hover {
background-color: #45a049;
}
/* Task List */
.task-list {
list-style: none;
}
.task-item {
background-color: #fafafa;
padding: 15px;
margin-bottom: 15px;
border-left: 5px solid #4CAF50;
border-radius: 8px;
display: flex;
flex-direction: column;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
transition: background-color 0.3s ease;
}
.task-item.completed {
background-color: #e0ffe0;
border-left-color: #2196F3;
text-decoration: line-through;
color: #555;
}
.task-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.task-header h3 {
font-size: 1.2rem;
color: #333;
}
.task-header .task-actions button {
background: none;
border: none;
cursor: pointer;
margin-left: 10px;
font-size: 1.1rem;
transition: color 0.3s ease;
}
.task-header .task-actions button:hover {
color: #4CAF50;
}
.task-desc {
margin: 10px 0;
color: #555;
}
.task-meta {
display: flex;
justify-content: space-between;
font-size: 0.9rem;
color: #777;
}
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.5);
justify-content: center;
align-items: center;
}
.modal-content {
background-color: #fff;
padding: 20px;
border-radius: 10px;
width: 90%;
max-width: 500px;
position: relative;
}
.close {
position: absolute;
top: 15px;
right: 20px;
font-size: 1.5rem;
font-weight: bold;
color: #aaa;
cursor: pointer;
}
.close:hover {
color: #000;
}
.modal-form input, .modal-form textarea, .modal-form button {
width: 100%;
padding: 10px;
margin-top: 10px;
border: none;
border-radius: 8px;
font-size: 1rem;
}
.modal-form input, .modal-form textarea {
background-color: #f0f0f0;
}
.modal-form input:focus, .modal-form textarea:focus {
outline: none;
background-color: #e0e0e0;
}
.modal-form button {
background-color: #2196F3;
color: white;
cursor: pointer;
transition: background-color 0.3s ease;
}
.modal-form button:hover {
background-color: #0b7dda;
}
/* Responsive */
@media (max-width: 600px) {
.task-form {
flex-direction: column;
}
.task-form button {
flex: 1;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📚 Study Planner</h1>
</div>
<form class="task-form" id="taskForm">
<input type="text" id="taskTitle" placeholder="Task Title" required>
<input type="date" id="taskDate" required>
<textarea id="taskDesc" placeholder="Task Description" rows="1" required></textarea>
<button type="submit">Add Task</button>
</form>
<ul class="task-list" id="taskList">
<!-- Tasks will be dynamically added here -->
</ul>
</div>
<!-- Edit Modal -->
<div id="editModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<h2>Edit Task</h2>
<form class="modal-form" id="editForm">
<input type="text" id="editTitle" placeholder="Task Title" required>
<input type="date" id="editDate" required>
<textarea id="editDesc" placeholder="Task Description" rows="3" required></textarea>
<button type="submit">Update Task</button>
</form>
</div>
</div>
<script>
// Task Array
let tasks = [];
// Elements
const taskForm = document.getElementById('taskForm');
const taskList = document.getElementById('taskList');
const editModal = document.getElementById('editModal');
const closeModal = document.querySelector('.close');
const editForm = document.getElementById('editForm');
let currentEditId = null;
// Load Tasks from Local Storage
window.onload = function() {
if (localStorage.getItem('tasks')) {
tasks = JSON.parse(localStorage.getItem('tasks'));
renderTasks();
}
}
// Add Task
taskForm.addEventListener('submit', function(e) {
e.preventDefault();
const title = document.getElementById('taskTitle').value.trim();
const date = document.getElementById('taskDate').value;
const desc = document.getElementById('taskDesc').value.trim();
if (title && date && desc) {
const task = {
id: Date.now(),
title,
date,
desc,
completed: false
};
tasks.push(task);
saveTasks();
renderTasks();
taskForm.reset();
}
});
// Save Tasks to Local Storage
function saveTasks() {
localStorage.setItem('tasks', JSON.stringify(tasks));
}
// Render Tasks
function renderTasks() {
taskList.innerHTML = '';
if (tasks.length === 0) {
taskList.innerHTML = '<p style="text-align:center; color:#777;">No tasks added yet.</p>';
return;
}
tasks.sort((a, b) => new Date(a.date) - new Date(b.date));
tasks.forEach(task => {
const li = document.createElement('li');
li.className = 'task-item';
if (task.completed) li.classList.add('completed');
const header = document.createElement('div');
header.className = 'task-header';
const title = document.createElement('h3');
title.textContent = task.title;
const actions = document.createElement('div');
actions.className = 'task-actions';
const completeBtn = document.createElement('button');
completeBtn.innerHTML = task.completed ? '✅' : '✔️';
completeBtn.title = task.completed ? 'Mark as Incomplete' : 'Mark as Complete';
completeBtn.onclick = () => toggleComplete(task.id);
const editBtn = document.createElement('button');
editBtn.innerHTML = '✏️';
editBtn.title = 'Edit Task';
editBtn.onclick = () => openEditModal(task.id);
const deleteBtn = document.createElement('button');
deleteBtn.innerHTML = '🗑️';
deleteBtn.title = 'Delete Task';
deleteBtn.onclick = () => deleteTask(task.id);
actions.appendChild(completeBtn);
actions.appendChild(editBtn);
actions.appendChild(deleteBtn);
header.appendChild(title);
header.appendChild(actions);
const desc = document.createElement('p');
desc.className = 'task-desc';
desc.textContent = task.desc;
const meta = document.createElement('div');
meta.className = 'task-meta';
const dueDate = document.createElement('span');
dueDate.textContent = `Due: ${task.date}`;
meta.appendChild(dueDate);
li.appendChild(header);
li.appendChild(desc);
li.appendChild(meta);
taskList.appendChild(li);
});
}
// Toggle Complete
function toggleComplete(id) {
tasks = tasks.map(task => {
if (task.id === id) {
task.completed = !task.completed;
}
return task;
});
saveTasks();
renderTasks();
}
// Delete Task
function deleteTask(id) {
if (confirm('Are you sure you want to delete this task?')) {
tasks = tasks.filter(task => task.id !== id);
saveTasks();
renderTasks();
}
}
// Open Edit Modal
function openEditModal(id) {
currentEditId = id;
const task = tasks.find(t => t.id === id);
if (task) {
document.getElementById('editTitle').value = task.title;
document.getElementById('editDate').value = task.date;
document.getElementById('editDesc').value = task.desc;
editModal.style.display = 'flex';
}
}
// Close Modal
closeModal.onclick = function() {
editModal.style.display = 'none';
}
window.onclick = function(event) {
if (event.target == editModal) {
editModal.style.display = 'none';
}
}
// Update Task
editForm.addEventListener('submit', function(e) {
e.preventDefault();
const title = document.getElementById('editTitle').value.trim();
const date = document.getElementById('editDate').value;
const desc = document.getElementById('editDesc').value.trim();
if (title && date && desc && currentEditId !== null) {
tasks = tasks.map(task => {
if (task.id === currentEditId) {
return { ...task, title, date, desc };
}
return task;
});
saveTasks();
renderTasks();
editModal.style.display = 'none';
}
});
</script>
</body>
</html>
Add Tasks : Input fields for task title, due date, and description. Pressing the "Add Task" button will add the task to the list.
Display Tasks : All tasks are displayed in a list, sorted by due date. Each task shows its title, description, and due date.
Edit Tasks : Each task has an edit button (✏️) that opens a modal where you can update the task details.
Delete Tasks : Each task has a delete button (🗑️) to remove the task from the list after confirmation.
Mark as Completed : Tasks can be marked as completed (✔️) which changes their appearance and status.
Local Storage : All tasks are saved in the browser's local storage, ensuring that your tasks persist even after refreshing the page.
Responsive Design : The app is responsive and looks good on both desktop and mobile devices.
Modern and Clean UI : Utilizes modern CSS features like flexbox, shadows, and smooth transitions to ensure a visually appealing interface.
Feel free to customize the styles and functionality further to suit your specific needs!