|
| 1 | +# Kanban Board Component |
| 2 | + |
| 3 | +A fully functional, schema-driven Kanban board component for Object UI with drag-and-drop support. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Multiple Columns**: Create unlimited columns with customizable titles |
| 8 | +- **Rich Cards**: Cards support title, description, and multiple badges |
| 9 | +- **Drag & Drop**: Smooth drag-and-drop functionality powered by @dnd-kit |
| 10 | +- **Reordering**: Reorder cards within the same column |
| 11 | +- **Cross-Column Moves**: Move cards between different columns |
| 12 | +- **Column Limits**: Optional capacity limits with visual indicators |
| 13 | +- **Card Counters**: Shows current count and limit per column |
| 14 | +- **Schema-Driven**: Configure entirely through JSON/YAML |
| 15 | +- **Event Callbacks**: Custom event handling for card movements |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +### Basic Example |
| 20 | + |
| 21 | +```json |
| 22 | +{ |
| 23 | + "type": "kanban", |
| 24 | + "className": "w-full h-[600px]", |
| 25 | + "columns": [ |
| 26 | + { |
| 27 | + "id": "todo", |
| 28 | + "title": "To Do", |
| 29 | + "cards": [ |
| 30 | + { |
| 31 | + "id": "card-1", |
| 32 | + "title": "Task Title", |
| 33 | + "description": "Task description", |
| 34 | + "badges": [ |
| 35 | + { "label": "High Priority", "variant": "destructive" } |
| 36 | + ] |
| 37 | + } |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "id": "in-progress", |
| 42 | + "title": "In Progress", |
| 43 | + "limit": 3, |
| 44 | + "cards": [] |
| 45 | + }, |
| 46 | + { |
| 47 | + "id": "done", |
| 48 | + "title": "Done", |
| 49 | + "cards": [] |
| 50 | + } |
| 51 | + ] |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +### With Event Handling |
| 56 | + |
| 57 | +```json |
| 58 | +{ |
| 59 | + "type": "kanban", |
| 60 | + "columns": [...], |
| 61 | + "onCardMove": "(event) => { console.log('Card moved:', event); }" |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +## Schema Reference |
| 66 | + |
| 67 | +### Kanban Props |
| 68 | + |
| 69 | +| Property | Type | Required | Description | |
| 70 | +|----------|------|----------|-------------| |
| 71 | +| `type` | `"kanban"` | Yes | Component type identifier | |
| 72 | +| `columns` | `KanbanColumn[]` | Yes | Array of column configurations | |
| 73 | +| `className` | `string` | No | Custom CSS classes | |
| 74 | +| `onCardMove` | `function` | No | Callback when a card is moved | |
| 75 | + |
| 76 | +### KanbanColumn |
| 77 | + |
| 78 | +| Property | Type | Required | Description | |
| 79 | +|----------|------|----------|-------------| |
| 80 | +| `id` | `string` | Yes | Unique column identifier | |
| 81 | +| `title` | `string` | Yes | Column header title | |
| 82 | +| `cards` | `KanbanCard[]` | Yes | Array of cards in this column | |
| 83 | +| `limit` | `number` | No | Maximum number of cards allowed | |
| 84 | +| `className` | `string` | No | Custom CSS classes for column | |
| 85 | + |
| 86 | +### KanbanCard |
| 87 | + |
| 88 | +| Property | Type | Required | Description | |
| 89 | +|----------|------|----------|-------------| |
| 90 | +| `id` | `string` | Yes | Unique card identifier | |
| 91 | +| `title` | `string` | Yes | Card title | |
| 92 | +| `description` | `string` | No | Card description text | |
| 93 | +| `badges` | `Badge[]` | No | Array of badge objects | |
| 94 | + |
| 95 | +### Badge |
| 96 | + |
| 97 | +| Property | Type | Required | Description | |
| 98 | +|----------|------|----------|-------------| |
| 99 | +| `label` | `string` | Yes | Badge text | |
| 100 | +| `variant` | `"default" \| "secondary" \| "destructive" \| "outline"` | No | Badge color variant | |
| 101 | + |
| 102 | +## Examples |
| 103 | + |
| 104 | +### Simple Task Board |
| 105 | + |
| 106 | +```json |
| 107 | +{ |
| 108 | + "type": "kanban", |
| 109 | + "columns": [ |
| 110 | + { |
| 111 | + "id": "backlog", |
| 112 | + "title": "📋 Backlog", |
| 113 | + "cards": [ |
| 114 | + { |
| 115 | + "id": "1", |
| 116 | + "title": "Setup project", |
| 117 | + "badges": [{ "label": "Setup" }] |
| 118 | + } |
| 119 | + ] |
| 120 | + }, |
| 121 | + { |
| 122 | + "id": "doing", |
| 123 | + "title": "🚀 Doing", |
| 124 | + "limit": 2, |
| 125 | + "cards": [] |
| 126 | + }, |
| 127 | + { |
| 128 | + "id": "done", |
| 129 | + "title": "✅ Done", |
| 130 | + "cards": [] |
| 131 | + } |
| 132 | + ] |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +### Issue Tracking Board |
| 137 | + |
| 138 | +```json |
| 139 | +{ |
| 140 | + "type": "kanban", |
| 141 | + "columns": [ |
| 142 | + { |
| 143 | + "id": "new", |
| 144 | + "title": "New Issues", |
| 145 | + "cards": [ |
| 146 | + { |
| 147 | + "id": "issue-1", |
| 148 | + "title": "Bug: Login fails on Safari", |
| 149 | + "description": "Users can't login using Safari browser", |
| 150 | + "badges": [ |
| 151 | + { "label": "Bug", "variant": "destructive" }, |
| 152 | + { "label": "P0", "variant": "destructive" } |
| 153 | + ] |
| 154 | + } |
| 155 | + ] |
| 156 | + }, |
| 157 | + { |
| 158 | + "id": "investigating", |
| 159 | + "title": "Investigating", |
| 160 | + "limit": 3, |
| 161 | + "cards": [] |
| 162 | + }, |
| 163 | + { |
| 164 | + "id": "fixed", |
| 165 | + "title": "Fixed", |
| 166 | + "cards": [] |
| 167 | + } |
| 168 | + ] |
| 169 | +} |
| 170 | +``` |
| 171 | + |
| 172 | +## Styling |
| 173 | + |
| 174 | +The Kanban component uses Tailwind CSS and can be customized using the `className` prop: |
| 175 | + |
| 176 | +```json |
| 177 | +{ |
| 178 | + "type": "kanban", |
| 179 | + "className": "w-full h-[800px] bg-gray-50 p-4 rounded-lg", |
| 180 | + "columns": [...] |
| 181 | +} |
| 182 | +``` |
| 183 | + |
| 184 | +Individual columns can also be styled: |
| 185 | + |
| 186 | +```json |
| 187 | +{ |
| 188 | + "id": "urgent", |
| 189 | + "title": "🔥 Urgent", |
| 190 | + "className": "bg-red-50", |
| 191 | + "cards": [...] |
| 192 | +} |
| 193 | +``` |
| 194 | + |
| 195 | +## Technical Details |
| 196 | + |
| 197 | +- Built with React 18+ and TypeScript |
| 198 | +- Uses @dnd-kit for drag-and-drop functionality |
| 199 | +- Integrates with Shadcn UI components (Card, Badge, ScrollArea) |
| 200 | +- Supports both pointer and touch interactions |
| 201 | +- Accessible keyboard navigation (via @dnd-kit) |
| 202 | + |
| 203 | +## Browser Support |
| 204 | + |
| 205 | +- Chrome/Edge: Full support |
| 206 | +- Firefox: Full support |
| 207 | +- Safari: Full support |
| 208 | +- Mobile browsers: Full support with touch gestures |
0 commit comments