@critical-path/react 0.1.0 → 0.1.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.
- package/README.md +69 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @critical-path/react
|
|
2
|
+
|
|
3
|
+
> **React Context Provider & Hooks for Critical Path.**
|
|
4
|
+
|
|
5
|
+
`@critical-path/react` provides components and custom React hooks (`useProjects`, `useTasks`, `useKanban`) for rendering project management UIs in React and Next.js.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 📦 Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @critical-path/react @critical-path/client
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @critical-path/react @critical-path/client
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 💡 Usage Example
|
|
20
|
+
|
|
21
|
+
### 1. Wrap Application with Provider
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { CriticalPathProvider } from '@critical-path/react';
|
|
25
|
+
|
|
26
|
+
export default function RootLayout({ children }) {
|
|
27
|
+
return (
|
|
28
|
+
<CriticalPathProvider options={{ baseUrl: '/api/critical-path' }}>
|
|
29
|
+
{children}
|
|
30
|
+
</CriticalPathProvider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Render Kanban Board
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
'use client';
|
|
39
|
+
|
|
40
|
+
import { useKanban } from '@critical-path/react';
|
|
41
|
+
|
|
42
|
+
export function Board({ projectId }: { projectId: string }) {
|
|
43
|
+
const { columns, moveTask, loading } = useKanban(projectId);
|
|
44
|
+
|
|
45
|
+
if (loading) return <div>Loading board...</div>;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className="flex gap-4">
|
|
49
|
+
{Object.entries(columns).map(([status, tasks]) => (
|
|
50
|
+
<div key={status} className="column">
|
|
51
|
+
<h2>{status} ({tasks.length})</h2>
|
|
52
|
+
{tasks.map((task) => (
|
|
53
|
+
<div key={task.id} className="card">
|
|
54
|
+
<h3>{task.title}</h3>
|
|
55
|
+
<button onClick={() => moveTask(task.id, 'done')}>Mark Done</button>
|
|
56
|
+
</div>
|
|
57
|
+
))}
|
|
58
|
+
</div>
|
|
59
|
+
))}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 📄 License
|
|
68
|
+
|
|
69
|
+
MIT © [Critical Path](https://github.com/Pixerate/Critical-Path)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@critical-path/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React Context Provider and Hooks for Critical Path headless project management framework",
|
|
5
5
|
"author": "Jack James",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@critical-path/client": "0.1.
|
|
18
|
-
"@critical-path/core": "0.1.
|
|
17
|
+
"@critical-path/client": "0.1.1",
|
|
18
|
+
"@critical-path/core": "0.1.1"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": "^18.0.0 || ^19.0.0"
|