Implement dashboard composition (task 20)

- Add default_dashboard_layout jsonb to users + migration 0007
- Create _core/manifest.tsx with core.activity placeholder widget
- Register core manifest alongside calendar/lists/notes
- Update all three module manifests with real async server-component
  widget renders (upcoming events, month view, list items, notes)
- Add src/lib/dashboard.ts: computeDefaultLayout greedy packer +
  parseDashboardLayout Zod validator
- Build src/app/page.tsx: 12-col CSS Grid, static smColSpan lookup,
  per-widget Suspense for parallel loading, generic widget.render()
  dispatch — no widgetId branches
- Add tests/e2e/dashboard.spec.ts; all 4 E2E specs pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ginnoir
2026-05-06 13:24:56 -05:00
co-authored by Claude Sonnet 4.6
parent d7069d14a2
commit b4dde92757
11 changed files with 380 additions and 46 deletions
+67
View File
@@ -0,0 +1,67 @@
import { z } from "zod";
import { getRegistry } from "@/modules/_core";
export type WidgetPlacement = {
widgetId: string;
config: unknown;
x: number;
y: number;
w: number;
h: number;
};
export type DashboardLayout = {
version: 1;
widgets: WidgetPlacement[];
};
const placementSchema = z.object({
widgetId: z.string(),
config: z.unknown(),
x: z.number().int().min(0),
y: z.number().int().min(0),
w: z.number().int().min(1).max(12),
h: z.number().int().min(1),
});
const layoutSchema = z.object({
version: z.literal(1),
widgets: z.array(placementSchema),
});
export function parseDashboardLayout(raw: unknown): DashboardLayout | null {
const result = layoutSchema.safeParse(raw);
if (!result.success) return null;
return result.data;
}
export function computeDefaultLayout(): DashboardLayout {
const { widgets } = getRegistry();
const sorted = [...widgets].sort((a, b) => a.defaultPriority - b.defaultPriority);
const placements: WidgetPlacement[] = [];
let curX = 0;
let curY = 0;
let rowH = 0;
for (const widget of sorted) {
const { w, h } = widget.defaultSize;
if (curX + w > 12) {
curY += rowH;
curX = 0;
rowH = 0;
}
placements.push({
widgetId: widget.id,
config: widget.defaultConfig,
x: curX,
y: curY,
w,
h,
});
curX += w;
rowH = Math.max(rowH, h);
}
return { version: 1, widgets: placements };
}