danylokhodus commited on
Commit
c98b323
·
1 Parent(s): 2f6e9e4

feat: add goal node settings modal, hotbar progress slider and subtask constraints

Browse files
src/features/canvas/components/nodes/SketchNode.jsx CHANGED
@@ -1,17 +1,12 @@
1
  import React, { useState, useRef, useEffect } from 'react';
2
  import { Handle, Position, useReactFlow } from '@xyflow/react';
3
- import { CheckCircle2, Circle, X, ArrowRight, Sparkles, AlertCircle, CheckSquare } from 'lucide-react';
4
  import { useTranslation } from 'react-i18next';
5
  import { isDefaultLabel } from '../../utils';
6
 
7
  const SketchNode = ({ id, data, selected }) => {
8
  const { setNodes } = useReactFlow();
9
  const { t } = useTranslation();
10
- const [isEditing, setIsEditing] = useState(false);
11
- const [editData, setEditData] = useState({
12
- label: isDefaultLabel(data.label) ? '' : data.label,
13
- description: data.description || ''
14
- });
15
  const [showWarning, setShowWarning] = useState(false);
16
  const warningTimeoutRef = useRef(null);
17
 
@@ -21,16 +16,6 @@ const SketchNode = ({ id, data, selected }) => {
21
  };
22
  }, []);
23
 
24
- // Synchronize local editData with incoming WebRTC data updates when not actively editing
25
- useEffect(() => {
26
- if (!isEditing) {
27
- setEditData({
28
- label: isDefaultLabel(data.label) ? '' : data.label,
29
- description: data.description || ''
30
- });
31
- }
32
- }, [data.label, data.description, isEditing]);
33
-
34
  const toggleDone = (e) => {
35
  e.stopPropagation();
36
 
@@ -45,37 +30,65 @@ const SketchNode = ({ id, data, selected }) => {
45
  }
46
 
47
  const newStatus = data.status === 'Done' ? 'Pending' : 'Done';
 
 
48
  if (data.updateNodeData) {
49
- data.updateNodeData(id, { status: newStatus });
 
 
 
50
  } else {
51
  setNodes((nds) =>
52
  nds.map((node) =>
53
- node.id === id ? { ...node, data: { ...node.data, status: newStatus } } : node
 
 
 
 
 
 
 
54
  )
55
  );
56
  }
57
  };
58
 
59
- const handleDoubleClick = (e) => {
60
  e.stopPropagation();
61
- setIsEditing(true);
62
- setEditData({
63
- label: isDefaultLabel(data.label) ? '' : data.label,
64
- description: data.description || ''
65
- });
 
 
 
 
 
 
 
 
 
 
 
 
66
  };
67
 
68
- const saveEdit = () => {
69
  if (data.updateNodeData) {
70
- data.updateNodeData(id, { label: editData.label, description: editData.description });
71
  } else {
72
  setNodes((nds) =>
73
  nds.map((node) =>
74
- node.id === id ? { ...node, data: { ...node.data, label: editData.label, description: editData.description } } : node
75
  )
76
  );
77
  }
78
- setIsEditing(false);
 
 
 
 
79
  };
80
 
81
  const getStatusColor = (status) => {
@@ -87,93 +100,103 @@ const SketchNode = ({ id, data, selected }) => {
87
  }
88
  };
89
 
 
 
