danylokhodus commited on
Commit
8059ea2
·
1 Parent(s): 10d53a4

fix: restore original theme color as default for goal nodes, keeping comments yellow by default

Browse files
src/features/canvas/components/nodes/CommentNode.jsx CHANGED
@@ -55,7 +55,8 @@ const CommentNode = ({ id, data, selected }) => {
55
  const remainingCount = assignees.length - visibleAssignees.length;
56
 
57
  // Background and border style resolution based on selected color or default to yellow
58
- const selectedColor = PASTEL_COLORS[data.color || 'yellow'];
 
59
  const nodeBg = isDarkMode ? selectedColor.dark : selectedColor.light;
60
  const nodeBorder = isDarkMode ? selectedColor.borderDark : selectedColor.borderLight;
61
 
 
55
  const remainingCount = assignees.length - visibleAssignees.length;
56
 
57
  // Background and border style resolution based on selected color or default to yellow
58
+ const colorKey = data.color && data.color !== 'default' ? data.color : 'yellow';
59
+ const selectedColor = PASTEL_COLORS[colorKey];
60
  const nodeBg = isDarkMode ? selectedColor.dark : selectedColor.light;
61
  const nodeBorder = isDarkMode ? selectedColor.borderDark : selectedColor.borderLight;
62
 
src/features/canvas/components/nodes/SketchNode.jsx CHANGED
@@ -142,7 +142,7 @@ const SketchNode = ({ id, data, selected }) => {
142
  const visibleAssignees = shouldTruncate ? assignees.slice(0, 2) : assignees;
143
  const remainingCount = assignees.length - visibleAssignees.length;
144
 
145
- const selectedColor = PASTEL_COLORS[data.color];
146
  const nodeBg = selectedColor
147
  ? (isDarkMode ? selectedColor.dark : selectedColor.light)
148
  : 'var(--color-surface-container-lowest)';
 
142
  const visibleAssignees = shouldTruncate ? assignees.slice(0, 2) : assignees;
143
  const remainingCount = assignees.length - visibleAssignees.length;
144
 
145
+ const selectedColor = data.color && data.color !== 'default' ? PASTEL_COLORS[data.color] : null;
146
  const nodeBg = selectedColor
147
  ? (isDarkMode ? selectedColor.dark : selectedColor.light)
148
  : 'var(--color-surface-container-lowest)';
src/features/canvas/hooks/useCanvasLogic.js CHANGED
@@ -595,7 +595,7 @@ export const useCanvasLogic = (projectId, user) => {
595
  }
596
  } else if (n.type === 'sketch') {
597
  let assignees = [];
598
- let color = 'yellow';
599
  if (n.decision && n.decision.startsWith('{')) {
600
  try {
601
  const parsed = JSON.parse(n.decision);
@@ -603,7 +603,7 @@ export const useCanvasLogic = (projectId, user) => {
603
  progress = parsed.progress || 0;
604
  showProgress = !!parsed.showProgress;
605
  decision = parsed.decision || 'bottom';
606
- color = parsed.color || 'yellow';
607
  if (parsed.assignees && Array.isArray(parsed.assignees)) {
608
  assignees = parsed.assignees;
609
  } else if (parsed.assignee) {
@@ -796,7 +796,7 @@ export const useCanvasLogic = (projectId, user) => {
796
  showProgress: !!n.data.showProgress,
797
  decision: n.data.decision || 'bottom',
798
  assignees: n.data.assignees || [],
799
- color: n.data.color || 'yellow'
800
  })
801
  : n.type === 'comment'
802
  ? JSON.stringify({
@@ -1121,7 +1121,7 @@ export const useCanvasLogic = (projectId, user) => {
1121
  nodeData.assignees = [];
1122
  } else if (type === 'sketch') {
1123
  nodeData.decision = 'bottom';
1124
- nodeData.color = 'yellow';
1125
  nodeData.assignees = [];
1126
  } else {
1127
  nodeData.decision = 'bottom';
 
595
  }
596
  } else if (n.type === 'sketch') {
597
  let assignees = [];
598
+ let color = undefined;
599
  if (n.decision && n.decision.startsWith('{')) {
600
  try {
601
  const parsed = JSON.parse(n.decision);
 
603
  progress = parsed.progress || 0;
604
  showProgress = !!parsed.showProgress;
605
  decision = parsed.decision || 'bottom';
606
+ color = parsed.color || undefined;
607
  if (parsed.assignees && Array.isArray(parsed.assignees)) {
608
  assignees = parsed.assignees;
609
  } else if (parsed.assignee) {
 
796
  showProgress: !!n.data.showProgress,
797
  decision: n.data.decision || 'bottom',
798
  assignees: n.data.assignees || [],
799
+ color: n.data.color
800
  })
801
  : n.type === 'comment'
802
  ? JSON.stringify({
 
1121
  nodeData.assignees = [];
1122
  } else if (type === 'sketch') {
1123
  nodeData.decision = 'bottom';
1124
+ nodeData.color = undefined;
1125
  nodeData.assignees = [];
1126
  } else {
1127
  nodeData.decision = 'bottom';
src/pages/CanvasPage.jsx CHANGED
@@ -477,6 +477,7 @@ const getAssigneeInitials = (displayName, email) => {
477
  // Premium digital sketchbook style settings modal for goal (sketch) and comment nodes
478
  const SketchSettingsModal = ({ node, onClose, onSave, collaborators = [] }) => {
479
  const { t } = useTranslation();
 
480
  const [label, setLabel] = useState(() =>
481
  isDefaultLabel(node.data.label) ? '' : node.data.label
482
  );
@@ -485,9 +486,10 @@ const SketchSettingsModal = ({ node, onClose, onSave, collaborators = [] }) => {
485
  const [progress, setProgress] = useState(node.data.progress || 0);
486
  const [assignees, setAssignees] = useState(node.data.assignees || []);
487
  const [isAssigneesExpanded, setIsAssigneesExpanded] = useState(false);
488
- const [color, setColor] = useState(node.data.color || 'yellow');
489
 
490
  const PASTEL_COLORS = {
 
491
  yellow: { light: '#fef9c3', dark: '#2e2b14', borderLight: '#eab308', borderDark: '#ca8a04' },
492
  blue: { light: '#dbeafe', dark: '#111827', borderLight: '#3b82f6', borderDark: '#2563eb' },
493
  green: { light: '#dcfce7', dark: '#062f17', borderLight: '#22c55e', borderDark: '#16a34a' },
@@ -582,14 +584,14 @@ const SketchSettingsModal = ({ node, onClose, onSave, collaborators = [] }) => {
582
  onClick={() => setColor(cKey)}
583
  className="w-8 h-8 rounded-full border-2 transition-all cursor-pointer relative shadow-[1px_1px_0px_0px_rgba(0,0,0,0.15)] hover:scale-110 flex items-center justify-center"
584
  style={{
585
- backgroundColor: colors.light,
586
- borderColor: isSelected ? colors.borderLight : 'var(--color-primary)',
587
  borderWidth: isSelected ? '3px' : '2px'
588
  }}
589
- title={cKey}
590
  >
591
  {isSelected && (
592
- <Check size={14} className="text-black stroke-[3px]" />
593
  )}
594
  </button>
595
  );
 
477
  // Premium digital sketchbook style settings modal for goal (sketch) and comment nodes
478
  const SketchSettingsModal = ({ node, onClose, onSave, collaborators = [] }) => {
479
  const { t } = useTranslation();
480
+ const { isDarkMode } = useTheme();
481
  const [label, setLabel] = useState(() =>
482
  isDefaultLabel(node.data.label) ? '' : node.data.label
483
  );
 
486
  const [progress, setProgress] = useState(node.data.progress || 0);
487
  const [assignees, setAssignees] = useState(node.data.assignees || []);
488
  const [isAssigneesExpanded, setIsAssigneesExpanded] = useState(false);
489
+ const [color, setColor] = useState(node.data.color || (node.type === 'comment' ? 'yellow' : 'default'));
490
 
491
  const PASTEL_COLORS = {
492
+ default: { light: '#ffffff', dark: '#1e293b', borderLight: '#cbd5e1', borderDark: '#475569', isDefault: true },
493
  yellow: { light: '#fef9c3', dark: '#2e2b14', borderLight: '#eab308', borderDark: '#ca8a04' },
494
  blue: { light: '#dbeafe', dark: '#111827', borderLight: '#3b82f6', borderDark: '#2563eb' },
495
  green: { light: '#dcfce7', dark: '#062f17', borderLight: '#22c55e', borderDark: '#16a34a' },
 
584
  onClick={() => setColor(cKey)}
585
  className="w-8 h-8 rounded-full border-2 transition-all cursor-pointer relative shadow-[1px_1px_0px_0px_rgba(0,0,0,0.15)] hover:scale-110 flex items-center justify-center"
586
  style={{
587
+ backgroundColor: colors.isDefault ? (isDarkMode ? '#1e293b' : '#ffffff') : colors.light,
588
+ borderColor: isSelected ? (colors.isDefault ? '#3b82f6' : colors.borderLight) : 'var(--color-primary)',
589
  borderWidth: isSelected ? '3px' : '2px'
590
  }}
591
+ title={cKey === 'default' ? t('canvas.color_default', 'Дефолт') : cKey}
592
  >
593
  {isSelected && (
594
+ <Check size={14} className={colors.isDefault && isDarkMode ? "text-white stroke-[3px]" : "text-black stroke-[3px]"} />
595
  )}
596
  </button>
597
  );