From a89c38117105978633d78bf98813a7db4145f2ac Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 15 Feb 2025 18:00:29 +0000 Subject: [PATCH] feat: responsive auth page --- apps/web/src/components/AuthForm.tsx | 43 ++++++++++---------- apps/web/src/components/Button.tsx | 5 ++- apps/web/src/components/Dashboard.tsx | 2 +- apps/web/src/components/Input.tsx | 2 +- apps/web/src/views/auth/login/index.tsx | 49 ++++++++++++++--------- apps/web/src/views/auth/signup/index.tsx | 51 ++++++++++++++---------- 6 files changed, 89 insertions(+), 63 deletions(-) diff --git a/apps/web/src/components/AuthForm.tsx b/apps/web/src/components/AuthForm.tsx index 16efc148..b1a6dfa2 100644 --- a/apps/web/src/components/AuthForm.tsx +++ b/apps/web/src/components/AuthForm.tsx @@ -3,7 +3,8 @@ import { useForm } from "react-hook-form"; import { FaGoogle } from "react-icons/fa"; import { z } from "zod"; -import LoadingSpinner from "~/components/LoadingSpinner"; +import Button from "~/components/Button"; +import Input from "~/components/Input"; import { api } from "~/utils/api"; interface FormValues { @@ -36,7 +37,7 @@ export function Auth({ setIsMagicLinkSent }: AuthProps) { const loginWithOAuth = api.auth.loginWithOAuth.useMutation({ onSuccess: (data) => { - if (data?.url) window.open(data.url); + if (data.url) window.open(data.url); }, }); @@ -53,21 +54,24 @@ export function Auth({ setIsMagicLinkSent }: AuthProps) { return (
- + Continue with Google +
-
- +
+ or +
+
+ {!loginWithEmail.error && !loginWithOAuth.error && errors.email && (

@@ -82,17 +86,14 @@ export function Auth({ setIsMagicLinkSent }: AuthProps) { ) : null}

- + Continue with email +
diff --git a/apps/web/src/components/Button.tsx b/apps/web/src/components/Button.tsx index 312ff266..228a8965 100644 --- a/apps/web/src/components/Button.tsx +++ b/apps/web/src/components/Button.tsx @@ -10,6 +10,7 @@ interface ButtonProps extends React.ButtonHTMLAttributes { iconLeft?: React.ReactNode; iconRight?: React.ReactNode; href?: string; + fullWidth?: boolean; openInNewTab?: boolean; } @@ -21,13 +22,15 @@ const Button = ({ isLoading, variant = "primary", href, + fullWidth, openInNewTab, ...props }: ButtonProps) => { const classes = twMerge( "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-2 text-sm font-semibold text-light-50 shadow-sm focus-visible:outline-none", size === "sm" && "text-xs", - size === "lg" && "px-4 py-3 text-lg", + size === "lg" && "py-[0.65rem]", + fullWidth && "w-full", variant === "primary" && "bg-light-1000 dark:bg-dark-1000 dark:text-dark-50", variant === "secondary" && diff --git a/apps/web/src/components/Dashboard.tsx b/apps/web/src/components/Dashboard.tsx index 8533c1f2..959a75b6 100644 --- a/apps/web/src/components/Dashboard.tsx +++ b/apps/web/src/components/Dashboard.tsx @@ -15,7 +15,7 @@ export default function Dashboard(props: { children: React.ReactNode }) { overflow: hidden; } `} -
+
diff --git a/apps/web/src/components/Input.tsx b/apps/web/src/components/Input.tsx index fbf106f2..911dbabd 100644 --- a/apps/web/src/components/Input.tsx +++ b/apps/web/src/components/Input.tsx @@ -58,7 +58,7 @@ const Input = forwardRef( ref={ref} onChange={onChange} className={twMerge( - "block w-full rounded-md border-0 bg-dark-300 bg-white/5 py-1.5 shadow-sm ring-1 ring-inset ring-light-600 placeholder:text-dark-800 focus:ring-2 focus:ring-inset focus:ring-light-700 dark:text-dark-1000 dark:ring-dark-700 dark:focus:ring-dark-700 sm:text-sm sm:leading-6", + "block w-full rounded-md border-0 bg-dark-300 bg-white/5 py-1.5 text-sm shadow-sm ring-1 ring-inset ring-light-600 placeholder:text-dark-800 focus:ring-2 focus:ring-inset focus:ring-light-700 dark:text-dark-1000 dark:ring-dark-700 dark:focus:ring-dark-700 sm:leading-6", prefix && "rounded-l-none", className && className, )} diff --git a/apps/web/src/views/auth/login/index.tsx b/apps/web/src/views/auth/login/index.tsx index 6b338311..74b608fe 100644 --- a/apps/web/src/views/auth/login/index.tsx +++ b/apps/web/src/views/auth/login/index.tsx @@ -1,8 +1,10 @@ +import Link from "next/link"; import { useState } from "react"; // import { useRouter } from "next/navigation"; import { Auth } from "~/components/AuthForm"; import { PageHead } from "~/components/PageHead"; +import PatternedBackground from "~/components/PatternedBackground"; // import { api } from "~/utils/api"; @@ -29,27 +31,36 @@ export default function LoginPage() { return ( <> -
-
-

- kan.bn -

-

- {isMagicLinkSent ? "Check your inbox" : "Welcome back"} -

- {isMagicLinkSent ? ( -
-

- {`Click on the link we've sent to ${magicLinkRecipient} to sign in.`} -

-
- ) : ( -
+
+
+
+

+ kan.bn +

+

+ {isMagicLinkSent ? "Check your inbox" : "Welcome back"} +

+ {isMagicLinkSent ? (
- +

+ {`Click on the link we've sent to ${magicLinkRecipient} to sign in.`} +

-
- )} + ) : ( +
+
+ +
+
+ )} +

+ Don't have an account?{" "} + + Sign up + +

+
+
diff --git a/apps/web/src/views/auth/signup/index.tsx b/apps/web/src/views/auth/signup/index.tsx index b5777aa4..5dd3c7b5 100644 --- a/apps/web/src/views/auth/signup/index.tsx +++ b/apps/web/src/views/auth/signup/index.tsx @@ -1,8 +1,10 @@ +import Link from "next/link"; import { useState } from "react"; // import { useRouter } from "next/navigation"; import { Auth } from "~/components/AuthForm"; import { PageHead } from "~/components/PageHead"; +import PatternedBackground from "~/components/PatternedBackground"; // import { api } from "~/utils/api"; @@ -28,28 +30,37 @@ export default function SignupPage() { return ( <> - -
-
-

- kan.bn -

-

- {isMagicLinkSent ? "Check your inbox" : "Get started"} -

- {isMagicLinkSent ? ( -
-

- {`Click on the link we've sent to ${magicLinkRecipient} to sign in.`} -

-
- ) : ( -
+ +
+
+
+

+ kan.bn +

+

+ {isMagicLinkSent ? "Check your inbox" : "Create your account"} +

+ {isMagicLinkSent ? (
- +

+ {`Click on the link we've sent to ${magicLinkRecipient} to sign in.`} +

-
- )} + ) : ( +
+
+ +
+
+ )} +

+ Already have an account?{" "} + + Sign in + +

+
+