90
  return (
91
  <div
92
- onDoubleClick={handleDoubleClick}
93
- className={`px-4 py-3 min-w-[200px] max-w-[300px] rough-border bg-surface-container-lowest transition-all group ${
94
  selected ? 'shadow-[6px_6px_0px_0px_rgba(52,211,153,0.3)] dark:shadow-[6px_6px_0px_0px_rgba(52,211,153,0.3)] -translate-y-1 border-emerald-400 ring-4 ring-emerald-400/20 scale-[1.01]' : ''
95
  } ${data.status === 'Done' ? 'opacity-80' : ''} ${
96
  data.isNextStep ? 'ring-4 ring-success/30 ring-offset-2 ring-offset-background shadow-[0_0_20px_rgba(34,197,94,0.2)]' : ''
97
- }`}
98
  >
99
  <Handle type="target" position={Position.Top} id="main-target" className="!bg-primary !w-3 !h-3 !border-2 !border-white" />
100
  <Handle type="source" position={Position.Bottom} id="main-source" className="!bg-primary !w-3 !h-3 !border-2 !border-white" />
101
  <Handle type="target" position={Position.Left} id="subgoals-target-left" className="!bg-yellow-500 !w-3 !h-3 !border-2 !border-white" />
102
  <Handle type="source" position={Position.Left} id="subgoals-source-left" className="!bg-yellow-500 !w-3 !h-3 !border-2 !border-white !opacity-0" />
103
 
104
- {isEditing ? (
105
- <div className="flex flex-col gap-2 p-1" onKeyDown={(e) => e.key === 'Enter' && saveEdit()}>
106
- <input
107
- autoFocus
108
- className="text-lg font-display-lg border-b-2 border-primary outline-none w-full bg-transparent text-primary nodrag"
109
- onMouseDown={(e) => e.stopPropagation()}
110
- onPointerDown={(e) => e.stopPropagation()}
111
- value={editData.label}
112
- placeholder={t('canvas.new_goal', 'New Goal')}
113
- onChange={(e) => setEditData({...editData, label: e.target.value})}
114
- />
115
- <textarea
116
- className="text-sm font-accent-note outline-none w-full h-12 resize-none bg-transparent text-primary nodrag"
117
- onMouseDown={(e) => e.stopPropagation()}
118
- onPointerDown={(e) => e.stopPropagation()}
119
- placeholder="Add description..."
120
- value={editData.description}
121
- onChange={(e) => setEditData({...editData, description: e.target.value})}
122
- />
123
- <div className="flex justify-end gap-2 mt-2">
124
- <button onClick={() => setIsEditing(false)} className="p-1 hover:text-error cursor-pointer"><X size={16}/></button>
125
- <button onClick={saveEdit} className="p-1 hover:text-success cursor-pointer"><CheckCircle2 size={16}/></button>
 
126
  </div>
127
  </div>
128
- ) : (
129
- <div className="flex flex-col gap-2 pointer-events-none">
130
- <div className="flex justify-between items-start gap-4 pointer-events-none">
131
- <div className="flex items-center gap-2 pointer-events-none">
132
- <button onClick={toggleDone} className="transition-colors hover:scale-110 cursor-pointer pointer-events-auto">
133
- {data.status === 'Done' ?
134
- <CheckCircle2 size={20} className="text-success fill-success/10" /> :
135
- <Circle size={20} className="text-on-surface-variant/30" />
136
- }
137
- </button>
138
- <span className="font-display-lg text-xl text-primary leading-tight break-words pointer-events-none">
139
- {isDefaultLabel(data.label) ? t('canvas.new_goal', 'New Goal') : data.label}
140
- </span>
141
- </div>
142
- {data.isNextStep && <ArrowRight size={18} className="text-success animate-bounce-x pointer-events-none" />}
143
  </div>
144
-
145
- {data.description && (
146
- <p className="text-sm font-accent-note text-on-surface-variant line-clamp-2 italic pointer-events-none">
147
- {data.description}
148
- </p>
149
- )}
150
-
151
- {data.subgoals && data.subgoals.total > 0 && (
152
- <div className="mt-1 flex items-center gap-1.5 text-[10px] font-bold text-secondary bg-secondary/5 px-2 py-1 rounded-sm border border-secondary/10 w-fit pointer-events-none">
153
- <CheckSquare size={11} className="text-secondary pointer-events-none" />
154
- <span className="pointer-events-none">
155
- {t('canvas.subgoals_progress', { done: data.subgoals.done, total: data.subgoals.total })}
156
  </span>
157
  </div>
158
- )}
159
-
160
- {showWarning && (
161
- <div className="mt-1.5 p-1.5 rounded-sm bg-red-500/10 border border-red-500/30 flex items-center gap-1.5 text-[10px] font-bold text-red-600 dark:text-red-400 animate-shake shadow-sm pointer-events-none">
162
- <AlertCircle size={12} className="text-red-500 shrink-0 pointer-events-none" />
163
- <span className="pointer-events-none">{t('canvas.subgoal_warning')}</span>
 
 
 
 
 
 
164
  </div>
165
- )}
 
166
 
167
- <div className="flex items-center justify-between mt-1 pointer-events-none">
168
- <span className={`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded-sm border pointer-events-none ${getStatusColor(data.status)}`}>
169
- {data.status}
170
- </span>
171
- <div className="flex items-center gap-2 pointer-events-none">
172
- {data.ai && <Sparkles size={12} className="text-secondary animate-pulse pointer-events-none" />}
173
- </div>
 
 
 
 
 
 
174
  </div>
175
  </div>
176
- )}
177
 
178
  <Handle type="target" position={Position.Right} id="subgoals-target-right" className="!bg-yellow-500 !w-3 !h-3 !border-2 !border-white !opacity-0" />
179
  <Handle type="source" position={Position.Right} id="subgoals-source-right" className="!bg-yellow-500 !w-3 !h-3 !border-2 !border-white" />
 
1
  import React, { useState, useRef, useEffect } from 'react';
2
  import { Handle, Position, useReactFlow } from '@xyflow/react';
3
+ import { CheckCircle2, Circle, X, ArrowRight, Sparkles, AlertCircle, CheckSquare, Settings } from 'lucide-react';
4
  import { useTranslation } from 'react-i18next';
5
  import { isDefaultLabel } from '../../utils';
6
 
7
  const SketchNode = ({ id, data, selected }) => {
8
  const { setNodes } = useReactFlow();
9
  const { t } = useTranslation();
 
 
 
 
 
10
  const [showWarning, setShowWarning] = useState(false);
11
  const warningTimeoutRef = useRef(null);
12
 
 
16
  };
17
  }, []);
