danylokhodus commited on
Commit
433b3b5
·
1 Parent(s): 208a8d6

feat: redesign visual branches connections in TaskListView to match custom tree layout

Browse files
Files changed (1) hide show
  1. src/pages/CanvasPage.jsx +34 -28
src/pages/CanvasPage.jsx CHANGED
@@ -1822,7 +1822,7 @@ const TaskListView = ({
1822
  </div>
1823
 
1824
  {hasSubtasks && isExpanded && (
1825
- <div className="pl-4 ml-2 space-y-6 pt-2 pb-2">
1826
  {(() => {
1827
  const directSubgoals = subgoalEdges
1828
  .filter(e => e.source === node.id)
@@ -1835,38 +1835,44 @@ const TaskListView = ({
1835
  if (branchNodes.length === 0) return null;
1836
 
1837
  const isBranchCollapsed = collapsedBranches.has(subgoal.id);
 
 
1838
 
1839
  return (
1840
- <div key={subgoal.id} className="space-y-4">
1841
- {/* Branch divider */}
1842
- <div className="flex items-center gap-2 py-1 select-none">
1843
- <div className="flex-1 h-0.5 border-t-2 border-dashed border-primary/20" />
1844
- <button
1845
- onClick={() => {
1846
- const newSet = new Set(collapsedBranches);
1847
- if (newSet.has(subgoal.id)) {
1848
- newSet.delete(subgoal.id);
1849
- } else {
1850
- newSet.add(subgoal.id);
1851
- }
1852
- setCollapsedBranches(newSet);
1853
- }}
1854
- className="px-4 py-1 border-2 border-primary rounded-full bg-surface-container-lowest text-primary text-[10px] font-extrabold flex items-center gap-2 shadow-[2px_2px_0px_0px_var(--color-primary)] active:translate-y-0.5 active:shadow-[1px_1px_0px_0px_var(--color-primary)] cursor-pointer hover:bg-secondary/10"
1855
- >
1856
- <span className="font-mono text-xs font-extrabold tracking-tighter">
1857
- {isBranchCollapsed ? '----(+)' : '----(-)'}
1858
- </span>
1859
- </button>
1860
- <div className="flex-1 h-0.5 border-t-2 border-dashed border-primary/20" />
1861
- </div>
1862
 
1863
  {/* Branch contents */}
1864
  {!isBranchCollapsed && (
1865
- <div className="pl-6 border-l-2 border-dashed border-primary/20 ml-4 space-y-4">
1866
- {branchNodes.map((bNode) => {
1867
- const isHead = bNode.id === subgoal.id;
1868
- return renderTaskCard(bNode, depth + 1, isHead, !isHead);
1869
- })}
 
 
 
 
 
1870
  </div>
1871
  )}
1872
  </div>
 
1822
  </div>
1823
 
1824
  {hasSubtasks && isExpanded && (
1825
+ <div className="relative ml-8 pl-6 border-l-2 border-dashed border-yellow-500/50 dark:border-yellow-500/30 space-y-6 pt-2 pb-2">
1826
  {(() => {
1827
  const directSubgoals = subgoalEdges
1828
  .filter(e => e.source === node.id)
 
1835
  if (branchNodes.length === 0) return null;
1836
 
1837
  const isBranchCollapsed = collapsedBranches.has(subgoal.id);
1838
+ const headNode = branchNodes[0];
1839
+ const continuationNodes = branchNodes.slice(1);
1840
 
1841
  return (
1842
+ <div key={subgoal.id} className="relative space-y-4">
1843
+ {/* Collapse button centered on the yellow dashed line */}
1844
+ <button
1845
+ onClick={() => {
1846
+ const newSet = new Set(collapsedBranches);
1847
+ if (newSet.has(subgoal.id)) {
1848
+ newSet.delete(subgoal.id);
1849
+ } else {
1850
+ newSet.add(subgoal.id);
1851
+ }
1852
+ setCollapsedBranches(newSet);
1853
+ }}
1854
+ className={`absolute -left-[36px] top-3.5 w-6 h-6 rounded-full border-2 border-primary flex items-center justify-center cursor-pointer shadow-[2px_2px_0px_0px_var(--color-primary)] hover:scale-105 active:translate-y-0.5 transition-all font-mono text-sm font-extrabold z-10 ${
1855
+ isBranchCollapsed
1856
+ ? 'bg-amber-400 text-black border-primary'
1857
+ : 'bg-surface-container-lowest text-primary border-primary'
1858
+ }`}
1859
+ title={isBranchCollapsed ? 'Розгорнути гілку' : 'Згорнути гілку'}
1860
+ >
1861
+ {isBranchCollapsed ? '+' : '−'}
1862
+ </button>
 
1863
 
1864
  {/* Branch contents */}
1865
  {!isBranchCollapsed && (
1866
+ <div className="space-y-4">
1867
+ {/* Branch Head (Yellow dashed left border) */}
1868
+ {renderTaskCard(headNode, depth + 1, true, false)}
1869
+
1870
+ {/* Continuations (Green solid vertical connecting line) */}
1871
+ {continuationNodes.length > 0 && (
1872
+ <div className="pl-6 border-l-2 border-solid border-emerald-500 dark:border-emerald-600/60 ml-8 space-y-4 pt-1 pb-1">
1873
+ {continuationNodes.map((cNode) => renderTaskCard(cNode, depth + 1, false, true))}
1874
+ </div>
1875
+ )}
1876
  </div>
1877
  )}
1878
  </div>