-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmux-node-base.tsx
55 lines (50 loc) · 1.37 KB
/
mux-node-base.tsx
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
import { Handle, Position } from '@xyflow/react'
import * as config from '../constants/mux-node-config'
import { twMerge } from 'tailwind-merge'
import { tv } from 'tailwind-variants'
import { CSSProperties, ReactNode } from 'react'
const nodeStyles = tv({
base: 'w-full overflow-hidden rounded border border-gray-200 bg-base shadow-sm',
})
export const MuxNodeBase = ({
hasSourceRight,
hasTargetLeft,
children,
className,
icon: Icon,
style,
}: {
icon: (props: React.SVGProps<SVGSVGElement>) => React.JSX.Element
className?: string
children: ReactNode
hasTargetLeft?: boolean
hasSourceRight?: boolean
style?: CSSProperties
}) => {
return (
<>
{hasTargetLeft ? <Handle type="target" position={Position.Left} /> : null}
<div
style={{
height: config.HEIGHT_NODE,
...style,
}}
className={twMerge(nodeStyles(), 'flex items-center')}
>
<div
className="flex shrink-0 items-center justify-center bg-gray-50"
style={{
height: config.HEIGHT_NODE,
width: config.HEIGHT_NODE,
}}
>
<Icon className="size-5" />
</div>
<div className={twMerge('w-full px-4 py-3', className)}>{children}</div>
</div>
{hasSourceRight ? (
<Handle type="source" position={Position.Right} />
) : null}
</>
)
}