astryx-dracula 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/astryx.integration.mjs +1 -1
  2. package/icons.mjs +17 -17
  3. package/icons.tsx +61 -62
  4. package/package.json +120 -116
  5. package/shared/auth-chrome-config.ts +6 -6
  6. package/shared/auth-chrome.tsx +168 -19
  7. package/shared/auth-copy.ts +14 -14
  8. package/shared/chaptered-doc-config.ts +48 -51
  9. package/shared/chaptered-doc.tsx +270 -292
  10. package/shared/chart-hues.ts +10 -15
  11. package/shared/chart-labels.tsx +31 -30
  12. package/shared/chart-legend.tsx +55 -57
  13. package/shared/chart-panel-style.ts +3 -3
  14. package/shared/data-bar.tsx +97 -102
  15. package/shared/format-money.ts +3 -0
  16. package/shared/gallery-image.ts +6 -6
  17. package/shared/login-demo.ts +1 -1
  18. package/shared/metric-card.tsx +123 -0
  19. package/shared/metric-delta.tsx +28 -27
  20. package/shared/order-desk.tsx +205 -216
  21. package/shared/revenue-chart.tsx +145 -165
  22. package/shared/scene-castle.tsx +206 -291
  23. package/shared/scene-frame.tsx +33 -32
  24. package/shared/scene-hues.ts +17 -25
  25. package/shared/scene-tile.tsx +88 -100
  26. package/shared/settings-data.ts +132 -104
  27. package/shared/settings-rows.tsx +143 -163
  28. package/shared/sparkline.tsx +75 -88
  29. package/shared/sso-icons.tsx +10 -22
  30. package/shared/stars.tsx +19 -0
  31. package/templates/ai-chat-landing.template.mjs +4 -4
  32. package/templates/ai-chat-landing.tsx +468 -447
  33. package/templates/ai-chat.template.mjs +4 -4
  34. package/templates/ai-chat.tsx +561 -645
  35. package/templates/blank.template.mjs +4 -4
  36. package/templates/blank.tsx +14 -12
  37. package/templates/centered-hero.template.mjs +4 -4
  38. package/templates/centered-hero.tsx +52 -67
  39. package/templates/classic-gallery.template.mjs +4 -4
  40. package/templates/classic-gallery.tsx +92 -101
  41. package/templates/contact-form.template.mjs +4 -4
  42. package/templates/contact-form.tsx +243 -280
  43. package/templates/dashboard-portfolio.template.mjs +4 -4
  44. package/templates/dashboard-portfolio.tsx +723 -634
  45. package/templates/dashboard.template.mjs +4 -4
  46. package/templates/dashboard.tsx +592 -682
  47. package/templates/detail-page.template.mjs +4 -4
  48. package/templates/detail-page.tsx +537 -598
  49. package/templates/documentation-design.template.mjs +4 -4
  50. package/templates/documentation-design.tsx +242 -709
  51. package/templates/documentation-technical.template.mjs +4 -4
  52. package/templates/documentation-technical.tsx +233 -258
  53. package/templates/documentation.template.mjs +4 -4
  54. package/templates/documentation.tsx +263 -277
  55. package/templates/editor.template.mjs +4 -4
  56. package/templates/editor.tsx +847 -899
  57. package/templates/file-explorer.template.mjs +4 -4
  58. package/templates/file-explorer.tsx +562 -602
  59. package/templates/form-two-column.template.mjs +4 -4
  60. package/templates/form-two-column.tsx +187 -208
  61. package/templates/gallery-hero.template.mjs +4 -4
  62. package/templates/gallery-hero.tsx +89 -112
  63. package/templates/ide.template.mjs +4 -4
  64. package/templates/ide.tsx +405 -462
  65. package/templates/incident-console.template.mjs +4 -4
  66. package/templates/incident-console.tsx +559 -581
  67. package/templates/kanban-board.template.mjs +4 -4
  68. package/templates/kanban-board.tsx +660 -729
  69. package/templates/library.template.mjs +4 -4
  70. package/templates/library.tsx +405 -452
  71. package/templates/login-card.template.mjs +4 -4
  72. package/templates/login-card.tsx +59 -163
  73. package/templates/login-split.template.mjs +4 -4
  74. package/templates/login-split.tsx +196 -232
  75. package/templates/login-sso.template.mjs +4 -4
  76. package/templates/login-sso.tsx +253 -277
  77. package/templates/login.template.mjs +4 -4
  78. package/templates/login.tsx +51 -149
  79. package/templates/messaging-shell.template.mjs +4 -4
  80. package/templates/messaging-shell.tsx +596 -624
  81. package/templates/mixed-gallery.template.mjs +4 -4
  82. package/templates/mixed-gallery.tsx +56 -56
  83. package/templates/payment-form.template.mjs +4 -4
  84. package/templates/payment-form.tsx +877 -990
  85. package/templates/product-detail.template.mjs +4 -4
  86. package/templates/product-detail.tsx +251 -302
  87. package/templates/product-gallery.template.mjs +4 -4
  88. package/templates/product-gallery.tsx +122 -135
  89. package/templates/product-tour.template.mjs +4 -4
  90. package/templates/product-tour.tsx +737 -794
  91. package/templates/settings-dialog.template.mjs +4 -4
  92. package/templates/settings-dialog.tsx +694 -747
  93. package/templates/settings-sidebar.template.mjs +4 -4
  94. package/templates/settings-sidebar.tsx +768 -848
  95. package/templates/settings.template.mjs +4 -4
  96. package/templates/settings.tsx +306 -230
  97. package/templates/shell-nav.template.mjs +4 -4
  98. package/templates/shell-nav.tsx +217 -277
  99. package/templates/shell-side-nav.template.mjs +4 -4
  100. package/templates/shell-side-nav.tsx +130 -231
  101. package/templates/shell-top-nav.template.mjs +4 -4
  102. package/templates/shell-top-nav.tsx +192 -248
  103. package/templates/side-gallery.template.mjs +4 -4
  104. package/templates/side-gallery.tsx +87 -94
  105. package/templates/table-grouped.template.mjs +4 -4
  106. package/templates/table-grouped.tsx +999 -1201
  107. package/templates/table-page-chart.template.mjs +4 -4
  108. package/templates/table-page-chart.tsx +398 -397
  109. package/templates/table-page-heatmap-status.template.mjs +4 -4
  110. package/templates/table-page-heatmap-status.tsx +479 -527
  111. package/templates/table-page-shoe-store-heatmap.template.mjs +4 -4
  112. package/templates/table-page-shoe-store-heatmap.tsx +746 -746
  113. package/templates/table-page.template.mjs +4 -4
  114. package/templates/table-page.tsx +393 -431
  115. package/templates/table.template.mjs +4 -4
  116. package/templates/table.tsx +93 -99
  117. package/templates/tech-report.template.mjs +4 -4
  118. package/templates/tech-report.tsx +1320 -1324
  119. package/templates/theme-showcase.template.mjs +4 -4
  120. package/templates/theme-showcase.tsx +869 -1246
  121. package/tokens.css +340 -343
@@ -2,249 +2,234 @@
2
2
  // XLE (canonical structure, validated with `bunx astryx layout check`):
3
3
  // S > L > (LH[divider] > Tbar > (Hd"Sprint Board"[level=1] + Bd.neutral"8") + (H[g=2] > SE + D.strong + IB"Sort" + IB"Filter" + IB"Search" + B.primary"Add task")) + (LC[p=0] > G[c={min:280,max:4} g=4] > (C.muted[p=0] > L > (LH[divider] > H[j=between a=center] > (H[g=2 a=center] > SD + Hd"To-do"[level=2] + IB) + Tx) + (LC[p=3] > V[g=2] > (C[p=3] > V[g=2] > (H[j=between] > (H[g=2] > Tk + Bd) + MM) + (V[g=1] > Hd[level=3] + Tx) + Tx)*2))*4)
