Skip to content

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

4.0 KB
Raw Blame
import { ReactNode } from "react";
import { BookOpen } from "lucide-react";

import { Button } from "@app/components/v3";
import { cn } from "@app/components/v3/utils";

import { AuthPageBackground } from "./AuthPageBackground";
import { AuthPageFooter } from "./AuthPageFooter";
import { AuthPageHeader } from "./AuthPageHeader";

type Props = {
  anchorBottomContent?: boolean;
  /** Per-step overrides for the marketing panel copy; the headline stays fixed. */
  aside?: {
    eyebrow?: ReactNode;
    description?: ReactNode;
  };
  bottomContent?: ReactNode;
  children: ReactNode;
  contentClassName?: string;
  headerAction?: ReactNode;
  onDocumentationClick?: () => void;
  showFooter?: boolean;
  variant?: "focused" | "split";
};

export const AuthPageLayout = ({
  anchorBottomContent = false,
  aside,
  bottomContent,
  children,
  contentClassName,
  headerAction,
  onDocumentationClick,
  showFooter = true,
  variant = "split"
}: Props) => {
  const isSplit = variant === "split";

  return (
    <div
      className={cn(
        "min-h-screen bg-linear-to-r from-card to-page-deep to-75%",
        isSplit &&
          "lg:grid lg:grid-cols-[minmax(440px,44%)_minmax(0,1fr)] xl:grid-cols-[minmax(520px,40%)_minmax(0,1fr)]"
      )}
      data-variant={variant}
    >
      <section
        className={cn(
          "flex h-screen min-h-0 min-w-0 flex-col",
          anchorBottomContent ? "overflow-hidden" : "thin-scrollbar overflow-y-auto",
          isSplit && "lg:border-r lg:border-border"
        )}
      >
        <AuthPageHeader>{headerAction}</AuthPageHeader>
        <main
          className={cn(
            "flex flex-1 px-5 pt-10 pb-26 sm:px-8 lg:px-10 xl:px-14",
            anchorBottomContent
              ? "min-h-0 thin-scrollbar overflow-x-hidden overflow-y-auto"
              : "items-center justify-center"
          )}
        >
          <div className={cn("w-full max-w-md", anchorBottomContent && "m-auto", contentClassName)}>
            {children}
          </div>
        </main>
        {(bottomContent || showFooter) && (
          <div
            className={cn(
              "relative z-10 px-5 pb-6 text-center sm:px-8 lg:px-10 xl:px-14",
              anchorBottomContent && "shrink-0 border-t border-border pt-4"
            )}
          >
            {bottomContent}
            {showFooter && <AuthPageFooter />}
          </div>
        )}
      </section>

      {isSplit && (
        <aside className="relative hidden h-screen min-w-0 overflow-hidden lg:sticky lg:top-0 lg:flex lg:flex-col">
          <AuthPageBackground />
          <div className="relative z-10 flex h-16 items-center justify-end px-8 xl:px-12">
            <Button asChild variant="outline" size="sm">
              <a
                href="https://infisical.com/docs"
                target="_blank"
                rel="noopener noreferrer"
                onClick={onDocumentationClick}
              >
                <BookOpen />
                Documentation
              </a>
            </Button>
          </div>

          <div className="relative z-10 flex flex-1 items-center justify-center px-10 pb-16 xl:px-20">
            <div className="max-w-xl">
              <p className="mb-4 font-mono text-xs tracking-[0.02em] text-project uppercase">
                {aside?.eyebrow ?? "Trusted by 400,000+ developers"}
              </p>
              <h2 className="font-alliance text-3xl leading-tight font-normal text-foreground xl:text-4xl">
                <span className="block">
                  Security <span className="text-highlight">infrastructure</span>
                </span>
                <span className="block">for developers and agents</span>
              </h2>
              <p className="mt-4 max-w-lg font-sans text-sm leading-relaxed text-label xl:text-base">
                {aside?.description ??
                  "One place to audit every credential your apps and agents use."}
              </p>
            </div>
          </div>
        </aside>
      )}
    </div>
  );
};