π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix Space auth mobile CTAs
Anand Baburajan51ede12b93cc
diff --git a/web/apps/space/src/components/SpaceAvatarCropPage.tsx b/web/apps/space/src/components/SpaceAvatarCropPage.tsxindex 655178b843..da6bedb379 100644--- a/web/apps/space/src/components/SpaceAvatarCropPage.tsx+++ b/web/apps/space/src/components/SpaceAvatarCropPage.tsx@@ -1,6 +1,7 @@import { ArrowLeft02Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { Box } from "@mui/material";+import { SpaceButtonSpinner } from "components/SpaceButtonSpinner";import React from "react";import Cropper, { type Area, type Point } from "react-easy-crop";@@ -50,20 +51,23 @@ const SetupBackIcon: React.FC = () => (const SpaceAvatarCropPageButton: React.FC<{children: React.ReactNode;disabled?: boolean;+ loading?: boolean;onClick?: () => void;-}> = ({ children, disabled = false, onClick }) => (+}> = ({ children, disabled = false, loading = false, onClick }) => (<Box- className={!disabled ? "green-bg" : undefined}+ className={!disabled || loading ? "green-bg" : undefined}component="button"type="button"disabled={disabled}+ aria-label={loading ? "Saving" : undefined}+ aria-busy={loading ? true : undefined}onClick={onClick}sx={{alignItems: "center",- bgcolor: disabled ? "#F5F5F5" : green,+ bgcolor: disabled && !loading ? "#F5F5F5" : green,border: 0,borderRadius: "20px",- color: disabled ? textLight : "white",+ color: disabled && !loading ? textLight : "white",cursor: disabled ? "default" : "pointer",display: "flex",flex: "0 0 auto",@@ -372,9 +376,10 @@ export const SpaceAvatarCropPage: React.FC<SpaceAvatarCropPageProps> = ({><SpaceAvatarCropPageButtondisabled={isSaving || isDoneDisabled}+ loading={isSaving}onClick={onDone}>- {isSaving ? "Saving..." : "Done"}+ {isSaving ? <SpaceButtonSpinner /> : "Done"}</SpaceAvatarCropPageButton><SpaceAvatarCropPageLinkButtondisabled={isSaving}diff --git a/web/apps/space/src/components/SpaceButtonSpinner.tsx b/web/apps/space/src/components/SpaceButtonSpinner.tsxnew file mode 100644index 0000000000..34c0b5bfac--- /dev/null+++ b/web/apps/space/src/components/SpaceButtonSpinner.tsx@@ -0,0 +1,11 @@+import { SpaceLoadingSpinner } from "components/SpaceRouteFallback";+import React from "react";++export const SpaceButtonSpinner: React.FC = () => (+ <SpaceLoadingSpinner+ ariaLabel="Loading"+ color="currentColor"+ size={20}+ trackColor="rgba(255, 255, 255, 0.38)"+ />+);diff --git a/web/apps/space/src/components/SpaceRouteFallback.tsx b/web/apps/space/src/components/SpaceRouteFallback.tsxindex d17787274f..f3718afcf9 100644--- a/web/apps/space/src/components/SpaceRouteFallback.tsx+++ b/web/apps/space/src/components/SpaceRouteFallback.tsx@@ -9,10 +9,16 @@ interface SpaceRouteFallbackProps {interface SpaceLoadingSpinnerProps {ariaLabel?: string;+ color?: string;+ size?: number;+ trackColor?: string;}export const SpaceLoadingSpinner: React.FC<SpaceLoadingSpinnerProps> = ({ariaLabel = "Loading",+ color = "#08C225",+ size = 26,+ trackColor = "rgba(8, 194, 37, 0.18)",}) => (<Boxcomponent="span"@@ -20,11 +26,11 @@ export const SpaceLoadingSpinner: React.FC<SpaceLoadingSpinnerProps> = ({aria-label={ariaLabel}sx={{animation: "spaceRouteFallbackSpin 800ms linear infinite",- border: "2px solid rgba(8, 194, 37, 0.18)",+ border: `2px solid ${trackColor}`,borderRadius: "50%",- borderTopColor: "#08C225",- height: 26,- width: 26,+ borderTopColor: color,+ height: size,+ width: size,"@keyframes spaceRouteFallbackSpin": {to: { transform: "rotate(360deg)" },},diff --git a/web/apps/space/src/pages/verify.tsx b/web/apps/space/src/pages/verify.tsxindex c2f3d1c576..fb818812c7 100644--- a/web/apps/space/src/pages/verify.tsx+++ b/web/apps/space/src/pages/verify.tsx@@ -206,6 +206,7 @@ const Page: React.FC = () => {? "": undefined}+ isResending={isResending}isSubmitting={isSubmitting}onBack={() =>void router.push(diff --git a/web/apps/space/src/screens/CreateAccountScreen.tsx b/web/apps/space/src/screens/CreateAccountScreen.tsxindex 5d0038991f..cbf82d86c3 100644--- a/web/apps/space/src/screens/CreateAccountScreen.tsx+++ b/web/apps/space/src/screens/CreateAccountScreen.tsx@@ -1,4 +1,5 @@import { Box } from "@mui/material";+import { SpaceButtonSpinner } from "components/SpaceButtonSpinner";import {estimatePasswordStrength,type PasswordStrength,@@ -331,6 +332,7 @@ export const CreateAccountScreen: React.FC<CreateAccountScreenProps> = ({confirmPassword.length > 0 &&password == confirmPassword &&acceptedTerms;+ const isCreateAccountButtonActive = canCreateAccount || isSubmitting;const submitCreateAccount = () => {if (canCreateAccount) {@@ -617,17 +619,27 @@ export const CreateAccountScreen: React.FC<CreateAccountScreenProps> = ({}}><Box- className={canCreateAccount ? "green-bg" : undefined}+ className={+ isCreateAccountButtonActive ? "green-bg" : undefined+ }component="button"form={createAccountFormID}type="submit"disabled={!canCreateAccount}+ aria-label={+ isSubmitting ? "Creating account" : undefined+ }+ aria-busy={isSubmitting ? true : undefined}sx={{alignItems: "center",- bgcolor: canCreateAccount ? green : "#F5F5F5",+ bgcolor: isCreateAccountButtonActive+ ? green+ : "#F5F5F5",border: 0,borderRadius: "20px",- color: canCreateAccount ? "white" : textLight,+ color: isCreateAccountButtonActive+ ? "white"+ : textLight,cursor: canCreateAccount ? "pointer" : "default",display: "flex",fontFamily: '"Inter Variable", Inter, sans-serif',@@ -647,9 +659,11 @@ export const CreateAccountScreen: React.FC<CreateAccountScreenProps> = ({: undefined,}}>- {isSubmitting- ? "Creating account..."- : "Create an account"}+ {isSubmitting ? (+ <SpaceButtonSpinner />+ ) : (+ "Create an account"+ )}</Box></Box></Box>diff --git a/web/apps/space/src/screens/LoginScreen.tsx b/web/apps/space/src/screens/LoginScreen.tsxindex dcd1b3c439..21768c2523 100644--- a/web/apps/space/src/screens/LoginScreen.tsx+++ b/web/apps/space/src/screens/LoginScreen.tsx@@ -1,4 +1,5 @@import { Box } from "@mui/material";+import { SpaceButtonSpinner } from "components/SpaceButtonSpinner";import React, { useEffect, useRef, useState } from "react";export const loginBackground = "#FAFAFA";@@ -95,7 +96,28 @@ const TextInput: React.FC<TextInputProps> = ({value,}) => {const [showPassword, setShowPassword] = useState(false);+ const internalInputRef = useRef<HTMLInputElement | null>(null);const isPassword = type == "password";+ const setInputRef = (element: HTMLInputElement | null) => {+ internalInputRef.current = element;+ if (typeof inputRef == "function") {+ inputRef(element);+ } else if (inputRef) {+ inputRef.current = element;+ }+ };++ const togglePasswordVisibility = () => {+ const inputElement = internalInputRef.current;+ const shouldRestoreFocus = document.activeElement == inputElement;++ setShowPassword((value) => !value);+ if (shouldRestoreFocus) {+ window.requestAnimationFrame(() =>+ inputElement?.focus({ preventScroll: true }),+ );+ }+ };return (<Box sx={{ width: "100%" }}>@@ -132,7 +154,7 @@ const TextInput: React.FC<TextInputProps> = ({><Boxcomponent="input"- ref={inputRef}+ ref={setInputRef}autoFocus={autoFocus}onChange={(event) => onChange?.(event.target.value)}placeholder={placeholder}@@ -162,7 +184,8 @@ const TextInput: React.FC<TextInputProps> = ({aria-label={showPassword ? "Hide password" : "Show password"}- onClick={() => setShowPassword((value) => !value)}+ onClick={togglePasswordVisibility}+ onPointerDown={(event) => event.preventDefault()}sx={{alignItems: "center",bgcolor: "transparent",@@ -247,6 +270,8 @@ export const LoginScreen: React.FC<LoginScreenProps> = ({}) => {const [email, setEmail] = useState(initialEmail ?? "");const [password, setPassword] = useState("");+ const [visualViewportBottomInset, setVisualViewportBottomInset] =+ useState(0);const passwordInputRef = useRef<HTMLInputElement | null>(null);const appliedInitialEmailRef = useRef<string | undefined>(initialEmail);@@ -270,13 +295,70 @@ export const LoginScreen: React.FC<LoginScreenProps> = ({return () => window.cancelAnimationFrame(animationFrame);}, [focusPassword, initialEmail]);+ useEffect(() => {+ const viewport = window.visualViewport;+ if (!viewport) return undefined;++ const updateBottomInset = () => {+ const activeElement = document.activeElement;+ const isEditingText =+ activeElement instanceof HTMLInputElement ||+ activeElement instanceof HTMLTextAreaElement ||+ (activeElement instanceof HTMLElement &&+ activeElement.isContentEditable);++ setVisualViewportBottomInset(+ isEditingText+ ? Math.max(+ 0,+ Math.round(+ window.innerHeight -+ viewport.height -+ viewport.offsetTop,+ ),+ )+ : 0,+ );+ };++ updateBottomInset();+ viewport.addEventListener("resize", updateBottomInset);+ viewport.addEventListener("scroll", updateBottomInset);+ window.addEventListener("focusin", updateBottomInset);+ window.addEventListener("focusout", updateBottomInset);++ return () => {+ viewport.removeEventListener("resize", updateBottomInset);+ viewport.removeEventListener("scroll", updateBottomInset);+ window.removeEventListener("focusin", updateBottomInset);+ window.removeEventListener("focusout", updateBottomInset);+ };+ }, []);+const canContinue =!isSubmitting && email.trim().length > 0 && password.length > 0;+ const isContinueButtonActive = canContinue || isSubmitting;+ const footerPaddingBottom =+ visualViewportBottomInset > 0+ ? "24px"+ : "calc(24px + env(safe-area-inset-bottom))";const submitLogin = () => {if (canContinue) void onContinue?.({ email, password });};+ const handleContinuePointerDown: React.PointerEventHandler<+ HTMLButtonElement+ > = (event) => {+ if (event.pointerType != "touch") return;++ event.preventDefault();+ submitLogin();+ if (document.activeElement instanceof HTMLElement) {+ document.activeElement.blur();+ }+ };+const handleSubmit: React.FormEventHandler<HTMLFormElement> = (event) => {event.preventDefault();submitLogin();@@ -290,7 +372,6 @@ export const LoginScreen: React.FC<LoginScreenProps> = ({color: textBase,display: "grid",minHeight: "100svh",- overflow: "hidden",placeItems: { xs: "stretch", sm: "start center" },}}>@@ -302,7 +383,6 @@ export const LoginScreen: React.FC<LoginScreenProps> = ({flexDirection: "column",minHeight: "100svh",mx: "auto",- pb: "154px",px: 3,width: "100%","@media (min-width: 600px)": { maxWidth: 390 },@@ -418,31 +498,36 @@ export const LoginScreen: React.FC<LoginScreenProps> = ({<Boxsx={{bgcolor: loginBackground,- bottom: 0,+ bottom: `${visualViewportBottomInset}px`,boxSizing: "border-box",display: "flex",flexDirection: "column",gap: "16px",- left: "50%",- maxWidth: 390,- p: 3,- position: "fixed",- transform: "translateX(-50%)",+ mt: "auto",+ pb: footerPaddingBottom,+ pt: 3,+ position: "sticky",width: "100%",+ zIndex: 1,}}><Box- className={canContinue ? "green-bg" : undefined}+ className={+ isContinueButtonActive ? "green-bg" : undefined+ }component="button"form={loginFormID}type="submit"disabled={!canContinue}+ aria-label={isSubmitting ? "Signing in" : undefined}+ aria-busy={isSubmitting ? true : undefined}+ onPointerDown={handleContinuePointerDown}sx={{alignItems: "center",- bgcolor: canContinue ? green : "#F5F5F5",+ bgcolor: isContinueButtonActive ? green : "#F5F5F5",border: 0,borderRadius: "20px",- color: canContinue ? "white" : textLight,+ color: isContinueButtonActive ? "white" : textLight,cursor: canContinue ? "pointer" : "default",display: "flex",fontFamily: '"Inter Variable", Inter, sans-serif',@@ -462,7 +547,7 @@ export const LoginScreen: React.FC<LoginScreenProps> = ({: undefined,}}>- {isSubmitting ? "Signing in..." : "Continue"}+ {isSubmitting ? <SpaceButtonSpinner /> : "Continue"}</Box>{readOnlyEmail && onChangeEmail && (<FooterLinkButtondiff --git a/web/apps/space/src/screens/PasskeyVerificationScreen.tsx b/web/apps/space/src/screens/PasskeyVerificationScreen.tsxindex b53675c85d..3fd55235b1 100644--- a/web/apps/space/src/screens/PasskeyVerificationScreen.tsx+++ b/web/apps/space/src/screens/PasskeyVerificationScreen.tsx@@ -1,4 +1,5 @@import { Box } from "@mui/material";+import { SpaceButtonSpinner } from "components/SpaceButtonSpinner";import React from "react";export const passkeyVerificationBackground = "#FAFAFA";@@ -7,7 +8,6 @@ const green = "#08C225";const primaryLight = "#DDEEDF";const primaryDark = "#069D1E";const textBase = "#000";-const textLight = "#969696";const warning = "#F63A3A";export type PasskeyVerificationStatus = "waiting" | "checking" | "pending";@@ -269,13 +269,15 @@ export const PasskeyVerificationScreen: React.FC<component="button"type="button"disabled={isChecking}+ aria-label={isChecking ? "Checking status" : undefined}+ aria-busy={isChecking ? true : undefined}onClick={onCheckStatus}sx={{alignItems: "center",bgcolor: primaryLight,border: 0,borderRadius: "20px",- color: isChecking ? textLight : primaryDark,+ color: primaryDark,cursor: isChecking ? "default" : "pointer",display: "flex",fontFamily: '"Inter Variable", Inter, sans-serif',@@ -292,7 +294,7 @@ export const PasskeyVerificationScreen: React.FC<},}}>- {isChecking ? "Checking..." : "Check status"}+ {isChecking ? <SpaceButtonSpinner /> : "Check status"}</Box></Box></Box>diff --git a/web/apps/space/src/screens/SetupProfileScreen.tsx b/web/apps/space/src/screens/SetupProfileScreen.tsxindex e26551dba1..7e0931faf7 100644--- a/web/apps/space/src/screens/SetupProfileScreen.tsx+++ b/web/apps/space/src/screens/SetupProfileScreen.tsx@@ -1,6 +1,7 @@import { Box } from "@mui/material";import { SpaceAvatarCropPage } from "components/SpaceAvatarCropPage";import { SpaceAvatarEditButton } from "components/SpaceAvatarEditButton";+import { SpaceButtonSpinner } from "components/SpaceButtonSpinner";import React, { useEffect, useRef, useState } from "react";import type { Area, Point } from "react-easy-crop";import {@@ -268,6 +269,7 @@ export const SetupProfileScreen: React.FC<SetupProfileScreenProps> = ({usernameStatus != "unavailable" &&username.trim().length > 0 &&fullName.trim().length > 0;+ const isContinueButtonActive = canContinue || isSubmitting;useEffect(() => () => {@@ -645,17 +647,21 @@ export const SetupProfileScreen: React.FC<SetupProfileScreenProps> = ({}}><Box- className={canContinue ? "green-bg" : undefined}+ className={+ isContinueButtonActive ? "green-bg" : undefined+ }component="button"form={setupProfileFormID}type="submit"disabled={!canContinue}+ aria-label={isSubmitting ? "Saving" : undefined}+ aria-busy={isSubmitting ? true : undefined}sx={{alignItems: "center",- bgcolor: canContinue ? green : "#F5F5F5",+ bgcolor: isContinueButtonActive ? green : "#F5F5F5",border: 0,borderRadius: "20px",- color: canContinue ? "white" : textLight,+ color: isContinueButtonActive ? "white" : textLight,cursor: canContinue ? "pointer" : "default",display: "flex",fontFamily: '"Inter Variable", Inter, sans-serif',@@ -675,7 +681,7 @@ export const SetupProfileScreen: React.FC<SetupProfileScreenProps> = ({: undefined,}}>- {isSubmitting ? "Saving..." : ctaLabel}+ {isSubmitting ? <SpaceButtonSpinner /> : ctaLabel}</Box></Box></Box>diff --git a/web/apps/space/src/screens/VerifyEmailScreen.tsx b/web/apps/space/src/screens/VerifyEmailScreen.tsxindex c23365fad1..fdef81636c 100644--- a/web/apps/space/src/screens/VerifyEmailScreen.tsx+++ b/web/apps/space/src/screens/VerifyEmailScreen.tsx@@ -1,4 +1,5 @@import { Box } from "@mui/material";+import { SpaceButtonSpinner } from "components/SpaceButtonSpinner";import React, { useEffect, useRef, useState } from "react";export const verifyEmailBackground = "#FAFAFA";@@ -16,6 +17,7 @@ interface VerifyEmailScreenProps {email: string;errorMessage?: string;initialCode?: string;+ isResending?: boolean;isSubmitting?: boolean;onBack: () => void;onChangeEmail: () => void;@@ -121,6 +123,7 @@ export const VerifyEmailScreen: React.FC<VerifyEmailScreenProps> = ({email,errorMessage,initialCode = "",+ isResending = false,isSubmitting = false,onBack,onChangeEmail,@@ -143,6 +146,7 @@ export const VerifyEmailScreen: React.FC<VerifyEmailScreenProps> = ({);const otpComplete = otp.every((digit) => digit.length == 1);const canVerify = otpComplete && !isSubmitting;+ const isVerifyButtonActive = canVerify || isSubmitting;const focusInput = (index: number) => {inputRefs.current[index]?.focus();@@ -216,6 +220,8 @@ export const VerifyEmailScreen: React.FC<VerifyEmailScreenProps> = ({};const handleResendCode = () => {+ if (isResending) return;+setOtp(Array(6).fill(""));focusInput(0);onResendCode?.();@@ -446,23 +452,39 @@ export const VerifyEmailScreen: React.FC<VerifyEmailScreenProps> = ({<Boxcomponent="button"type="button"+ disabled={isResending}+ aria-label={+ isResending+ ? "Resending code"+ : undefined+ }+ aria-busy={+ isResending ? true : undefined+ }onClick={handleResendCode}sx={{bgcolor: "transparent",border: 0,color: green,- cursor: "pointer",+ cursor: isResending+ ? "default"+ : "pointer",fontFamily:'"Inter Variable", Inter, sans-serif',fontSize: 14,fontWeight: 500,lineHeight: "20px",+ minWidth: 84,p: 0,textDecoration: "underline",textUnderlineOffset: "2px",}}>- Resend code+ {isResending ? (+ <SpaceButtonSpinner />+ ) : (+ "Resend code"+ )}</Box>)}</Box>@@ -484,17 +506,21 @@ export const VerifyEmailScreen: React.FC<VerifyEmailScreenProps> = ({}}><Box- className={canVerify ? "green-bg" : undefined}+ className={+ isVerifyButtonActive ? "green-bg" : undefined+ }component="button"form={verifyEmailFormID}type="submit"disabled={!canVerify}+ aria-label={isSubmitting ? "Verifying" : undefined}+ aria-busy={isSubmitting ? true : undefined}sx={{alignItems: "center",- bgcolor: canVerify ? green : "#F5F5F5",+ bgcolor: isVerifyButtonActive ? green : "#F5F5F5",border: 0,borderRadius: "20px",- color: canVerify ? "white" : textLight,+ color: isVerifyButtonActive ? "white" : textLight,cursor: canVerify ? "pointer" : "default",display: "flex",fontFamily: '"Inter Variable", Inter, sans-serif',@@ -514,7 +540,7 @@ export const VerifyEmailScreen: React.FC<VerifyEmailScreenProps> = ({: undefined,}}>- {isSubmitting ? "Verifying..." : "Verify"}+ {isSubmitting ? <SpaceButtonSpinner /> : "Verify"}</Box></Box></Box>diff --git a/web/apps/space/src/screens/VerifyTwoFactorScreen.tsx b/web/apps/space/src/screens/VerifyTwoFactorScreen.tsxindex db1b8969e1..16de010500 100644--- a/web/apps/space/src/screens/VerifyTwoFactorScreen.tsx+++ b/web/apps/space/src/screens/VerifyTwoFactorScreen.tsx@@ -1,6 +1,7 @@import { Shield01Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { Box } from "@mui/material";+import { SpaceButtonSpinner } from "components/SpaceButtonSpinner";import React, { useEffect, useRef, useState } from "react";export const verifyTwoFactorBackground = "#FAFAFA";@@ -139,6 +140,7 @@ export const VerifyTwoFactorScreen: React.FC<VerifyTwoFactorScreenProps> = ({);const otpComplete = otp.every((digit) => digit.length == 1);const canVerify = otpComplete && !isSubmitting;+ const isVerifyButtonActive = canVerify || isSubmitting;const focusInput = (index: number) => {inputRefs.current[index]?.focus();@@ -414,17 +416,21 @@ export const VerifyTwoFactorScreen: React.FC<VerifyTwoFactorScreenProps> = ({}}><Box- className={canVerify ? "green-bg" : undefined}+ className={+ isVerifyButtonActive ? "green-bg" : undefined+ }component="button"form={verifyTwoFactorFormID}type="submit"disabled={!canVerify}+ aria-label={isSubmitting ? "Verifying" : undefined}+ aria-busy={isSubmitting ? true : undefined}sx={{alignItems: "center",- bgcolor: canVerify ? green : "#F5F5F5",+ bgcolor: isVerifyButtonActive ? green : "#F5F5F5",border: 0,borderRadius: "20px",- color: canVerify ? "white" : textLight,+ color: isVerifyButtonActive ? "white" : textLight,cursor: canVerify ? "pointer" : "default",display: "flex",fontFamily: '"Inter Variable", Inter, sans-serif',@@ -444,7 +450,7 @@ export const VerifyTwoFactorScreen: React.FC<VerifyTwoFactorScreenProps> = ({: undefined,}}>- {isSubmitting ? "Verifying..." : "Verify"}+ {isSubmitting ? <SpaceButtonSpinner /> : "Verify"}</Box></Box></Box>