4
4
 
5
+ import { Badge } from "@astryxdesign/core/Badge";
6
+ import { Button } from "@astryxdesign/core/Button";
7
+ import { Card } from "@astryxdesign/core/Card";
8
+ import { Divider } from "@astryxdesign/core/Divider";
9
+ import { EmptyState } from "@astryxdesign/core/EmptyState";
10
+ import { Grid } from "@astryxdesign/core/Grid";
11
+ import { Icon } from "@astryxdesign/core/Icon";
12
+ import { IconButton } from "@astryxdesign/core/IconButton";
13
+ import { HStack, Layout, LayoutContent, LayoutHeader, VStack } from "@astryxdesign/core/Layout";
14
+ import { MoreMenu } from "@astryxdesign/core/MoreMenu";
15
+ import { Popover } from "@astryxdesign/core/Popover";
16
+ import { Section } from "@astryxdesign/core/Section";
17
+ import { Selector } from "@astryxdesign/core/Selector";
18
+ import { StatusDot } from "@astryxdesign/core/StatusDot";
19
+ import { Heading, Text } from "@astryxdesign/core/Text";
20
+ import { Token } from "@astryxdesign/core/Token";
21
+ import { Toolbar } from "@astryxdesign/core/Toolbar";
5
22
  import {
6
- useEffect,
7
- useRef,
8
- useState,
9
- type CSSProperties,
10
- type PointerEvent as ReactPointerEvent,
11
- type KeyboardEvent as ReactKeyboardEvent,
12
- type ReactNode,
13
- } from 'react';
14
-
15
- import {
16
- Layout,
17
- LayoutHeader,
18
- LayoutContent,
19
- HStack,
20
- VStack,
21
- } from '@astryxdesign/core/Layout';
22
- import {Text, Heading} from '@astryxdesign/core/Text';
23
- import {Card} from '@astryxdesign/core/Card';
24
- import {Badge} from '@astryxdesign/core/Badge';
25
- import {Token} from '@astryxdesign/core/Token';
26
- import {Button} from '@astryxdesign/core/Button';
27
- import {IconButton} from '@astryxdesign/core/IconButton';
28
- import {Icon} from '@astryxdesign/core/Icon';
29
- import {StatusDot} from '@astryxdesign/core/StatusDot';
30
- import {EmptyState} from '@astryxdesign/core/EmptyState';
31
- import {MoreMenu} from '@astryxdesign/core/MoreMenu';
32
- import {Selector} from '@astryxdesign/core/Selector';
33
- import {Popover} from '@astryxdesign/core/Popover';
34
- import {Divider} from '@astryxdesign/core/Divider';
35
- import {Toolbar} from '@astryxdesign/core/Toolbar';
36
- import {Section} from '@astryxdesign/core/Section';
37
- import {Grid} from '@astryxdesign/core/Grid';
38
-
23
+ ArrowUpDown,
24
+ CircleCheck,
25
+ ClipboardCheck,
26
+ Filter,
27
+ Inbox,
28
+ Info,
29
+ Plus,
30
+ RotateCw,
31
+ Search,
32
+ } from "lucide-react";
39
33
  import {
40
- Plus,
41
- Search,
42
- ArrowUpDown,
43
- Filter,
44
- RotateCw,
45
- CircleCheck,
46
- Inbox,
47
- Info,
48
- ClipboardCheck,
49
- } from 'lucide-react';
34
+ type KeyboardEvent as ReactKeyboardEvent,
35
+ type ReactNode,
36
+ type PointerEvent as ReactPointerEvent,
37
+ useEffect,
38
+ useRef,
39
+ useState,
40
+ } from "react";
50
41
 
51
42
  // ============= TYPES =============
52
43
 
53
- type ColumnId = 'todo' | 'in-progress' | 'in-review' | 'done';
54
- type Priority = 'high' | 'medium' | 'low';
44
+ type ColumnId = "todo" | "in-progress" | "in-review" | "done";
45
+ type Priority = "high" | "medium" | "low";
55
46
 
56
47
  interface WorkItem {
57
- id: string;
58
- column: ColumnId;
59
- ref: string;
60
- priority: Priority;
61
- title: string;
62
- description: string;
63
- lastEdited: string;
64
- dueDate: string;
48
+ id: string;
49
+ column: ColumnId;
50
+ ref: string;
51
+ priority: Priority;
52
+ title: string;
53
+ description: string;
54
+ lastEdited: string;
55
+ dueDate: string;
65
56
  }
66
57
 
67
58
  interface ColumnMeta {
68
- id: ColumnId;
69
- title: string;
70
- variant: 'neutral' | 'info' | 'warning' | 'success';
71
- tooltip: string;
72
- emptyTitle: string;
73
- emptyDescription: string;
74
- emptyIcon: typeof Inbox;
59
+ id: ColumnId;
60
+ title: string;
61
+ variant: "neutral" | "info" | "warning" | "success";
62
+ tooltip: string;
63
+ emptyTitle: string;
64
+ emptyDescription: string;
65
+ emptyIcon: typeof Inbox;
75
66
  }
76
67
 
77
68
  // Where a dragged card will land: a column and an insertion index within it
78
69
  // (measured against the cards remaining after the dragged card is removed).
79
70
  interface DropTarget {
80
- column: ColumnId;
81
- index: number;
71
+ column: ColumnId;
72
+ index: number;
82
73
  }
83
74
 
84
75
  // Live state of an in-progress pointer drag. Coordinates are in viewport space.
85
76
  interface DragState {
86
- id: string;
87
- width: number;
88
- height: number;
89
- offsetX: number;
90
- offsetY: number;
91
- pointerX: number;
92
- pointerY: number;
93
- target: DropTarget | null;
77
+ id: string;
78
+ width: number;
79
+ height: number;
80
+ offsetX: number;
81
+ offsetY: number;
82
+ pointerX: number;
83
+ pointerY: number;
84
+ target: DropTarget | null;
94
85
  }
95
86
 
96
87
  // ============= DATA =============
97
88
 
