22
33import { ModalShell } from "@cheatcode/ui" ;
44import { SignIn , SignUp } from "@clerk/nextjs" ;
5- import { useState , useSyncExternalStore } from "react" ;
6- import { CheatcodeMark } from "@/components/ui/cheatcode-mark" ;
5+ import { useSyncExternalStore } from "react" ;
76import { X } from "@/components/ui/icons" ;
8- import { cn } from "@/lib/ui/cn" ;
97import { clerkAuthAppearance } from "./clerk-auth-appearance" ;
108
119export type AuthMode = "sign-in" | "sign-up" ;
@@ -32,96 +30,43 @@ export function AuthModal({
3230 return null ;
3331 }
3432
35- return (
36- < AuthModalContent
37- initialMode = { mode }
38- key = { mode }
39- onClose = { onClose }
40- redirectPath = { redirectPath }
41- titleId = { titleId }
42- />
43- ) ;
44- }
45-
46- function AuthModalContent ( {
47- initialMode,
48- onClose,
49- redirectPath,
50- titleId,
51- } : {
52- initialMode : AuthMode ;
53- onClose : ( ) => void ;
54- redirectPath : string ;
55- titleId : string ;
56- } ) {
57- const [ activeMode , setActiveMode ] = useState < AuthMode > ( initialMode ) ;
58- const isSignIn = activeMode === "sign-in" ;
59-
33+ const isSignIn = mode === "sign-in" ;
6034 return (
6135 < ModalShell
62- className = "cheatcode-auth-dialog m-auto max-h-[calc(100vh-2rem)] w-[min(calc(100vw-2rem),442px )] max-w-[442px ] overflow-visible border-0 bg-transparent p-0 text-[#1b1b1b] shadow-none backdrop:bg-black/25 backdrop:backdrop-blur-[8px ]"
36+ className = "cheatcode-auth-dialog m-auto max-h-[calc(100vh-2rem)] w-[min(calc(100vw-2rem),25rem )] max-w-[25rem ] overflow-visible border-0 bg-transparent p-0 text-white shadow-none backdrop:bg-black/60 backdrop:backdrop-blur-[6px ]"
6337 labelledBy = { titleId }
6438 onClose = { onClose }
6539 open = { true }
6640 >
67- < div className = "cheatcode-auth-card relative max-h-[calc(100vh-2rem)] overflow-hidden rounded-[22px] bg-white shadow-[0_28px_80px_rgba(0,0,0,0.16)] ring-1 ring-[#eeeeee]" >
41+ < div className = "relative mx-auto max-h-[calc(100vh-2rem)] overflow-y-auto" >
42+ < span className = "sr-only" id = { titleId } >
43+ { isSignIn ? "Sign in to Cheatcode" : "Create your account" }
44+ </ span >
6845 < button
6946 aria-label = "Close authentication modal"
70- className = "absolute top-3 right-3 z-10 flex h-8 w-8 items-center justify-center rounded-full text-[#707070] outline-none transition-colors hover:bg-[#f7f7f7] hover:text-[#1b1b1b] focus-visible:ring-2 focus-visible:ring-[#1b1b1b]/15 "
47+ className = "absolute top-4 right-6 z-10 flex h-8 w-8 items-center justify-center rounded-full text-white/60 outline-none transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white/25 "
7148 onClick = { onClose }
7249 type = "button"
7350 >
74- < X aria-hidden = "true" className = "h-4 w-4 " />
51+ < X aria-hidden = "true" className = "h-5 w-5 " />
7552 </ button >
76- < div className = "px-10 pt-9 pb-8 max-sm:px-6" >
77- < div className = "mb-4 flex justify-center" >
78- < span className = "flex size-12 items-center justify-center text-[#dfa94f] drop-shadow-[0_1px_0_rgba(255,255,255,0.65)]" >
79- < CheatcodeMark aria-hidden = "true" className = "size-10" />
80- </ span >
81- </ div >
82- < div className = "mb-6 text-center" >
83- < h2 className = "font-semibold text-[#1b1b1b] text-[20px] leading-6" id = { titleId } >
84- { isSignIn ? "Sign in to Cheatcode" : "Create your account" }
85- </ h2 >
86- < p className = "mt-2 text-[#707070] text-[14px] leading-5" >
87- { isSignIn
88- ? "Welcome back! Please sign in to continue"
89- : "Welcome! Please fill in the details to get started." }
90- </ p >
91- </ div >
92- { isSignIn ? (
93- < SignIn
94- appearance = { clerkAuthAppearance }
95- fallbackRedirectUrl = { redirectPath }
96- forceRedirectUrl = { redirectPath }
97- oauthFlow = "popup"
98- routing = "hash"
99- signUpUrl = "#sign-up"
100- />
101- ) : (
102- < SignUp
103- appearance = { clerkAuthAppearance }
104- fallbackRedirectUrl = { redirectPath }
105- forceRedirectUrl = { redirectPath }
106- oauthFlow = "popup"
107- routing = "hash"
108- signInUrl = "#sign-in"
109- />
110- ) }
111- </ div >
112- < div className = "flex justify-center border-[#eeeeee] border-t bg-[#fafafa] px-4 py-5 text-[#707070] text-[14px]" >
113- < span > { isSignIn ? "Don’t have an account?" : "Already have an account?" } </ span >
114- < button
115- className = { cn (
116- "ml-1 font-medium text-[#d99b36] transition-colors hover:text-[#b87418]" ,
117- "paper-focus-ring rounded-sm" ,
118- ) }
119- onClick = { ( ) => setActiveMode ( isSignIn ? "sign-up" : "sign-in" ) }
120- type = "button"
121- >
122- { isSignIn ? "Sign up" : "Sign in" }
123- </ button >
124- </ div >
53+ { isSignIn ? (
54+ < SignIn
55+ appearance = { clerkAuthAppearance }
56+ fallbackRedirectUrl = { redirectPath }
57+ forceRedirectUrl = { redirectPath }
58+ oauthFlow = "popup"
59+ routing = "hash"
60+ />
61+ ) : (
62+ < SignUp
63+ appearance = { clerkAuthAppearance }
64+ fallbackRedirectUrl = { redirectPath }
65+ forceRedirectUrl = { redirectPath }
66+ oauthFlow = "popup"
67+ routing = "hash"
68+ />
69+ ) }
12570 </ div >
12671 </ ModalShell >
12772 ) ;
0 commit comments