mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-10 08:05:22 +02:00
49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
import { forwardRef, HTMLAttributes } from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
export const BaseNode = forwardRef<
|
|
HTMLDivElement,
|
|
HTMLAttributes<HTMLDivElement> & {
|
|
selected?: boolean;
|
|
invalid?: boolean;
|
|
selected_through_edge?: boolean;
|
|
hovered_through_edge?: boolean;
|
|
runtimeActive?: boolean;
|
|
runtimePulseNonce?: number;
|
|
}
|
|
>(({ children, className, selected, invalid, selected_through_edge, hovered_through_edge, runtimeActive, runtimePulseNonce, ...props }, ref) => (
|
|
<div
|
|
ref={ref}
|
|
className={cn(
|
|
// Base styling - larger with max width, uses semantic colors
|
|
"relative rounded-lg border bg-card text-card-foreground min-w-[320px] max-w-[400px] min-h-[120px]",
|
|
// Border styling
|
|
"border-border",
|
|
className,
|
|
// Selected state - prominent halo effect
|
|
selected ? "border-primary ring-2 ring-primary/40 shadow-[0_0_20px_rgba(59,130,246,0.5)]" : "",
|
|
// Invalid state
|
|
invalid ? "border-destructive shadow-[0_0_10px_rgba(239,68,68,0.3)]" : "",
|
|
// Hovered through edge takes precedence over selected through edge
|
|
hovered_through_edge ? "ring-2 ring-primary/60 shadow-[0_0_12px_rgba(96,165,250,0.3)]" : "",
|
|
!hovered_through_edge && selected_through_edge ? "ring-1 ring-primary/50 shadow-[0_0_8px_rgba(59,130,246,0.2)]" : "",
|
|
runtimeActive ? "ring-2 ring-sky-400/60 shadow-[0_0_0_1px_rgba(56,189,248,0.18),0_0_24px_rgba(14,165,233,0.18)]" : "",
|
|
!selected_through_edge && !hovered_through_edge && "hover:border-muted-foreground/50",
|
|
)}
|
|
tabIndex={0}
|
|
{...props}
|
|
>
|
|
{runtimeActive ? (
|
|
<span
|
|
key={`runtime-pulse-${runtimePulseNonce ?? 0}`}
|
|
className="pointer-events-none absolute -inset-2 rounded-[18px] border-2 border-sky-400/55"
|
|
aria-hidden="true"
|
|
style={{ animation: "ping 900ms ease-out 2" }}
|
|
/>
|
|
) : null}
|
|
{children}
|
|
</div>
|
|
));
|
|
|
|
BaseNode.displayName = "BaseNode";
|