All files / src/components/WorkflowBuilder/nodes HandNode.tsx

0% Statements 0/43
0% Branches 0/1
0% Functions 0/1
0% Lines 0/43

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77                                                                                                                                                         
/**
 * Hand Node Component
 *
 * Node for executing hand actions.
 */
 
import { memo } from 'react';
import { Handle, Position, NodeProps, Node } from '@xyflow/react';
import type { HandNodeData } from '../../../lib/workflow-builder/types';
 
type HandNodeType = Node<HandNodeData>;
 
export const HandNode = memo(({ data, selected }: NodeProps<HandNodeType>) => {
  const hasHand = Boolean(data.handId);
  const hasAction = Boolean(data.action);
 
  return (
    <div
      className={`
        px-4 py-3 rounded-lg border-2 min-w-[180px]
        bg-rose-50 border-rose-300
        ${selected ? 'border-rose-500 shadow-lg shadow-rose-200' : ''}
      `}
    >
      {/* Input Handle */}
      <Handle
        type="target"
        position={Position.Left}
        className="w-3 h-3 bg-rose-400 border-2 border-white"
      />
 
      {/* Output Handle */}
      <Handle
        type="source"
        position={Position.Right}
        className="w-3 h-3 bg-rose-500 border-2 border-white"
      />
 
      {/* Header */}
      <div className="flex items-center gap-2 mb-2">
        <span className="text-lg">✋</span>
        <span className="font-medium text-rose-800">{data.label}</span>
      </div>
 
      {/* Hand Info */}
      <div className="space-y-1">
        <div className={`text-sm ${hasHand ? 'text-rose-600' : 'text-rose-400 italic'}`}>
          {hasHand ? (
            <span className="font-mono bg-rose-100 px-1.5 py-0.5 rounded">
              {data.handName || data.handId}
            </span>
          ) : (
            'No hand selected'
          )}
        </div>
 
        {hasAction && (
          <div className="text-xs text-rose-500">
            Action: <span className="font-mono">{data.action}</span>
          </div>
        )}
      </div>
 
      {/* Params Count */}
      {Object.keys(data.params).length > 0 && (
        <div className="text-xs text-rose-500 mt-1">
          {Object.keys(data.params).length} param(s)
        </div>
      )}
    </div>
  );
});
 
HandNode.displayName = 'HandNode';
 
export default HandNode;