anycoder-b24f3c9c / index.html
akhaliq's picture
akhaliq HF Staff
Upload folder using huggingface_hub
d536cce verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Todo App</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary: #6366f1;
--primary-dark: #4f46e5;
--primary-light: #818cf8;
--success: #10b981;
--danger: #ef4444;
--warning: #f59e0b;
--bg-dark: #0f172a;
--bg-card: #1e293b;
--bg-input: #334155;
--text-primary: #f8fafc;
--text-secondary: #94a3b8;
--border: #475569;
}
body {
font-family: 'Inter', sans-serif;
background: var(--bg-dark);
min-height: 100vh;
color: var(--text-primary);
line-height: 1.6;
}
.container {
max-width: 700px;
margin: 0 auto;
padding: 2rem 1rem;
}
header {
text-align: center;
margin-bottom: 2rem;
}
.built-with {
font-size: 0.75rem;
color: var(--text-secondary);
margin-bottom: 1rem;
}
.built-with a {
color: var(--primary-light);
text-decoration: none;
transition: color 0.3s ease;
}
.built-with a:hover {
color: var(--primary);
text-decoration: underline;
}
h1 {
font-size: 2.5rem;
font-weight: 700;
background: linear-gradient(135deg, var(--primary-light), var(--primary));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 0.5rem;
}
.subtitle {
color: var(--text-secondary);
font-size: 1rem;
}
.stats {
display: flex;
justify-content: center;
gap: 2rem;
margin: 1.5rem 0;
flex-wrap: wrap;
}
.stat-item {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.25rem;
background: var(--bg-card);
border-radius: 12px;
border: 1px solid var(--border);
}
.stat-item i {
font-size: 1.25rem;
}
.stat-item.total i { color: var(--primary-light); }
.stat-item.completed i { color: var(--success); }
.stat-item.pending i { color: var(--warning); }
.stat-value {
font-weight: 600;
font-size: 1.25rem;
}
.stat-label {
font-size: 0.75rem;
color: var(--text-secondary);
}
.input-section {
background: var(--bg-card);
padding: 1.5rem;
border-radius: 16px;
margin-bottom: 1.5rem;
border: 1px solid var(--border);
}
.input-group {
display: flex;
gap: 0.75rem;
margin-bottom: 1rem;
}
.input-group input {
flex: 1;
padding: 1rem 1.25rem;
border: 2px solid var(--border);
border-radius: 12px;
background: var(--bg-input);
color: var(--text-primary);
font-size: 1rem;
font-family: inherit;
transition: all 0.3s ease;
}
.input-group input:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.input-group input::placeholder {
color: var(--text-secondary);
}
.btn {
padding: 1rem 1.5rem;
border: none;
border-radius: 12px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
gap: 0.5rem;
font-family: inherit;
}
.btn-primary {
background: linear-gradient(135deg, var(--primary), var(--primary-dark));
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}
.options-row {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.priority-select, .category-select {
padding: 0.75rem 1rem;
border: 2px solid var(--border);
border-radius: 10px;
background: var(--bg-input);
color: var(--text-primary);
font-size: 0.9rem;
font-family: inherit;
cursor: pointer;
transition: all 0.3s ease;
}
.priority-select:focus, .category-select:focus {
outline: none;
border-color: var(--primary);
}
.filters {
display: flex;
gap: 0.5rem;
margin-bottom: 1.5rem;
flex-wrap: wrap;
}
.filter-btn {
padding: 0.6rem 1.2rem;
border: 2px solid var(--border);
border-radius: 25px;
background: transparent;
color: var(--text-secondary);
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
font-family: inherit;
}
.filter-btn:hover {
border-color: var(--primary);
color: var(--primary-light);
}
.filter-btn.active {
background: var(--primary);
border-color: var(--primary);
color: white;
}
.todo-list {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.todo-item {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 14px;
padding: 1.25rem;
display: flex;
align-items: center;
gap: 1rem;
transition: all 0.3s ease;
animation: slideIn 0.3s ease;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.todo-item:hover {
border-color: var(--primary);
transform: translateX(5px);
}
.todo-item.completed {
opacity: 0.6;
}
.todo-item.completed .todo-text {
text-decoration: line-through;
color: var(--text-secondary);
}
.checkbox {
width: 24px;
height: 24px;
border: 2px solid var(--border);
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
flex-shrink: 0;
}
.checkbox:hover {
border-color: var(--success);
}
.checkbox.checked {
background: var(--success);
border-color: var(--success);
}
.checkbox.checked i {
color: white;
font-size: 0.75rem;
}
.todo-content {
flex: 1;
min-width: 0;
}
.todo-text {
font-size: 1rem;
margin-bottom: 0.5rem;
word-break: break-word;
}
.todo-meta {
display: flex;
gap: 0.75rem;
flex-wrap: wrap;
}
.badge {
padding: 0.25rem 0.75rem;
border-radius: 20px;
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.badge-priority-high {
background: rgba(239, 68, 68, 0.2);
color: #f87171;
}
.badge-priority-medium {
background: rgba(245, 158, 11, 0.2);
color: #fbbf24;
}
.badge-priority-low {
background: rgba(16, 185, 129, 0.2);
color: #34d399;
}
.badge-category {
background: rgba(99, 102, 241, 0.2);
color: var(--primary-light);
}
.todo-date {
font-size: 0.75rem;
color: var(--text-secondary);
}
.todo-actions {
display: flex;
gap: 0.5rem;
}
.action-btn {
width: 36px;
height: 36px;
border: none;
border-radius: 10px;
background: var(--bg-input);
color: var(--text-secondary);
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
}
.action-btn:hover {
transform: scale(1.1);
}
.action-btn.edit:hover {
background: var(--primary);
color: white;
}
.action-btn.delete:hover {
background: var(--danger);
color: white;
}
.empty-state {
text-align: center;
padding: 3rem 1rem;
color: var(--text-secondary);
}
.empty-state i {
font-size: 4rem;
margin-bottom: 1rem;
opacity: 0.5;
}
.empty-state h3 {
font-size: 1.25rem;
margin-bottom: 0.5rem;
color: var(--text-primary);
}
.clear-completed {
margin-top: 1.5rem;
text-align: center;
}
.btn-outline {
background: transparent;
border: 2px solid var(--border);
color: var(--text-secondary);
}
.btn-outline:hover {
border-color: var(--danger);
color: var(--danger);
background: rgba(239, 68, 68, 0.1);
}
/* Edit Modal */
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(5px);
z-index: 1000;
align-items: center;
justify-content: center;
padding: 1rem;
}
.modal.active {
display: flex;
}
.modal-content {
background: var(--bg-card);
border-radius: 20px;
padding: 2rem;
width: 100%;
max-width: 450px;
border: 1px solid var(--border);
animation: modalSlide 0.3s ease;
}
@keyframes modalSlide {
from {
opacity: 0;
transform: scale(0.9);
}
to {
opacity: 1;
transform: scale(1);
}
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
.modal-header h2 {
font-size: 1.5rem;
}
.close-modal {
background: none;
border: none;
color: var(--text-secondary);
font-size: 1.5rem;
cursor: pointer;
transition: color 0.3s ease;
}
.close-modal:hover {
color: var(--text-primary);
}
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
color: var(--text-secondary);
}
.form-group input,
.form-group select {
width: 100%;
padding: 0.875rem 1rem;
border: 2px solid var(--border);
border-radius: 10px;
background: var(--bg-input);
color: var(--text-primary);
font-size: 1rem;
font-family: inherit;
}
.form-group input:focus,
.form-group select:focus {
outline: none;
border-color: var(--primary);
}
.modal-actions {
display: flex;
gap: 1rem;
margin-top: 1.5rem;
}
.modal-actions .btn {
flex: 1;
}
.btn-secondary {
background: var(--bg-input);
color: var(--text-primary);
}
.btn-secondary:hover {
background: var(--border);
}
@media (max-width: 600px) {
h1 {
font-size: 2rem;
}
.stats {
gap: 1rem;
}
.stat-item {
padding: 0.6rem 1rem;
}
.input-group {
flex-direction: column;
}
.todo-item {
flex-wrap: wrap;
}
.todo-actions {
width: 100%;
justify-content: flex-end;
margin-top: 0.5rem;
}
.filters {
justify-content: center;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<p class="built-with">Built with <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">anycoder</a></p>
<h1><i class="fas fa-check-double"></i> Todo App</h1>
<p class="subtitle">Organize your tasks efficiently</p>
<div class="stats">
<div class="stat-item total">
<i class="fas fa-list-check"></i>
<div>
<div class="stat-value" id="totalTasks">0</div>
<div class="stat-label">Total</div>
</div>
</div>
<div class="stat-item completed">
<i class="fas fa-circle-check"></i>
<div>
<div class="stat-value" id="completedTasks">0</div>
<div class="stat-label">Completed</div>
</div>
</div>
<div class="stat-item pending">
<i class="fas fa-clock"></i>
<div>
<div class="stat-value" id="pendingTasks">0</div>
<div class="stat-label">Pending</div>
</div>
</div>
</div>
</header>
<section class="input-section">
<div class="input-group">
<input type="text" id="todoInput" placeholder="What needs to be done?" autocomplete="off">
<button class="btn btn-primary" onclick="addTodo()">
<i class="fas fa-plus"></i>
Add
</button>
</div>
<div class="options-row">
<select class="priority-select" id="prioritySelect">
<option value="low">🟢 Low Priority</option>
<option value="medium" selected>🟡 Medium Priority</option>
<option value="high">🔴 High Priority</option>
</select>
<select class="category-select" id="categorySelect">
<option value="personal">👤 Personal</option>
<option value="work">💼 Work</option>
<option value="shopping">🛒 Shopping</option>
<option value="health">❤️ Health</option>
<option value="other">📌 Other</option>
</select>
</div>
</section>
<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>
<button class="filter-btn" data-filter="high">High Priority</button>
</div>
<div class="todo-list" id="todoList">
<!-- Todos will be rendered here -->
</div>
<div class="clear-completed">
<button class="btn btn-outline" onclick="clearCompleted()">
<i class="fas fa-trash-alt"></i>
Clear Completed
</button>
</div>
</div>
<!-- Edit Modal -->
<div class="modal" id="editModal">
<div class="modal-content">
<div class="modal-header">
<h2><i class="fas fa-edit"></i> Edit Task</h2>
<button class="close-modal" onclick="closeModal()">
<i class="fas fa-times"></i>
</button>
</div>
<div class="form-group">
<label for="editText">Task Description</label>
<input type="text" id="editText" placeholder="Enter task description">
</div>
<div class="form-group">
<label for="editPriority">Priority</label>
<select id="editPriority">
<option value="low">🟢 Low Priority</option>
<option value="medium">🟡 Medium Priority</option>
<option value="high">🔴 High Priority</option>
</select>
</div>
<div class="form-group">
<label for="editCategory">Category</label>
<select id="editCategory">
<option value="personal">👤 Personal</option>
<option value="work">💼 Work</option>
<option value="shopping">🛒 Shopping</option>
<option value="health">❤️ Health</option>
<option value="other">📌 Other</option>
</select>
</div>
<div class="modal-actions">
<button class="btn btn-secondary" onclick="closeModal()">Cancel</button>
<button class="btn btn-primary" onclick="saveEdit()">
<i class="fas fa-save"></i>
Save Changes
</button>
</div>
</div>
</div>
<script>
let todos = JSON.parse(localStorage.getItem('todos')) || [];
let currentFilter = 'all';
let editingId = null;
// Initialize
document.addEventListener('DOMContentLoaded', () => {
renderTodos();
updateStats();
// Enter key to add todo
document.getElementById('todoInput').addEventListener('keypress', (e) => {
if (e.key === 'Enter') addTodo();
});
// Filter buttons
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
currentFilter = btn.dataset.filter;
renderTodos();
});
});
});
function generateId() {
return Date.now().toString(36) + Math.random().toString(36).substr(2);
}
function formatDate(date) {
return new Date(date).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
}
function addTodo() {
const input = document.getElementById('todoInput');
const text = input.value.trim();
if (!text) {
input.focus();
input.style.borderColor = 'var(--danger)';
setTimeout(() => input.style.borderColor = '', 500);
return;
}
const todo = {
id: generateId(),
text: text,
completed: false,
priority: document.getElementById('prioritySelect').value,
category: document.getElementById('categorySelect').value,
createdAt: new Date().toISOString()
};
todos.unshift(todo);
saveTodos();
renderTodos();
updateStats();
input.value = '';
input.focus();
}
function toggleTodo(id) {
todos = todos.map(todo =>
todo.id === id ? { ...todo, completed: !todo.completed } : todo
);
saveTodos();
renderTodos();
updateStats();
}
function deleteTodo(id) {
todos = todos.filter(todo => todo.id !== id);
saveTodos();
renderTodos();
updateStats();
}
function editTodo(id) {
const todo = todos.find(t => t.id === id);
if (!todo) return;
editingId = id;
document.getElementById('editText').value = todo.text;
document.getElementById('editPriority').value = todo.priority;
document.getElementById('editCategory').value = todo.category;
document.getElementById('editModal').classList.add('active');
}
function closeModal() {
document.getElementById('editModal').classList.remove('active');
editingId = null;
}
function saveEdit() {
if (!editingId) return;
const text = document.getElementById('editText').value.trim();
if (!text) return;
todos = todos.map(todo =>
todo.id === editingId
? {
...todo,
text: text,
priority: document.getElementById('editPriority').value,
category: document.getElementById('editCategory').value
}
: todo
);
saveTodos();
renderTodos();
closeModal();
}
function clearCompleted() {
todos = todos.filter(todo => !todo.completed);
saveTodos();
renderTodos();
updateStats();
}
function getFilteredTodos() {
switch (currentFilter) {
case 'pending':
return todos.filter(t => !t.completed);
case 'completed':
return todos.filter(t => t.completed);
case 'high':
return todos.filter(t => t.priority === 'high');
default:
return todos;
}
}
function renderTodos() {
const container = document.getElementById('todoList');
const filteredTodos = getFilteredTodos();
if (filteredTodos.length === 0) {
container.innerHTML = `
<div class="empty-state">
<i class="fas fa-clipboard-list"></i>
<h3>No tasks found</h3>
<p>Add a new task to get started!</p>
</div>
`;
return;
}
container.innerHTML = filteredTodos.map(todo => `
<div class="todo-item ${todo.completed ? 'completed' : ''}" data-id="${todo.id}">
<div class="checkbox ${todo.completed ? 'checked' : ''}" onclick="toggleTodo('${todo.id}')">
${todo.completed ? '<i class="fas fa-check"></i>' : ''}
</div>
<div class="todo-content">
<div class="todo-text">${escapeHtml(todo.text)}</div>
<div class="todo-meta">
<span class="badge badge-priority-${todo.priority}">${todo.priority}</span>
<span class="badge badge-category">${todo.category}</span>
<span class="todo-date">${formatDate(todo.createdAt)}</span>
</div>
</div>
<div class="todo-actions">
<button class="action-btn edit" onclick="editTodo('${todo.id}')" title="Edit">
<i class="fas fa-pen"></i>
</button>
<button class="action-btn delete" onclick="deleteTodo('${todo.id}')" title="Delete">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
`).join('');
}
function updateStats() {
const total = todos.length;
const completed = todos.filter(t => t.completed).length;
const pending = total - completed;
document.getElementById('totalTasks').textContent = total;
document.getElementById('completedTasks').textContent = completed;
document.getElementById('pendingTasks').textContent = pending;
}
function saveTodos() {
localStorage.setItem('todos', JSON.stringify(todos));
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Close modal on outside click
document.getElementById('editModal').addEventListener('click', (e) => {
if (e.target.id === 'editModal') closeModal();
});
// Close modal on Escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') closeModal();
});
</script>
</body>
</html>