18
 
 
 
 
 
 
 
 
 
 
 
19
  const toggleDone = (e) => {
20
  e.stopPropagation();
21
 
 
30
  }
31
 
32
  const newStatus = data.status === 'Done' ? 'Pending' : 'Done';
33
+ const newProgress = newStatus === 'Done' ? 100 : 0;
34
+
35
  if (data.updateNodeData) {
36
+ data.updateNodeData(id, {
37
+ status: newStatus,
38
+ progress: data.showProgress ? newProgress : (data.progress || 0)
39
+ });
40
  } else {
41
  setNodes((nds) =>
42
  nds.map((node) =>
43
+ node.id === id ? {
44
+ ...node,
45
+ data: {
46
+ ...node.data,
47
+ status: newStatus,
48
+ progress: data.showProgress ? newProgress : (data.progress || 0)
49
+ }
50
+ } : node
51
  )
52
  );
53
  }
54
  };
55
 
56
+ const handleProgressChange = (e) => {
57
  e.stopPropagation();
58
+ const val = parseInt(e.target.value, 10);
59
+
60
+ // Check if subgoals constraint is satisfied
61
+ if (val === 100 && data.subgoals && data.subgoals.done < data.subgoals.total) {
62
+ setShowWarning(true);
63
+ if (warningTimeoutRef.current) clearTimeout(warningTimeoutRef.current);
64
+ warningTimeoutRef.current = setTimeout(() => {
65
+ setShowWarning(false);
66
+ }, 3000);
67
+
68
+ // Cap progress at 99% and status to Pending
69
+ updateProgress(99, 'Pending');
70
+ return;
71
+ }
72
+
73
+ const newStatus = val === 100 ? 'Done' : 'Pending';
74
+ updateProgress(val, newStatus);
75
  };
76
 
77
+ const updateProgress = (progressVal, newStatus) => {
78
  if (data.updateNodeData) {
79
+ data.updateNodeData(id, { progress: progressVal, status: newStatus });
80
  } else {
81
  setNodes((nds) =>
82
  nds.map((node) =>
83
+ node.id === id ? { ...node, data: { ...node.data, progress: progressVal, status: newStatus } } : node
84
  )
85
  );
86
  }
87
+ };
88
+
89
+ const openConfigureModal = (e) => {
90
+ e.stopPropagation();
91
+ window.dispatchEvent(new CustomEvent('configure-sketch-node', { detail: { nodeId: id } }));
92
  };
93
 
94
  const getStatusColor = (status) => {
 
100
  }
