Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

2.7 KB
Raw Blame
import { TooltipProvider } from "@radix-ui/react-tooltip";
import {
  Button,
  Flex,
  Text,
  theme,
  cssVar,
  webstudioBrand,
} from "@webstudio-is/design-system";
import { GithubIcon, GoogleIcon, WebstudioIcon } from "@webstudio-is/icons";
import { Form } from "@remix-run/react";
import { authPath } from "~/shared/router-utils";
import { SecretLogin } from "./secret-login";

export type LoginProps = {
  errorMessage?: string;
  isGithubEnabled?: boolean;
  isGoogleEnabled?: boolean;
  isSecretLoginEnabled?: boolean;
  devPlanNames?: string[];
};

export const Login = ({
  errorMessage,
  isGithubEnabled,
  isGoogleEnabled,
  isSecretLoginEnabled,
  devPlanNames,
}: LoginProps) => {
  return (
    <Flex
      align="center"
      justify="center"
      css={{
        height: "100vh",
        color: cssVar("--foreground-primary"),
        background: webstudioBrand.backgroundGradient,
      }}
    >
      <Flex
        direction="column"
        align="center"
        gap="6"
        css={{
          width: theme.spacing[35],
          minWidth: theme.spacing[20],
          padding: theme.spacing[17],
          borderRadius: theme.spacing[5],
          backgroundColor: `oklch(from ${cssVar("--background-primary")} l c h / 50%)`,
        }}
      >
        <WebstudioIcon size={48} />
        <Text variant="brandSectionTitle" as="h1" align="center">
          Welcome to Webstudio
        </Text>

        <TooltipProvider>
          <Flex direction="column" gap="3" css={{ width: "100%" }}>
            <Form method="post" style={{ display: "contents" }}>
              <Button
                disabled={isGoogleEnabled === false}
                prefix={<GoogleIcon size={22} />}
                color="primary"
                css={{ height: theme.spacing[15] }}
                formAction={authPath({ provider: "google" })}
              >
                Sign in with Google
              </Button>
              <Button
                disabled={isGithubEnabled === false}
                prefix={<GithubIcon size={22} fill="currentColor" />}
                color="ghost"
                css={{
                  border: `1px solid ${cssVar("--border-default")}`,
                  height: theme.spacing[15],
                }}
                formAction={authPath({ provider: "github" })}
              >
                Sign in with GitHub
              </Button>
            </Form>
            {isSecretLoginEnabled && (
              <SecretLogin devPlanNames={devPlanNames} />
            )}
          </Flex>
        </TooltipProvider>
        {errorMessage ? (
          <Text align="center" color="destructive">
            {errorMessage}
          </Text>
        ) : null}
      </Flex>
    </Flex>
  );
};