Complete architecture for a ClickUp/Notion/Miro-class project management app: - Turborepo monorepo with Next.js 15, TypeScript, PostgreSQL (Drizzle ORM) - Object-centered database schema (everything is an Object: tasks, projects, docs, whiteboards) - NextAuth v5 authentication with credentials + OAuth providers - tRPC v11 API layer with full CRUD for objects, properties, relations, templates, search - Three-panel UI: collapsible sidebar, center content area, push-in right panel - Purple/teal theme with light/dark mode via Shadcn/ui + Tailwind CSS - Multiple views: List, Kanban board (dnd-kit), Table (spreadsheet), Embedded iframe - TipTap rich text editor with slash commands, custom blocks (callout, toggle, mention, embed, divider), AI block - Real-time collaboration via Yjs + Hocuspocus with presence/cursors - tldraw whiteboard with custom shape cards (task, document, project) - MCP server exposing all app data/tools for AI agents - AI chat panel, editor AI slash commands, Cmd+K command palette - Template system with built-in templates (Bug Report, Meeting Notes, Sprint) - Full-text search with result highlighting - Docker Compose for full-stack deployment (web + collab + postgres + redis) Made-with: Cursor
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { create } from "zustand";
|
|
|
|
const DEFAULT_SECTIONS: Record<string, boolean> = {
|
|
projects: true,
|
|
documents: true,
|
|
whiteboards: true,
|
|
};
|
|
|
|
interface SidebarState {
|
|
isCollapsed: boolean;
|
|
toggle: () => void;
|
|
collapse: () => void;
|
|
expand: () => void;
|
|
/** Tree node id → expanded (default true when key missing) */
|
|
expandedNodes: Record<string, boolean>;
|
|
toggleNode: (id: string) => void;
|
|
expandNode: (id: string) => void;
|
|
collapseNode: (id: string) => void;
|
|
expandedSections: Record<string, boolean>;
|
|
toggleSection: (name: string) => void;
|
|
}
|
|
|
|
export const useSidebarStore = create<SidebarState>((set) => ({
|
|
isCollapsed: false,
|
|
toggle: () => set((s) => ({ isCollapsed: !s.isCollapsed })),
|
|
collapse: () => set({ isCollapsed: true }),
|
|
expand: () => set({ isCollapsed: false }),
|
|
|
|
expandedNodes: {},
|
|
toggleNode: (id) =>
|
|
set((s) => {
|
|
const cur = s.expandedNodes[id] !== false;
|
|
return {
|
|
expandedNodes: { ...s.expandedNodes, [id]: !cur },
|
|
};
|
|
}),
|
|
expandNode: (id) =>
|
|
set((s) => ({
|
|
expandedNodes: { ...s.expandedNodes, [id]: true },
|
|
})),
|
|
collapseNode: (id) =>
|
|
set((s) => ({
|
|
expandedNodes: { ...s.expandedNodes, [id]: false },
|
|
})),
|
|
|
|
expandedSections: { ...DEFAULT_SECTIONS },
|
|
toggleSection: (name) =>
|
|
set((s) => ({
|
|
expandedSections: {
|
|
...s.expandedSections,
|
|
[name]: !(s.expandedSections[name] !== false),
|
|
},
|
|
})),
|
|
}));
|
|
|
|
export function isSidebarNodeExpanded(
|
|
expandedNodes: Record<string, boolean>,
|
|
id: string,
|
|
): boolean {
|
|
return expandedNodes[id] !== false;
|
|
}
|
|
|
|
export function isSidebarSectionExpanded(
|
|
expandedSections: Record<string, boolean>,
|
|
name: string,
|
|
): boolean {
|
|
return expandedSections[name] !== false;
|
|
}
|