Etch-A-Sketch
An Etch-A-Sketch implementation built to practice dynamic DOM generation, event delegation at scale, and per-cell state management with CSS Grid.
recruiter perspective
Etch-A-Sketch with CSS Grid, event delegation, and multiple color modes
- ›Dynamically generated N×N CSS Grid with single delegated listener (not per-cell)
- ›Three color modes: single color, random RGB, progressive darkening
- ›Configurable grid size up to 100×100 with clean regeneration
Try it live
Hiring Summary
Hiring Summary
A browser Etch-A-Sketch with resizable grid (up to 100×100), multiple color modes, and hover-activated drawing. Built with event delegation on a dynamically generated CSS Grid.
Context & Problem
Build a browser Etch-A-Sketch with configurable grid size (up to 100×100), multiple color modes, and hover-activated drawing.
Challenges Addressed
- Grid must regenerate cleanly on size change without memory leaks from old listeners
- Color modes: single color, random RGB, progressive darkening
- Drawing activates on mousedown-hover, not click-per-cell
Architecture
Vanilla JavaScript: generate N×N div grid with CSS Grid, attach a single mouseover listener to the grid container (event delegation), track mousedown state for drag-to-draw behavior.
Stack
Technical Decisions
Decision
Event delegation on grid container vs. per-cell listeners
A 100×100 grid has 10,000 cells. Per-cell listeners would create 10,000 event listeners. A single delegated listener scales to any grid size with no memory overhead.
Tradeoff
CSS Grid vs. Canvas for grid rendering
Chose: CSS Grid with div cells
Canvas is more performant for very large grids but requires manual pixel math. CSS Grid makes individual cell targeting trivial — each cell is a DOM element that can be styled independently.
Future Work
01Pencil and eraser tools
02Save drawing as PNG via Canvas toDataURL
03Fill bucket using flood-fill algorithm