Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 48 additions & 10 deletions frontend/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import { Alert, Platform, SafeAreaView } from 'react-native';
import { ActivityIndicator, Alert, Platform, SafeAreaView, Text, TouchableOpacity, View } from 'react-native';
import { useOAuth, useAuth } from "@clerk/clerk-expo";
import { useRouter } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
Expand All @@ -8,6 +8,7 @@ import Animated, { useAnimatedScrollHandler, useAnimatedStyle } from 'react-nati
import { UI } from '../constants/colors';
import DesktopLanding from '../components/landing/DesktopLanding';
import { useDesktopLayout } from '../utils/useDesktopLayout';
import { recordWebStartup } from '../utils/startupTiming';
import { LandingViewportProvider, useLandingViewport } from '../components/landing/landingMotion';
import {
HeroSection,
Expand Down Expand Up @@ -44,6 +45,7 @@ function LandingPageContent() {
const { startOAuthFlow } = useOAuth({ strategy: "oauth_google" });
const [loginRequested, setLoginRequested] = useState(false);
const [sessionRetry, setSessionRetry] = useState(0);
const [sessionError, setSessionError] = useState<string | null>(null);
const oauthPending = useRef(false);
const { scrollY, viewportHeight, scrollDirection } = useLandingViewport();

Expand All @@ -63,15 +65,20 @@ function LandingPageContent() {

useEffect(() => {
if (!isLoaded) return;
recordWebStartup('session-ready');
let cancelled = false;
setSessionError(null);
async function initialize() {
if (!isSignedIn) {
clearSyncedUser();
return;
}
const token = await getToken();
if (!token) return;
recordWebStartup('session-token-ready');
if (!token) throw new Error('Session token is unavailable');
if (cancelled) return;
const user = await syncUser(token);
recordWebStartup('account-ready');
if (cancelled) return;
if (user.username) {
router.replace("/(tabs)/ask");
Expand All @@ -82,43 +89,74 @@ function LandingPageContent() {
initialize().catch(error => {
if (cancelled) return;
console.warn('Unable to initialize session', error);
if (sessionRetry > 0) {
showSignInError('You are signed in, but PathFinder could not connect to the server. Please try again.');
}
setSessionError('You are signed in, but PathFinder could not connect to the server. Please try again.');
});
return () => { cancelled = true; };
}, [isLoaded, isSignedIn, getToken, router, sessionRetry]);

useEffect(() => {
if (!loginRequested || !isLoaded || oauthPending.current) return;
// A failed backend sync does not end the Google session. Retry that sync.
if (!loginRequested || !isLoaded) return;
if (isSignedIn) {
oauthPending.current = false;
setLoginRequested(false);
setSessionRetry(attempt => attempt + 1);
return;
}
if (oauthPending.current) return;
oauthPending.current = true;
// Load destination code during OAuth, without mounting either screen.
void Promise.all([import('./(tabs)/ask'), import('./(tabs)/profile')]).catch(console.warn);
async function login() {
let activated = false;
try {
const { createdSessionId, setActive } = await startOAuthFlow();
if (createdSessionId && setActive) {
await setActive({ session: createdSessionId });
activated = true;
// Keep the landing page hidden until useAuth observes the active session.
} else {
setLoginRequested(false);
}
} catch (err) {
console.warn('OAuth error', err);
showSignInError('Google sign-in could not complete. Please try again.');
} finally {
oauthPending.current = false;
setLoginRequested(false);
} finally {
if (!activated) oauthPending.current = false;
}
}
void login();
}, [loginRequested, isLoaded, isSignedIn, startOAuthFlow]);

const onPressGoogle = () => setLoginRequested(true);

// Only confirmed signed-out visitors should see the public homepage.
if (!isLoaded || isSignedIn || loginRequested) {
return (
<View style={{ flex: 1, backgroundColor: '#FAF9F6', alignItems: 'center', justifyContent: 'center', padding: 24 }}>
{isLoaded && isSignedIn && sessionError ? (
<View style={{ width: '100%', maxWidth: 400, alignItems: 'center', gap: 20 }}>
<Text accessibilityRole="alert" style={{ color: UI.foreground, fontSize: 16, textAlign: 'center' }}>
{sessionError}
</Text>
<TouchableOpacity
accessibilityRole="button"
onPress={() => {
// A failed backend sync does not end the Google session. Retry that sync.
setSessionError(null);
setSessionRetry(attempt => attempt + 1);
}}
style={{ backgroundColor: UI.accent, borderRadius: 12, paddingHorizontal: 24, paddingVertical: 14 }}
>
<Text style={{ color: UI.onDark, fontSize: 16 }}>Try again</Text>
</TouchableOpacity>
</View>
) : (
<ActivityIndicator size="large" color={UI.accent} accessibilityLabel="Opening PathFinder" />
)}
</View>
);
}

if (desktop) return <DesktopLanding onPressGoogle={onPressGoogle} />;

return (
Expand Down
8 changes: 8 additions & 0 deletions frontend/components/landing/DesktopLanding.web.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Asset } from 'expo-asset';
import { useFonts } from 'expo-font';
import { ArchivoNarrow_400Regular } from '@expo-google-fonts/archivo-narrow/400Regular';
import { ArchivoNarrow_700Bold } from '@expo-google-fonts/archivo-narrow/700Bold';
import { Feather, MaterialCommunityIcons } from '@expo/vector-icons';
import {
JOURNEY_TAGS,
Expand Down Expand Up @@ -233,6 +236,7 @@ function LandingStory() {
</div>
</div>
</section>
<div className="st-closing">
<section className="st-vision">
<div className="st-inner">
<p className="st-label">Our vision</p>
Expand Down Expand Up @@ -290,11 +294,15 @@ function LandingStory() {
</p>
</div>
</footer>
</div>
</div>
);
}

export default function DesktopLanding({ onPressGoogle }: DesktopLandingProps) {
// Load these weights only when the desktop homepage is mounted.
useFonts({ ArchivoNarrow_400Regular, ArchivoNarrow_700Bold });

return (
<main className="pf-landing">
<div className="continuity">
Expand Down
66 changes: 43 additions & 23 deletions frontend/components/landing/desktopLanding.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.pf-landing .continuity {
min-height: 100vh;
min-height: 100dvh;
display: grid;
grid-template-rows: auto 1fr;
background: #0a0f1d;
color: #fff;
}
Expand Down Expand Up @@ -53,6 +57,7 @@
color: #ff9652;
}
.pf-landing .continuity .hero {
margin: 0 auto;
display: grid;
grid-template-columns: minmax(0, 1.07fr) minmax(0, 1fr);
gap: clamp(35px, 6vw, 105px);
Expand All @@ -66,11 +71,11 @@
margin: 0;
}
.pf-landing .continuity h1 {
font-size: clamp(56px, 5.05vw, 80px);
line-height: 1.02;
font-size: clamp(42px, 3.8vw, 64px);
line-height: 1.08;
font-weight: 400;
letter-spacing: -0.03em;
font-family: InstrumentSerif_400Regular, Georgia, serif;
font-family: ArchivoNarrow_700Bold, Arial, sans-serif;
}
.pf-landing .continuity h1 .line {
display: block;
Expand Down Expand Up @@ -122,6 +127,7 @@
min-width: 0;
}
.pf-landing .continuity .journey h2 {
font-family: ArchivoNarrow_400Regular, Arial, sans-serif;
color: #142235;
font-size: clamp(23px, 1.81vw, 30px);
font-weight: 400;
Expand Down Expand Up @@ -182,6 +188,7 @@
box-shadow: none;
}
.pf-landing .continuity .stage {
font-family: ArchivoNarrow_400Regular, Arial, sans-serif;
font-size: 14px;
line-height: 19px;
font-weight: 400;
Expand Down Expand Up @@ -218,7 +225,7 @@
background: var(--st-paper);
color: var(--st-text);
font:
400 16px/1.65 Manrope_400Regular,
400 16px/1.65 ArchivoNarrow_400Regular,
Arial,
sans-serif;
letter-spacing: normal;
Expand Down Expand Up @@ -261,7 +268,7 @@
.pf-story h2,
.pf-story h3,
.pf-story h4 {
font-family: Manrope_400Regular, Arial, sans-serif;
font-family: ArchivoNarrow_400Regular, Arial, sans-serif;
color: inherit;
text-transform: none;
}
Expand Down Expand Up @@ -293,7 +300,7 @@
}
.pf-story .st-label {
font:
400 11px/1.4 Manrope_700Bold,
400 11px/1.4 ArchivoNarrow_700Bold,
Arial,
sans-serif;
letter-spacing: 0.14em;
Expand All @@ -303,9 +310,9 @@
}
.pf-story h2.st-heading {
font:
400 clamp(32px, 3.35vw, 52px)/1.13 InstrumentSerif_400Regular,
Georgia,
serif;
400 clamp(30px, 3vw, 46px)/1.15 ArchivoNarrow_700Bold,
Arial,
sans-serif;
letter-spacing: -0.03em;
max-width: 24ch;
text-wrap: balance;
Expand Down Expand Up @@ -443,9 +450,9 @@
.pf-story .st-question-list li:before {
content: '“';
font:
27px/0.9 InstrumentSerif_400Regular,
Georgia,
serif;
27px/0.9 ArchivoNarrow_400Regular,
Arial,
sans-serif;
color: #9a4409;
transform: translateY(4px);
}
Expand Down Expand Up @@ -587,7 +594,7 @@
}
.pf-story .st-langs li {
font:
400 14px/1.4 Manrope_400Regular,
400 14px/1.4 ArchivoNarrow_400Regular,
'Nirmala UI',
Arial,
sans-serif;
Expand Down Expand Up @@ -629,6 +636,19 @@
line-height: 1.55;
margin-top: 3px;
}
.pf-story .st-closing {
min-height: 100vh;
min-height: 100dvh;
display: flex;
flex-direction: column;
background: var(--st-navy);
color: #fff;
}
.pf-story .st-closing .st-vision {
flex: 1;
display: flex;
align-items: center;
}
.pf-story .st-vision,
.pf-story .st-footer {
background: var(--st-navy);
Expand All @@ -638,16 +658,16 @@
color: #ff9a56;
}
.pf-story .st-vision .st-inner {
padding-bottom: clamp(50px, 5.5vw, 80px);
padding: clamp(32px, 4vh, 56px) 0;
}
.pf-story .st-vision blockquote {
font:
400 clamp(33px, 4.7vw, 73px)/1.04 InstrumentSerif_400Regular,
Georgia,
serif;
400 clamp(32px, 3.4vw, 52px)/1.15 ArchivoNarrow_700Bold,
Arial,
sans-serif;
letter-spacing: -0.03em;
color: #f9f6ef;
max-width: 27ch;
max-width: 36ch;
}
.pf-story .st-vision .st-copy {
color: #b1b5bd;
Expand Down Expand Up @@ -710,7 +730,7 @@
}
.pf-story .st-contact h2 {
font-size: 20px;
font-family: Manrope_700Bold, Arial, sans-serif;
font-family: ArchivoNarrow_700Bold, Arial, sans-serif;
color: #f6f3ed;
}
.pf-story .st-contact-grid {
Expand All @@ -721,7 +741,7 @@
}
.pf-story .st-contact-person h3 {
font-size: 14px;
font-family: Manrope_700Bold, Arial, sans-serif;
font-family: ArchivoNarrow_700Bold, Arial, sans-serif;
color: #f6f3ed;
margin-bottom: 12px;
}
Expand All @@ -746,7 +766,7 @@
flex: 1;
min-height: 0;
overflow-y: auto;
font-family: Manrope_400Regular, Arial, sans-serif;
font-family: ArchivoNarrow_400Regular, Arial, sans-serif;
color: #152238;
background: #faf9f6;
}
Expand All @@ -756,8 +776,8 @@
box-sizing: border-box;
}
.pf-landing
:is(button, .journey h2, h3, h4, b, strong, .stage, .st-platform b) {
font-family: Manrope_700Bold, Arial, sans-serif;
:is(button, h3, h4, b, strong, .st-platform b) {
font-family: ArchivoNarrow_700Bold, Arial, sans-serif;
font-weight: 400;
}
.pf-landing .login {
Expand Down
Loading
Loading