@kendew-agency/react-feedback-layer 0.1.0
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/LICENSE +21 -0
- package/README.md +1156 -0
- package/dist/comment.types-B7xO89Wt.d.cts +240 -0
- package/dist/comment.types-B7xO89Wt.d.ts +240 -0
- package/dist/index.cjs +756 -0
- package/dist/index.d.cts +87 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +712 -0
- package/dist/types.cjs +18 -0
- package/dist/types.d.cts +39 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.js +0 -0
- package/package.json +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,1156 @@
|
|
|
1
|
+
# @kendew/react-feedback-layer
|
|
2
|
+
|
|
3
|
+
A drop-in React feedback layer for collecting contextual user feedback through interactive comments and annotations. Perfect for design review tools, bug reporting systems, and collaborative annotation platforms.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎯 **Contextual Feedback** - Click or drag to create comments anywhere on your UI
|
|
8
|
+
- 💬 **Comment Lifecycle** - Draft → Published → Resolving → Resolved states
|
|
9
|
+
- 👥 **User Attribution** - Track who created each comment with timestamps
|
|
10
|
+
- 🎨 **Fully Customizable** - Headless UI with complete styling control
|
|
11
|
+
- 📦 **TypeScript First** - Full type definitions included
|
|
12
|
+
- âš¡ **Minimal Dependencies** - Only React 18+ and Radix UI Slot
|
|
13
|
+
- 🔧 **Compound Components** - Flexible composition patterns
|
|
14
|
+
- 🎪 **Visual Indicators** - Highlight specific UI areas with selection boxes
|
|
15
|
+
- 🔄 **Real-time Sync** - Optional subscription support for live updates
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @kendew/react-feedback-layer
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Peer Dependencies
|
|
24
|
+
|
|
25
|
+
This package requires React 18 or higher:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install react react-dom
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import {
|
|
35
|
+
CommentContextProvider,
|
|
36
|
+
CommentOverlay,
|
|
37
|
+
CommentRenderer,
|
|
38
|
+
} from '@kendew/react-feedback-layer';
|
|
39
|
+
|
|
40
|
+
function App() {
|
|
41
|
+
const handleConfirm = async (comments) => {
|
|
42
|
+
// Save comments to your database
|
|
43
|
+
await saveToDatabase(comments);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const handleResolve = async (comments) => {
|
|
47
|
+
// Mark comments as resolved in your database
|
|
48
|
+
await resolveInDatabase(comments);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<CommentContextProvider
|
|
53
|
+
currentUser={{ name: 'John Doe', id: 'user-123' }}
|
|
54
|
+
onConfirm={handleConfirm}
|
|
55
|
+
onResolve={handleResolve}
|
|
56
|
+
initialComments={[]}
|
|
57
|
+
>
|
|
58
|
+
<CommentOverlay>
|
|
59
|
+
<YourContent />
|
|
60
|
+
<CommentRenderer
|
|
61
|
+
Comment={YourCommentComponent}
|
|
62
|
+
DraftComment={YourDraftComponent}
|
|
63
|
+
ResolvingComment={YourResolvingComponent}
|
|
64
|
+
ResolvedComment={YourResolvedComponent}
|
|
65
|
+
/>
|
|
66
|
+
</CommentOverlay>
|
|
67
|
+
</CommentContextProvider>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Core Concepts
|
|
73
|
+
|
|
74
|
+
### Comment Lifecycle
|
|
75
|
+
|
|
76
|
+
Comments flow through four distinct states:
|
|
77
|
+
|
|
78
|
+
1. **Draft** - Newly created, not yet saved
|
|
79
|
+
2. **Published** - Confirmed and saved to your database
|
|
80
|
+
3. **Resolving** - Marked for resolution (in progress)
|
|
81
|
+
4. **Resolved** - Completed and archived
|
|
82
|
+
|
|
83
|
+
### Headless UI Architecture
|
|
84
|
+
|
|
85
|
+
This library provides the logic and structure without imposing any styling. You have complete control over how comments look and behave by providing your own component implementations.
|
|
86
|
+
|
|
87
|
+
### Compound Component Pattern
|
|
88
|
+
|
|
89
|
+
The `Comment` component uses a compound pattern for maximum flexibility:
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<Comment.Root comment={comment}>
|
|
93
|
+
<Comment.Indicator />
|
|
94
|
+
<Comment.Content />
|
|
95
|
+
<Comment.Edit />
|
|
96
|
+
<Comment.Confirm />
|
|
97
|
+
<Comment.Delete />
|
|
98
|
+
<Comment.Resolve />
|
|
99
|
+
</Comment.Root>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Complete API Reference
|
|
103
|
+
|
|
104
|
+
### Components
|
|
105
|
+
|
|
106
|
+
#### `CommentContextProvider`
|
|
107
|
+
|
|
108
|
+
The root provider that manages all comment state and actions.
|
|
109
|
+
|
|
110
|
+
**Props:**
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
interface CommentOverlayProps {
|
|
114
|
+
// Initial comments from your database
|
|
115
|
+
initialComments?: ConfirmedComment[];
|
|
116
|
+
|
|
117
|
+
// Current logged-in user
|
|
118
|
+
currentUser: User | null;
|
|
119
|
+
|
|
120
|
+
// Your app content
|
|
121
|
+
children: ReactNode;
|
|
122
|
+
|
|
123
|
+
// Initial overlay state (default: "inactive")
|
|
124
|
+
initialOverlayState?: "idle" | "editing" | "saving" | "error" | "resolving" | "inactive";
|
|
125
|
+
|
|
126
|
+
// Optional real-time subscription
|
|
127
|
+
subscription?: {
|
|
128
|
+
subscribe: (update: unknown) => void;
|
|
129
|
+
unsubscribe: () => void;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// Callback when user confirms draft comments
|
|
133
|
+
onConfirm: (comments: ConfirmedComment[]) => Promise<void>;
|
|
134
|
+
|
|
135
|
+
// Callback when user resolves comments
|
|
136
|
+
onResolve: (comments: ConfirmedComment[]) => Promise<void>;
|
|
137
|
+
|
|
138
|
+
// Callback to handle errors (optional)
|
|
139
|
+
onError?: (error: Error) => void;
|
|
140
|
+
|
|
141
|
+
// Optional configuration for the comment layer
|
|
142
|
+
config?: {
|
|
143
|
+
// Custom prefix for comment IDs
|
|
144
|
+
idPrefix?: string;
|
|
145
|
+
// Visibility of comment indicators: "always" | "active"
|
|
146
|
+
indicatorVisibility?: "always" | "active";
|
|
147
|
+
// Comment visibility settings
|
|
148
|
+
commentVisibility?: {
|
|
149
|
+
hideResolved?: boolean;
|
|
150
|
+
hideResolving?: boolean;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Example:**
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<CommentContextProvider
|
|
160
|
+
currentUser={{ name: 'Jane Smith', id: '456', avatar: '/avatar.jpg' }}
|
|
161
|
+
initialComments={existingComments}
|
|
162
|
+
onConfirm={async (comments) => {
|
|
163
|
+
await api.createComments(comments);
|
|
164
|
+
}}
|
|
165
|
+
onResolve={async (comments) => {
|
|
166
|
+
await api.resolveComments(comments);
|
|
167
|
+
}}
|
|
168
|
+
onError={(error) => {
|
|
169
|
+
console.error('Comment operation failed:', error);
|
|
170
|
+
toast.error('Failed to save comments');
|
|
171
|
+
}}
|
|
172
|
+
initialOverlayState="idle"
|
|
173
|
+
config={{
|
|
174
|
+
idPrefix: 'proj_',
|
|
175
|
+
indicatorVisibility: 'active',
|
|
176
|
+
commentVisibility: {
|
|
177
|
+
hideResolved: false,
|
|
178
|
+
hideResolving: false,
|
|
179
|
+
},
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
{children}
|
|
183
|
+
</CommentContextProvider>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### `CommentOverlay`
|
|
187
|
+
|
|
188
|
+
Creates an interactive overlay for adding comments via click or drag selection.
|
|
189
|
+
|
|
190
|
+
**Props:**
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
interface CommentOverlayProps {
|
|
194
|
+
children: ReactNode;
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Behavior:**
|
|
199
|
+
|
|
200
|
+
- **Click** - Creates a comment at the clicked position
|
|
201
|
+
- **Drag** - Creates a comment with a visual indicator box
|
|
202
|
+
- **Inactive State** - Renders children without overlay when `overlayState === "inactive"`
|
|
203
|
+
|
|
204
|
+
**Example:**
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
<CommentOverlay>
|
|
208
|
+
<div>Your annotatable content</div>
|
|
209
|
+
<CommentRenderer {...} />
|
|
210
|
+
</CommentOverlay>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### `CommentRenderer`
|
|
214
|
+
|
|
215
|
+
Renders all comments based on their current state.
|
|
216
|
+
|
|
217
|
+
**Props:**
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
interface CommentRendererProps {
|
|
221
|
+
// Component for published comments
|
|
222
|
+
Comment: ElementType<{ comment: CommentType }>;
|
|
223
|
+
|
|
224
|
+
// Component for draft comments
|
|
225
|
+
DraftComment: ElementType<{ comment: CommentType }>;
|
|
226
|
+
|
|
227
|
+
// Component for resolving comments
|
|
228
|
+
ResolvingComment: ElementType<{ comment: CommentType }>;
|
|
229
|
+
|
|
230
|
+
// Component for resolved comments
|
|
231
|
+
ResolvedComment: ElementType<{ comment: CommentType }>;
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Example:**
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
<CommentRenderer
|
|
239
|
+
Comment={PublishedComment}
|
|
240
|
+
DraftComment={DraftComment}
|
|
241
|
+
ResolvingComment={ResolvingComment}
|
|
242
|
+
ResolvedComment={ResolvedComment}
|
|
243
|
+
/>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
#### `Comment` (Compound Component)
|
|
247
|
+
|
|
248
|
+
A collection of sub-components for building custom comment UIs.
|
|
249
|
+
|
|
250
|
+
##### `Comment.Root`
|
|
251
|
+
|
|
252
|
+
Container for a single comment with positioning and active state management.
|
|
253
|
+
|
|
254
|
+
**Props:**
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
interface CommentRootProps extends HTMLProps<HTMLDivElement> {
|
|
258
|
+
comment: CommentType;
|
|
259
|
+
children?: ReactNode;
|
|
260
|
+
defaultDraft?: string; // Initial draft content
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Example:**
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
<Comment.Root comment={comment} className="comment-card">
|
|
268
|
+
{/* Sub-components */}
|
|
269
|
+
</Comment.Root>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
##### `Comment.Indicator`
|
|
273
|
+
|
|
274
|
+
Visual indicator showing the area a comment refers to (when created via drag).
|
|
275
|
+
|
|
276
|
+
**Props:**
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
interface CommentIndicatorProps extends HTMLProps<HTMLDivElement> {}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Example:**
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
<Comment.Indicator className="highlight-box" />
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
##### `Comment.Content`
|
|
289
|
+
|
|
290
|
+
Displays the comment text content.
|
|
291
|
+
|
|
292
|
+
**Props:**
|
|
293
|
+
|
|
294
|
+
```tsx
|
|
295
|
+
interface CommentContentProps extends HTMLProps<HTMLParagraphElement> {
|
|
296
|
+
asChild?: boolean; // Use Radix Slot for custom element
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Example:**
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
<Comment.Content className="comment-text" />
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
##### `Comment.Edit`
|
|
307
|
+
|
|
308
|
+
Textarea for editing comment content.
|
|
309
|
+
|
|
310
|
+
**Props:**
|
|
311
|
+
|
|
312
|
+
```tsx
|
|
313
|
+
interface CommentEditProps extends HTMLProps<HTMLTextAreaElement> {
|
|
314
|
+
asChild?: boolean;
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Example:**
|
|
319
|
+
|
|
320
|
+
```tsx
|
|
321
|
+
<Comment.Edit
|
|
322
|
+
className="comment-input"
|
|
323
|
+
placeholder="Write your feedback..."
|
|
324
|
+
/>
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
##### `Comment.Confirm`
|
|
328
|
+
|
|
329
|
+
Button to save/confirm comment changes.
|
|
330
|
+
|
|
331
|
+
**Props:**
|
|
332
|
+
|
|
333
|
+
```tsx
|
|
334
|
+
interface CommentConfirmProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
335
|
+
asChild?: boolean;
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Example:**
|
|
340
|
+
|
|
341
|
+
```tsx
|
|
342
|
+
<Comment.Confirm className="btn-primary">
|
|
343
|
+
Save Comment
|
|
344
|
+
</Comment.Confirm>
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
##### `Comment.Delete`
|
|
348
|
+
|
|
349
|
+
Button to delete a comment.
|
|
350
|
+
|
|
351
|
+
**Props:**
|
|
352
|
+
|
|
353
|
+
```tsx
|
|
354
|
+
interface CommentDeleteProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
355
|
+
asChild?: boolean;
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**Example:**
|
|
360
|
+
|
|
361
|
+
```tsx
|
|
362
|
+
<Comment.Delete className="btn-danger">
|
|
363
|
+
Delete
|
|
364
|
+
</Comment.Delete>
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
##### `Comment.Resolve`
|
|
368
|
+
|
|
369
|
+
Button to toggle resolving state (only for published/resolving comments).
|
|
370
|
+
|
|
371
|
+
**Props:**
|
|
372
|
+
|
|
373
|
+
```tsx
|
|
374
|
+
interface CommentResolveProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
375
|
+
asChild?: boolean;
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**Example:**
|
|
380
|
+
|
|
381
|
+
```tsx
|
|
382
|
+
<Comment.Resolve className="btn-resolve">
|
|
383
|
+
Mark as Resolved
|
|
384
|
+
</Comment.Resolve>
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
#### Action Components
|
|
388
|
+
|
|
389
|
+
##### `ToggleOverlayButton`
|
|
390
|
+
|
|
391
|
+
Toggles the comment overlay on/off.
|
|
392
|
+
|
|
393
|
+
**Props:**
|
|
394
|
+
|
|
395
|
+
```tsx
|
|
396
|
+
interface CommentButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
397
|
+
asChild?: boolean;
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
**Example:**
|
|
402
|
+
|
|
403
|
+
```tsx
|
|
404
|
+
import { ToggleOverlayButton } from '@kendew/react-feedback-layer';
|
|
405
|
+
|
|
406
|
+
<ToggleOverlayButton className="toggle-btn">
|
|
407
|
+
Toggle Comments
|
|
408
|
+
</ToggleOverlayButton>
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
##### `ConfirmComments`
|
|
412
|
+
|
|
413
|
+
Confirms all draft comments and triggers the `onConfirm` callback.
|
|
414
|
+
|
|
415
|
+
**Example:**
|
|
416
|
+
|
|
417
|
+
```tsx
|
|
418
|
+
import { ConfirmComments } from '@kendew/react-feedback-layer';
|
|
419
|
+
|
|
420
|
+
<ConfirmComments className="btn-save">
|
|
421
|
+
Save All Comments
|
|
422
|
+
</ConfirmComments>
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
##### `ResolveComments`
|
|
426
|
+
|
|
427
|
+
Resolves all resolving comments and triggers the `onResolve` callback.
|
|
428
|
+
|
|
429
|
+
**Example:**
|
|
430
|
+
|
|
431
|
+
```tsx
|
|
432
|
+
import { ResolveComments } from '@kendew/react-feedback-layer';
|
|
433
|
+
|
|
434
|
+
<ResolveComments className="btn-resolve-all">
|
|
435
|
+
Resolve All
|
|
436
|
+
</ResolveComments>
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Hooks
|
|
440
|
+
|
|
441
|
+
#### `useComments()`
|
|
442
|
+
|
|
443
|
+
Access the global comment context and actions.
|
|
444
|
+
|
|
445
|
+
**Returns:**
|
|
446
|
+
|
|
447
|
+
```tsx
|
|
448
|
+
interface CommentContext {
|
|
449
|
+
// Filtered comment arrays
|
|
450
|
+
draftComments: CommentType[];
|
|
451
|
+
comments: CommentType[]; // Published comments
|
|
452
|
+
resolvingComments: CommentType[];
|
|
453
|
+
resolvedComments: CommentType[];
|
|
454
|
+
allComments: CommentType[];
|
|
455
|
+
|
|
456
|
+
// State
|
|
457
|
+
overlayState: CommentOverlayState;
|
|
458
|
+
currentUser: User | null;
|
|
459
|
+
config: Config | undefined;
|
|
460
|
+
|
|
461
|
+
// Actions
|
|
462
|
+
registerComment: (position: Position, indicatorPosition?: Indicator) => void;
|
|
463
|
+
updateComment: (id: string, newComment: Pick<CommentType, "content">) => void;
|
|
464
|
+
deleteComment: (id: string) => void;
|
|
465
|
+
focusOnComment: (id: string | null) => void;
|
|
466
|
+
getActiveComment: () => CommentType | undefined;
|
|
467
|
+
toggleOverlay: () => void;
|
|
468
|
+
toggleResolvingComment: (id: string) => void;
|
|
469
|
+
changeOverlayState: (state: CommentOverlayState) => void;
|
|
470
|
+
confirmComments: () => Promise<{ error: Error | DOMException | null }>;
|
|
471
|
+
resolveComments: () => Promise<{ error: Error | DOMException | null }>;
|
|
472
|
+
updateCommentVisibility: (visibility: Partial<CommentVisibility>) => void;
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
**Example:**
|
|
477
|
+
|
|
478
|
+
```tsx
|
|
479
|
+
import { useComments } from '@kendew/react-feedback-layer';
|
|
480
|
+
|
|
481
|
+
function CommentToolbar() {
|
|
482
|
+
const {
|
|
483
|
+
draftComments,
|
|
484
|
+
confirmComments,
|
|
485
|
+
overlayState,
|
|
486
|
+
toggleOverlay,
|
|
487
|
+
config
|
|
488
|
+
} = useComments();
|
|
489
|
+
|
|
490
|
+
return (
|
|
491
|
+
<div>
|
|
492
|
+
<button onClick={toggleOverlay}>
|
|
493
|
+
{overlayState === 'inactive' ? 'Enable' : 'Disable'} Comments
|
|
494
|
+
</button>
|
|
495
|
+
<button
|
|
496
|
+
onClick={confirmComments}
|
|
497
|
+
disabled={draftComments.length === 0}
|
|
498
|
+
>
|
|
499
|
+
Save {draftComments.length} Comments
|
|
500
|
+
</button>
|
|
501
|
+
{config?.commentVisibility && (
|
|
502
|
+
<span>Resolved hidden: {config.commentVisibility.hideResolved ? 'Yes' : 'No'}</span>
|
|
503
|
+
)}
|
|
504
|
+
</div>
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
#### `useCommentScope()`
|
|
510
|
+
|
|
511
|
+
Access scoped data for a specific comment (must be used within `Comment.Root`).
|
|
512
|
+
|
|
513
|
+
**Returns:**
|
|
514
|
+
|
|
515
|
+
```tsx
|
|
516
|
+
interface CommentScope {
|
|
517
|
+
comment: CommentType;
|
|
518
|
+
isActive: boolean;
|
|
519
|
+
draft: string;
|
|
520
|
+
setDraft: React.Dispatch<React.SetStateAction<string>>;
|
|
521
|
+
}
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
**Example:**
|
|
525
|
+
|
|
526
|
+
```tsx
|
|
527
|
+
import { useCommentScope } from '@kendew/react-feedback-layer';
|
|
528
|
+
|
|
529
|
+
function CustomCommentContent() {
|
|
530
|
+
const { comment, isActive, draft } = useCommentScope();
|
|
531
|
+
|
|
532
|
+
return (
|
|
533
|
+
<div className={isActive ? 'active' : ''}>
|
|
534
|
+
<p>{draft}</p>
|
|
535
|
+
<small>By {comment.user?.name}</small>
|
|
536
|
+
</div>
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### Types
|
|
542
|
+
|
|
543
|
+
Import types from the `/types` subpath:
|
|
544
|
+
|
|
545
|
+
```tsx
|
|
546
|
+
import type {
|
|
547
|
+
CommentType,
|
|
548
|
+
ConfirmedComment,
|
|
549
|
+
User,
|
|
550
|
+
Position,
|
|
551
|
+
Indicator,
|
|
552
|
+
CommentOverlayState,
|
|
553
|
+
CommentVisibility,
|
|
554
|
+
CommentAction,
|
|
555
|
+
Config
|
|
556
|
+
} from '@kendew/react-feedback-layer/types';
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
#### `CommentType`
|
|
560
|
+
|
|
561
|
+
```tsx
|
|
562
|
+
type CommentType = {
|
|
563
|
+
id: string;
|
|
564
|
+
position: Position;
|
|
565
|
+
content: string;
|
|
566
|
+
user: User | null;
|
|
567
|
+
createdAt: Date;
|
|
568
|
+
resolvedAt?: Date;
|
|
569
|
+
status: "draft" | "published" | "resolving" | "resolved";
|
|
570
|
+
indicator?: Indicator | null;
|
|
571
|
+
};
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
#### `User`
|
|
575
|
+
|
|
576
|
+
```tsx
|
|
577
|
+
type User = {
|
|
578
|
+
id?: string;
|
|
579
|
+
name: string;
|
|
580
|
+
avatar?: string;
|
|
581
|
+
};
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
#### `Position`
|
|
585
|
+
|
|
586
|
+
```tsx
|
|
587
|
+
type Position = {
|
|
588
|
+
x: number;
|
|
589
|
+
y: number;
|
|
590
|
+
};
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
#### `Indicator`
|
|
594
|
+
|
|
595
|
+
```tsx
|
|
596
|
+
type Indicator = {
|
|
597
|
+
width: number;
|
|
598
|
+
height: number;
|
|
599
|
+
};
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
#### `CommentVisibility`
|
|
603
|
+
|
|
604
|
+
```tsx
|
|
605
|
+
type CommentVisibility = {
|
|
606
|
+
hideResolved?: boolean;
|
|
607
|
+
hideResolving?: boolean;
|
|
608
|
+
};
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
#### `Config`
|
|
612
|
+
|
|
613
|
+
```tsx
|
|
614
|
+
type Config = {
|
|
615
|
+
// Custom prefix for comment IDs
|
|
616
|
+
idPrefix?: string;
|
|
617
|
+
// Visibility of comment indicators
|
|
618
|
+
indicatorVisibility?: "always" | "active";
|
|
619
|
+
// Comment visibility settings
|
|
620
|
+
commentVisibility?: CommentVisibility;
|
|
621
|
+
};
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
## Usage Examples
|
|
625
|
+
|
|
626
|
+
### Basic Implementation
|
|
627
|
+
|
|
628
|
+
```tsx
|
|
629
|
+
import {
|
|
630
|
+
CommentContextProvider,
|
|
631
|
+
CommentOverlay,
|
|
632
|
+
CommentRenderer,
|
|
633
|
+
Comment,
|
|
634
|
+
ToggleOverlayButton,
|
|
635
|
+
ConfirmComments,
|
|
636
|
+
} from '@kendew/react-feedback-layer';
|
|
637
|
+
|
|
638
|
+
function DraftComment({ comment }) {
|
|
639
|
+
return (
|
|
640
|
+
<Comment.Root comment={comment} className="draft-comment">
|
|
641
|
+
<Comment.Indicator className="indicator" />
|
|
642
|
+
<div className="comment-body">
|
|
643
|
+
<Comment.Edit placeholder="Add your feedback..." />
|
|
644
|
+
<div className="actions">
|
|
645
|
+
<Comment.Confirm>Save</Comment.Confirm>
|
|
646
|
+
<Comment.Delete>Cancel</Comment.Delete>
|
|
647
|
+
</div>
|
|
648
|
+
</div>
|
|
649
|
+
</Comment.Root>
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function PublishedComment({ comment }) {
|
|
654
|
+
return (
|
|
655
|
+
<Comment.Root comment={comment} className="published-comment">
|
|
656
|
+
<Comment.Indicator className="indicator" />
|
|
657
|
+
<div className="comment-body">
|
|
658
|
+
<Comment.Content />
|
|
659
|
+
<div className="meta">
|
|
660
|
+
<span>{comment.user?.name}</span>
|
|
661
|
+
<span>{comment.createdAt.toLocaleDateString()}</span>
|
|
662
|
+
</div>
|
|
663
|
+
<div className="actions">
|
|
664
|
+
<Comment.Resolve>Resolve</Comment.Resolve>
|
|
665
|
+
<Comment.Delete>Delete</Comment.Delete>
|
|
666
|
+
</div>
|
|
667
|
+
</div>
|
|
668
|
+
</Comment.Root>
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function App() {
|
|
673
|
+
return (
|
|
674
|
+
<CommentContextProvider
|
|
675
|
+
currentUser={{ name: 'John Doe', id: '123' }}
|
|
676
|
+
onConfirm={async (comments) => {
|
|
677
|
+
const response = await fetch('/api/comments', {
|
|
678
|
+
method: 'POST',
|
|
679
|
+
body: JSON.stringify(comments),
|
|
680
|
+
});
|
|
681
|
+
if (!response.ok) {
|
|
682
|
+
throw new Error('Failed to save comments');
|
|
683
|
+
}
|
|
684
|
+
}}
|
|
685
|
+
onResolve={async (comments) => {
|
|
686
|
+
const response = await fetch('/api/comments/resolve', {
|
|
687
|
+
method: 'POST',
|
|
688
|
+
body: JSON.stringify(comments),
|
|
689
|
+
});
|
|
690
|
+
if (!response.ok) {
|
|
691
|
+
throw new Error('Failed to resolve comments');
|
|
692
|
+
}
|
|
693
|
+
}}
|
|
694
|
+
onError={(error) => {
|
|
695
|
+
console.error('Comment operation failed:', error);
|
|
696
|
+
// Show user-friendly error message
|
|
697
|
+
}}
|
|
698
|
+
config={{
|
|
699
|
+
commentVisibility: {
|
|
700
|
+
hideResolved: false,
|
|
701
|
+
hideResolving: false,
|
|
702
|
+
},
|
|
703
|
+
}}
|
|
704
|
+
>
|
|
705
|
+
<ToggleOverlayButton>Toggle Feedback Mode</ToggleOverlayButton>
|
|
706
|
+
<ConfirmComments>Save All Comments</ConfirmComments>
|
|
707
|
+
|
|
708
|
+
<CommentOverlay>
|
|
709
|
+
<YourContent />
|
|
710
|
+
<CommentRenderer
|
|
711
|
+
Comment={PublishedComment}
|
|
712
|
+
DraftComment={DraftComment}
|
|
713
|
+
ResolvingComment={PublishedComment}
|
|
714
|
+
ResolvedComment={PublishedComment}
|
|
715
|
+
/>
|
|
716
|
+
</CommentOverlay>
|
|
717
|
+
</CommentContextProvider>
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
### With Real-time Subscription
|
|
723
|
+
|
|
724
|
+
```tsx
|
|
725
|
+
import { useEffect, useState } from 'react';
|
|
726
|
+
|
|
727
|
+
function App() {
|
|
728
|
+
const [subscription, setSubscription] = useState(null);
|
|
729
|
+
|
|
730
|
+
useEffect(() => {
|
|
731
|
+
// Example with a WebSocket or real-time database
|
|
732
|
+
const sub = {
|
|
733
|
+
subscribe: (callback) => {
|
|
734
|
+
socket.on('comments:update', callback);
|
|
735
|
+
},
|
|
736
|
+
unsubscribe: () => {
|
|
737
|
+
socket.off('comments:update');
|
|
738
|
+
},
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
setSubscription(sub);
|
|
742
|
+
}, []);
|
|
743
|
+
|
|
744
|
+
return (
|
|
745
|
+
<CommentContextProvider
|
|
746
|
+
currentUser={currentUser}
|
|
747
|
+
subscription={subscription}
|
|
748
|
+
onConfirm={saveComments}
|
|
749
|
+
onResolve={resolveComments}
|
|
750
|
+
>
|
|
751
|
+
{/* ... */}
|
|
752
|
+
</CommentContextProvider>
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
### Custom Toolbar with Visibility Controls
|
|
758
|
+
|
|
759
|
+
```tsx
|
|
760
|
+
import { useComments } from '@kendew/react-feedback-layer';
|
|
761
|
+
|
|
762
|
+
function CommentToolbar() {
|
|
763
|
+
const {
|
|
764
|
+
draftComments,
|
|
765
|
+
resolvingComments,
|
|
766
|
+
config,
|
|
767
|
+
updateCommentVisibility,
|
|
768
|
+
confirmComments,
|
|
769
|
+
resolveComments,
|
|
770
|
+
overlayState,
|
|
771
|
+
} = useComments();
|
|
772
|
+
|
|
773
|
+
return (
|
|
774
|
+
<div className="toolbar">
|
|
775
|
+
<div className="stats">
|
|
776
|
+
<span>{draftComments.length} drafts</span>
|
|
777
|
+
<span>{resolvingComments.length} resolving</span>
|
|
778
|
+
</div>
|
|
779
|
+
|
|
780
|
+
<div className="visibility">
|
|
781
|
+
<label>
|
|
782
|
+
<input
|
|
783
|
+
type="checkbox"
|
|
784
|
+
checked={!config?.commentVisibility?.hideResolved}
|
|
785
|
+
onChange={(e) =>
|
|
786
|
+
updateCommentVisibility({ hideResolved: !e.target.checked })
|
|
787
|
+
}
|
|
788
|
+
/>
|
|
789
|
+
Show Resolved
|
|
790
|
+
</label>
|
|
791
|
+
<label>
|
|
792
|
+
<input
|
|
793
|
+
type="checkbox"
|
|
794
|
+
checked={!config?.commentVisibility?.hideResolving}
|
|
795
|
+
onChange={(e) =>
|
|
796
|
+
updateCommentVisibility({ hideResolving: !e.target.checked })
|
|
797
|
+
}
|
|
798
|
+
/>
|
|
799
|
+
Show Resolving
|
|
800
|
+
</label>
|
|
801
|
+
</div>
|
|
802
|
+
|
|
803
|
+
<div className="actions">
|
|
804
|
+
<button
|
|
805
|
+
onClick={confirmComments}
|
|
806
|
+
disabled={draftComments.length === 0 || overlayState === 'saving'}
|
|
807
|
+
>
|
|
808
|
+
{overlayState === 'saving' ? 'Saving...' : 'Save Comments'}
|
|
809
|
+
</button>
|
|
810
|
+
<button
|
|
811
|
+
onClick={resolveComments}
|
|
812
|
+
disabled={resolvingComments.length === 0}
|
|
813
|
+
>
|
|
814
|
+
Resolve All
|
|
815
|
+
</button>
|
|
816
|
+
</div>
|
|
817
|
+
</div>
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
### Using the `asChild` Prop
|
|
823
|
+
|
|
824
|
+
The `asChild` prop (powered by Radix UI Slot) lets you render components as different elements:
|
|
825
|
+
|
|
826
|
+
```tsx
|
|
827
|
+
import { Comment } from '@kendew/react-feedback-layer';
|
|
828
|
+
|
|
829
|
+
function CustomComment({ comment }) {
|
|
830
|
+
return (
|
|
831
|
+
<Comment.Root comment={comment}>
|
|
832
|
+
{/* Render as a custom button */}
|
|
833
|
+
<Comment.Confirm asChild>
|
|
834
|
+
<MyCustomButton variant="primary">
|
|
835
|
+
Save Comment
|
|
836
|
+
</MyCustomButton>
|
|
837
|
+
</Comment.Confirm>
|
|
838
|
+
|
|
839
|
+
{/* Render content as a div */}
|
|
840
|
+
<Comment.Content asChild>
|
|
841
|
+
<div className="rich-text-content" />
|
|
842
|
+
</Comment.Content>
|
|
843
|
+
</Comment.Root>
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
## Configuration Options
|
|
849
|
+
|
|
850
|
+
The `config` prop allows you to customize various aspects of the comment system:
|
|
851
|
+
|
|
852
|
+
### ID Prefix
|
|
853
|
+
|
|
854
|
+
Add a custom prefix to all comment IDs:
|
|
855
|
+
|
|
856
|
+
```tsx
|
|
857
|
+
<CommentContextProvider
|
|
858
|
+
config={{
|
|
859
|
+
idPrefix: 'proj_a_', // Results in IDs like "proj_a_uuid"
|
|
860
|
+
}}
|
|
861
|
+
// ... other props
|
|
862
|
+
>
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
### Indicator Visibility
|
|
866
|
+
|
|
867
|
+
Control when comment indicators (selection boxes) are shown:
|
|
868
|
+
|
|
869
|
+
```tsx
|
|
870
|
+
<CommentContextProvider
|
|
871
|
+
config={{
|
|
872
|
+
indicatorVisibility: 'active', // Only show when comment is active
|
|
873
|
+
// or 'always' to always show indicators
|
|
874
|
+
}}
|
|
875
|
+
// ... other props
|
|
876
|
+
>
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
### Comment Visibility
|
|
880
|
+
|
|
881
|
+
Hide specific types of comments from the UI:
|
|
882
|
+
|
|
883
|
+
```tsx
|
|
884
|
+
<CommentContextProvider
|
|
885
|
+
config={{
|
|
886
|
+
commentVisibility: {
|
|
887
|
+
hideResolved: true, // Hide resolved comments
|
|
888
|
+
hideResolving: false, // Show resolving comments
|
|
889
|
+
},
|
|
890
|
+
}}
|
|
891
|
+
// ... other props
|
|
892
|
+
>
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
You can also update visibility dynamically:
|
|
896
|
+
|
|
897
|
+
```tsx
|
|
898
|
+
function VisibilityControls() {
|
|
899
|
+
const { config, updateCommentVisibility } = useComments();
|
|
900
|
+
|
|
901
|
+
return (
|
|
902
|
+
<div>
|
|
903
|
+
<label>
|
|
904
|
+
<input
|
|
905
|
+
type="checkbox"
|
|
906
|
+
checked={!config?.commentVisibility?.hideResolved}
|
|
907
|
+
onChange={(e) =>
|
|
908
|
+
updateCommentVisibility({ hideResolved: !e.target.checked })
|
|
909
|
+
}
|
|
910
|
+
/>
|
|
911
|
+
Show Resolved Comments
|
|
912
|
+
</label>
|
|
913
|
+
</div>
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
## Advanced Patterns
|
|
919
|
+
|
|
920
|
+
### Programmatic Comment Creation
|
|
921
|
+
|
|
922
|
+
```tsx
|
|
923
|
+
import { useComments } from '@kendew/react-feedback-layer';
|
|
924
|
+
|
|
925
|
+
function CustomTool() {
|
|
926
|
+
const { registerComment } = useComments();
|
|
927
|
+
|
|
928
|
+
const addCommentAtElement = (elementId: string) => {
|
|
929
|
+
const element = document.getElementById(elementId);
|
|
930
|
+
if (!element) return;
|
|
931
|
+
|
|
932
|
+
const rect = element.getBoundingClientRect();
|
|
933
|
+
registerComment(
|
|
934
|
+
{ x: rect.right, y: rect.bottom },
|
|
935
|
+
{ width: rect.width, height: rect.height }
|
|
936
|
+
);
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
return (
|
|
940
|
+
<button onClick={() => addCommentAtElement('target-element')}>
|
|
941
|
+
Comment on Element
|
|
942
|
+
</button>
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
### Error Handling
|
|
948
|
+
|
|
949
|
+
You can handle errors in two ways:
|
|
950
|
+
|
|
951
|
+
**1. Using the `onError` callback (recommended):**
|
|
952
|
+
|
|
953
|
+
```tsx
|
|
954
|
+
<CommentContextProvider
|
|
955
|
+
currentUser={currentUser}
|
|
956
|
+
onConfirm={saveComments}
|
|
957
|
+
onResolve={resolveComments}
|
|
958
|
+
onError={(error) => {
|
|
959
|
+
console.error('Comment operation failed:', error);
|
|
960
|
+
// Show user-friendly error message
|
|
961
|
+
toast.error('Failed to save comments. Please try again.');
|
|
962
|
+
}}
|
|
963
|
+
>
|
|
964
|
+
{children}
|
|
965
|
+
</CommentContextProvider>
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
**2. Handling errors from action results:**
|
|
969
|
+
|
|
970
|
+
```tsx
|
|
971
|
+
import { useComments } from '@kendew/react-feedback-layer';
|
|
972
|
+
|
|
973
|
+
function SaveButton() {
|
|
974
|
+
const { confirmComments, overlayState } = useComments();
|
|
975
|
+
|
|
976
|
+
const handleSave = async () => {
|
|
977
|
+
const { error } = await confirmComments();
|
|
978
|
+
|
|
979
|
+
if (error) {
|
|
980
|
+
console.error('Failed to save comments:', error);
|
|
981
|
+
alert('Failed to save comments. Please try again.');
|
|
982
|
+
} else {
|
|
983
|
+
alert('Comments saved successfully!');
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
return (
|
|
988
|
+
<button
|
|
989
|
+
onClick={handleSave}
|
|
990
|
+
disabled={overlayState === 'saving'}
|
|
991
|
+
>
|
|
992
|
+
{overlayState === 'saving' ? 'Saving...' : 'Save Comments'}
|
|
993
|
+
</button>
|
|
994
|
+
);
|
|
995
|
+
}
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
### Filtering and Searching Comments
|
|
999
|
+
|
|
1000
|
+
```tsx
|
|
1001
|
+
import { useComments } from '@kendew/react-feedback-layer';
|
|
1002
|
+
import { useState } from 'react';
|
|
1003
|
+
|
|
1004
|
+
function CommentList() {
|
|
1005
|
+
const { allComments } = useComments();
|
|
1006
|
+
const [filter, setFilter] = useState('');
|
|
1007
|
+
|
|
1008
|
+
const filteredComments = allComments.filter(comment =>
|
|
1009
|
+
comment.content.toLowerCase().includes(filter.toLowerCase()) ||
|
|
1010
|
+
comment.user?.name.toLowerCase().includes(filter.toLowerCase())
|
|
1011
|
+
);
|
|
1012
|
+
|
|
1013
|
+
return (
|
|
1014
|
+
<div>
|
|
1015
|
+
<input
|
|
1016
|
+
type="text"
|
|
1017
|
+
placeholder="Search comments..."
|
|
1018
|
+
value={filter}
|
|
1019
|
+
onChange={(e) => setFilter(e.target.value)}
|
|
1020
|
+
/>
|
|
1021
|
+
<ul>
|
|
1022
|
+
{filteredComments.map(comment => (
|
|
1023
|
+
<li key={comment.id}>
|
|
1024
|
+
<strong>{comment.user?.name}:</strong> {comment.content}
|
|
1025
|
+
</li>
|
|
1026
|
+
))}
|
|
1027
|
+
</ul>
|
|
1028
|
+
</div>
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
## Styling
|
|
1034
|
+
|
|
1035
|
+
This library is completely unstyled (headless). Here's a basic CSS example to get started:
|
|
1036
|
+
|
|
1037
|
+
```css
|
|
1038
|
+
/* Comment positioning */
|
|
1039
|
+
[data-comment] {
|
|
1040
|
+
position: absolute;
|
|
1041
|
+
z-index: 30;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
[data-comment][data-active="true"] {
|
|
1045
|
+
z-index: 40;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/* Indicator box */
|
|
1049
|
+
[data-parent] {
|
|
1050
|
+
border: 2px dashed #3b82f6;
|
|
1051
|
+
background: rgba(59, 130, 246, 0.1);
|
|
1052
|
+
pointer-events: none;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/* Comment card */
|
|
1056
|
+
.comment-card {
|
|
1057
|
+
background: white;
|
|
1058
|
+
border: 1px solid #e5e7eb;
|
|
1059
|
+
border-radius: 8px;
|
|
1060
|
+
padding: 12px;
|
|
1061
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
1062
|
+
min-width: 250px;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
.comment-card[data-active="true"] {
|
|
1066
|
+
border-color: #3b82f6;
|
|
1067
|
+
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/* Overlay */
|
|
1071
|
+
[data-overlay] {
|
|
1072
|
+
position: relative;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/* Guard layer */
|
|
1076
|
+
[data-comment-guard] {
|
|
1077
|
+
position: fixed;
|
|
1078
|
+
inset: 0;
|
|
1079
|
+
z-index: 20;
|
|
1080
|
+
background: rgba(0, 0, 0, 0.1);
|
|
1081
|
+
}
|
|
1082
|
+
```
|
|
1083
|
+
|
|
1084
|
+
## Browser Support
|
|
1085
|
+
|
|
1086
|
+
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
1087
|
+
- Requires support for:
|
|
1088
|
+
- React 18+
|
|
1089
|
+
- CSS `position: absolute`
|
|
1090
|
+
- Pointer Events API
|
|
1091
|
+
- `crypto.randomUUID()`
|
|
1092
|
+
|
|
1093
|
+
## TypeScript
|
|
1094
|
+
|
|
1095
|
+
This library is written in TypeScript and includes full type definitions. No additional `@types` packages needed.
|
|
1096
|
+
|
|
1097
|
+
```tsx
|
|
1098
|
+
import type { CommentType, User } from '@kendew/react-feedback-layer/types';
|
|
1099
|
+
|
|
1100
|
+
const user: User = {
|
|
1101
|
+
id: '123',
|
|
1102
|
+
name: 'John Doe',
|
|
1103
|
+
avatar: '/avatar.jpg',
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
const comment: CommentType = {
|
|
1107
|
+
id: crypto.randomUUID(),
|
|
1108
|
+
position: { x: 100, y: 200 },
|
|
1109
|
+
content: 'Great work!',
|
|
1110
|
+
user,
|
|
1111
|
+
createdAt: new Date(),
|
|
1112
|
+
status: 'published',
|
|
1113
|
+
};
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
## Contributing
|
|
1117
|
+
|
|
1118
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
1119
|
+
|
|
1120
|
+
1. Fork the repository
|
|
1121
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
1122
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
1123
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
1124
|
+
5. Open a Pull Request
|
|
1125
|
+
|
|
1126
|
+
## Development
|
|
1127
|
+
|
|
1128
|
+
```bash
|
|
1129
|
+
# Install dependencies
|
|
1130
|
+
npm install
|
|
1131
|
+
|
|
1132
|
+
# Start development build (watch mode)
|
|
1133
|
+
npm run dev
|
|
1134
|
+
|
|
1135
|
+
# Run playground for testing
|
|
1136
|
+
npm run playground
|
|
1137
|
+
|
|
1138
|
+
# Type checking
|
|
1139
|
+
npm run typecheck
|
|
1140
|
+
|
|
1141
|
+
# Linting and formatting
|
|
1142
|
+
npm run format-and-lint:fix
|
|
1143
|
+
|
|
1144
|
+
# Build for production
|
|
1145
|
+
npm run build
|
|
1146
|
+
```
|
|
1147
|
+
|
|
1148
|
+
## License
|
|
1149
|
+
|
|
1150
|
+
MIT © [Kendew Agency](https://github.com/Kendew-Agency)
|
|
1151
|
+
|
|
1152
|
+
## Links
|
|
1153
|
+
|
|
1154
|
+
- [GitHub Repository](https://github.com/Kendew-Agency/react-feedback-layer)
|
|
1155
|
+
- [Issue Tracker](https://github.com/Kendew-Agency/react-feedback-layer/issues)
|
|
1156
|
+
- [NPM Package](https://www.npmjs.com/package/@kendew/react-feedback-layer)
|