98
89
  const COLUMNS: ColumnMeta[] = [
99
- {
100
- id: 'todo',
101
- title: 'To-do',
102
- variant: 'neutral',
103
- tooltip: 'Palette tasks queued for this sprint, waiting to be picked up.',
104
- emptyTitle: 'To-do is empty',
105
- emptyDescription: 'Tasks pulled into this sprint appear here.',
106
- emptyIcon: Inbox,
107
- },
108
- {
109
- id: 'in-progress',
110
- title: 'In progress',
111
- variant: 'info',
112
- tooltip: 'Theme work currently on the easel.',
113
- emptyTitle: 'Nothing in progress',
114
- emptyDescription: 'Tasks being worked on appear here.',
115
- emptyIcon: RotateCw,
116
- },
117
- {
118
- id: 'in-review',
119
- title: 'In review',
120
- variant: 'info',
121
- tooltip: 'Shades waiting for your contrast review.',
122
- emptyTitle: 'Nothing in review',
123
- emptyDescription: 'Tasks awaiting your review appear here.',
124
- emptyIcon: ClipboardCheck,
125
- },
126
- {
127
- id: 'done',
128
- title: 'Done',
129
- variant: 'success',
130
- tooltip: 'Shipped shades, sealed after dark.',
131
- emptyTitle: 'Nothing done yet',
132
- emptyDescription: 'Completed tasks appear here.',
133
- emptyIcon: CircleCheck,
134
- },
90
+ {
91
+ id: "todo",
92
+ title: "To-do",
93
+ variant: "neutral",
94
+ tooltip: "Palette tasks queued for this sprint, waiting to be picked up.",
95
+ emptyTitle: "To-do is empty",
96
+ emptyDescription: "Tasks pulled into this sprint appear here.",
97
+ emptyIcon: Inbox,
98
+ },
99
+ {
100
+ id: "in-progress",
101
+ title: "In progress",
102
+ variant: "info",
103
+ tooltip: "Theme work currently on the easel.",
104
+ emptyTitle: "Nothing in progress",
105
+ emptyDescription: "Tasks being worked on appear here.",
106
+ emptyIcon: RotateCw,
107
+ },
108
+ {
109
+ id: "in-review",
110
+ title: "In review",
111
+ variant: "info",
112
+ tooltip: "Shades waiting for your contrast review.",
113
+ emptyTitle: "Nothing in review",
114
+ emptyDescription: "Tasks awaiting your review appear here.",
115
+ emptyIcon: ClipboardCheck,
116
+ },
117
+ {
118
+ id: "done",
119
+ title: "Done",
120
+ variant: "success",
121
+ tooltip: "Shipped shades, sealed after dark.",
122
+ emptyTitle: "Nothing done yet",
123
+ emptyDescription: "Completed tasks appear here.",
124
+ emptyIcon: CircleCheck,
125
+ },
135
126
  ];
136
127
 
