Skip to content
TheChatArchiveThe Chat Archive
GLMGLM-5 / Pony Alpha· unknownHugging Face Frontier Reasoning Traces

Create a simple "To-Do List" application using React

  1. User

    Create a simple "To-Do List" application using React

  2. GLM Assistant

    The user wants a simple "To-Do List" application using React. I need to create a single HTML file that includes React (via CDN) and implements a to-do list with good visual design and interactions.

    Let me plan the features:

    1. Add new tasks
    2. Mark tasks as complete/incomplete
    3. Delete tasks
    4. Filter tasks (all, active, completed)
    5. Task counter

    Design considerations:

    • Avoid bland/template colors
    • Use a distinctive font
    • Create depth with gradients/patterns
    • Meaningful interactions (at least 2)
    • Motion with staggered reveals
    • Mobile-first responsive design

    Color scheme: Let me go with a dark, sophisticated theme with a warm accent color (like amber/gold or coral). Avoiding the typical blue/purple gradients.

    Font: I'll use "Space Grotesk" for a modern, technical feel.

    Interactions:

    1. Task completion animation
    2. Delete animation with fade out
    3. Staggered entrance animation
    4. Hover states on buttons and tasks
    5. Focus states for accessibility

    Let me build this: Here's a polished, interactive To-Do List application built with React. I've gone for a dark industrial aesthetic with warm amber accents, featuring smooth animations and satisfying interactions.

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Task Flow - To Do List</title>
      <script src="https://cdn.tailwindcss.com"></script>
      <script src="https://unpkg.com/react@18/umd/react.development.js"></script>
      <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
      <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
      <link rel="preconnect" href="https://fonts.googleapis.com">
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
      <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
      <style>
        :root {
          --bg: #0a0a0b;
          --bg-elevated: #141416;
          --card: #1a1a1e;
          --border: #2a2a30;
          --fg: #f5f5f4;
          --muted: #737373;
          --accent: #f59e0b;
          --accent-dim: rgba(245, 158, 11, 0.15);
          --danger: #ef4444;
          --success: #22c55e;
        }
    
        * {
          box-sizing: border-box;
        }
    
        body {
          font-family: 'Space Grotesk', sans-serif;
          background: var(--bg);
          color: var(--fg);
          min-height: 100vh;
          margin: 0;
        }
    
        /* Background pattern */
        .bg-pattern {
          position: fixed;
          inset: 0;
          background-image: 
            radial-gradient(circle at 20% 20%, rgba(245, 158, 11, 0.03) 0%, transparent 50%),
            radial-gradient(circle at 80% 80%, rgba(245, 158, 11, 0.02) 0%, transparent 50%);
          pointer-events: none;
        }
    
        .bg-grid {
          position: fixed;
          inset: 0;
          background-image: 
            linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
          background-size: 60px 60px;
          pointer-events: none;
        }
    
        /* Custom checkbox */
        .task-checkbox {
          width: 22px;
          height: 22px;
          border: 2px solid var(--border);
          border-radius: 6px;
          cursor: pointer;
          display: flex;
          align-items: center;
          justify-content: center;
          transition: all 0.2s ease;
          flex-shrink: 0;
        }
    
        .task-checkbox:hover {
          border-color: var(--accent);
          background: var(--accent-dim);
        }
    
        .task-checkbox.checked {
          background: var(--accent);
          border-color: var(--accent);
        }
    
        .task-checkbox svg {
          opacity: 0;
          transform: scale(0.5);
          transition: all 0.2s ease;
        }
    
        .task-checkbox.checked svg {
          opacity: 1;
          transform: scale(1);
        }
    
        /* Task item animations */
        .task-item {
          animation: slideIn 0.3s ease forwards;
          opacity: 0;
          transform: translateX(-20px);
        }
    
        .task-item.removing {
          animation: slideOut 0.3s ease forwards;
        }
    
        @keyframes slideIn {
          to {
            opacity: 1;
            transform: translateX(0);
          }
        }
    
        @keyframes slideOut {
          to {
            opacity: 0;
            transform: translateX(20px);
          }
        }
    
        /* Staggered entrance */
        .stagger-1 { animation-delay: 0.05s; }
        .stagger-2 { animation-delay: 0.1s; }
        .stagger-3 { animation-delay: 0.15s; }
        .stagger-4 { animation-delay: 0.2s; }
        .stagger-5 { animation-delay: 0.25s; }
    
        /* Header animation */
        .header-glow {
          animation: glowPulse 3s ease-in-out infinite;
        }
    
        @keyframes glowPulse {
          0%, 100% { opacity: 0.5; }
          50% { opacity: 1; }
        }
    
        /* Input focus effect */
        .input-glow:focus {
          box-shadow: 0 0 0 3px var(--accent-dim), 0 0 20px rgba(245, 158, 11, 0.1);
        }
    
        /* Button interactions */
        .btn-primary {
          background: var(--accent);
          color: var(--bg);
          transition: all 0.2s ease;
        }
    
        .btn-primary:hover {
          transform: translateY(-2px);
          box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
        }
    
        .btn-primary:active {
          transform: translateY(0);
        }
    
        /* Filter tabs */
        .filter-tab {
          transition: all 0.2s ease;
        }
    
        .filter-tab.active {
          background: var(--accent-dim);
          color: var(--accent);
        }
    
        .filter-tab:not(.active):hover {
          background: rgba(255,255,255,0.05);
        }
    
        /* Delete button */
        .delete-btn {
          opacity: 0;
          transition: all 0.2s ease;
        }
    
        .task-item:hover .delete-btn {
          opacity: 1;
        }
    
        .delete-btn:hover {
          color: var(--danger);
          transform: scale(1.1);
        }
    
        /* Completed task style */
        .task-text.completed {
          text-decoration: line-through;
          color: var(--muted);
        }
    
        /* Empty state */
        .empty-state {
          animation: fadeIn 0.5s ease;
        }
    
        @keyframes fadeIn {
          from { opacity: 0; transform: translateY(10px); }
          to { opacity: 1; transform: translateY(0); }
        }
    
        /* Counter badge */
        .counter-badge {
          font-family: 'JetBrains Mono', monospace;
          font-size: 12px;
        }
    
        /* Scrollbar */
        ::-webkit-scrollbar {
          width: 6px;
        }
    
        ::-webkit-scrollbar-track {
          background: var(--bg-elevated);
        }
    
        ::-webkit-scrollbar-thumb {
          background: var(--border);
          border-radius: 3px;
        }
    
        ::-webkit-scrollbar-thumb:hover {
          background: var(--muted);
        }
    
        /* Reduced motion */
        @media (prefers-reduced-motion: reduce) {
          *, *::before, *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
          }
        }
      </style>
    </head>
    <body>
      <div id="root"></div>
    
      <script type="text/babel">
        const { useState, useEffect, useRef } = React;
    
        // Initial tasks
        const initialTasks = [
          { id: 1, text: 'Review project requirements', completed: false },
          { id: 2, text: 'Set up development environment', completed: true },
          { id: 3, text: 'Create component architecture', completed: false },
        ];
    
        // Check icon component
        const CheckIcon = () => (
          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round">
            <polyline points="20 6 9 17 4 12"></polyline>
          </svg>
        );
    
        // Delete icon component
        const DeleteIcon = () => (
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
            <path d="M3 6h18"></path>
            <path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path>
            <path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path>
          </svg>
        );
    
        // Plus icon component
        const PlusIcon = () => (
          <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
            <line x1="12" y1="5" x2="12" y2="19"></line>
            <line x1="5" y1="12" x2="19" y2="12"></line>
          </svg>
        );
    
        // Task Item Component
        const TaskItem = ({ task, onToggle, onDelete, index }) => {
          const [isRemoving, setIsRemoving] = useState(false);
    
          const handleDelete = () => {
            setIsRemoving(true);
            setTimeout(() => onDelete(task.id), 280);
          };
    
          const staggerClass = `stagger-${Math.min(index + 1, 5)}`;
    
          return (
            <div 
              className={`task-item ${staggerClass} ${isRemoving ? 'removing' : ''} group flex items-center gap-4 p-4 bg-[var(--card)] border border-[var(--border)] rounded-xl hover:border-[var(--accent)] transition-all duration-200`}
            >
              <button
                onClick={() => onToggle(task.id)}
                className={`task-checkbox ${task.completed ? 'checked' : ''}`}
                aria-label={task.completed ? 'Mark as incomplete' : 'Mark as complete'}
              >
                <svg 
                  width="14" 
                  height="14" 
                  viewBox="0 0 24 24" 
                  fill="none" 
                  stroke={task.completed ? 'var(--bg)' : 'currentColor'} 
                  strokeWidth="3" 
                  strokeLinecap="round" 
                  strokeLinejoin="round"
                >
                  <polyline points="20 6 9 17 4 12"></polyline>
                </svg>
              </button>
              
              <span className={`task-text flex-1 text-base ${task.completed ? 'completed' : ''}`}>
                {task.text}
              </span>
              
              <button
                onClick={handleDelete}
                className="delete-btn p-2 text-[var(--muted)] hover:text-[var(--danger)] transition-all"
                aria-label="Delete task"
              >
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                  <path d="M3 6h18"></path>
                  <path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path>
                  <path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path>
                </svg>
              </button>
            </div>
          );
        };
    
        // Empty State Component
        const EmptyState = ({ filter }) => {
          const messages = {
            all: { title: 'No tasks yet', subtitle: 'Add your first task to get started' },
            active: { title: 'All caught up', subtitle: 'No active tasks remaining' },
            completed: { title: 'Nothing completed', subtitle: 'Finish some tasks to see them here' }
          };
    
          const { title, subtitle } = messages[filter];
    
          return (
            <div className="empty-state flex flex-col items-center justify-center py-16 text-center">
              <div className="w-20 h-20 mb-6 rounded-2xl bg-[var(--card)] border border-[var(--border)] flex items-center justify-center">
                <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="var(--muted)" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
                  <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path>
                  <polyline points="14 2 14 8 20 8"></polyline>
                  <line x1="16" y1="13" x2="8" y2="13"></line>
                  <line x1="16" y1="17" x2="8" y2="17"></line>
                  <line x1="10" y1="9" x2="8" y2="9"></line>
                </svg>
              </div>
              <h3 className="text-lg font-medium text-[var(--fg)] mb-2">{title}</h3>
              <p className="text-sm text-[var(--muted)]">{subtitle}</p>
            </div>
          );
        };
    
        // Main App Component
        const App = () => {
          const [tasks, setTasks] = useState(initialTasks);
          const [inputValue, setInputValue] = useState('');
          const [filter, setFilter] = useState('all');
          const inputRef = useRef(null);
    
          // Generate unique ID
          const generateId = () => Date.now() + Math.random();
    
          // Add new task
          const handleAddTask = (e) => {
            e.preventDefault();
            if (!inputValue.trim()) return;
    
            const newTask = {
              id: generateId(),
              text: inputValue.trim(),
              completed: false
            };
    
            setTasks([newTask, ...tasks]);
            setInputValue('');
            inputRef.current?.focus();
          };
    
          // Toggle task completion
          const handleToggle = (id) => {
            setTasks(tasks.map(task => 
              task.id === id ? { ...task, completed: !task.completed } : task
            ));
          };
    
          // Delete task
          const handleDelete = (id) => {
            setTasks(tasks.filter(task => task.id !== id));
          };
    
          // Clear completed tasks
          const handleClearCompleted = () => {
            setTasks(tasks.filter(task => !task.completed));
          };
    
          // Filtered tasks
          const filteredTasks = tasks.filter(task => {
            if (filter === 'active') return !task.completed;
            if (filter === 'completed') return task.completed;
            return true;
          });
    
          // Task counts
          const activeCount = tasks.filter(t => !t.completed).length;
          const completedCount = tasks.filter(t => t.completed).length;
    
          return (
            <div className="min-h-screen relative">
              {/* Background effects */}
              <div className="bg-pattern"></div>
              <div className="bg-grid"></div>
    
              {/* Main content */}
              <div className="relative z-10 max-w-xl mx-auto px-4 py-12 md:py-20">
                
                {/* Header */}
                <header className="mb-10 text-center">
                  <div className="inline-flex items-center gap-3 mb-4">
                    <div className="header-glow w-3 h-3 rounded-full bg-[var(--accent)]"></div>
                    <span className="text-xs font-medium tracking-[0.2em] text-[var(--muted)] uppercase">Task Manager</span>
                  </div>
                  <h1 className="text-4xl md:text-5xl font-bold tracking-tight mb-3">
                    <span className="text-[var(--fg)]">Task</span>
                    <span className="text-[var(--accent)]">Flow</span>
                  </h1>
                  <p className="text-[var(--muted)] text-base">Organize your day, one task at a time</p>
                </header>
    
                {/* Add Task Form */}
                <form onSubmit={handleAddTask} className="mb-8">
                  <div className="flex gap-3">
                    <input
                      ref={inputRef}
                      type="text"
                      value={inputValue}
                      onChange={(e) => setInputValue(e.target.value)}
                      placeholder="What needs to be done?"
                      className="input-glow flex-1 bg-[var(--card)] border border-[var(--border)] rounded-xl px-5 py-4 text-[var(--fg)] placeholder:text-[var(--muted)] outline-none transition-all duration-200"
                    />
                    <button
                      type="submit"
                      disabled={!inputValue.trim()}
                      className="btn-primary px-5 py-4 rounded-xl font-semibold disabled:opacity-40 disabled:cursor-not-allowed disabled:transform-none flex items-center gap-2"
                    >
                      <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
                        <line x1="12" y1="5" x2="12" y2="19"></line>
                        <line x1="5" y1="12" x2="19" y2="12"></line>
                      </svg>
                      <span className="hidden sm:inline">Add</span>
                    </button>
                  </div>
                </form>
    
                {/* Filter Tabs & Stats */}
                <div className="flex items-center justify-between mb-6 flex-wrap gap-4">
                  <div className="flex bg-[var(--bg-elevated)] rounded-lg p-1 border border-[var(--border)]">
                    {['all', 'active', 'completed'].map((f) => (
                      <button
                        key={f}
                        onClick={() => setFilter(f)}
                        className={`filter-tab px-4 py-2 rounded-md text-sm font-medium capitalize ${
                          filter === f ? 'active' : 'text-[var(--muted)]'
                        }`}
                      >
                        {f}
                      </button>
                    ))}
                  </div>
    
                  <div className="flex items-center gap-4">
                    <div className="counter-badge px-3 py-1.5 bg-[var(--bg-elevated)] border border-[var(--border)] rounded-lg">
                      <span className="text-[var(--accent)]">{activeCount}</span>
                      <span className="text-[var(--muted)]"> active</span>
                    </div>
                    {completedCount > 0 && (
                      <button
                        onClick={handleClearCompleted}
                        className="text-xs text-[var(--muted)] hover:text-[var(--danger)] transition-colors"
                      >
                        Clear completed
                      </button>
                    )}
                  </div>
                </div>
    
                {/* Task List */}
                <div className="space-y-3">
                  {filteredTasks.length > 0 ? (
                    filteredTasks.map((task, index) => (
                      <TaskItem
                        key={task.id}
                        task={task}
                        onToggle={handleToggle}
                        onDelete={handleDelete}
                        index={index}
                      />
                    ))
                  ) : (
                    <EmptyState filter={filter} />
                  )}
                </div>
    
                {/* Footer */}
                <footer className="mt-12 text-center">
                  <p className="text-xs text-[var(--muted)]">
                    Press <kbd className="px-2 py-1 bg-[var(--card)] border border-[var(--border)] rounded text-[10px] mx-1">Enter</kbd> to add a task
                  </p>
                </footer>
              </div>
            </div>
          );
        };
    
        // Render the app
        const root = ReactDOM.createRoot(document.getElementById('root'));
        root.render(<App />);
      </script>
    </body>
    </html>
    

    Features & Design Choices

    Functionality:

    • Add new tasks via input + Enter key or button
    • Toggle task completion with animated checkboxes
    • Delete tasks with slide-out animation
    • Filter tasks by: All / Active / Completed
    • Clear all completed tasks at once
    • Task counter showing active items

    Visual Design:

    • Color Palette: Dark industrial theme with warm amber (#f59e0b) accent — avoids typical blue/purple templates
    • Typography: Space Grotesk for a modern technical feel, JetBrains Mono for counter badges
    • Background: Subtle grid pattern with radial gradient glows for depth

    Interactions & Animations:

    1. Staggered entrance — tasks slide in sequentially on load
    2. Checkbox animation — smooth scale + opacity transition when checking
    3. Delete animation — tasks slide out before removal
    4. Hover states — task borders highlight, delete button appears
    5. Button micro-interactions — lift effect on primary button
    6. Focus states — glowing ring around input when focused

    Accessibility:

    • Semantic HTML structure
    • ARIA labels on interactive elements
    • Keyboard navigation support
    • Respects prefers-reduced-motion

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.