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.

better file structure

Sara Vieirab2a705fbab71
diff --git a/app/auth/index.ts b/app/auth/index.ts
new file mode 100644
index 0000000000..f54d11bdd2
--- /dev/null
+++ b/app/auth/index.ts
@@ -0,0 +1 @@
+export * from "./login";
diff --git a/app/auth/login.css b/app/auth/login.css
new file mode 100644
index 0000000000..778f302cf4
--- /dev/null
+++ b/app/auth/login.css
@@ -0,0 +1,6 @@
+body {
+ margin: 0;
+ overflow: hidden;
+ font-family: var(--fonts-sans);
+ font-size: var(--fontSizes-1);
+}
diff --git a/app/auth/login.tsx b/app/auth/login.tsx
new file mode 100644
index 0000000000..4fad78e83b
--- /dev/null
+++ b/app/auth/login.tsx
@@ -0,0 +1,60 @@
+import { LinksFunction, MetaFunction } from "@remix-run/node";
+import { Form } from "@remix-run/react";
+import { Button, Card, Flex, Heading } from "~/shared/design-system";
+import interStyles from "~/shared/font-faces/inter.css";
+
+import { GoogleIcon, GithubIcon } from "~/shared/icons";
+import loginStyles from "./login.css";
+
+export const links: LinksFunction = () => {
+ return [
+ {
+ rel: "stylesheet",
+ href: interStyles,
+ },
+ {
+ rel: "stylesheet",
+ href: loginStyles,
+ },
+ ];
+};
+
+export const meta: MetaFunction = () => {
+ return { title: "Webstudio Login" };
+};
+
+export const Login = () => {
+ return (
+ <Flex
+ css={{ height: "100vh" }}
+ direction="column"
+ align="center"
+ justify="center"
+ >
+ <Card css={{ width: "$10", padding: "$5", zoom: 1.4 }} variant="active">
+ <Flex direction="column" gap="2" align="center">
+ <Heading>Login</Heading>
+
+ <Flex gap="2" direction="column" align="center">
+ <Form action="/auth/github" method="post">
+ <Button type="submit">
+ <Flex gap="1">
+ <GithubIcon width="16" />
+ Login with GitHub
+ </Flex>
+ </Button>
+ </Form>
+ <Form action="/auth/google" method="post">
+ <Button type="submit">
+ <Flex gap="1">
+ <GoogleIcon width="16" color="white" />
+ Login with Google
+ </Flex>
+ </Button>
+ </Form>
+ </Flex>
+ </Flex>
+ </Card>
+ </Flex>
+ );
+};
diff --git a/app/routes/dashboard/index.tsx b/app/routes/dashboard/index.tsx
index 9345c2f584..3f2939b601 100644
--- a/app/routes/dashboard/index.tsx
+++ b/app/routes/dashboard/index.tsx
@@ -31,7 +31,6 @@ export const action: ActionFunction = async ({ request }) => {
export const loader: LoaderFunction = async ({ request }) => {
const user = await authenticator.isAuthenticated(request);
- console.log(user)
if (!user) {
return redirect(config.loginPath);
}
diff --git a/app/routes/login.tsx b/app/routes/login.tsx
deleted file mode 100644
index f1efd71239..0000000000
--- a/app/routes/login.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-import { Links, LiveReload, Meta, Scripts } from "@remix-run/react";
-import {
- LinksFunction,
- LoaderFunction,
- MetaFunction,
- redirect,
-} from "@remix-run/node";
-import { CriticalCss } from "@webstudio-is/sdk";
-import { darkTheme } from "~/shared/design-system";
-import { Form } from "@remix-run/react";
-import { Button, Card, Flex, Heading } from "~/shared/design-system";
-import interStyles from "~/shared/font-faces/inter.css";
-
-import { GoogleIcon, GithubIcon } from "~/shared/icons";
-import { authenticator } from "~/services/auth.server";
-import config from "~/config";
-
-export const links: LinksFunction = () => {
- return [
- {
- rel: "stylesheet",
- href: interStyles,
- },
- ];
-};
-
-export const meta: MetaFunction = () => {
- return { title: "Webstudio Login" };
-};
-
-const RootDesignerRoute = () => {
- return (
- <html lang="en">
- <head>
- <meta charSet="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <Meta />
- <Links />
- <CriticalCss />
- </head>
- <body className={darkTheme}>
- <Flex
- css={{ height: "100vh" }}
- direction="column"
- align="center"
- justify="center"
- >
- <Card
- css={{ width: "$10", padding: "$5", zoom: 1.4 }}
- variant="active"
- >
- <Flex direction="column" gap="2" align="center">
- <Heading>Login</Heading>
-
- <Flex gap="2" direction="column" align="center">
- <Form action="/auth/github" method="post">
- <Button type="submit">
- <Flex gap="1">
- <GithubIcon width="16" />
- Login with GitHub
- </Flex>
- </Button>
- </Form>
- <Form action="/auth/google" method="post">
- <Button type="submit">
- <Flex gap="1">
- <GoogleIcon width="16" color="white" />
- Login with Google
- </Flex>
- </Button>
- </Form>
- </Flex>
- </Flex>
- </Card>
- </Flex>
- <Scripts />
- {process.env.NODE_ENV === "development" && <LiveReload />}
- </body>
- </html>
- );
-};
-
-export const loader: LoaderFunction = async ({ request }) => {
- const user = await authenticator.isAuthenticated(request);
- if (user) {
- return redirect(config.dashboardPath);
- }
-
- return {};
-};
-
-export default RootDesignerRoute;
diff --git a/app/routes/login/index.tsx b/app/routes/login/index.tsx
new file mode 100644
index 0000000000..0cc4b3f484
--- /dev/null
+++ b/app/routes/login/index.tsx
@@ -0,0 +1,45 @@
+import { Links, LiveReload, Meta, Scripts } from "@remix-run/react";
+import { LoaderFunction, MetaFunction, redirect } from "@remix-run/node";
+import { CriticalCss } from "@webstudio-is/sdk";
+import { darkTheme } from "~/shared/design-system";
+
+import { authenticator } from "~/services/auth.server";
+import config from "~/config";
+
+import { Login, links } from "~/auth/";
+
+export { links };
+
+export const meta: MetaFunction = () => {
+ return { title: "Webstudio Login" };
+};
+
+const LoginRoute = () => {
+ return (
+ <html lang="en">
+ <head>
+ <meta charSet="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <Meta />
+ <Links />
+ <CriticalCss />
+ </head>
+ <body className={darkTheme}>
+ <Login />
+ <Scripts />
+ {process.env.NODE_ENV === "development" && <LiveReload />}
+ </body>
+ </html>
+ );
+};
+
+export const loader: LoaderFunction = async ({ request }) => {
+ const user = await authenticator.isAuthenticated(request);
+ if (user) {
+ return redirect(config.dashboardPath);
+ }
+
+ return {};
+};
+
+export default LoginRoute;
diff --git a/app/routes/logout.tsx b/app/routes/logout.tsx
index 6799dd897a..a761b0f04b 100644
--- a/app/routes/logout.tsx
+++ b/app/routes/logout.tsx
@@ -2,7 +2,7 @@ import { ActionFunction } from "@remix-run/node";
import { authenticator } from "~/services/auth.server";
export default function Login() {
- return "loging you out";
+ return "";
}
export const loader: ActionFunction = async ({ request }) => {