Machine Coding
Machine Coding — Kanban
Learn to build an interactive Kanban Board in Angular using HTML5 Drag and Drop APIs, custom lists, column states, and status transitions.
1. Learning Objectives
In this machine coding guide, you will build a dynamic, draggable Kanban Board. By the end of this exercise, you will be able to:
- Handle HTML5 Drag and Drop API events (
dragstart,dragover,drop) natively. - Manage column lanes and categorizations using signals.
- Shift item records cleanly between states immutably.
- Build adding input drawers to append cards to selected columns.
- Apply drag indicators and CSS transitions to provide smooth feedback loops.
2. What We Are Building & Design System
Under interview settings, you are tasked with building a board organizer. Requirements include:
- Columns View: Render columns (Todo, In Progress, Done). Each column contains stack cards.
- Drag-and-Drop: Allow users to click and drag a card, dropping it into another column to change its status.
- Adding Controls: Input fields inside columns to add new cards to that column quickly.
- Deleting Cards: A delete action button on hover on cards to clear them from lists.
3. Step-by-Step Implementation Guide
Step 1: Declare Interfaces
Map tasks to statuses:
Step 2: Bind HTML5 Drag Handlers
Add draggable="true" to card elements. Listen to (dragstart) to save target item IDs:
Step 3: Handle Drop Actions
Listen to (dragover) and call event.preventDefault() to permit drops. Catch drops in (drop) to update states:
4. Full Working Code
Save this standalone component definition to build the Kanban Board:
5. Reviewing the Build / Self-Correction Checks
Verify your drag operations and list states update correctly:
- Check drag start events: Verify that dragging a card copies its exact ID string payload to the transfer buffer.
- Test status changes: Drag a card from "To Do" to "Done". Verify that the counts in the headers of both columns update immediately.
6. Practice Exercises & Extensions
Exercise 1: Implement card ordering indexes
Add an `order` property to cards. Integrate logic so that dropping a card inside a column sorts it into the exact slot index it was dropped (e.g. above or below existing cards).
7. Summary & Next Steps
By building this Kanban board, you have integrated drag-and-drop actions, mapped card statuses, and computed lane counters dynamically.
- Next, proceed to **Machine Coding — Chat App** to build asynchronous message streams.