diff --git a/src/interface/web/app/components/loginPrompt/loginPrompt.module.css b/src/interface/web/app/components/loginPrompt/loginPrompt.module.css new file mode 100644 index 00000000..419274ca --- /dev/null +++ b/src/interface/web/app/components/loginPrompt/loginPrompt.module.css @@ -0,0 +1,115 @@ +.gsiMaterialButton { + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + -webkit-appearance: none; + background-color: WHITE; + background-image: none; + /* border: 1px solid #747775; */ + -webkit-border-radius: 20px; + border-radius: 20px; + -webkit-box-sizing: border-box; + box-sizing: border-box; + color: #1f1f1f; + cursor: pointer; + font-family: "Roboto", arial, sans-serif; + font-size: 14px; + height: 40px; + letter-spacing: 0.25px; + outline: none; + overflow: hidden; + padding: 0; + position: relative; + text-align: center; + -webkit-transition: + background-color 0.218s, + border-color 0.218s, + box-shadow 0.218s; + transition: + background-color 0.218s, + border-color 0.218s, + box-shadow 0.218s; + vertical-align: middle; + white-space: nowrap; + width: 40px; + max-width: 400px; + min-width: min-content; +} + +.gsiMaterialButton .gsiMaterialButtonIcon { + height: 100%; + margin-right: 12px; + min-width: 20px; + width: 100%; + margin: 0; + padding: 9px; +} + +.gsiMaterialButton .gsiMaterialButtonContentWrapper { + -webkit-align-items: center; + align-items: center; + display: flex; + -webkit-flex-direction: row; + flex-direction: row; + -webkit-flex-wrap: nowrap; + flex-wrap: nowrap; + height: 100%; + justify-content: space-between; + position: relative; + width: 100%; +} + +.gsiMaterialButton .gsiMaterialButtonContents { + -webkit-flex-grow: 1; + flex-grow: 1; + font-family: "Roboto", arial, sans-serif; + font-weight: 500; + overflow: hidden; + text-overflow: ellipsis; + vertical-align: top; +} + +.gsiMaterialButton .gsiMaterialButtonState { + -webkit-transition: opacity 0.218s; + transition: opacity 0.218s; + bottom: 0; + left: 0; + opacity: 0; + position: absolute; + right: 0; + top: 0; +} + +.gsiMaterialButton:disabled { + cursor: default; + background-color: #ffffff61; + border-color: #1f1f1f1f; +} + +.gsiMaterialButton:disabled .gsiMaterialButtonContents { + opacity: 38%; +} + +.gsiMaterialButton:disabled .gsiMaterialButtonIcon { + opacity: 38%; +} + +.gsiMaterialButton:not(:disabled):active .gsiMaterialButton-State, +.gsiMaterialButton:not(:disabled):focus .gsiMaterialButtonState { + background-color: #303030; + opacity: 12%; +} + +.gsiMaterialButton:not(:disabled):hover { + -webkit-box-shadow: + 0 1px 2px 0 rgba(60, 64, 67, 0.3), + 0 1px 3px 1px rgba(60, 64, 67, 0.15); + box-shadow: + 0 1px 2px 0 rgba(60, 64, 67, 0.3), + 0 1px 3px 1px rgba(60, 64, 67, 0.15); +} + +.gsiMaterialButton:not(:disabled):hover .gsiMaterialButtonState { + background-color: #303030; + opacity: 8%; +} diff --git a/src/interface/web/app/components/loginPrompt/loginPrompt.tsx b/src/interface/web/app/components/loginPrompt/loginPrompt.tsx index 746beaac..0f9ea381 100644 --- a/src/interface/web/app/components/loginPrompt/loginPrompt.tsx +++ b/src/interface/web/app/components/loginPrompt/loginPrompt.tsx @@ -1,3 +1,6 @@ +"use client"; + +import styles from "./loginPrompt.module.css"; import { Button } from "@/components/ui/button"; import { Dialog, @@ -64,6 +67,29 @@ export default function LoginPrompt(props: LoginPromptProps) { setAutoRotate(false); }; + useEffect(() => { + const google = (window as any).google; + + console.log(data, isLoading, error); + + if (!google) return; + + // Initialize Google Sign In after script loads + google.accounts.id.initialize({ + client_id: data?.google?.client_id, + callback: handleGoogleSignIn, + auto_select: false, + login_uri: data?.google?.redirect_uri, + }); + + // Render the button + google.accounts.id.renderButton(document.getElementById("g_id_signin")!, { + theme: "outline", + size: "large", + width: "100%", + }); + }, [data]); + const handleGoogleSignIn = () => { if (!data?.google?.client_id || !data?.google?.redirect_uri) return; @@ -85,16 +111,22 @@ export default function LoginPrompt(props: LoginPromptProps) { }; const handleGoogleScriptLoad = () => { + const google = (window as any).google; + + console.log(data, isLoading, error); + + if (!data?.google?.client_id || !data?.google?.redirect_uri) return; + // Initialize Google Sign In after script loads - window.google.accounts.id.initialize({ - client_id: "blahblahblah.apps.googleusercontent.com", + google.accounts.id.initialize({ + client_id: data?.google?.client_id, callback: handleGoogleSignIn, auto_select: false, - login_uri: "http://localhost:42110/auth/redirect", + login_uri: data?.google?.redirect_uri, }); // Render the button - window.google.accounts.id.renderButton(document.getElementById("g_id_signin")!, { + google.accounts.id.renderButton(document.getElementById("g_id_signin")!, { theme: "outline", size: "large", width: "100%", @@ -172,6 +204,7 @@ export default function LoginPrompt(props: LoginPromptProps) { isLoading={isLoading} data={data} setUseEmailSignIn={setUseEmailSignIn} + isMobileWidth={props.isMobileWidth} /> )} @@ -209,6 +242,7 @@ export default function LoginPrompt(props: LoginPromptProps) { isLoading={isLoading} data={data} setUseEmailSignIn={setUseEmailSignIn} + isMobileWidth={props.isMobileWidth ?? false} /> )} @@ -314,6 +348,7 @@ function MainSignInContext({ isLoading, data, setUseEmailSignIn, + isMobileWidth, }: { tips: { src: string; alt: string }[]; currentTip: number; @@ -324,35 +359,40 @@ function MainSignInContext({ isLoading: boolean; data: CredentialsData | undefined; setUseEmailSignIn: (useEmailSignIn: boolean) => void; + isMobileWidth: boolean; }) { return (
-
- {tips.map((tip, index) => ( - {tip.alt} - ))} - - -
+ {!isMobileWidth && ( +
+ {tips.map((tip, index) => ( + {tip.alt} + ))} + + +
+ )}
Sign In for free to start using Khoj: Your AI-powered second brain @@ -360,7 +400,7 @@ function MainSignInContext({
-
+ {/*
*/} )} Continue with Google