forked from lightningpixel/modly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWaitNode.tsx
More file actions
63 lines (59 loc) · 2.13 KB
/
Copy pathWaitNode.tsx
File metadata and controls
63 lines (59 loc) · 2.13 KB
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
import { Handle, Position } from '@xyflow/react'
import type { WFNodeData } from '@shared/types/electron.d'
import { useWaitButton } from '../useWaitButton'
import BaseNode from './BaseNode'
const HANDLE_STYLE = { background: '#71717a', width: 14, height: 14, border: '2.5px solid #18181b' }
export default function WaitNode({ id, data, selected }: { id: string; data: WFNodeData; selected?: boolean }) {
const { waitState, canContinue, isRunning, label, buttonClass, statusText, onContinue } = useWaitButton(id)
const subheader = waitState ? (
<button
onClick={onContinue}
disabled={!canContinue}
className={`nodrag w-full flex items-center justify-center gap-1.5 px-2.5 py-2 border-y transition-colors text-[10px] font-medium ${buttonClass} ${
canContinue ? (waitState === 'pending' ? 'animate-pulse' : '') : 'opacity-40 cursor-not-allowed'
}`}
>
{isRunning ? (
<>
<svg width="9" height="9" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" className="animate-spin">
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
</svg>
Running…
</>
) : (
<>
<svg width="9" height="9" viewBox="0 0 24 24" fill="currentColor">
<polygon points="5 3 19 12 5 21 5 3"/>
</svg>
{label}
</>
)}
</button>
) : undefined
return (
<BaseNode
id={id}
selected={selected}
title="Wait"
minWidth={170}
showInGenerate={data.showInGenerate ?? false}
icon={
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="#71717a" strokeWidth="2">
<circle cx="12" cy="12" r="10"/>
<polyline points="12 6 12 12 16 14"/>
</svg>
}
subheader={subheader}
handles={
<>
<Handle type="target" position={Position.Left} style={HANDLE_STYLE} />
<Handle type="source" position={Position.Right} style={HANDLE_STYLE} />
</>
}
>
<div className="px-3 pb-3 pt-2.5">
<p className="text-[10px] text-zinc-500 italic">{statusText}</p>
</div>
</BaseNode>
)
}