101
  };
102
 
103
+ const progressValue = data.progress !== undefined ? data.progress : 0;
104
+
105
  return (
106
  <div
107
+ onDoubleClick={openConfigureModal}
108
+ className={`px-4 py-3 min-w-[220px] max-w-[320px] rough-border bg-surface-container-lowest transition-all group relative ${
109
  selected ? 'shadow-[6px_6px_0px_0px_rgba(52,211,153,0.3)] dark:shadow-[6px_6px_0px_0px_rgba(52,211,153,0.3)] -translate-y-1 border-emerald-400 ring-4 ring-emerald-400/20 scale-[1.01]' : ''
110
  } ${data.status === 'Done' ? 'opacity-80' : ''} ${
111
  data.isNextStep ? 'ring-4 ring-success/30 ring-offset-2 ring-offset-background shadow-[0_0_20px_rgba(34,197,94,0.2)]' : ''
112
+ } ${showWarning ? 'animate-shake' : ''}`}
113
  >
114
  <Handle type="target" position={Position.Top} id="main-target" className="!bg-primary !w-3 !h-3 !border-2 !border-white" />
115
  <Handle type="source" position={Position.Bottom} id="main-source" className="!bg-primary !w-3 !h-3 !border-2 !border-white" />
116
  <Handle type="target" position={Position.Left} id="subgoals-target-left" className="!bg-yellow-500 !w-3 !h-3 !border-2 !border-white" />
117
  <Handle type="source" position={Position.Left} id="subgoals-source-left" className="!bg-yellow-500 !w-3 !h-3 !border-2 !border-white !opacity-0" />
118
 
119
+ <div className="flex flex-col gap-2">
120
+ <div className="flex justify-between items-start gap-2">
121
+ <div className="flex items-center gap-2 flex-1 min-w-0">
122
+ <button onClick={toggleDone} className="transition-colors hover:scale-110 cursor-pointer shrink-0">
123
+ {data.status === 'Done' ?
124
+ <CheckCircle2 size={20} className="text-success fill-success/10" /> :
125
+ <Circle size={20} className="text-on-surface-variant/30" />
126
+ }
127
+ </button>
128
+ <span className="font-display-lg text-lg text-primary leading-tight break-words flex-1 min-w-0">
129
+ {isDefaultLabel(data.label) ? t('canvas.new_goal', 'New Goal') : data.label}
130
+ </span>
131
+ </div>
132
+
133
+ <div className="flex items-center gap-1 shrink-0">
134
+ {data.isNextStep && <ArrowRight size={18} className="text-success animate-bounce-x" />}
135
+ <button
136
+ onClick={openConfigureModal}
137
+ className="opacity-0 group-hover:opacity-100 transition-opacity p-1 text-on-surface-variant/70 hover:text-primary hover:bg-primary/5 rounded-full cursor-pointer pointer-events-auto shrink-0"
138
+ title={t('canvas.configure', 'Configure')}
139
+ >
140
+ <Settings size={14} />
141
+ </button>
142
  </div>
143
  </div>
144
+
145
+ {data.description && (
146
+ <p className="text-sm font-accent-note text-on-surface-variant line-clamp-2 italic">
147
+ {data.description}
148
+ </p>
149
+ )}
150
+
151
+ {data.subgoals && data.subgoals.total > 0 && (
152
+ <div className="mt-0.5 flex items-center gap-1.5 text-[10px] font-bold text-secondary bg-secondary/5 px-2 py-1 rounded-sm border border-secondary/10 w-fit">
153
+ <CheckSquare size={11} className="text-secondary" />
154
+ <span>
155
+ {t('canvas.subgoals_progress', { done: data.subgoals.done, total: data.subgoals.total })}
156
+ </span>
 
 
157
  </div>
158
+ )}
159
+
160
+ {data.showProgress && (
161
+ <div className="mt-2 flex flex-col gap-1 nodrag" onMouseDown={e => e.stopPropagation()}>
162
+ <div className="flex justify-between items-center text-[10px] font-bold text-on-surface-variant">
163
+ <span>{t('canvas.progress_readiness', 'Readiness')}</span>
164
+ <span className="bg-primary/10 text-primary px-1.5 py-0.5 rounded-full font-mono text-[10px]">
165
+ {progressValue}%
 
 
 
 
166
  </span>
167
  </div>
168
+ <div className="relative flex items-center mt-1">
169
+ <input
170
+ type="range"
171
+ min="0"
172
+ max="100"
173
+ value={progressValue}
174
+ onChange={handleProgressChange}
175
+ className="w-full h-2 rounded-lg appearance-none cursor-pointer focus:outline-none transition-all"
176
+ style={{
177
+ background: `linear-gradient(to right, var(--color-primary, #10b981) ${progressValue}%, var(--color-border, #e2e8f0) ${progressValue}%)`
178
+ }}
179
+ />
180
  </div>
181
+ </div>
182
+ )}
183
 
184
+ {showWarning && (
185
+ <div className="mt-1.5 p-1.5 rounded-sm bg-red-500/10 border border-red-500/30 flex items-center gap-1.5 text-[10px] font-bold text-red-600 dark:text-red-400 animate-shake shadow-sm">
186
+ <AlertCircle size={12} className="text-red-500 shrink-0" />
187
+ <span>{t('canvas.subgoal_warning')}</span>
188
+ </div>
189
+ )}
190
+
191
+ <div className="flex items-center justify-between mt-1">
192
+ <span className={`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded-sm border ${getStatusColor(data.status)}`}>
193
+ {data.status}
194
+ </span>
195
+ <div className="flex items-center gap-2">
196
+ {data.ai && <Sparkles size={12} className="text-secondary animate-pulse" />}
197
  </div>
198
  </div>
199
+ </div>
200
 
201
  <Handle type="target" position={Position.Right} id="subgoals-target-right" className="!bg-yellow-500 !w-3 !h-3 !border-2 !border-white !opacity-0" />
202
  <Handle type="source" position={Position.Right} id="subgoals-source-right" className="!bg-yellow-500 !w-3 !h-3 !border-2 !border-white" />
src/features/canvas/hooks/useCanvasLogic.js CHANGED
@@ -373,6 +373,18 @@ export const useCanvasLogic = (projectId, user) => {
373
  console.error('Failed to parse habit decision JSON', e);
374
  }
375
  }
 
 
 
 
 
 
 
 
 
 
 
 
