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.

Merge branch 'main' of github.com:webstudio-is/webstudio-designer into no-gh-preview

Sara Vieira8aa1d3a427c2
diff --cc app/auth/components/login-button.tsx
index 34776c4220,0000000000..bc4234cc38
mode 100644,000000..100644
--- a/app/auth/components/login-button.tsx
+++ b/app/auth/components/login-button.tsx
@@@ -1,33 -1,0 +1,45 @@@
+import React from "react";
+import { Button, Tooltip } from "~/shared/design-system";
+import env from "~/shared/env";
+
+const isPreviewEnvironment = env.VERCEL_ENV === "preview";
+
+export const LoginButton = ({
+ children,
+ isDevLogin = false,
++ enabled,
+ ...props
+}: {
+ children: React.ReactChild;
+ isDevLogin?: boolean;
+ onClick?: () => void;
++ enabled: boolean;
+}) => {
- if (isPreviewEnvironment && !isDevLogin) {
- <Tooltip
- content="Social login does not work in preview deployments"
- delayDuration={0}
- >
- <span tabIndex={0}>
- <Button {...props} css={{ width: "100%" }} type="submit" disabled>
- {children}
- </Button>
- </span>
- </Tooltip>;
++ const showTooltip = isPreviewEnvironment && isDevLogin === false && enabled;
++ if (showTooltip) {
++ const content = isPreviewEnvironment
++ ? "Social login does not work in preview deployments"
++ : "This login is not configured";
++
++ return (
++ <Tooltip content={content} delayDuration={0}>
++ <span tabIndex={0}>
++ <Button
++ {...props}
++ css={{ width: "100%" }}
++ size={3}
++ type="submit"
++ disabled
++ >
++ {children}
++ </Button>
++ </span>
++ </Tooltip>
++ );
+ }
+ return (
- <Button {...props} css={{ width: "100%" }} type="submit">
++ <Button {...props} css={{ width: "100%" }} size={3} type="submit">
+ {children}
+ </Button>
+ );
+};
diff --cc app/auth/login.tsx
index 9756c09816,d37bde959a..0e0935d525
--- a/app/auth/login.tsx
+++ b/app/auth/login.tsx
@@@ -1,12 -1,17 +1,12 @@@
import { LinksFunction, MetaFunction } from "@remix-run/node";
import { Form, useLoaderData } from "@remix-run/react";
import { useState } from "react";
-import {
- Button,
- Card,
- Flex,
- Heading,
- Text,
- TextField,
-} from "~/shared/design-system";
+
+import { Card, Flex, Heading, Text, TextField } from "~/shared/design-system";
import interStyles from "~/shared/font-faces/inter.css";
- import { GithubIcon, CommitIcon } from "~/shared/icons";
-import { GoogleIcon, GithubIcon, CommitIcon } from "~/shared/icons";
++import { GithubIcon, CommitIcon, GoogleIcon } from "~/shared/icons";
+import { LoginButton } from "./components/login-button";
import loginStyles from "./login.css";
export const links: LinksFunction = () => {
@@@ -27,8 -32,8 +27,8 @@@ export const meta: MetaFunction = () =
};
export const Login = ({ errorMessage }: { errorMessage: string }) => {
-- const [isDevLogin, setIsDevLogin] = useState(false);
- const loaderData = useLoaderData();
++ const [isDevLoginOpen, openDevLogin] = useState(false);
+ const data = useLoaderData();
return (
<Flex
@@@ -37,9 -42,9 +37,9 @@@
align="center"
justify="center"
>
- <Card css={{ width: 200, padding: "$5" }} variant="active">
- <Card size={2}>
- <Flex direction="column" gap="4" align="center">
++ <Card size={2} variant="active">
+ <Flex direction="column" gap="2" align="center">
- <Heading>Login</Heading>
+ <Heading size="2">Login</Heading>
{errorMessage.length ? (
<Text css={{ textAlign: "center" }} variant="red">
{errorMessage}
@@@ -47,26 -52,35 +47,27 @@@
) : null}
<Flex gap="2" direction="column" align="center">
<Form action="/auth/github" method="post">
- <LoginButton>
- <Button
- size={3}
- type="submit"
- disabled={data.isGithubEnabled === false}
- >
++ <LoginButton enabled={data.isGithubEnabled}>
<Flex gap="1">
- <GithubIcon width="16" />
+ <GithubIcon width="20" />
Login with GitHub
</Flex>
- </Button>
+ </LoginButton>
</Form>
- {/* <Form action="/auth/google" method="post">
- <LoginButton>
+ <Form action="/auth/google" method="post">
- <Button
- size={3}
- type="submit"
- disabled={data.isGoogleEnabled === false}
- >
++ <LoginButton enabled={data.isGoogleEnabled}>
<Flex gap="1">
- <GoogleIcon width="16" />
+ <GoogleIcon width="20" />
Login with Google
</Flex>
- </Button>
+ </LoginButton>
- </Form> */}
- {loaderData.devLogin && (
+ </Form>
+ {data.isDevLogin && (
<>
-- {isDevLogin ? (
++ {isDevLoginOpen ? (
<Form action="/auth/dev" method="post">
<TextField
+ size={2}
css={{ width: "100%", flexGrow: 1 }}
name="secret"
type="text"
@@@ -77,12 -91,16 +78,16 @@@
/>
</Form>
) : (
- <LoginButton isDevLogin onClick={() => setIsDevLogin(true)}>
- <Button
- onClick={() => setIsDevLogin(true)}
- size={3}
- css={{ width: "100%" }}
++ <LoginButton
++ enabled={data.isDevLogin}
++ isDevLogin
++ onClick={() => openDevLogin(true)}
+ >
<Flex gap="1" align="center">
- <CommitIcon></CommitIcon>
+ <CommitIcon width="20" />
Dev Login
</Flex>
- </Button>
+ </LoginButton>
)}
</>
)}