diff --git a/apps/star-chart/web/src/components/project/TaskNode.tsx b/apps/star-chart/web/src/components/project/TaskNode.tsx index 73cd7485..6627ad27 100644 --- a/apps/star-chart/web/src/components/project/TaskNode.tsx +++ b/apps/star-chart/web/src/components/project/TaskNode.tsx @@ -1,30 +1,28 @@ +import { hooks } from '@/store.js'; +import { clsx } from '@a-type/ui'; +import { Checkbox } from '@a-type/ui/components/checkbox'; +import { Icon } from '@a-type/ui/components/icon'; +import { LiveUpdateTextField } from '@a-type/ui/components/liveUpdateTextField'; +import { Tooltip } from '@a-type/ui/components/tooltip'; import { Task } from '@star-chart.biscuits/verdant'; +import { useCallback, useEffect, useMemo } from 'react'; +import { useIsPendingSelection, useIsSelected } from '../canvas/canvasHooks.js'; import { CanvasObjectRoot, useCanvasObject } from '../canvas/CanvasObject.jsx'; -import { hooks } from '@/store.js'; -import { useCallback, useEffect, useMemo, useState } from 'react'; import { CanvasObjectDragHandle, disableDragProps, } from '../canvas/CanvasObjectDragHandle.jsx'; -import { TaskMenu } from './TaskMenu.jsx'; -import { Checkbox } from '@a-type/ui/components/checkbox'; +import { useCanvas } from '../canvas/CanvasProvider.jsx'; import { ConnectionSource } from './ConnectionSource.jsx'; -import { LiveUpdateTextField } from '@a-type/ui/components/liveUpdateTextField'; -import { CollapsibleSimple } from '@a-type/ui/components/collapsible'; import { useDownstreamCount, useUpstreamUncompletedCount } from './hooks.js'; -import { clsx } from '@a-type/ui'; -import { Icon } from '@a-type/ui/components/icon'; -import { Tooltip } from '@a-type/ui/components/tooltip'; -import { useIsPendingSelection, useIsSelected } from '../canvas/canvasHooks.js'; -import { useCanvas } from '../canvas/CanvasProvider.jsx'; +import { TaskMenu } from './TaskMenu.jsx'; export interface TaskNodeProps { task: Task; } export function TaskNode({ task }: TaskNodeProps) { - const { id, content, position, completedAt, projectId } = - hooks.useWatch(task); + const { id, position, completedAt } = hooks.useWatch(task); const initialPosition = useMemo(() => position.getSnapshot(), []); const canvasObject = useCanvasObject({ @@ -43,20 +41,6 @@ export function TaskNode({ task }: TaskNodeProps) { }); }, [position, canvasObject]); - const client = hooks.useClient(); - const createConnectionTo = useCallback( - (targetTaskId: string) => { - console.log('connecting', id, targetTaskId); - client.connections.put({ - id: `connection-${id}-${targetTaskId}`, - projectId, - sourceTaskId: id, - targetTaskId, - }); - }, - [client, id, projectId], - ); - const { selected, exclusive } = useIsSelected(id); const pendingSelect = useIsPendingSelection(id); @@ -68,72 +52,23 @@ export function TaskNode({ task }: TaskNodeProps) { const downstreams = useDownstreamCount(id); const upstreams = useUpstreamUncompletedCount(id); - const isPriority = upstreams === 0 && downstreams > 2; - return ( 0 && 'layer-variants:bg-wash', selected && 'layer-variants:border-primary', !selected && pendingSelect && 'layer-variants:border-primary-wash', )} canvasObject={canvasObject} > - -
- 0 ? 'opacity-50' : '')} - checked={!!completedAt} - onCheckedChange={(val) => { - if (val) task.set('completedAt', Date.now()); - else task.set('completedAt', null); - }} - {...disableDragProps} - /> - {exclusive ? ( - task.set('content', v)} - autoSelect - autoFocus - /> - ) : ( -
- {isPriority && ( - - 🔥 - - )} - {content} -
- )} - - {downstreams === 0 ? null : downstreams} - - - {upstreams > 0 && ( -
- - {upstreams} -
- )} -
+ + {exclusive && ( ); } + +function isPriority(upstreams: number, downstreams: number) { + return upstreams === 0 && downstreams > 2; +} + +function TaskFullContent({ + task, + upstreams, + downstreams, +}: { + task: Task; + upstreams: number; + downstreams: number; +}) { + const { completedAt, content, projectId, id } = hooks.useWatch(task); + const { exclusive } = useIsSelected(id); + + const client = hooks.useClient(); + const createConnectionTo = useCallback( + (targetTaskId: string) => { + console.log('connecting', id, targetTaskId); + client.connections.put({ + id: `connection-${id}-${targetTaskId}`, + projectId, + sourceTaskId: id, + targetTaskId, + }); + }, + [client, id, projectId], + ); + + return ( +
+ 0 ? 'opacity-50' : '')} + checked={!!completedAt} + onCheckedChange={(val) => { + if (val) task.set('completedAt', Date.now()); + else task.set('completedAt', null); + }} + {...disableDragProps} + /> + {exclusive ? ( + task.set('content', v)} + autoSelect + autoFocus + /> + ) : ( +
+ {isPriority(upstreams, downstreams) && ( + + 🔥 + + )} + {content} +
+ )} + + {downstreams === 0 ? null : downstreams} + + + {upstreams > 0 && ( +
+ + {upstreams} +
+ )} +
+ ); +}