376
  }
377
 
378
  return {
@@ -390,6 +402,8 @@ export const useCanvasLogic = (projectId, user) => {
390
  lastResetTime,
391
  createdAt,
392
  description: description || '',
 
 
393
  updateNodeData: updateNodeDataCallback
394
  }
395
  };
@@ -488,7 +502,14 @@ export const useCanvasLogic = (projectId, user) => {
488
  createdAt: n.data.createdAt || new Date().toISOString(),
489
  description: n.data.description || ''
490
  })
491
- : n.data.decision
 
 
 
 
 
 
 
492
  })),
493
  edges: edges.map(e => {
494
  let cond = e.sourceHandle;
 
373
  console.error('Failed to parse habit decision JSON', e);
374
  }
375
  }
376
+ } else if (n.type === 'sketch') {
377
+ if (n.decision && n.decision.startsWith('{')) {
378
+ try {
379
+ const parsed = JSON.parse(n.decision);
380
+ description = parsed.description || '';
381
+ progress = parsed.progress || 0;
382
+ showProgress = !!parsed.showProgress;
383
+ decision = parsed.decision || 'bottom';
384
+ } catch (e) {
385
+ console.error('Failed to parse sketch decision JSON', e);
386
+ }
387
+ }
388
  }
389
 
390
  return {
 
402
  lastResetTime,
403
  createdAt,
404
  description: description || '',
405
+ progress: progress,
406
+ showProgress: showProgress,
407
  updateNodeData: updateNodeDataCallback
408
  }
409
  };
 
502
  createdAt: n.data.createdAt || new Date().toISOString(),
503
  description: n.data.description || ''
504
  })
505
+ : n.type === 'sketch'
506
+ ? JSON.stringify({
507
+ description: n.data.description || '',
508
+ progress: n.data.progress || 0,
509
+ showProgress: !!n.data.showProgress,
510
+ decision: n.data.decision || 'bottom'
511
+ })
512
+ : n.data.decision
513
  })),
