Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

1.3 KB
Raw Blame
import { twMerge } from "tailwind-merge";

export interface DiffContainerProps {
  variant?: "added" | "removed";
  children: React.ReactNode;
  containerRef?: React.RefObject<HTMLDivElement | null>;
  className?: string;
  isSingleLine?: boolean;
}

/**
 * Styled container with consistent backgrounds for diff views
 */
export const DiffContainer = ({
  variant,
  children,
  containerRef,
  className,
  isSingleLine = false
}: DiffContainerProps) => {
  if (isSingleLine) {
    return (
      <div
        className={twMerge(
          "relative thin-scrollbar overflow-x-auto rounded-md border border-border p-2",
          "bg-page/60",
          variant && variant === "added" && "border-success/45",
          variant && variant === "removed" && "border-danger/45",
          className
        )}
      >
        <div className="w-max min-w-full">{children}</div>
      </div>
    );
  }

  return (
    <div
      ref={containerRef}
      className={twMerge(
        "relative max-h-96 thin-scrollbar overflow-x-auto overflow-y-auto rounded-md border border-border p-2",
        "bg-page/60",
        variant && variant === "added" && "border-success/45",
        variant && variant === "removed" && "border-danger/45",
        className
      )}
    >
      <div className="w-max min-w-full">{children}</div>
    </div>
  );
};