Spaces:
Running
Running
Commit ·
2c04f4b
1
Parent(s): e55a0d1
fix: replace crooked arrow with pixel-perfect SVG and unify collapse/expand state inside standard chevron card buttons
Browse files1570 unmodified lines1571157215731574157515761577157837 unmodified lines1616161716181619162016211622205 unmodified lines18281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821570 unmodified linesconst renderTaskCard = (node, depth = 0, isSubgoalHead = false, isContinuation = false) => {const subtasks = getSubtasks(node.id).filter(nodeOrDescendantMatches);const isExpanded = expandedNodes.has(node.id);const hasSubtasks = subtasks.length > 0;const isDone = node.data?.status === 'Done';const status = node.data?.status || 'Todo';37 unmodified lines{hasSubtasks ? (<buttononClick={() => toggleExpanded(node.id)}className="mt-1 flex-shrink-0 p-0.5 border-2 border-primary rounded-md bg-surface-container-lowest hover:bg-secondary/10 text-primary transition-all cursor-pointer shadow-[1px_1px_0px_0px_var(--color-primary)]">{isExpanded ? <ChevronUp size={12} strokeWidth={3} /> : <ChevronDown size={12} strokeWidth={3} />}205 unmodified linesconst branchNodes = getBranchNodes(subgoal.id).filter(nodeOrDescendantMatches);if (branchNodes.length === 0) return null;const isBranchCollapsed = collapsedBranches.has(subgoal.id);const headNode = branchNodes[0];const continuationNodes = branchNodes.slice(1);return (<div key={subgoal.id} className="relative space-y-4">{/* Collapse button centered on the yellow dashed line */}<buttononClick={() => {const newSet = new Set(collapsedBranches);if (newSet.has(subgoal.id)) {newSet.delete(subgoal.id);} else {newSet.add(subgoal.id);}setCollapsedBranches(newSet);}}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 ${isBranchCollapsed? 'bg-amber-400 text-black border-primary': 'bg-surface-container-lowest text-primary border-primary'}`}title={isBranchCollapsed ? 'Розгорнути гілку' : 'Згорнути гілку'}>{isBranchCollapsed ? '+' : '−'}</button>{/* Branch contents */}{!isBranchCollapsed && (<div className="space-y-4">{/* Branch Head (Yellow dashed left border) */}{renderTaskCard(headNode, depth + 1, true, false)}{/* Continuations (Green dashed vertical connecting line in the center) */}{continuationNodes.length > 0 && (<div className="flex flex-col gap-0">{continuationNodes.map((cNode) => (<React.Fragment key={cNode.id}>{/* Center vertical dashed green line with down arrow */}<div className="flex justify-center h-8 my-1 z-10"><div className="h-8 w-0 border-l-2 border-dashed border-emerald-500 dark:border-emerald-600/70 flex items-center justify-center relative"><div className="absolute bottom-0 left-1/2 -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-[6px] border-l-transparent border-r-transparent border-t-emerald-500 dark:border-t-emerald-600/70" /></div></div>{renderTaskCard(cNode, depth + 1, false, true)}</React.Fragment>))}</div>)}</div>)}</div>1570 unmodified lines15711572157315741575157615771578157915801581158237 unmodified lines1620162116221623162416251626162716281629163016311632163316341635163616371638205 unmodified lines1844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731570 unmodified linesconst renderTaskCard = (node, depth = 0, isSubgoalHead = false, isContinuation = false) => {const subtasks = getSubtasks(node.id).filter(nodeOrDescendantMatches);const hasContinuations = normalEdges.some(e => e.source === node.id);const hasSubtasks = subtasks.length > 0 || (isSubgoalHead && hasContinuations);const isExpanded = isSubgoalHead? !collapsedBranches.has(node.id): expandedNodes.has(node.id);const isDone = node.data?.status === 'Done';const status = node.data?.status || 'Todo';37 unmodified lines{hasSubtasks ? (<buttononClick={() => {if (isSubgoalHead) {const newSet = new Set(collapsedBranches);if (newSet.has(node.id)) {newSet.delete(node.id);} else {newSet.add(node.id);}setCollapsedBranches(newSet);} else {toggleExpanded(node.id);}}}className="mt-1 flex-shrink-0 p-0.5 border-2 border-primary rounded-md bg-surface-container-lowest hover:bg-secondary/10 text-primary transition-all cursor-pointer shadow-[1px_1px_0px_0px_var(--color-primary)]">{isExpanded ? <ChevronUp size={12} strokeWidth={3} /> : <ChevronDown size={12} strokeWidth={3} />}205 unmodified linesconst branchNodes = getBranchNodes(subgoal.id).filter(nodeOrDescendantMatches);if (branchNodes.length === 0) return null;const isBranchExpanded = !collapsedBranches.has(subgoal.id);const headNode = branchNodes[0];const continuationNodes = branchNodes.slice(1);return (<div key={subgoal.id} className="relative space-y-4">{/* Branch Head */}{renderTaskCard(headNode, depth + 1, true, false)}{/* Continuations (Green dashed vertical connecting line in the center) */}{isBranchExpanded && continuationNodes.length > 0 && (<div className="flex flex-col gap-0">{continuationNodes.map((cNode) => (<React.Fragment key={cNode.id}>{/* Center vertical dashed green line with down arrow */}<div className="flex justify-center h-8 my-1 z-10"><svg width="16" height="32" viewBox="0 0 16 32" fill="none" className="text-emerald-500 dark:text-emerald-600/70"><line x1="8" y1="0" x2="8" y2="24" stroke="currentColor" strokeWidth="2.5" strokeDasharray="5 4" /><path d="M3.5 22 L8 29 L12.5 22 Z" fill="currentColor" /></svg></div>{renderTaskCard(cNode, depth + 1, false, true)}</React.Fragment>))}</div>)}</div>
src/pages/CanvasPage.jsx+37-46