514
  edges: edges.map(e => {
515
  let cond = e.sourceHandle;
src/pages/CanvasPage.jsx CHANGED
@@ -459,6 +459,141 @@ const HabitSettingsModal = ({ node, onClose, onSave }) => {
459
  );
460
  };
461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
  // Initials extractor helper for collaborator cursor badges
463
  const getInitials = (name) => {
464
  if (!name) return '';
@@ -650,6 +785,7 @@ const CanvasInner = () => {
650
 
651
  const [editingConditionNodeId, setEditingConditionNodeId] = useState(null);
652
  const [editingHabitNodeId, setEditingHabitNodeId] = useState(null);
 
653
  const [isShareModalOpen, setIsShareModalOpen] = useState(false);
654
 
655
  useEffect(() => {
@@ -659,11 +795,16 @@ const CanvasInner = () => {
659
  const handleConfigureHabit = (e) => {
660
  setEditingHabitNodeId(e.detail.nodeId);
661
  };
 
 
 
662
  window.addEventListener('configure-condition-node', handleConfigureCondition);
663
  window.addEventListener('configure-habit-node', handleConfigureHabit);
 
664
  return () => {
665
  window.removeEventListener('configure-condition-node', handleConfigureCondition);
666
  window.removeEventListener('configure-habit-node', handleConfigureHabit);
 
667
  };
668
  }, []);
669
 
@@ -675,6 +816,10 @@ const CanvasInner = () => {
675
  return nodes.find(n => n.id === editingHabitNodeId);
676
  }, [nodes, editingHabitNodeId]);
677
 
 
 
 
 
678
  const handleSaveConditionConfig = (updatedData) => {
679
  if (!editingConditionNodeId) return;
680
  updateNodeData(editingConditionNodeId, updatedData);
@@ -690,6 +835,12 @@ const CanvasInner = () => {
690
  setEditingHabitNodeId(null);
691
  };
692
 
 
 
 
 
 
 
693
  const nodeTypes = useMemo(() => ({
694
  sketch: SketchNode,
695
  condition: ConditionNode,
@@ -1000,6 +1151,14 @@ const CanvasInner = () => {
1000
  />
1001
  )}
1002
 
 
 
 
 
 
 
 
 
1003
  {isShareModalOpen && (
1004
  <ShareModal
1005
  projectId={id}
 
459
  );
460
  };
461
 
462
+ // Premium digital sketchbook style settings modal for goal (sketch) nodes
463
+ const SketchSettingsModal = ({ node, onClose, onSave }) => {
464
+ const { t } = useTranslation();
465
+ const [label, setLabel] = useState(() =>
466
+ isDefaultLabel(node.data.label) ? '' : node.data.label
467
+ );
468
+ const [description, setDescription] = useState(node.data.description || '');
469
+ const [showProgress, setShowProgress] = useState(!!node.data.showProgress);
470
+ const [progress, setProgress] = useState(node.data.progress || 0);
471
+
472
+ const handleSave = () => {
473
+ const status = progress === 100 ? 'Done' : 'Pending';
474
+ onSave({
475
+ label: label || t('canvas.goal_node', 'Goal'),
476
+ description,
477
+ showProgress,
478
+ progress: Number(progress),
479
+ status
480
+ });
481
+ };
482
+
483
+ return (
484
+ <div className="fixed inset-0 bg-primary/40 backdrop-blur-md z-[60] flex items-center justify-center p-4">
485
+ <div className="bg-surface-container-lowest border-4 border-primary rounded-3xl p-8 max-w-md w-full shadow-[8px_8px_0px_0px_var(--color-primary)] relative transition-all">
486
+ {/* Close Button */}
487
+ <button
488
+ onClick={onClose}
489
+ className="absolute top-6 right-6 p-1.5 bg-surface-container-lowest hover:bg-red-500/20 border-2 border-primary rounded-xl transition-all cursor-pointer shadow-[2px_2px_0px_0px_var(--color-primary)] hover:scale-105 text-primary"
490
+ >
491
+ <X size={18} className="text-primary" />
492
+ </button>
493
+
494
+ <h3 className="text-2xl font-display-lg text-primary mb-6 flex items-center gap-2">
495
+ <Target size={24} className="text-primary animate-pulse" />
496
+ <span>{t('canvas.goal_settings_title', 'Налаштування цілі')}</span>
497
+ </h3>
498
+
499
+ <div className="space-y-5">
500
+ {/* Goal Name Input */}
501
+ <div>
502
+ <label className="block text-[11px] font-bold uppercase tracking-widest text-primary/60 mb-2">
503
+ {t('canvas.goal_name_label', 'Назва цілі')}
504
+ </label>
505
+ <input
506
+ type="text"
507
+ value={label}
508
+ onChange={(e) => setLabel(e.target.value)}
509
+ placeholder={t('canvas.goal_name_placeholder', 'Введіть назву цілі')}
510
+ className="w-full px-4 py-3 bg-secondary/10 border-2 border-primary rounded-xl font-bold text-primary focus:outline-none focus:bg-surface-container-lowest transition-all shadow-[2px_2px_0px_0px_rgba(49,54,63,0.1)]"
511
+ />
512
+ </div>
513
+
514
+ {/* Description Input */}
515
+ <div>
516
+ <label className="block text-[11px] font-bold uppercase tracking-widest text-primary/60 mb-2">
517
+ {t('canvas.goal_description_label', 'Опис цілі')}
518
+ </label>
519
+ <textarea
520
+ value={description}
521
+ onChange={(e) => setDescription(e.target.value)}
522
+ placeholder={t('canvas.goal_description_placeholder', 'Додайте опис цілі...')}
523
+ className="w-full h-24 px-4 py-2.5 bg-secondary/10 border-2 border-primary rounded-xl font-bold text-primary focus:outline-none focus:bg-surface-container-lowest transition-all resize-none shadow-[2px_2px_0px_0px_rgba(49,54,63,0.1)] text-xs"
524
+ />
525
+ </div>
526
+
527
+ {/* Show Progress Toggle */}
528
+ <div className="flex items-center justify-between bg-secondary/5 border-2 border-primary rounded-xl p-4">
529
+ <div>
530
+ <span className="block font-bold text-xs text-primary">{t('canvas.goal_progress_toggle', 'Трекер прогресу')}</span>
531
+ <span className="block text-[10px] text-primary/60">{t('canvas.goal_progress_desc', 'Відображати повзунок виконання цілі від 0% до 100%')}</span>
532
+ </div>
533
+
534
+ <label className="relative inline-flex items-center cursor-pointer select-none">
535
+ <input
536
+ type="checkbox"
537
+ checked={showProgress}
538
+ onChange={(e) => setShowProgress(e.target.checked)}
539
+ className="sr-only peer"
540
+ />
541
+ <div className="w-11 h-6 bg-secondary/20 peer-focus:outline-none border-2 border-primary rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[4px] after:left-[4px] after:bg-primary after:border-primary after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-success/20"></div>
542
+ </label>
543
+ </div>
544
+
545
+ {/* Progress Slider */}
546
+ {showProgress && (
547
+ <div className="border-2 border-primary rounded-2xl p-4 bg-secondary/5 space-y-3">
548
+ <div className="flex items-center justify-between mb-1">
549
+ <label className="block text-[11px] font-bold uppercase tracking-widest text-primary/60">
550
+ {t('canvas.goal_progress_value', 'Готовність цілі')}
551
+ </label>
552
+ <span className="px-2 py-0.5 bg-primary text-white font-extrabold text-xs rounded-lg border-2 border-primary shadow-[1.5px_1.5px_0px_0px_rgba(0,0,0,0.15)]">
553
+ {progress}%
554
+ </span>
555
+ </div>
556
+
557
+ <input
558
+ type="range"
559
+ min="0"
560
+ max="100"
561
+ value={progress}
562
+ onChange={(e) => setProgress(Number(e.target.value))}
563
+ className="w-full h-2 bg-secondary/20 rounded-lg appearance-none cursor-pointer accent-primary border-2 border-primary"
564
+ />
565
+
566
+ <div className="flex justify-between text-[9px] font-extrabold uppercase text-primary/40 px-1 pt-1">
567
+ <span>0%</span>
568
+ <span>25%</span>
569
+ <span>50%</span>
570
+ <span>75%</span>
571
+ <span>100%</span>
572
+ </div>
573
+ </div>
574
+ )}
575
+
576
+ {/* Actions */}
577
+ <div className="flex items-center gap-4 pt-2">
578
+ <button
579
+ onClick={onClose}
580
+ className="flex-1 py-3 text-xs font-bold uppercase tracking-wider text-primary border-2 border-primary rounded-xl bg-surface-container-lowest hover:bg-surface-variant transition-all cursor-pointer shadow-[3px_3px_0px_0px_var(--color-primary)] active:translate-y-0.5 active:shadow-[1px_1px_0px_0px_var(--color-primary)]"
581
+ >
582
+ {t('common.cancel')}
583
+ </button>
584
+ <button
585
+ onClick={handleSave}
586
+ className="flex-1 py-3 text-xs font-bold uppercase tracking-wider text-white bg-primary hover:bg-primary/95 border-2 border-primary rounded-xl transition-all cursor-pointer shadow-[3px_3px_0px_0px_var(--color-primary)] active:translate-y-0.5 active:shadow-[1px_1px_0px_0px_var(--color-primary)]"
587
+ >
588
+ {t('common.apply')}
589
+ </button>
590
+ </div>
591
+ </div>
592
+ </div>
593
+ </div>
594
+ );
595
+ };
596
+
597
  // Initials extractor helper for collaborator cursor badges
598
  const getInitials = (name) => {
599
  if (!name) return '';
 
785
 
786
  const [editingConditionNodeId, setEditingConditionNodeId] = useState(null);
787
  const [editingHabitNodeId, setEditingHabitNodeId] = useState(null);
788
+ const [editingSketchNodeId, setEditingSketchNodeId] = useState(null);
789
  const [isShareModalOpen, setIsShareModalOpen] = useState(false);
790
 
791
  useEffect(() => {
 
795
  const handleConfigureHabit = (e) => {
796
  setEditingHabitNodeId(e.detail.nodeId);
797
  };
798
+ const handleConfigureSketch = (e) => {
799
+ setEditingSketchNodeId(e.detail.nodeId);
800
+ };
801
  window.addEventListener('configure-condition-node', handleConfigureCondition);
802
  window.addEventListener('configure-habit-node', handleConfigureHabit);
803
+ window.addEventListener('configure-sketch-node', handleConfigureSketch);
804
  return () => {
805
  window.removeEventListener('configure-condition-node', handleConfigureCondition);
806
  window.removeEventListener('configure-habit-node', handleConfigureHabit);
807
+ window.removeEventListener('configure-sketch-node', handleConfigureSketch);
808
  };
809
  }, []);
810
 
 
816
  return nodes.find(n => n.id === editingHabitNodeId);
817
  }, [nodes, editingHabitNodeId]);
818
 
819
+ const editingSketchNode = useMemo(() => {
820
+ return nodes.find(n => n.id === editingSketchNodeId);
821
+ }, [nodes, editingSketchNodeId]);
822
+
823
  const handleSaveConditionConfig = (updatedData) => {
824
  if (!editingConditionNodeId) return;
825
  updateNodeData(editingConditionNodeId, updatedData);
 
835
  setEditingHabitNodeId(null);
836
  };
837
 
838
+ const handleSaveSketchConfig = (updatedData) => {
839
+ if (!editingSketchNodeId) return;
840
+ updateNodeData(editingSketchNodeId, updatedData);
841
+ setEditingSketchNodeId(null);
842
+ };
843
+
844
  const nodeTypes = useMemo(() => ({
845
  sketch: SketchNode,
846
  condition: ConditionNode,
 
1151
  />
1152
  )}
1153
 
1154
+ {editingSketchNode && (
1155
+ <SketchSettingsModal
1156
+ node={editingSketchNode}
1157
+ onClose={() => setEditingSketchNodeId(null)}
1158
+ onSave={handleSaveSketchConfig}
1159
+ />
1160
+ )}
1161
+
1162
  {isShareModalOpen && (
1163
  <ShareModal
1164
  projectId={id}