mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
Add shadcn components: avatar, breadcrumb, checkbox, collapsible, command, dialog, dropdown-menu, label, popover, scroll-area, sheet, skeleton, tabs, textarea, tooltip. Add shared components: BreadcrumbBar, CommandPalette, CompanySwitcher, CommentThread, EmptyState, EntityRow, FilterBar, InlineEditor, MetricCard, PageSkeleton, PriorityIcon, PropertiesPanel, StatusIcon, SidebarNavItem/Section. Add contexts for breadcrumbs, dialogs, and side panels. Add keyboard shortcut hook and utility helpers. Update layout, sidebar, and main app shell. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { createContext, useCallback, useContext, useState, type ReactNode } from "react";
|
|
|
|
interface NewIssueDefaults {
|
|
status?: string;
|
|
priority?: string;
|
|
projectId?: string;
|
|
}
|
|
|
|
interface DialogContextValue {
|
|
newIssueOpen: boolean;
|
|
newIssueDefaults: NewIssueDefaults;
|
|
openNewIssue: (defaults?: NewIssueDefaults) => void;
|
|
closeNewIssue: () => void;
|
|
}
|
|
|
|
const DialogContext = createContext<DialogContextValue | null>(null);
|
|
|
|
export function DialogProvider({ children }: { children: ReactNode }) {
|
|
const [newIssueOpen, setNewIssueOpen] = useState(false);
|
|
const [newIssueDefaults, setNewIssueDefaults] = useState<NewIssueDefaults>({});
|
|
|
|
const openNewIssue = useCallback((defaults: NewIssueDefaults = {}) => {
|
|
setNewIssueDefaults(defaults);
|
|
setNewIssueOpen(true);
|
|
}, []);
|
|
|
|
const closeNewIssue = useCallback(() => {
|
|
setNewIssueOpen(false);
|
|
setNewIssueDefaults({});
|
|
}, []);
|
|
|
|
return (
|
|
<DialogContext.Provider value={{ newIssueOpen, newIssueDefaults, openNewIssue, closeNewIssue }}>
|
|
{children}
|
|
</DialogContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function useDialog() {
|
|
const ctx = useContext(DialogContext);
|
|
if (!ctx) {
|
|
throw new Error("useDialog must be used within DialogProvider");
|
|
}
|
|
return ctx;
|
|
}
|