137
- const PRIORITY_META: Record<
138
- Priority,
139
- {label: string; variant: 'red' | 'yellow' | 'neutral'}
140
- > = {
141
- high: {label: 'High', variant: 'red'},
142
- medium: {label: 'Medium', variant: 'yellow'},
143
- low: {label: 'Low', variant: 'neutral'}, // neutral: low priority is not info
128
+ const PRIORITY_META: Record<Priority, { label: string; variant: "red" | "yellow" | "neutral" }> = {
129
+ high: { label: "High", variant: "red" },
130
+ medium: { label: "Medium", variant: "yellow" },
131
+ low: { label: "Low", variant: "neutral" }, // neutral: low priority is not info
144
132
  };
145
133
 
146
134
  function groupByColumn(items: WorkItem[]): Record<ColumnId, WorkItem[]> {
147
- const map: Record<ColumnId, WorkItem[]> = {
148
- todo: [],
149
- 'in-progress': [],
150
- 'in-review': [],
151
- done: [],
152
- };
153
- for (const item of items) {
154
- map[item.column].push(item);
155
- }
156
- return map;
135
+ const map: Record<ColumnId, WorkItem[]> = {
136
+ todo: [],
137
+ "in-progress": [],
138
+ "in-review": [],
139
+ done: [],
140
+ };
141
+ for (const item of items) {
142
+ map[item.column].push(item);
143
+ }
144
+ return map;
157
145
  }
158
146
 
159
147
  const INITIAL_ITEMS: WorkItem[] = [
160
- {
161
- id: 't1',
162
- column: 'todo',
163
- ref: 'Task 4821',
164
- priority: 'low',
165
- title: 'Draft the palette rollout brief',
166
- description:
167
- 'Write a short brief outlining goals, scope, and contrast criteria for the Dracula rollout.',
168
- lastEdited: '2h ago',
169
- dueDate: 'Jul 8',
170
- },
171
- {
172
- id: 't2',
173
- column: 'todo',
174
- ref: 'Task 4842',
175
- priority: 'low',
176
- title: 'Collect feedback from night-shift reviewers',
177
- description:
178
- 'Gather input from key reviewers and summarize the main themes for the next review.',
179
- lastEdited: '1d ago',
180
- dueDate: 'Jul 11',
181
- },
182
- {
183
- id: 'p1',
184
- column: 'in-progress',
185
- ref: 'Task 4825',
186
- priority: 'high',
187
- title: 'Design the midnight landing page',
188
- description:
189
- 'Create a first-pass layout in pure Dracula and share it for early feedback after dark.',
190
- lastEdited: '18m ago',
191
- dueDate: 'Jul 3',
192
- },
193
- {
194
- id: 'p2',
195
- column: 'in-progress',
196
- ref: 'Task 4833',
197
- priority: 'medium',
198
- title: 'Set up the theme workspace',
199
- description:
200
- 'Configure the shared workspace and invite the coven so everyone has access.',
201
- lastEdited: '5m ago',
202
- dueDate: 'Jul 4',
203
- },
204
- {
205
- id: 'v1',
206
- column: 'in-review',
207
- ref: 'Task 4831',
208
- priority: 'medium',
209
- title: 'Review the moonlight contrast pass',
210
- description:
211
- 'Check the new palette against text and border contrast gates before it ships.',
212
- lastEdited: '2h ago',
213
- dueDate: 'Jul 5',
214
- },
215
- {
216
- id: 'r1',
217
- column: 'done',
218
- ref: 'Task 4788',
219
- priority: 'low',
220
- title: 'Publish the weekly changelog',
221
- description:
222
- 'Summarize progress, blockers, and next steps in a short update for the night shift.',
223
- lastEdited: 'Yesterday',
224
- dueDate: 'Jul 1',
225
- },
226
- {
227
- id: 'r2',
228
- column: 'done',
229
- ref: 'Task 4789',
230
- priority: 'high',
231
- title: 'Prepare the midnight demo walkthrough',
232
- description:
233
- 'Put together a candlelit walkthrough covering the main haunts for the demo.',
234
- lastEdited: '3d ago',
235
- dueDate: 'Jun 30',
236
- },
237
- {
238
- id: 'r3',
239
- column: 'done',
240
- ref: 'Task 4790',
241
- priority: 'medium',
242
- title: 'Review and merge open pull requests',
243
- description:
244
- 'Go through the pending bloodlines, leave comments, and merge the ones that are ready.',
245
- lastEdited: '4d ago',
246
- dueDate: 'Jun 28',
247
- },
148
+ {
149
+ id: "t1",
150
+ column: "todo",
151
+ ref: "Task 4821",
152
+ priority: "low",
153
+ title: "Draft the palette rollout brief",
154
+ description:
155
+ "Write a short brief outlining goals, scope, and contrast criteria for the Dracula rollout.",
156
+ lastEdited: "2h ago",
157
+ dueDate: "Jul 8",
158
+ },
159
+ {
160
+ id: "t2",
161
+ column: "todo",
162
+ ref: "Task 4842",
163
+ priority: "low",
164
+ title: "Collect feedback from night-shift reviewers",
165
+ description:
166
+ "Gather input from key reviewers and summarize the main themes for the next review.",
167
+ lastEdited: "1d ago",
168
+ dueDate: "Jul 11",
169
+ },
170
+ {
171
+ id: "p1",
172
+ column: "in-progress",
173
+ ref: "Task 4825",
174
+ priority: "high",
175
+ title: "Design the midnight landing page",
176
+ description:
177
+ "Create a first-pass layout in pure Dracula and share it for early feedback after dark.",
178
+ lastEdited: "18m ago",
179
+ dueDate: "Jul 3",
180
+ },
181
+ {
182
+ id: "p2",
183
+ column: "in-progress",
184
+ ref: "Task 4833",
185
+ priority: "medium",
186
+ title: "Set up the theme workspace",
187
+ description: "Configure the shared workspace and invite the coven so everyone has access.",
188
+ lastEdited: "5m ago",
189
+ dueDate: "Jul 4",
190
+ },
191
+ {
192
+ id: "v1",
193
+ column: "in-review",
194
+ ref: "Task 4831",
195
+ priority: "medium",
196
+ title: "Review the moonlight contrast pass",
197
+ description: "Check the new palette against text and border contrast gates before it ships.",
198
+ lastEdited: "2h ago",
199
+ dueDate: "Jul 5",
200
+ },
201
+ {
202
+ id: "r1",
203
+ column: "done",
204
+ ref: "Task 4788",
205
+ priority: "low",
206
+ title: "Publish the weekly changelog",
207
+ description:
208
+ "Summarize progress, blockers, and next steps in a short update for the night shift.",
209
+ lastEdited: "Yesterday",
210
+ dueDate: "Jul 1",
211
+ },
212
+ {
213
+ id: "r2",
214
+ column: "done",
215
+ ref: "Task 4789",
216
+ priority: "high",
217
+ title: "Prepare the midnight demo walkthrough",
218
+ description: "Put together a candlelit walkthrough covering the main haunts for the demo.",
219
+ lastEdited: "3d ago",
220
+ dueDate: "Jun 30",
221
+ },
222
+ {
223
+ id: "r3",
224
+ column: "done",
225
+ ref: "Task 4790",
226
+ priority: "medium",
227
+ title: "Review and merge open pull requests",
228
+ description:
229
+ "Go through the pending bloodlines, leave comments, and merge the ones that are ready.",
230
+ lastEdited: "4d ago",
231
+ dueDate: "Jun 28",
232
+ },
248
233
  ];
249
234
 
250
235
  // Pointer travel (px) before a press is promoted to a drag, so taps and clicks
@@ -253,553 +238,499 @@ const DRAG_THRESHOLD = 5;
253
238
 
254
239
  // ============= STYLES =============
255
240
 
256
- // Responsive board grid: columns collapse to fewer tracks, then a single
257
- // stack. The board keeps its own internal scroll as the only scroller;
258
- // grid children get room to shrink so nothing forces page-level scroll.
259
- const boardColumnsStyle: CSSProperties = {
260
- overflowX: 'auto',
261
- overflowY: 'auto',
262
- height: '100%',
263
- padding: 'var(--spacing-6)',
264
- };
265
- const columnShellStyle: CSSProperties = {
266
- minWidth: 0,
267
- height: '100%',
268
- };
269
- // Cards stay static per the Dracula brand (no hover lift); the floating drag
270
- // clone floats above the board with the high shadow token instead.
271
- const cardStyle: CSSProperties = {
272
- cursor: 'grab',
273
- userSelect: 'none',
274
- touchAction: 'none',
275
- };
276
241
  // The dragged card is lifted out of flow and follows the pointer. It ignores
277
242
  // pointer events so hit-testing reads the columns underneath it. The clone
278
243
  // rides above shell chrome (layered 0-3) but stays under overlay surfaces
279
244
  // (menus, dialogs layer at 500+ plus the top layer), so an open menu wins.
280
245
  const DRAG_CLONE_LAYER = 100;
281
- const floatingStyle: CSSProperties = {
282
- position: 'fixed',
283
- insetBlockStart: 0,
284
- insetInlineStart: 0,
285
- pointerEvents: 'none',
286
- cursor: 'grabbing',
287
- zIndex: DRAG_CLONE_LAYER,
288
- };
289
- // Placeholder marking the landing slot; matches the dragged card's height.
290
- const ghostStyle = (height: number): CSSProperties => ({
291
- height,
292
- borderRadius: 'var(--radius-element)',
293
- backgroundColor: 'var(--color-background-muted)',
294
- });
295
- const toolbarDividerStyle: CSSProperties = {
296
- alignSelf: 'stretch',
297
- };
298
- const columnEmptyStateStyle: CSSProperties = {
299
- // 12px, not 24. This applies to an EmptyState inside a LayoutContent
300
- // padding={3} (12px), so 24 rendered as 36px of block air on the empty
301
- // branch against 12px on the populated one -- a 3x difference between two
302
- // states of the same column, and the only nested inset in the kit that
303
- // exceeded its container. The block padding is the CONTAINER's job; this
304
- // one is the placeholder's room to breathe inside it.
305
- paddingBlock: 'var(--spacing-3)',
306
- };
307
-
308
246
  // ============= CARD BODY =============
309
247
 
310
248
  // Shared card contents, rendered both in the column list and inside the
311
249
  // floating drag clone so the two stay pixel-identical.
312
250
  function BoardCardBody({
313
- item,
314
- onMove,
251
+ item,
252
+ onMove,
315
253
  }: {
316
- item: WorkItem;
317
- onMove: (id: string, to: ColumnId) => void;
254
+ item: WorkItem;
255
+ onMove: (id: string, to: ColumnId) => void;
318
256
  }) {
319
- const priority = PRIORITY_META[item.priority];
320
- const moveTargets = COLUMNS.filter(c => c.id !== item.column).map(c => ({
321
- label: `Move to ${c.title}`,
322
- onClick: () => onMove(item.id, c.id),
323
- }));
324
-
325
- return (
326
- <VStack gap={2}>
327
- <HStack hAlign="between" vAlign="start">
328
- <HStack gap={2} vAlign="center" wrap="wrap">
329
- <Token label={item.ref} size="sm" />
330
- <Badge label={priority.label} variant={priority.variant} />
331
- </HStack>
332
- <MoreMenu
333
- label="Work item actions"
334
- size="sm"
335
- items={[
336
- {label: 'Open', onClick: () => {}},
337
- {label: 'Assign to me', onClick: () => {}},
338
- {type: 'divider'},
339
- ...moveTargets,
340
- ]}
341
- />
342
- </HStack>
343
-
344
- <VStack gap={1}>
345
- <Heading level={3}>{item.title}</Heading>
346
- <Text type="body" color="secondary" maxLines={2}>
347
- {item.description}
348
- </Text>
349
- </VStack>
350
-
351
- <Text type="supporting" color="secondary">
352
- Edited {item.lastEdited} · Due {item.dueDate}
353
- </Text>
354
- </VStack>
355
- );
257
+ const priority = PRIORITY_META[item.priority];
258
+ const moveTargets = COLUMNS.filter((c) => c.id !== item.column).map((c) => ({
259
+ label: `Move to ${c.title}`,
260
+ onClick: () => onMove(item.id, c.id),
261
+ }));
262
+
263
+ return (
264
+ <VStack gap={2}>
265
+ <HStack hAlign="between" vAlign="start">
266
+ <HStack gap={2} vAlign="center" wrap="wrap">
267
+ <Token label={item.ref} size="sm" />
268
+ <Badge label={priority.label} variant={priority.variant} />
269
+ </HStack>
270
+ <MoreMenu
271
+ label="Work item actions"
272
+ size="sm"
273
+ items={[
274
+ { label: "Open" },
275
+ { label: "Assign to me" },
276
+ { type: "divider" },
277
+ ...moveTargets,
278
+ ]}
279
+ />
280
+ </HStack>
281
+
282
+ <VStack gap={1}>
283
+ <Heading level={3}>{item.title}</Heading>
284
+ <Text type="body" color="secondary" maxLines={2}>
285
+ {item.description}
286
+ </Text>
287
+ </VStack>
288
+
289
+ <Text type="supporting" color="secondary">
290
+ Edited {item.lastEdited} · Due {item.dueDate}
291
+ </Text>
292
+ </VStack>
293
+ );
356
294
  }
357
295
 
358
296
  // ============= BOARD CARD =============
359
297
 
360
298
  function BoardCard({
361
- item,
362
- cardRef,
363
- onPointerDown,
364
- onMove,
299
+ item,
300
+ cardRef,
301
+ onPointerDown,
302
+ onMove,
365
303
  }: {
366
- item: WorkItem;
367
- cardRef: (el: HTMLDivElement | null) => void;
368
- onPointerDown: (e: ReactPointerEvent, id: string) => void;
369
- onMove: (id: string, to: ColumnId) => void;
304
+ item: WorkItem;
305
+ cardRef: (el: HTMLDivElement | null) => void;
306
+ onPointerDown: (e: ReactPointerEvent, id: string) => void;
307
+ onMove: (id: string, to: ColumnId) => void;
370
308
  }) {
371
- // Keyboard-move path for the core drag interaction: arrow keys move the
372
- // focused card across columns. The pointer DnD below stays quarantined and
373
- // untouched; this only reuses its moveItem commit.
374
- const onKeyDown = (e: ReactKeyboardEvent) => {
375
- const at = COLUMNS.findIndex(c => c.id === item.column);
376
- const to =
377
- e.key === 'ArrowRight'
378
- ? COLUMNS[Math.min(COLUMNS.length - 1, at + 1)]
379
- : e.key === 'ArrowLeft'
380
- ? COLUMNS[Math.max(0, at - 1)]
381
- : undefined;
382
- if (!to || to.id === item.column) {
383
- return;
384
- }
385
- e.preventDefault();
386
- onMove(item.id, to.id);
387
- };
388
- return (
389
- <Card
390
- ref={cardRef}
391
- padding={3}
392
- style={cardStyle}
393
- tabIndex={0}
394
- role="button"
395
- aria-label={`${item.title}. In ${COLUMNS.find(c => c.id === item.column)?.title}. Press left or right arrow to move across columns.`}
396
- onPointerDown={e => onPointerDown(e, item.id)}
397
- onKeyDown={onKeyDown}>
398
- <BoardCardBody item={item} onMove={onMove} />
399
- </Card>
400
- );
309
+ // Keyboard-move path for the core drag interaction: arrow keys move the
310
+ // focused card across columns. The pointer DnD below stays quarantined and
311
+ // untouched; this only reuses its moveItem commit.
312
+ const onKeyDown = (e: ReactKeyboardEvent) => {
313
+ const at = COLUMNS.findIndex((c) => c.id === item.column);
314
+ const to =
315
+ e.key === "ArrowRight"
316
+ ? COLUMNS[Math.min(COLUMNS.length - 1, at + 1)]
317
+ : e.key === "ArrowLeft"
318
+ ? COLUMNS[Math.max(0, at - 1)]
319
+ : undefined;
320
+ if (!to || to.id === item.column) {
321
+ return;
322
+ }
323
+ e.preventDefault();
324
+ onMove(item.id, to.id);
325
+ };
326
+ return (
327
+ <Card
328
+ ref={cardRef}
329
+ padding={3}
330
+ // Cards stay static per the Dracula brand (no hover lift); the floating
331
+ // drag clone floats above the board with the high shadow token instead.
332
+ style={{ cursor: "grab", userSelect: "none", touchAction: "none" }}
333
+ tabIndex={0}
334
+ role="button"
335
+ aria-label={`${item.title}. In ${COLUMNS.find((c) => c.id === item.column)?.title}. Press left or right arrow to move across columns.`}
336
+ onPointerDown={(e) => onPointerDown(e, item.id)}
337
+ onKeyDown={onKeyDown}
338
+ >
339
+ <BoardCardBody item={item} onMove={onMove} />
340
+ </Card>
341
+ );
401
342
  }
402
343
 
403
344
  // ============= BOARD COLUMN =============
404
345
 
405
346
  function BoardColumn({
406
- meta,
407
- count,
408
- contentRef,
409
- children,
347
+ meta,
348
+ count,
349
+ contentRef,
350
+ children,
410
351
  }: {
411
- meta: ColumnMeta;
412
- count: number;
413
- contentRef: (el: HTMLDivElement | null) => void;
414
- children: ReactNode;
352
+ meta: ColumnMeta;
353
+ count: number;
354
+ contentRef: (el: HTMLDivElement | null) => void;
355
+ children: ReactNode;
415
356
  }) {
416
- return (
417
- <Card variant="muted" padding={0} style={columnShellStyle}>
418
- <Layout
419
- height="fill"
420
- header={
421
- <LayoutHeader hasDivider padding={3}>
422
- <HStack hAlign="between" vAlign="center">
423
- <HStack gap={1} vAlign="center">
424
- <StatusDot
425
- variant={meta.variant}
426
- label={`${meta.title} status`}
427
- isPulsing={meta.id === 'in-progress' || meta.id === 'in-review'}
428
- />
429
- <Heading level={2}>{meta.title}</Heading>
430
- <Popover
431
- placement="below"
432
- width="min(20rem, calc(100vw - 2 * var(--space-viewport)))"
433
- label={`${meta.title} column help`}
434
- content={
435
- <Text type="body" color="secondary">
436
- {meta.tooltip}
437
- </Text>
438
- }>
439
- <IconButton
440
- label={`About the ${meta.title} column`}
441
- icon={<Icon icon={Info} size="sm" />}
442
- variant="ghost"
443
- size="sm"
444
- />
445
- </Popover>
446
- </HStack>
447
- <Text type="supporting" color="secondary" hasTabularNumbers>
448
- {count}
449
- </Text>
450
- </HStack>
451
- </LayoutHeader>
452
- }
453
- content={
454
- <LayoutContent ref={contentRef} padding={3}>
455
- {children ?? (
456
- <EmptyState
457
- isCompact
458
- style={columnEmptyStateStyle}
459
- icon={
460
- <Icon icon={meta.emptyIcon} size="lg" color="secondary" />
461
- }
462
- title={meta.emptyTitle}
463
- description={meta.emptyDescription}
464
- />
465
- )}
466
- </LayoutContent>
467
- }
468
- />
469
- </Card>
470
- );
357
+ return (
358
+ <Card variant="muted" padding={0} style={{ minWidth: 0, height: "100%" }}>
359
+ <Layout
360
+ height="fill"
361
+ header={
362
+ <LayoutHeader hasDivider padding={3}>
363
+ <HStack hAlign="between" vAlign="center">
364
+ <HStack gap={1} vAlign="center">
365
+ <StatusDot
366
+ variant={meta.variant}
367
+ label={`${meta.title} status`}
368
+ isPulsing={meta.id === "in-progress" || meta.id === "in-review"}
369
+ />
370
+ <Heading level={2}>{meta.title}</Heading>
371
+ <Popover
372
+ placement="below"
373
+ width="min(20rem, calc(100vw - 2 * var(--space-viewport)))"
374
+ label={`${meta.title} column help`}
375
+ content={
376
+ <Text type="body" color="secondary">
377
+ {meta.tooltip}
378
+ </Text>
379
+ }
380
+ >
381
+ <IconButton
382
+ label={`About the ${meta.title} column`}
383
+ icon={<Icon icon={Info} size="sm" />}
384
+ variant="ghost"
385
+ size="sm"
386
+ />
387
+ </Popover>
388
+ </HStack>
389
+ <Text type="supporting" color="secondary" hasTabularNumbers>
390
+ {count}
391
+ </Text>
392
+ </HStack>
393
+ </LayoutHeader>
394
+ }
395
+ content={
396
+ <LayoutContent ref={contentRef} padding={3}>
397
+ {children ?? (
398
+ <EmptyState
399
+ isCompact
400
+ // 12px, not 24: this EmptyState sits inside a LayoutContent
401
+ // padding={3} (12px), so 24 would render as 36px of block air
402
+ // on the empty branch against 12px on the populated one.
403
+ style={{ paddingBlock: "var(--spacing-3)" }}
404
+ icon={<Icon icon={meta.emptyIcon} size="lg" color="secondary" />}
405
+ title={meta.emptyTitle}
406
+ description={meta.emptyDescription}
407
+ />
408
+ )}
409
+ </LayoutContent>
410
+ }
411
+ />
412
+ </Card>
413
+ );
471
414
  }
472
415
 
473
416
  // ============= MAIN =============
474
417
 
475
418
  export default function KanbanBoard() {
476
- const [items, setItems] = useState<WorkItem[]>(INITIAL_ITEMS);
477
- const [sprint, setSprint] = useState('003');
478
- const [drag, setDrag] = useState<DragState | null>(null);
479
-
480
- // Live element registries for pointer hit-testing (kept out of render state).
481
- const columnEls = useRef(new Map<ColumnId, HTMLElement>());
482
- const cardEls = useRef(new Map<string, HTMLElement>());
483
- const columnRefCbs = useRef(
484
- new Map<ColumnId, (el: HTMLDivElement | null) => void>(),
485
- );
486
- const cardRefCbs = useRef(
487
- new Map<string, (el: HTMLDivElement | null) => void>(),
488
- );
489
- const teardownRef = useRef<(() => void) | null>(null);
490
-
491
- // Stable ref callbacks so registering an element never churns across renders.
492
- const getColumnRef = (id: ColumnId) => {
493
- let cb = columnRefCbs.current.get(id);
494
- if (!cb) {
495
- cb = el => {
496
- if (el) {
497
- columnEls.current.set(id, el);
498
- } else {
499
- columnEls.current.delete(id);
500
- }
501
- };
502
- columnRefCbs.current.set(id, cb);
503
- }
504
- return cb;
505
- };
506
-
507
- const getCardRef = (id: string) => {
508
- let cb = cardRefCbs.current.get(id);
509
- if (!cb) {
510
- cb = el => {
511
- if (el) {
512
- cardEls.current.set(id, el);
513
- } else {
514
- cardEls.current.delete(id);
515
- }
516
- };
517
- cardRefCbs.current.set(id, cb);
518
- }
519
- return cb;
520
- };
521
-
522
- const itemsByColumn = groupByColumn(items);
523
-
524
- const moveItem = (id: string, to: ColumnId) => {
525
- setItems(prev =>
526
- prev.map(item => (item.id === id ? {...item, column: to} : item)),
527
- );
528
- };
529
-
530
- // Resolve the pointer position to a column + insertion index, ignoring the
531
- // card being dragged so the math is against the cards that stay in place.
532
- const computeTarget = (
533
- px: number,
534
- py: number,
535
- draggedId: string,
536
- ): DropTarget | null => {
537
- for (const [colId, el] of Array.from(columnEls.current.entries())) {
538
- const r = el.getBoundingClientRect();
539
- if (px < r.left || px > r.right || py < r.top || py > r.bottom) {
540
- continue;
541
- }
542
-
543
- const ids: string[] = [];
544
- for (const it of itemsByColumn[colId]) {
545
- if (it.id !== draggedId) {
546
- ids.push(it.id);
547
- }
548
- }
549
-
550
- let index = ids.length;
551
- for (let i = 0; i < ids.length; i++) {
552
- const cardEl = cardEls.current.get(ids[i]);
553
- if (!cardEl) {
554
- continue;
555
- }
556
- const cr = cardEl.getBoundingClientRect();
557
- if (py < cr.top + cr.height / 2) {
558
- index = i;
559
- break;
560
- }
561
- }
562
- return {column: colId, index};
563
- }
564
- return null;
565
- };
566
-
567
- // Rebuild the flat item list so the dragged card lands at the resolved slot
568
- // while every other card keeps its relative order.
569
- const commitDrag = (id: string, target: DropTarget) => {
570
- setItems(prev => {
571
- const moved = prev.find(it => it.id === id);
572
- if (!moved) {
573
- return prev;
574
- }
575
-
576
- const rest = prev.filter(it => it.id !== id);
577
- const updated: WorkItem = {...moved, column: target.column};
578
- const colItems = rest.filter(it => it.column === target.column);
579
- const anchor = colItems[target.index];
580
-
581
- if (!anchor) {
582
- return [...rest, updated];
583
- }
584
- const at = rest.indexOf(anchor);
585
- return [...rest.slice(0, at), updated, ...rest.slice(at)];
586
- });
587
- };
588
-
589
- const onCardPointerDown = (e: ReactPointerEvent, id: string) => {
590
- if (e.button !== 0) {
591
- return;
592
- }
593
- // Let the card's own controls (the actions menu) handle the press.
594
- if (
595
- (e.target as HTMLElement).closest(
596
- 'button, [role="menuitem"], [role="menu"]',
597
- )
598
- ) {
599
- return;
600
- }
601
-
602
- const el = cardEls.current.get(id);
603
- if (!el) {
604
- return;
605
- }
606
-
607
- const rect = el.getBoundingClientRect();
608
- const startX = e.clientX;
609
- const startY = e.clientY;
610
- const offsetX = startX - rect.left;
611
- const offsetY = startY - rect.top;
612
- const {width, height} = rect;
613
-
614
- let started = false;
615
- let target: DropTarget | null = null;
616
-
617
- const onMove = (ev: PointerEvent) => {
618
- if (
619
- !started &&
620
- Math.abs(ev.clientX - startX) + Math.abs(ev.clientY - startY) <
621
- DRAG_THRESHOLD
622
- ) {
623
- return;
624
- }
625
- started = true;
626
- target = computeTarget(ev.clientX, ev.clientY, id);
627
- setDrag({
628
- id,
629
- width,
630
- height,
631
- offsetX,
632
- offsetY,
633
- pointerX: ev.clientX,
634
- pointerY: ev.clientY,
635
- target,
636
- });
637
- };
638
-
639
- const onUp = () => {
640
- teardownRef.current?.();
641
- if (started && target) {
642
- commitDrag(id, target);
643
- }
644
- setDrag(null);
645
- };
646
-
647
- const teardown = () => {
648
- window.removeEventListener('pointermove', onMove);
649
- window.removeEventListener('pointerup', onUp);
650
- teardownRef.current = null;
651
- };
652
- teardownRef.current = teardown;
653
-
654
- window.addEventListener('pointermove', onMove);
655
- window.addEventListener('pointerup', onUp);
656
- };
657
-
658
- const draggedItem = drag ? items.find(it => it.id === drag.id) : undefined;
659
- const isDragging = drag !== null;
660
-
661
- // Suppress selection while dragging and detach listeners on unmount.
662
- useEffect(() => {
663
- if (!isDragging) {
664
- return;
665
- }
666
- const previous = document.body.style.userSelect;
667
- document.body.style.userSelect = 'none';
668
- return () => {
669
- document.body.style.userSelect = previous;
670
- };
671
- }, [isDragging]);
672
-
673
- useEffect(() => () => teardownRef.current?.(), []);
674
-
675
- // Card nodes for a column, or null when the column should show its empty
676
- // state. A dashed ghost box marks the landing slot during a drag.
677
- const renderColumnCards = (colId: ColumnId): ReactNode => {
678
- const colItems = itemsByColumn[colId];
679
- const visible = drag ? colItems.filter(it => it.id !== drag.id) : colItems;
680
- const ghostTarget =
681
- drag && drag.target && drag.target.column === colId ? drag : null;
682
-
683
- if (visible.length === 0 && !ghostTarget) {
684
- return null;
685
- }
686
-
687
- const nodes: ReactNode[] = visible.map(it => (
688
- <BoardCard
689
- key={it.id}
690
- item={it}
691
- cardRef={getCardRef(it.id)}
692
- onPointerDown={onCardPointerDown}
693
- onMove={moveItem}
694
- />
695
- ));
696
-
697
- if (ghostTarget && ghostTarget.target) {
698
- const index = Math.min(ghostTarget.target.index, nodes.length);
699
- nodes.splice(
700
- index,
701
- 0,
702
- <VStack key="drag-ghost" style={ghostStyle(ghostTarget.height)} />,
703
- );
704
- }
705
-
706
- return <VStack gap={2}>{nodes}</VStack>;
707
- };
708
-
709
- return (
710
- <Section height="100dvh">
711
- <Layout
712
- height="fill"
713
- header={
714
- <LayoutHeader hasDivider padding={6}>
715
- <Toolbar
716
- label="Board actions"
717
- gap={2}
718
- startContent={
719
- <>
720
- <Heading level={1} type="display-2">Sprint Board</Heading>
721
- <Badge label={items.length} variant="neutral" />
722
- </>
723
- }
724
- endContent={
725
- <HStack gap={2} wrap="wrap">
726
- <Selector
727
- label="Sprint"
728
- size="lg"
729
- width={160}
730
- isLabelHidden
731
- value={sprint}
732
- onChange={setSprint}
733
- options={[
734
- {value: '003', label: 'Sprint 003'},
735
- {value: '002', label: 'Sprint 002'},
736
- {value: '001', label: 'Sprint 001'},
737
- ]}
738
- />
739
- <Divider
740
- variant="strong"
741
- orientation="vertical"
742
- style={toolbarDividerStyle}
743
- />
744
- <HStack gap={1} vAlign="center" wrap="wrap">
745
- <IconButton
746
- icon={<Icon icon={ArrowUpDown} size="sm" />}
747
- label="Sort"
748
- />
749
- <IconButton
750
- icon={<Icon icon={Filter} size="sm" />}
751
- label="Filter"
752
- />
753
- <IconButton
754
- icon={<Icon icon={Search} size="sm" />}
755
- label="Search"
756
- />
757
- </HStack>
758
- <Button
759
- label="Add task"
760
- variant="primary"
761
- icon={<Icon icon={Plus} size="sm" />}
762
- />
763
- </HStack>
764
- }
765
- />
766
- </LayoutHeader>
767
- }
768
- content={
769
- <LayoutContent padding={0} isScrollable={false}>
770
- <Grid
771
- columns={{ minWidth: 280, max: 4 }}
772
- gap={4}
773
- style={boardColumnsStyle}
774
- tabIndex={0}
775
- role="region"
776
- aria-label="Sprint board columns">
777
- {COLUMNS.map(meta => (
778
- <BoardColumn
779
- key={meta.id}
780
- meta={meta}
781
- count={itemsByColumn[meta.id].length}
782
- contentRef={getColumnRef(meta.id)}>
783
- {renderColumnCards(meta.id)}
784
- </BoardColumn>
785
- ))}
786
- </Grid>
787
- </LayoutContent>
788
- }
789
- />
790
- {drag && draggedItem ? (
791
- <Card
792
- padding={3}
793
- elevation="none"
794
- style={{
795
- ...floatingStyle,
796
- width: drag.width,
797
- borderColor: 'var(--color-border-emphasized)',
798
- transform: `translate(${drag.pointerX - drag.offsetX}px, ${drag.pointerY - drag.offsetY}px)`,
799
- }}>
800
- <BoardCardBody item={draggedItem} onMove={() => {}} />
801
- </Card>
802
- ) : null}
803
- </Section>
804
- );
419
+ const [items, setItems] = useState<WorkItem[]>(INITIAL_ITEMS);
420
+ const [sprint, setSprint] = useState("003");
421
+ const [drag, setDrag] = useState<DragState | null>(null);
422
+
423
+ // Live element registries for pointer hit-testing (kept out of render state).
424
+ const columnEls = useRef(new Map<ColumnId, HTMLElement>());
425
+ const cardEls = useRef(new Map<string, HTMLElement>());
426
+ const columnRefCbs = useRef(new Map<ColumnId, (el: HTMLDivElement | null) => void>());
427
+ const cardRefCbs = useRef(new Map<string, (el: HTMLDivElement | null) => void>());
428
+ const teardownRef = useRef<(() => void) | null>(null);
429
+
430
+ // One helper for both registries: stable per-key ref callbacks so
431
+ // registering an element never churns across renders.
432
+ function refCallback<K>(
433
+ cbs: Map<K, (el: HTMLDivElement | null) => void>,
434
+ els: Map<K, HTMLElement>,
435
+ key: K,
436
+ ) {
437
+ let cb = cbs.get(key);
438
+ if (!cb) {
439
+ cb = (el) => {
440
+ if (el) {
441
+ els.set(key, el);
442
+ } else {
443
+ els.delete(key);
444
+ }
445
+ };
446
+ cbs.set(key, cb);
447
+ }
448
+ return cb;
449
+ }
450
+
451
+ const itemsByColumn = groupByColumn(items);
452
+
453
+ const moveItem = (id: string, to: ColumnId) => {
454
+ setItems((prev) => prev.map((item) => (item.id === id ? { ...item, column: to } : item)));
455
+ };
456
+
457
+ // Resolve the pointer position to a column + insertion index, ignoring the
458
+ // card being dragged so the math is against the cards that stay in place.
459
+ const computeTarget = (px: number, py: number, draggedId: string): DropTarget | null => {
460
+ for (const [colId, el] of Array.from(columnEls.current.entries())) {
461
+ const r = el.getBoundingClientRect();
462
+ if (px < r.left || px > r.right || py < r.top || py > r.bottom) {
463
+ continue;
464
+ }
465
+
466
+ const ids: string[] = [];
467
+ for (const it of itemsByColumn[colId]) {
468
+ if (it.id !== draggedId) {
469
+ ids.push(it.id);
470
+ }
471
+ }
472
+
473
+ let index = ids.length;
474
+ for (let i = 0; i < ids.length; i++) {
475
+ const cardEl = cardEls.current.get(ids[i]);
476
+ if (!cardEl) {
477
+ continue;
478
+ }
479
+ const cr = cardEl.getBoundingClientRect();
480
+ if (py < cr.top + cr.height / 2) {
481
+ index = i;
482
+ break;
483
+ }
484
+ }
485
+ return { column: colId, index };
486
+ }
487
+ return null;
488
+ };
489
+
490
+ // Rebuild the flat item list so the dragged card lands at the resolved slot
491
+ // while every other card keeps its relative order.
492
+ const commitDrag = (id: string, target: DropTarget) => {
493
+ setItems((prev) => {
494
+ const moved = prev.find((it) => it.id === id);
495
+ if (!moved) {
496
+ return prev;
497
+ }
498
+
499
+ const rest = prev.filter((it) => it.id !== id);
500
+ const updated: WorkItem = { ...moved, column: target.column };
501
+ const colItems = rest.filter((it) => it.column === target.column);
502
+ const anchor = colItems[target.index];
503
+
504
+ if (!anchor) {
505
+ return [...rest, updated];
506
+ }
507
+ const at = rest.indexOf(anchor);
508
+ return [...rest.slice(0, at), updated, ...rest.slice(at)];
509
+ });
510
+ };
511
+
512
+ const onCardPointerDown = (e: ReactPointerEvent, id: string) => {
513
+ if (e.button !== 0) {
514
+ return;
515
+ }
516
+ // Let the card's own controls (the actions menu) handle the press.
517
+ if ((e.target as HTMLElement).closest('button, [role="menuitem"], [role="menu"]')) {
518
+ return;
519
+ }
520
+
521
+ const el = cardEls.current.get(id);
522
+ if (!el) {
523
+ return;
524
+ }
525
+
526
+ const rect = el.getBoundingClientRect();
527
+ const startX = e.clientX;
528
+ const startY = e.clientY;
529
+ const offsetX = startX - rect.left;
530
+ const offsetY = startY - rect.top;
531
+ const { width, height } = rect;
532
+
533
+ let started = false;
534
+ let target: DropTarget | null = null;
535
+
536
+ const onMove = (ev: PointerEvent) => {
537
+ if (
538
+ !started &&
539
+ Math.abs(ev.clientX - startX) + Math.abs(ev.clientY - startY) < DRAG_THRESHOLD
540
+ ) {
541
+ return;
542
+ }
543
+ started = true;
544
+ target = computeTarget(ev.clientX, ev.clientY, id);
545
+ setDrag({
546
+ id,
547
+ width,
548
+ height,
549
+ offsetX,
550
+ offsetY,
551
+ pointerX: ev.clientX,
552
+ pointerY: ev.clientY,
553
+ target,
554
+ });
555
+ };
556
+
557
+ const onUp = () => {
558
+ teardownRef.current?.();
559
+ if (started && target) {
560
+ commitDrag(id, target);
561
+ }
562
+ setDrag(null);
563
+ };
564
+
565
+ const teardown = () => {
566
+ window.removeEventListener("pointermove", onMove);
567
+ window.removeEventListener("pointerup", onUp);
568
+ teardownRef.current = null;
569
+ };
570
+ teardownRef.current = teardown;
571
+
572
+ window.addEventListener("pointermove", onMove);
573
+ window.addEventListener("pointerup", onUp);
574
+ };
575
+
576
+ const draggedItem = drag ? items.find((it) => it.id === drag.id) : undefined;
577
+ const isDragging = drag !== null;
578
+
579
+ // Suppress selection while dragging and detach listeners on unmount.
580
+ useEffect(() => {
581
+ if (!isDragging) {
582
+ return;
583
+ }
584
+ const previous = document.body.style.userSelect;
585
+ document.body.style.userSelect = "none";
586
+ return () => {
587
+ document.body.style.userSelect = previous;
588
+ };
589
+ }, [isDragging]);
590
+
591
+ useEffect(() => () => teardownRef.current?.(), []);
592
+
593
+ // Card nodes for a column, or null when the column should show its empty
594
+ // state. A dashed ghost box marks the landing slot during a drag.
595
+ const renderColumnCards = (colId: ColumnId): ReactNode => {
596
+ const colItems = itemsByColumn[colId];
597
+ const visible = drag ? colItems.filter((it) => it.id !== drag.id) : colItems;
598
+ const ghostTarget = drag && drag.target && drag.target.column === colId ? drag : null;
599
+
600
+ if (visible.length === 0 && !ghostTarget) {
601
+ return null;
602
+ }
603
+
604
+ const nodes: ReactNode[] = visible.map((it) => (
605
+ <BoardCard
606
+ key={it.id}
607
+ item={it}
608
+ cardRef={refCallback(cardRefCbs.current, cardEls.current, it.id)}
609
+ onPointerDown={onCardPointerDown}
610
+ onMove={moveItem}
611
+ />
612
+ ));
613
+
614
+ if (ghostTarget && ghostTarget.target) {
615
+ const index = Math.min(ghostTarget.target.index, nodes.length);
616
+ nodes.splice(
617
+ index,
618
+ 0,
619
+ <VStack
620
+ key="drag-ghost"
621
+ // Placeholder marking the landing slot; matches the dragged card's height.
622
+ style={{
623
+ height: ghostTarget.height,
624
+ borderRadius: "var(--radius-element)",
625
+ backgroundColor: "var(--color-background-muted)",
626
+ }}
627
+ />,
628
+ );
629
+ }
630
+
631
+ return <VStack gap={2}>{nodes}</VStack>;
632
+ };
633
+
634
+ return (
635
+ <Section height="100dvh">
636
+ <Layout
637
+ height="fill"
638
+ header={
639
+ <LayoutHeader hasDivider padding={6}>
640
+ <Toolbar
641
+ label="Board actions"
642
+ gap={2}
643
+ startContent={
644
+ <>
645
+ <Heading level={1} type="display-2">
646
+ Sprint Board
647
+ </Heading>
648
+ <Badge label={items.length} variant="neutral" />
649
+ </>
650
+ }
651
+ endContent={
652
+ <HStack gap={2} wrap="wrap">
653
+ <Selector
654
+ label="Sprint"
655
+ size="lg"
656
+ width={160}
657
+ isLabelHidden
658
+ value={sprint}
659
+ onChange={setSprint}
660
+ options={[
661
+ { value: "003", label: "Sprint 003" },
662
+ { value: "002", label: "Sprint 002" },
663
+ { value: "001", label: "Sprint 001" },
664
+ ]}
665
+ />
666
+ <Divider
667
+ variant="strong"
668
+ orientation="vertical"
669
+ style={{ alignSelf: "stretch" }}
670
+ />
671
+ <HStack gap={1} vAlign="center" wrap="wrap">
672
+ <IconButton icon={<Icon icon={ArrowUpDown} size="sm" />} label="Sort" />
673
+ <IconButton icon={<Icon icon={Filter} size="sm" />} label="Filter" />
674
+ <IconButton icon={<Icon icon={Search} size="sm" />} label="Search" />
675
+ </HStack>
676
+ <Button
677
+ label="Add task"
678
+ variant="primary"
679
+ icon={<Icon icon={Plus} size="sm" />}
680
+ />
681
+ </HStack>
682
+ }
683
+ />
684
+ </LayoutHeader>
685
+ }
686
+ content={
687
+ <LayoutContent padding={0} isScrollable={false}>
688
+ <Grid
689
+ columns={{ minWidth: 280, max: 4 }}
690
+ gap={4}
691
+ style={{
692
+ overflowX: "auto",
693
+ overflowY: "auto",
694
+ height: "100%",
695
+ padding: "var(--spacing-6)",
696
+ }}
697
+ tabIndex={0}
698
+ role="region"
699
+ aria-label="Sprint board columns"
700
+ >
701
+ {COLUMNS.map((meta) => (
702
+ <BoardColumn
703
+ key={meta.id}
704
+ meta={meta}
705
+ count={itemsByColumn[meta.id].length}
706
+ contentRef={refCallback(columnRefCbs.current, columnEls.current, meta.id)}
707
+ >
708
+ {renderColumnCards(meta.id)}
709
+ </BoardColumn>
710
+ ))}
711
+ </Grid>
712
+ </LayoutContent>
713
+ }
714
+ />
715
+ {drag && draggedItem ? (
716
+ <Card
717
+ padding={3}
718
+ elevation="none"
719
+ style={{
720
+ position: "fixed",
721
+ insetBlockStart: 0,
722
+ insetInlineStart: 0,
723
+ pointerEvents: "none",
724
+ cursor: "grabbing",
725
+ zIndex: DRAG_CLONE_LAYER,
726
+ width: drag.width,
727
+ borderColor: "var(--color-border-emphasized)",
728
+ transform: `translate(${drag.pointerX - drag.offsetX}px, ${drag.pointerY - drag.offsetY}px)`,
729
+ }}
730
+ >
731
+ <BoardCardBody item={draggedItem} onMove={() => {}} />
732
+ </Card>
733
+ ) : null}
734
+ </Section>
735
+ );
805
736
  }