Apps
Kanban
A board with WIP limits, drag and drop for mouse, touch and keyboard, filters, a card panel and a list view.
The board (name, due, columns with an optional WIP limit, cards) comes from the provider. Cards carry assignees, description, priority, checklist items, attachments and comments. Every move goes through move(), which returns full instead of breaking a column limit.
Every app follows the same pattern: typed models in types/models/, demo data in mocks/, state and actions in a composable under composables/apps/, page-only components in components/pages/<app>/ and UI strings in locales/<code>/apps.json. Read the apps overview once and every app looks familiar.
Files
File | Role |
|---|---|
pages/kanban.vue | The page: filters, board or list and the drag provider. |
composables/apps/useKanban.ts | Board state, filters, moves and CRUD. |
composables/apps/useKanbanDrag.ts | provideKanbanDrag() and useKanbanDrag(): mouse, touch and auto-scroll. |
types/models/kanban.ts | Board, columns, cards and the provider. |
config/kanban.config.ts | Labels, priorities, column colours, default view and the due soon window. |
utils/kanban.ts | Pure rules, unit tested. |
components/pages/kanban/ | KanbanColumn, KanbanCard, KanbanCardPanel, KanbanList, KanbanToolbar, KanbanCardFormDialog, KanbanColumnFormDialog. |
Data and provider
export interface KanbanProvider {
load: () => Promise<KanbanBoard>
saveCard: (card: KanbanCard) => Promise<void>
removeCard: (id: string) => Promise<void>
moveCard: (id: string, columnId: string, index: number) => Promise<void>
saveColumn: (column: KanbanColumn, index: number) => Promise<void>
removeColumn: (id: string) => Promise<void>
}
Connect your backend
The page calls useKanban() with the mock provider. Write a provider that calls your API with useApi() and pass it in the page. The composable loads it through useAsyncData and applies every change optimistically, so the interface does not wait for the server.
import type { KanbanBoard, KanbanProvider } from '~/types/models/kanban'
export function createKanbanApiProvider(): KanbanProvider {
const api = useApi()
return {
load: () => api<KanbanBoard>('/board'),
saveCard: (card) => api(`/cards/${card.id}`, { method: 'PUT', body: card }),
removeCard: (id) => api(`/cards/${id}`, { method: 'DELETE' }),
moveCard: (id, columnId, index) => api(`/cards/${id}/move`, { method: 'POST', body: { columnId, index } }),
saveColumn: (column, index) => api(`/columns/${column.id}`, { method: 'PUT', body: { ...column, index } }),
removeColumn: (id) => api(`/columns/${id}`, { method: 'DELETE' }),
}
}
<script setup lang="ts">
import { createKanbanApiProvider } from '~/providers/kanban'
const { ... } = useKanban({ provider: createKanbanApiProvider() })
</script>
Keep ids in your data and labels in the locales: folders, labels and tags resolve their names through apps.<app>.* unless you give them a raw title. See Connect your API for the token, validation errors and the actions the demo only fakes.
Configuration
KANBAN_LABELS
Card labels with their colour.
const KANBAN_LABELS: KanbanLabelConfig[]
KANBAN_PRIORITIES
Priorities with their icon and colour.
const KANBAN_PRIORITIES: KanbanPriorityConfig[]
KANBAN_COLUMN_COLORS
The colours a column can take.
const KANBAN_COLUMN_COLORS: string[]
KANBAN_DEFAULT_VIEW
board or list. The user’s choice persists in the kanban-view cookie.
const KANBAN_DEFAULT_VIEW: KanbanViewSettings
KANBAN_DUE_SOON_DAYS
How many days before the due date a card counts as “due soon”.
const KANBAN_DUE_SOON_DAYS: 3
Rules
Pure functions in utils/, unit tested. Use them in your backend too if you want the same answers.
moveKanbanCard()
Moves a card and reorders both columns.
moveKanbanCard(cards: KanbanCard[], cardId: string, columnId: string, index?: number): KanbanCard[]
isColumnFull()
Whether a column reached its WIP limit.
isColumnFull(column: KanbanColumn, count: number): boolean
kanbanDueState()
The due state of a card.
kanbanDueState(due: string, today: string, isDone: boolean, soonDays: number): KanbanDueState
matchesKanbanFilters()
Whether a card passes the filters.
matchesKanbanFilters(card: KanbanCard, filters: KanbanFilters, dueState: KanbanDueState): boolean
checklistProgress()
Checklist progress.
checklistProgress(items: KanbanChecklistItem[]): { done: number; total: number; }donetotalHow it works
- Mouse uses native HTML5 drag; touch uses a 300 ms long press. Both resolve the drop target with
pointAt()from[data-kanban-column]and[data-kanban-card], and touch auto-scrolls[data-kanban-board]near its edges. - A focused card moves with Alt + arrows. Every move is announced in an
aria-liveregion and focus follows the card. - Filters (search, people through
BaseAvatarGroup selectable, labels throughBaseMenuOptions, due soon) apply to both views and show aBaseEmptyStatewhen nothing matches. - Each column has a “…” menu: edit name, colour and limit, sort by due date, collapse and delete when empty.
- When the board is narrower than every column at
KANBAN_COLUMN_MIN_WIDTH(232px, inconfig/kanban.config.ts), the columns stack vertically instead of scrolling sideways: each one is a full-width section with a chevron that folds it to its header, and its cards fill a grid of 260px tracks. Touch drag then scrolls the page near the top and bottom edges, and the drop index follows both rows and columns of that grid. - Clicking a card opens
KanbanCardPanel, a temporary drawer with status, facts, checklist, attachments and comments. The form dialog is only for creating and full edits. KanbanListis aBaseDataTablegrouped by column with bulk move and delete and an inline status menu.