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
+30 -11
View File
@@ -1,12 +1,38 @@
import type { ModuleManifest } from "../_core/module";
import type { ModuleManifest, WidgetContext } from "../_core/module";
import { z } from "zod";
import { searchNotes } from "./server/queries";
import { listWidgetNotes, searchNotes } from "./server/queries";
const notesWidgetConfigSchema = z.object({
filter: z.enum(["pinned", "all"]),
limit: z.number().int().min(1).max(50).optional(),
});
async function NotesWidget({ config }: { config: unknown; ctx: WidgetContext }) {
const parsed = notesWidgetConfigSchema.parse(config);
const notes = await listWidgetNotes({ filter: parsed.filter, limit: parsed.limit ?? 5 });
if (notes.length === 0) {
return (
<p className="text-sm text-muted-foreground">
{parsed.filter === "pinned" ? "No pinned notes" : "No notes"}
</p>
);
}
return (
<ul className="space-y-2">
{notes.map((note) => (
<li key={note.id} className="space-y-0.5">
<p className="text-sm font-medium leading-snug">{note.title}</p>
{note.body && (
<p className="line-clamp-2 text-xs text-muted-foreground">{note.body}</p>
)}
</li>
))}
</ul>
);
}
const manifest: ModuleManifest = {
id: "notes",
name: "Notes",
@@ -31,16 +57,9 @@ const manifest: ModuleManifest = {
minSize: { w: 3, h: 2 },
defaultPriority: 40,
configSchema: notesWidgetConfigSchema,
defaultConfig: { filter: "pinned", limit: 10 },
defaultConfig: { filter: "pinned", limit: 5 },
resolveConfigOptions: async () => undefined,
render: ({ config }) => {
const parsed = notesWidgetConfigSchema.parse(config);
return (
<div className="text-sm text-muted-foreground">
{parsed.filter === "pinned" ? "Pinned notes" : "Notes"}
</div>
);
},
render: (props) => <NotesWidget {...props} />,
},
],
quickAdds: [