generate a todolist webapp
- User
generate a todolist webapp
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
generate a todolist webapp
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
I'll create a complete todo list web application for you. Here's a fully functional single-page app with HTML, CSS, and JavaScript:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Todo List App</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
background: white;
border-radius: 15px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
}
.header p {
opacity: 0.9;
font-size: 1.1rem;
}
.input-section {
padding: 30px;
border-bottom: 1px solid #eee;
}
.input-container {
display: flex;
gap: 10px;
}
#todoInput {
flex: 1;
padding: 15px;
border: 2px solid #e1e5e9;
border-radius: 8px;
font-size: 16px;
transition: border-color 0.3s ease;
}
#todoInput:focus {
outline: none;
border-color: #667eea;
}
#addBtn {
padding: 15px 25px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
font-weight: 600;
transition: transform 0.2s ease;
}
#addBtn:hover {
transform: translateY(-2px);
}
#addBtn:active {
transform: translateY(0);
}
.stats {
padding: 20px 30px;
background: #f8f9fa;
display: flex;
justify-content: space-between;
font-size: 14px;
color: #666;
}
.todo-list {
padding: 0 30px 30px;
}
.todo-item {
display: flex;
align-items: center;
padding: 15px 0;
border-bottom: 1px solid #eee;
animation: slideIn 0.3s ease;
}
.todo-item:last-child {
border-bottom: none;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateX(-20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
.todo-checkbox {
width: 20px;
height: 20px;
margin-right: 15px;
cursor: pointer;
}
.todo-text {
flex: 1;
font-size: 16px;
transition: all 0.3s ease;
}
.todo-text.completed {
text-decoration: line-through;
color: #999;
opacity: 0.6;
}
.delete-btn {
background: #ff4757;
color: white;
border: none;
padding: 8px 12px;
border-radius: 5px;
cursor: pointer;
font-size: 12px;
transition: background-color 0.3s ease;
}
.delete-btn:hover {
background: #ff3742;
}
.empty-state {
text-align: center;
padding: 50px 20px;
color: #999;
}
.empty-state img {
width: 100px;
height: 100px;
margin-bottom: 20px;
opacity: 0.5;
}
.filters {
padding: 20px 30px;
display: flex;
gap: 10px;
justify-content: center;
border-top: 1px solid #eee;
}
.filter-btn {
padding: 8px 16px;
border: 2px solid #e1e5e9;
background: white;
border-radius: 20px;
cursor: pointer;
font-size: 14px;
transition: all 0.3s ease;
}
.filter-btn.active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-color: #667eea;
}
.filter-btn:hover {
border-color: #667eea;
}
@media (max-width: 480px) {
.input-container {
flex-direction: column;
}
.filters {
flex-wrap: wrap;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📝 Todo List</h1>
<p>Stay organized and get things done</p>
</div>
<div class="input-section">
<div class="input-container">
<input type="text" id="todoInput" placeholder="What needs to be done?" maxlength="100">
<button id="addBtn">Add Task</button>
</div>
</div>
<div class="stats">
<span id="totalTasks">Total: 0</span>
<span id="completedTasks">Completed: 0</span>
<span id="pendingTasks">Pending: 0</span>
</div>
<div class="filters">
<button class="filter-btn active" data-filter="all">All</button>
<button class="filter-btn" data-filter="pending">Pending</button>
<button class="filter-btn" data-filter="completed">Completed</button>
</div>
<div class="todo-list" id="todoList">
<div class="empty-state" id="emptyState">
<div style="font-size: 4rem; margin-bottom: 20px;">📋</div>
<h3>No tasks yet</h3>
<p>Add a task above to get started!</p>
</div>
</div>
</div>
<script>
class TodoApp {
constructor() {
this.todos = JSON.parse(localStorage.getItem('todos')) || [];
this.currentFilter = 'all';
this.init();
}
init() {
this.bindEvents();
this.render();
this.updateStats();
}
bindEvents() {
const todoInput = document.getElementById('todoInput');
const addBtn = document.getElementById('addBtn');
const filterBtns = document.querySelectorAll('.filter-btn');
addBtn.addEventListener('click', () => this.addTodo());
todoInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') this.addTodo();
});
filterBtns.forEach(btn => {
btn.addEventListener('click', (e) => {
this.setFilter(e.target.dataset.filter);
});
});
}
addTodo() {
const input = document.getElementById('todoInput');
const text = input.value.trim();
if (text === '') {
input.focus();
return;
}
const todo = {
id: Date.now(),
text: text,
completed: false,
createdAt: new Date().toISOString()
};
this.todos.unshift(todo);
input.value = '';
this.saveTodos();
this.render();
this.updateStats();
}
toggleTodo(id) {
const todo = this.todos.find(t => t.id === id);
if (todo) {
todo.completed = !todo.completed;
this.saveTodos();
this.render();
this.updateStats();
}
}
deleteTodo(id) {
this.todos = this.todos.filter(t => t.id !== id);
this.saveTodos();
this.render();
this.updateStats();
}
setFilter(filter) {
this.currentFilter = filter;
// Update active filter button
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.classList.remove('active');
});
document.querySelector(`[data-filter="${filter}"]`).classList.add('active');
this.render();
}
getFilteredTodos() {
switch (this.currentFilter) {
case 'completed':
return this.todos.filter(todo => todo.completed);
case 'pending':
return this.todos.filter(todo => !todo.completed);
default:
return this.todos;
}
}
render() {
const todoList = document.getElementById('todoList');
const emptyState = document.getElementById('emptyState');
const filteredTodos = this.getFilteredTodos();
if (filteredTodos.length === 0) {
emptyState.style.display = 'block';
todoList.innerHTML = '';
todoList.appendChild(emptyState);
return;
}
emptyState.style.display = 'none';
todoList.innerHTML = filteredTodos.map(todo => `
<div class="todo-item">
<input type="checkbox" class="todo-checkbox"
${todo.completed ? 'checked' : ''}
onchange="todoApp.toggleTodo(${todo.id})">
<span class="todo-text ${todo.completed ? 'completed' : ''}">${this.escapeHtml(todo.text)}</span>
<button class="delete-btn" onclick="todoApp.deleteTodo(${todo.id})">Delete</button>
</div>
`).join('');
}
updateStats() {
const total = this.todos.length;
const completed = this.todos.filter(t => t.completed).length;
const pending = total - completed;
document.getElementById('totalTasks').textContent = `Total: ${total}`;
document.getElementById('completedTasks').textContent = `Completed: ${completed}`;
document.getElementById('pendingTasks').textContent = `Pending: ${pending}`;
}
saveTodos() {
localStorage.setItem('todos', JSON.stringify(this.todos));
}
escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
}
// Initialize the app
const todoApp = new TodoApp();
</script>
</body>
</html>
This todo list webapp includes:
Features:
Design:
Technical:
Just save this code as an HTML file and open it in your browser. The app will work immediately and remember your tasks between sessions.