Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Todo App</title> | |
| <style> | |
| * { margin: 0; padding: 0; box-sizing: border-box; } | |
| body { | |
| font-family: 'Segoe UI', system-ui, sans-serif; | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| min-height: 100vh; | |
| padding: 2rem; | |
| display: grid; | |
| place-items: center; | |
| } | |
| .container { | |
| background: rgba(255, 255, 255, 0.95); | |
| backdrop-filter: blur(10px); | |
| border-radius: 20px; | |
| padding: 2rem; | |
| box-shadow: 0 20px 40px rgba(0,0,0,0.1); | |
| width: 90%; | |
| max-width: 500px; | |
| } | |
| h1 { | |
| text-align: center; | |
| color: #333; | |
| margin-bottom: 1.5rem; | |
| font-weight: 600; | |
| } | |
| .input-section { | |
| display: flex; | |
| gap: 0.5rem; | |
| margin-bottom: 1.5rem; | |
| } | |
| input { | |
| flex: 1; | |
| padding: 0.75rem 1rem; | |
| border: 2px solid #e1e5e9; | |
| border-radius: 12px; | |
| font-size: 1rem; | |
| transition: all 0.3s ease; | |
| } | |
| input:focus { | |
| outline: none; | |
| border-color: #667eea; | |
| box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); | |
| } | |
| button { | |
| background: linear-gradient(135deg, #667eea, #764ba2); | |
| color: white; | |
| border: none; | |
| padding: 0.75rem 1.5rem; | |
| border-radius: 12px; | |
| cursor: pointer; | |
| font-weight: 600; | |
| transition: transform 0.2s ease; | |
| } | |
| button:hover { transform: translateY(-2px); } | |
| .todo-item { | |
| background: white; | |
| padding: 1rem; | |
| margin-bottom: 0.5rem; | |
| border-radius: 12px; | |
| display: flex; | |
| align-items: center; | |
| gap: 1rem; | |
| border: 2px solid #f0f0f0; | |
| transition: all 0.3s ease; | |
| } | |
| .todo-item:hover { | |
| border-color: #667eea; | |
| transform: translateX(5px); | |
| } | |
| .todo-item.completed { | |
| opacity: 0.6; | |
| text-decoration: line-through; | |
| } | |
| .todo-text { flex: 1; } | |
| .delete-btn { | |
| background: #ff4757; | |
| color: white; | |
| border: none; | |
| padding: 0.5rem 1rem; | |
| border-radius: 8px; | |
| cursor: pointer; | |
| font-size: 0.875rem; | |
| } | |
| .header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| margin-bottom: 1rem; | |
| } | |
| .anycoder-link { | |
| color: #667eea; | |
| text-decoration: none; | |
| font-size: 0.875rem; | |
| font-weight: 500; | |
| } | |
| @media (max-width: 480px) { | |
| .container { padding: 1.5rem; } | |
| .input-section { flex-direction: column; } | |
| button { width: 100%; } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <div class="header"> | |
| <h1>π Todo App</h1> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link">Built with anycoder</a> | |
| </div> | |
| <div class="input-section"> | |
| <input type="text" id="todoInput" placeholder="Add a new task..." maxlength="100"> | |
| <button onclick="addTodo()">Add Task</button> | |
| </div> | |
| <div id="todoList"></div> | |
| </div> | |
| <script> | |
| let todos = JSON.parse(localStorage.getItem('todos')) || []; | |
| function renderTodos() { | |
| const todoList = document.getElementById('todoList'); | |
| todoList.innerHTML = todos.map((todo, index) => ` | |
| <div class="todo-item ${todo.completed ? 'completed' : ''}"> | |
| <span class="todo-text">${todo.text}</span> | |
| <button onclick="toggleTodo(${index})">${todo.completed ? 'Undo' : 'Done'}</button> | |
| <button class="delete-btn" onclick="deleteTodo(${index})">Delete</button> | |
| </div> | |
| `).join(''); | |
| localStorage.setItem('todos', JSON.stringify(todos)); | |
| } | |
| function addTodo() { | |
| const input = document.getElementById('todoInput'); | |
| const text = input.value.trim(); | |
| if (text) { | |
| todos.push({ text, completed: false }); | |
| input.value = ''; | |
| renderTodos(); | |
| } | |
| } | |
| function toggleTodo(index) { | |
| todos[index].completed = !todos[index].completed; | |
| renderTodos(); | |
| } | |
| function deleteTodo(index) { | |
| todos.splice(index, 1); | |
| renderTodos(); | |
| } | |
| document.getElementById('todoInput').addEventListener('keypress', (e) => { | |
| if (e.key === 'Enter') addTodo(); | |
| }); | |
| renderTodos(); | |
| </script> | |
| </body> | |
| </html> |