Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

1.4 KB
Raw Blame
import type { ReactNode } from "react";
import styles from "@editor/auth/ui/AuthShell.module.css";

export interface AuthShellProps {
  children: ReactNode;
  /** Optional fixed footer slot (the editor passes its legal/cookie footer). */
  footer?: ReactNode;
  /** `medium` fits a setting's label beside its control; `wide` fits code
   *  samples or side-by-side rows. Default `narrow`. */
  size?: "narrow" | "medium" | "wide";
}

/**
 * The login card shell shared by the editor and the portal: a single narrow
 * card centered on the screen. Purely presentational - callers provide the
 * form (children) and an optional footer.
 */
const SIZE_CLASS: Record<NonNullable<AuthShellProps["size"]>, string> = {
  narrow: "",
  medium: styles.authCardMedium,
  wide: styles.authCardWide,
};

export function AuthShell({
  children,
  footer,
  size = "narrow",
}: AuthShellProps) {
  return (
    <div className={styles.authContainer}>
      <div
        className={[styles.authCard, SIZE_CLASS[size]]
          .filter(Boolean)
          .join(" ")}
      >
        <div className={styles.authContent}>{children}</div>
      </div>
      {footer && (
        <div
          style={{
            position: "fixed",
            bottom: 0,
            left: 0,
            right: 0,
            width: "100%",
            zIndex: 10,
          }}
        >
          {footer}
        </div>
      )}
    </div>
  );
}

export default AuthShell;