I'll create a simple Vue.js todo dashboard for you. Here's a complete implementation:
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>Todo Dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
.dashboard {
max-width: 800px;
margin: 0 auto;
background-color: white;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
padding: 30px;
}
h1 {
color: #333;
margin-bottom: 30px;
text-align: center;
}
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 20px;
margin-bottom: 30px;
}
.stat-card {
background-color: #f8f9fa;
padding: 20px;
border-radius: 8px;
text-align: center;
}
.stat-number {
font-size: 2em;
font-weight: bold;
color: #007bff;
}
.stat-label {
color: #666;
margin-top: 5px;
}
.add-todo {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.add-todo input {
flex: 1;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 5px;
font-size: 16px;
}
.add-todo input:focus {
outline: none;
border-color: #007bff;
}
.btn {
padding: 12px 24px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
.btn:hover {
background-color: #0056b3;
}
.filter-buttons {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
}
.filter-btn {
padding: 8px 16px;
background-color: #e0e0e0;
border: none;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s;
}
.filter-btn.active {
background-color: #007bff;
color: white;
}
.todo-list {
list-style: none;
}
.todo-item {
display: flex;
align-items: center;
padding: 15px;
background-color: #f8f9fa;
margin-bottom: 10px;
border-radius: 5px;
transition: all 0.3s;
}
.todo-item:hover {
background-color: #e9ecef;
}
.todo-item.completed {
opacity: 0.7;
}
.todo-item.completed .todo-text {
text-decoration: line-through;
color: #666;
}
.todo-checkbox {
width: 20px;
height: 20px;
margin-right: 15px;
cursor: pointer;
}
.todo-text {
flex: 1;
font-size: 16px;
}
.todo-actions {
display: flex;
gap: 10px;
}
.btn-small {
padding: 5px 10px;
font-size: 14px;
border: none;
border-radius: 3px;
cursor: pointer;
transition: opacity 0.3s;
}
.btn-edit {
background-color: #28a745;
color: white;
}
.btn-delete {
background-color: #dc3545;
color: white;
}
.btn-small:hover {
opacity: 0.8;
}
.empty-state {
text-align: center;
padding: 40px;
color: #666;
}
.edit-input {
flex: 1;
padding: 8px;
margin-right: 10px;
border: 1px solid #007bff;
border-radius: 3px;
}
</style>
</head>
<body>
<div id="app">
<div class="dashboard">
<h1>📋 Todo Dashboard</h1>
<div class="stats">
<div class="stat-card">
<div class="stat-number">{{ totalTodos }}</div>
<div class="stat-label">Total Tasks</div>
</div>
<div class="stat-card">
<div class="stat-number">{{ completedTodos }}</div>
<div class="stat-label">Completed</div>
</div>
<div class="stat-card">
<div class="stat-number">{{ pendingTodos }}</div>
<div class="stat-label">Pending</div>
</div>
<div class="stat-card">
<div class="stat-number">{{ completionRate }}%</div>
<div class="stat-label">Completion Rate</div>
</div>
</div>
<div class="add-todo">
<input
v-model="newTodo"
@keyup.enter="addTodo"
placeholder="Add a new task..."
type="text"
>
<button @click="addTodo" class="btn">Add Task</button>
</div>
<div class="filter-buttons">
<button
@click="filter = 'all'"
:class="['filter-btn', { active: filter === 'all' }]"
>
All
</button>
<button
@click="filter = 'active'"
:class="['filter-btn', { active: filter === 'active' }]"
>
Active
</button>
<button
@click="filter = 'completed'"
:class="['filter-btn', { active: filter === 'completed' }]"
>
Completed
</button>
</div>
<ul class="todo-list" v-if="filteredTodos.length > 0">
<li
v-for="todo in filteredTodos"
:key="todo.id"
:class="['todo-item', { completed: todo.completed }]"
>
<input
type="checkbox"
v-model="todo.completed"
@change="saveTodos"
class="todo-checkbox"
>
<template v-if="editingId !== todo.id">
<span class="todo-text">{{ todo.text }}</span>
<div class="todo-actions">
<button @click="startEdit(todo)" class="btn-small btn-edit">Edit</button>
<button @click="deleteTodo(todo.id)" class="btn-small btn-delete">Delete</button>
</div>
</template>
<template v-else>
<input
v-model="editingText"
@keyup.enter="saveEdit"
@keyup.escape="cancelEdit"
class="edit-input"
ref="editInput"
>
<div class="todo-actions">
<button @click="saveEdit" class="btn-small btn-edit">Save</button>
<button @click="cancelEdit" class="btn-small btn-delete">Cancel</button>
</div>
</template>
</li>
</ul>
<div v-else class="empty-state">
<p>No tasks found. Add one above to get started!</p>
</div>
</div>
</div>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
todos: [],
newTodo: '',
filter: 'all',
editingId: null,
editingText: ''
}
},
computed: {
filteredTodos() {
switch(this.filter) {
case 'active':
return this.todos.filter(todo => !todo.completed);
case 'completed':
return this.todos.filter(todo => todo.completed);
default:
return this.todos;
}
},
totalTodos() {
return this.todos.length;
},
completedTodos() {
return this.todos.filter(todo => todo.completed).length;
},
pendingTodos() {
return this.todos.filter(todo => !todo.completed).length;
},
completionRate() {
if (this.totalTodos === 0) return 0;
return Math.round((this.completedTodos / this.totalTodos) * 100);
}
},
methods: {
addTodo() {
if (this.newTodo.trim()) {
this.todos.push({
id: Date.now(),
text: this.newTodo.trim(),
completed: false
});
this.newTodo = '';
this.saveTodos();
}
},
deleteTodo(id) {
this.todos = this.todos.filter(todo => todo.id !== id);
this.saveTodos();
},
startEdit(todo) {
this.editingId = todo.id;
this.editingText = todo.text;
this.$nextTick(() => {
this.$refs.editInput[0].focus();
});
},
saveEdit() {
const todo = this.todos.find(t => t.id === this.editingId);
if (todo && this.editingText.trim()) {
todo.text = this.editingText.trim();
this.saveTodos();
}
this.cancelEdit();
},
cancelEdit() {
this.editingId = null;
this.editingText = '';
},
saveTodos() {
localStorage.setItem('todos', JSON.stringify(this.todos));
},
loadTodos() {
const saved = localStorage.getItem('todos');
if (saved) {
this.todos = JSON.parse(saved);
}
}
},
mounted() {
this.loadTodos();
}
}).mount('#app');
</script>
</body>
</html>
The dashboard automatically saves your tasks to localStorage, so they'll persist even after refreshing the page. The clean interface makes it easy to manage your todos with visual feedback for completed tasks and real-time statistics.