From f60f36872f5fb5c4bf3838c3b438ba2cbea26269 Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Thu, 22 Oct 2026 18:36:31 -0400 Subject: [PATCH] Implement sign-in dialog with Google login and update styles --- src/components/HomePage.tsx | 80 +++++++++++++++++++++++++----------- src/styles/HomePage.css | 82 +++++++++++++++++++++++++++++++------ 2 files changed, 126 insertions(+), 36 deletions(-) diff --git a/src/components/HomePage.tsx b/src/components/HomePage.tsx index 9378086..1d14e42 100644 --- a/src/components/HomePage.tsx +++ b/src/components/HomePage.tsx @@ -1,18 +1,23 @@ import { useNavigate } from "react-router-dom"; +import Dialog from "@mui/material/Dialog"; +import CloseIcon from "@mui/icons-material/Close"; import "../styles/HomePage.css"; import { useAuth } from "../context/AuthContext"; import logo from "../assets/logo2.jpg"; import { useState } from "react"; -import { - GoogleLogin, - type CredentialResponse, -} from "@react-oauth/google"; +import { GoogleLogin, type CredentialResponse } from "@react-oauth/google"; const HomePage = () => { const { user, signInWithGoogle } = useAuth(); const navigate = useNavigate(); + const [loginOpen, setLoginOpen] = useState(false); const [loginError, setLoginError] = useState(""); + const closeLogin = () => { + setLoginOpen(false); + setLoginError(""); + }; + const handleGoogleSuccess = async (response: CredentialResponse) => { if (!response.credential) { setLoginError("Google did not return a login credential."); @@ -22,6 +27,7 @@ const HomePage = () => { try { setLoginError(""); await signInWithGoogle(response.credential); + closeLogin(); navigate("/map"); } catch (error) { console.error("Google sign-in failed:", error); @@ -38,19 +44,13 @@ const HomePage = () => { {!user && ( -
- - setLoginError("Google sign-in was cancelled or failed.") - } - shape="pill" - size="large" - text="signin_with" - theme="outline" - width="210" - /> -
+ )} @@ -87,15 +87,47 @@ const HomePage = () => { )} - - {loginError && ( -

- {loginError} -

- )} - + + + +

Sign in to GeoGallery

+

+ Welcome back! Please sign in to continue. +

+
+ + setLoginError("Google sign-in failed. Please try again.") + } + shape="pill" + size="large" + text="continue_with" + theme="outline" + width="260" + /> +
+ {loginError && ( +

+ {loginError} +

+ )} +
); }; diff --git a/src/styles/HomePage.css b/src/styles/HomePage.css index b54f68a..2d3cca4 100644 --- a/src/styles/HomePage.css +++ b/src/styles/HomePage.css @@ -119,19 +119,8 @@ margin-top: 34px; } -.nav-google-login { - display: flex; - align-items: center; - justify-content: flex-end; -} - -.login-error { - margin: 14px 0 0; - color: #ffb4b4; - font-size: 14px; -} - .explore-button, +.nav-signin-button, .guest-link { font-family: var(--calistoga); cursor: pointer; @@ -156,6 +145,75 @@ box-shadow: 0 18px 34px rgba(76, 202, 237, 0.26); } +.nav-signin-button { + padding: 11px 20px; + border: 1px solid rgba(246, 251, 255, 0.3); + border-radius: 8px; + background: rgba(255, 255, 255, 0.08); + color: #f6fbff; + font-size: 14px; +} + +.nav-signin-button:hover { + background: rgba(255, 255, 255, 0.16); + transform: translateY(-2px); +} + +.login-dialog { + position: relative; + width: min(380px, calc(100vw - 32px)); + margin: 16px; + padding: 36px 28px 32px; + border-radius: 18px !important; + background: #f9fcfd !important; + color: #17252d; + text-align: center; +} + +.login-dialog-close { + position: absolute; + top: 12px; + right: 12px; + width: 34px; + height: 34px; + display: grid; + place-items: center; + border: 0; + border-radius: 8px; + background: transparent; + color: #64757c; + cursor: pointer; +} + +.login-dialog-close:hover { + background: #edf3f5; + color: #17252d; +} + +.login-dialog h2 { + margin: 0; + font-family: var(--calistoga); + font-size: 26px; + font-weight: 400; +} + +.login-dialog > p { + margin: 10px 0 0; + color: #63767f; + font-size: 14px; + line-height: 1.5; +} + +.login-dialog-provider { + display: flex; + justify-content: center; + margin-top: 28px; +} + +.login-dialog .login-error { + color: #a33f3f; +} + .guest-link { border: 1px solid rgba(246, 251, 255, 0.2); background: rgba(255, 255, 255, 0.08);