rowboat/apps/rowboat/app/projects/[projectId]/workflow/pane.tsx

82 lines
2.5 KiB
TypeScript
Raw Normal View History

2025-01-18 14:20:40 +05:30
import clsx from "clsx";
import { InfoIcon } from "lucide-react";
import { Tooltip } from "@nextui-org/react";
2025-01-18 14:20:40 +05:30
2025-01-13 15:31:31 +05:30
export function Pane({
title,
2025-01-18 14:20:40 +05:30
actions = null,
2025-01-13 15:31:31 +05:30
children,
fancy = false,
tooltip = null,
2025-01-13 15:31:31 +05:30
}: {
title: React.ReactNode;
2025-01-18 14:20:40 +05:30
actions?: React.ReactNode[] | null;
2025-01-13 15:31:31 +05:30
children: React.ReactNode;
fancy?: boolean;
tooltip?: string | null;
2025-01-13 15:31:31 +05:30
}) {
2025-01-18 14:20:40 +05:30
return <div className={clsx("h-full flex flex-col overflow-auto rounded-md p-1", {
"bg-gray-100": !fancy,
"bg-blue-100": fancy,
})}>
<div className="shrink-0 flex justify-between items-center gap-2 px-2 py-1 rounded-t-sm">
<div className="flex items-center gap-1">
<div className={clsx("text-xs font-semibold uppercase", {
"text-gray-400": !fancy,
"text-blue-500": fancy,
})}>
{title}
</div>
{tooltip && (
<Tooltip
content={tooltip}
placement="right"
className="cursor-help"
>
<InfoIcon size={12} className={clsx({
"text-gray-400": !fancy,
"text-blue-500": fancy,
})} />
</Tooltip>
)}
2025-01-13 15:31:31 +05:30
</div>
2025-01-18 14:20:40 +05:30
{!actions && <div className="w-4 h-4" />}
2025-01-23 11:39:27 +05:30
{actions && <div className={clsx("rounded-md hover:text-gray-800 px-2 text-sm flex items-center gap-2", {
2025-01-18 14:20:40 +05:30
"text-blue-600": fancy,
"text-gray-400": !fancy,
})}>
2025-01-13 15:31:31 +05:30
{actions}
2025-01-18 14:20:40 +05:30
</div>}
2025-01-13 15:31:31 +05:30
</div>
2025-01-18 14:20:40 +05:30
<div className="grow bg-white rounded-md overflow-auto flex flex-col justify-start p-2">
2025-01-13 15:31:31 +05:30
{children}
</div>
</div>;
}
export function ActionButton({
icon = null,
children,
2025-01-20 12:35:17 +05:30
onClick = undefined,
2025-01-13 15:31:31 +05:30
disabled = false,
primary = false,
}: {
icon?: React.ReactNode;
children: React.ReactNode;
2025-01-20 12:35:17 +05:30
onClick?: () => void | undefined;
2025-01-13 15:31:31 +05:30
disabled?: boolean;
primary?: boolean;
}) {
2025-01-20 12:35:17 +05:30
const onClickProp = onClick ? { onClick } : {};
2025-01-13 15:31:31 +05:30
return <button
disabled={disabled}
2025-01-18 14:20:40 +05:30
className={clsx("rounded-md text-xs flex items-center gap-1 disabled:text-gray-300 hover:text-gray-600", {
"text-blue-600": primary,
"text-gray-400": !primary,
})}
2025-01-20 12:35:17 +05:30
{...onClickProp}
2025-01-13 15:31:31 +05:30
>
{icon}
{children}
</button>;
}