Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor login and signup pages for improved UI and component structure

Bill Yang506f410f7a04
diff --git a/client/src/app/[site]/components/shared/icons/Browser.tsx b/client/src/app/[site]/components/shared/icons/Browser.tsx
index 49df3e6e1..47b9bacd7 100644
--- a/client/src/app/[site]/components/shared/icons/Browser.tsx
+++ b/client/src/app/[site]/components/shared/icons/Browser.tsx
@@ -1,7 +1,5 @@
-import { m } from "framer-motion";
import { Compass } from "lucide-react";
import Image from "next/image";
-import { cn } from "../../../../../lib/utils";
const BROWSER_TO_LOGO: Record<string, string> = {
Chrome: "Chrome.svg",
diff --git a/client/src/app/login/page.tsx b/client/src/app/login/page.tsx
index 839ade5ae..b6de606a4 100644
--- a/client/src/app/login/page.tsx
+++ b/client/src/app/login/page.tsx
@@ -5,11 +5,11 @@ import { AuthError } from "@/components/auth/AuthError";
import { AuthInput } from "@/components/auth/AuthInput";
import { SocialButtons } from "@/components/auth/SocialButtons";
import { Turnstile } from "@/components/auth/Turnstile";
-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
-import { RybbitLogo } from "../../components/RybbitLogo";
+import { RybbitTextLogo } from "../../components/RybbitLogo";
+import { SpinningGlobe } from "../../components/SpinningGlobe";
import { useSetPageTitle } from "../../hooks/useSetPageTitle";
import { authClient } from "../../lib/auth";
import { useConfigs } from "../../lib/configs";
@@ -72,83 +72,102 @@ export default function Page() {
const turnstileEnabled = IS_CLOUD && process.env.NODE_ENV === "production";
return (
- <div className="flex flex-col justify-between items-center h-dvh w-full p-4">
- <div></div>
- <Card className="w-full max-w-sm p-1">
- <CardHeader>
- <RybbitLogo width={32} height={32} />
- <CardTitle className="text-2xl flex justify-center">Sign in</CardTitle>
- </CardHeader>
- <CardContent>
- <form onSubmit={handleSubmit}>
- <div className="flex flex-col gap-4">
- <AuthInput
- id="email"
- label="Email"
- type="email"
- placeholder="[email protected]"
- required
- value={email}
- onChange={e => setEmail(e.target.value)}
- />
-
- <AuthInput
- id="password"
- label="Password"
- type="password"
- placeholder="••••••••"
- required
- value={password}
- onChange={e => setPassword(e.target.value)}
- rightElement={
- <Link href="/reset-password" className="text-xs text-muted-foreground hover:text-primary">
- Forgot password?
- </Link>
- }
- />
-
- {turnstileEnabled && (
- <Turnstile
- onSuccess={token => setTurnstileToken(token)}
- onError={() => setTurnstileToken("")}
- onExpire={() => setTurnstileToken("")}
- className="flex justify-center"
- />
- )}
-
- <AuthButton
- isLoading={isLoading}
- loadingText="Logging in..."
- disabled={turnstileEnabled ? !turnstileToken || isLoading : isLoading}
- >
- Login
- </AuthButton>
-
- <SocialButtons onError={setError} />
-
- <AuthError error={error} title="Error Logging In" />
-
- {(!configs?.disableSignup || !isLoadingConfigs) && (
- <div className="text-center text-sm">
- Don't have an account?{" "}
- <Link href="/signup" className="underline">
- Sign up
- </Link>
- </div>
- )}
+ <div className="flex h-dvh w-full">
+ {/* Left panel - login form */}
+ <div className="w-full lg:w-[550px] flex flex-col p-6 lg:p-10">
+ {/* Logo at top left */}
+ <div className="mb-8">
+ <a href="https://rybbit.com" target="_blank" className="inline-block">
+ <RybbitTextLogo />
+ </a>
+ </div>
+
+ <div className="flex-1 flex flex-col justify-center w-full max-w-[550px] mx-auto">
+ <h1 className="text-lg text-neutral-600 dark:text-neutral-300 mb-6">Welcome back</h1>
+
+ <div className="flex flex-col gap-4">
+ <SocialButtons onError={setError} showDivider={false} />
+
+ <div className="relative flex justify-center text-xs uppercase">
+ <span className="text-muted-foreground">Or continue with email</span>
</div>
- </form>
- </CardContent>
- </Card>
- <div className="text-xs text-muted-foreground">
- <a
- href="https://rybbit.com"
- target="_blank"
- rel="noopener"
- title="Rybbit - Open Source Privacy-Focused Web Analytics"
- >
- Open source web analytics powered by Rybbit
- </a>
+
+ <form onSubmit={handleSubmit}>
+ <div className="flex flex-col gap-4">
+ <AuthInput
+ id="email"
+ label="Email"
+ type="email"
+ placeholder="[email protected]"
+ required
+ value={email}
+ onChange={e => setEmail(e.target.value)}
+ />
+
+ <AuthInput
+ id="password"
+ label="Password"
+ type="password"
+ placeholder="••••••••"
+ required
+ value={password}
+ onChange={e => setPassword(e.target.value)}
+ rightElement={
+ <Link href="/reset-password" className="text-xs text-muted-foreground hover:text-primary">
+ Forgot password?
+ </Link>
+ }
+ />
+
+ {turnstileEnabled && (
+ <Turnstile
+ onSuccess={token => setTurnstileToken(token)}
+ onError={() => setTurnstileToken("")}
+ onExpire={() => setTurnstileToken("")}
+ className="flex justify-center"
+ />
+ )}
+
+ <AuthButton
+ isLoading={isLoading}
+ loadingText="Logging in..."
+ disabled={turnstileEnabled ? !turnstileToken || isLoading : isLoading}
+ >
+ Login
+ </AuthButton>
+
+ <AuthError error={error} title="Error Logging In" />
+ </div>
+ </form>
+
+ {(!configs?.disableSignup || !isLoadingConfigs) && (
+ <div className="text-center text-sm">
+ Don't have an account?{" "}
+ <Link href="/signup" className="underline underline-offset-4 hover:text-emerald-400 transition-colors duration-300">
+ Sign up
+ </Link>
+ </div>
+ )}
+ </div>
+ </div>
+
+ {!IS_CLOUD && (
+ <div className="text-xs text-muted-foreground mt-8">
+ <a
+ href="https://rybbit.com"
+ target="_blank"
+ rel="noopener"
+ title="Rybbit - Open Source Privacy-Focused Web Analytics"
+ >
+ Open source web analytics powered by Rybbit
+ </a>
+ </div>
+ )}
+ </div>
+
+ {/* Right panel - globe (hidden on mobile/tablet) */}
+ <div className="hidden lg:block lg:w-[calc(100%-550px)] relative m-3 rounded-2xl overflow-hidden">
+ <SpinningGlobe />
</div>
</div>
);
diff --git a/client/src/app/signup/page.tsx b/client/src/app/signup/page.tsx
index 7934ef51b..35587385c 100644
--- a/client/src/app/signup/page.tsx
+++ b/client/src/app/signup/page.tsx
@@ -22,7 +22,7 @@ import { useConfigs } from "../../lib/configs";
import { IS_CLOUD } from "../../lib/const";
import { userStore } from "../../lib/userStore";
import { cn, isValidDomain, normalizeDomain } from "../../lib/utils";
-import { SpinningGlobe } from "./components/SpinningGlobe";
+import { SpinningGlobe } from "../../components/SpinningGlobe";
// Animation variants for step transitions
const contentVariants = {
@@ -195,6 +195,21 @@ export default function SignupPage() {
<motion.div initial="hidden" animate="visible" variants={contentVariants}>
<h2 className="text-2xl font-semibold mb-4">Signup</h2>
<div className="space-y-4">
+ {IS_CLOUD && (
+ <SocialButtons
+ onError={setError}
+ callbackURL="/signup?step=2"
+ mode="signup"
+ showDivider={false}
+ />
+ )}
+
+ {IS_CLOUD && (
+ <div className="relative flex justify-center text-xs uppercase">
+ <span className="text-muted-foreground">Or continue with email</span>
+ </div>
+ )}
+
<AuthInput
id="email"
label="Email"
@@ -236,15 +251,6 @@ export default function SignupPage() {
<ArrowRight className="ml-2 h-4 w-4" />
</AuthButton>
- {IS_CLOUD && (
- <SocialButtons
- onError={setError}
- callbackURL="/signup?step=2"
- mode="signup"
- className="grid grid-cols-2 gap-2"
- />
- )}
-
<div className="text-center text-sm">
Already have an account?{" "}
<Link
@@ -398,26 +404,42 @@ export default function SignupPage() {
<h1 className="text-lg text-neutral-600 dark:text-neutral-300 mb-6">Get started with Rybbit</h1>
{/* Horizontal step indicator */}
- <div className="flex items-center w-full mb-6">
- {[1, 2, 3].map((step, index) => (
+ <div className="flex items-center w-full mb-8">
+ {[
+ { step: 1, label: "Account" },
+ { step: 2, label: "Organization" },
+ { step: 3, label: "Website" },
+ ].map(({ step, label }, index) => (
<React.Fragment key={step}>
- <div
- className={cn(
- "flex items-center justify-center w-10 h-10 rounded-full text-sm font-semibold transition-all duration-300",
- currentStep === step
- ? "bg-emerald-600 text-primary-foreground"
- : currentStep > step
- ? "bg-emerald-600/20 text-emerald-400 border-2 border-emerald-600/40"
- : "bg-muted-foreground/20 text-muted-foreground border-2 border-muted-foreground/40"
- )}
- >
- {currentStep > step ? <Check className="h-5 w-5" /> : step}
+ <div className="flex flex-col items-center gap-2">
+ <div
+ className={cn(
+ "flex items-center justify-center w-8 h-8 rounded-full text-xs font-medium transition-all duration-300",
+ currentStep === step
+ ? "bg-emerald-600 text-white shadow-lg shadow-emerald-600/30"
+ : currentStep > step
+ ? "bg-emerald-600 text-white"
+ : "bg-neutral-200 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400"
+ )}
+ >
+ {currentStep > step ? <Check className="h-4 w-4" /> : step}
+ </div>
+ <span
+ className={cn(
+ "text-xs font-medium transition-colors duration-300",
+ currentStep >= step
+ ? "text-neutral-900 dark:text-neutral-100"
+ : "text-neutral-400 dark:text-neutral-500"
+ )}
+ >
+ {label}
+ </span>
</div>
{index < 2 && (
<div
className={cn(
- "flex-1 h-0.5 transition-all duration-300",
- currentStep > step ? "bg-emerald-600" : "bg-muted-foreground/40"
+ "flex-1 h-0.5 mx-3 mb-6 transition-all duration-300 rounded-full",
+ currentStep > step ? "bg-emerald-600" : "bg-neutral-200 dark:bg-neutral-800"
)}
/>
)}
diff --git a/client/src/app/signup/components/SpinningGlobe.tsx b/client/src/components/SpinningGlobe.tsx
similarity index 88%
rename from client/src/app/signup/components/SpinningGlobe.tsx
rename to client/src/components/SpinningGlobe.tsx
index bcda2d662..fd129cf3c 100644
--- a/client/src/app/signup/components/SpinningGlobe.tsx
+++ b/client/src/components/SpinningGlobe.tsx
@@ -5,9 +5,9 @@ import mapboxgl from "mapbox-gl";
import "mapbox-gl/dist/mapbox-gl.css";
import { useEffect, useRef, useState } from "react";
import { useQuery } from "@tanstack/react-query";
-import type { GetSessionsResponse } from "../../../api/analytics/useGetUserSessions";
-import { useConfigs } from "../../../lib/configs";
-import "../../[site]/globe/globe.css";
+import type { GetSessionsResponse } from "../api/analytics/useGetUserSessions";
+import { useConfigs } from "../lib/configs";
+import "../app/[site]/globe/globe.css";
// Constants
const SOURCE_ID = "demo-sessions";
@@ -26,7 +26,7 @@ import BoringAvatar from "boring-avatars";
import { createElement } from "react";
// @ts-ignore - React 19 has built-in types
import { renderToStaticMarkup } from "react-dom/server";
-import { AVATAR_COLORS } from "../../../components/Avatar";
+import { AVATAR_COLORS } from "./Avatar";
function generateAvatarSVG(userId: string, size: number): string {
const avatarElement = createElement(BoringAvatar, {
@@ -112,13 +112,16 @@ type MarkerData = {
element: HTMLDivElement;
};
+// Spin configuration
+const SECONDS_PER_REVOLUTION = 120;
+const MAX_SPIN_ZOOM = 5;
+const SLOW_SPIN_ZOOM = 3;
+
export function SpinningGlobe() {
const containerRef = useRef<HTMLDivElement>(null);
const mapRef = useRef<mapboxgl.Map | null>(null);
- const animationRef = useRef<number | null>(null);
const markersMapRef = useRef<Map<string, MarkerData>>(new Map());
const isUserInteractingRef = useRef(false);
- const resumeSpinTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const [mapLoaded, setMapLoaded] = useState(false);
const { configs, isLoading: isLoadingConfigs } = useConfigs();
@@ -127,15 +130,13 @@ export function SpinningGlobe() {
queryKey: ["demo-sessions"],
queryFn: async () => {
const response = await fetch(
- "https://demo.rybbit.com/api/sessions/1?past_minutes_start=1440&past_minutes_end=0&filters=[]&page=1&limit=1000"
+ "https://demo.rybbit.com/api/sessions/1?past_minutes_start=120&past_minutes_end=0&filters=[]&page=1&limit=100"
);
return response.json();
},
staleTime: Infinity,
});
- console.log("sessionsData", sessionsData);
-
const sessions = sessionsData?.data || [];
// Initialize map
@@ -256,53 +257,59 @@ export function SpinningGlobe() {
map.getCanvas().style.cursor = "";
});
- // Pause spinning when user interacts
- const handleInteractionStart = () => {
- isUserInteractingRef.current = true;
- if (resumeSpinTimeoutRef.current) {
- clearTimeout(resumeSpinTimeoutRef.current);
- resumeSpinTimeoutRef.current = null;
+ // Spin globe function using easeTo for smooth animation
+ const spinGlobe = () => {
+ if (!mapRef.current) return;
+ const zoom = mapRef.current.getZoom();
+ if (!isUserInteractingRef.current && zoom < MAX_SPIN_ZOOM) {
+ let distancePerSecond = 360 / SECONDS_PER_REVOLUTION;
+ if (zoom > SLOW_SPIN_ZOOM) {
+ // Slow spinning at higher zooms
+ const zoomDif = (MAX_SPIN_ZOOM - zoom) / (MAX_SPIN_ZOOM - SLOW_SPIN_ZOOM);
+ distancePerSecond *= zoomDif;
+ }
+ const center = mapRef.current.getCenter();
+ center.lng -= distancePerSecond;
+ // Smoothly animate the map over one second
+ mapRef.current.easeTo({ center, duration: 1000, easing: n => n });
}
};
- const handleInteractionEnd = () => {
- // Resume spinning after 2 seconds of no interaction
- resumeSpinTimeoutRef.current = setTimeout(() => {
- isUserInteractingRef.current = false;
- }, 2000);
- };
+ // Pause spinning on interaction
+ map.on("mousedown", () => {
+ isUserInteractingRef.current = true;
+ });
- map.on("dragstart", handleInteractionStart);
- map.on("dragend", handleInteractionEnd);
- map.on("zoomstart", handleInteractionStart);
- map.on("zoomend", handleInteractionEnd);
+ // Restart spinning after interaction ends
+ map.on("mouseup", () => {
+ isUserInteractingRef.current = false;
+ spinGlobe();
+ });
+ map.on("dragend", () => {
+ isUserInteractingRef.current = false;
+ spinGlobe();
+ });
+ map.on("pitchend", () => {
+ isUserInteractingRef.current = false;
+ spinGlobe();
+ });
+ map.on("rotateend", () => {
+ isUserInteractingRef.current = false;
+ spinGlobe();
+ });
+
+ // When animation completes, spin again (creates continuous rotation)
+ map.on("moveend", () => {
+ spinGlobe();
+ });
setMapLoaded(true);
- // Start spinning animation
- // const spinGlobe = () => {
- // if (!mapRef.current) return;
- // // Only spin if user is not interacting
- // if (!isUserInteractingRef.current) {
- // const center = mapRef.current.getCenter();
- // center.lng += 0.01;
- // mapRef.current.setCenter(center);
- // }
- // animationRef.current = requestAnimationFrame(spinGlobe);
- // };
-
- // spinGlobe();
+ // Start spinning
+ spinGlobe();
});
return () => {
- if (animationRef.current) {
- cancelAnimationFrame(animationRef.current);
- animationRef.current = null;
- }
- if (resumeSpinTimeoutRef.current) {
- clearTimeout(resumeSpinTimeoutRef.current);
- resumeSpinTimeoutRef.current = null;
- }
// Clear markers
markersMapRef.current.forEach(({ marker }) => marker.remove());
markersMapRef.current.clear();
diff --git a/client/src/components/auth/SocialButtons.tsx b/client/src/components/auth/SocialButtons.tsx
index eeca2bed0..82b46e2e1 100644
--- a/client/src/components/auth/SocialButtons.tsx
+++ b/client/src/components/auth/SocialButtons.tsx
@@ -4,15 +4,25 @@ import { Button } from "@/components/ui/button";
import { SiGoogle, SiGithub } from "@icons-pack/react-simple-icons";
import { authClient } from "@/lib/auth";
import { IS_CLOUD } from "@/lib/const";
+import Image from "next/image";
interface SocialButtonsProps {
onError: (error: string) => void;
callbackURL?: string;
mode?: "signin" | "signup";
className?: string;
+ showDivider?: boolean;
+ dividerText?: string;
}
-export function SocialButtons({ onError, callbackURL, mode = "signin", className = "" }: SocialButtonsProps) {
+export function SocialButtons({
+ onError,
+ callbackURL,
+ mode = "signin",
+ className = "",
+ showDivider = true,
+ dividerText = "Or continue with",
+}: SocialButtonsProps) {
if (!IS_CLOUD) return null;
const handleSocialAuth = async (provider: "google" | "github" | "twitter") => {
@@ -30,18 +40,20 @@ export function SocialButtons({ onError, callbackURL, mode = "signin", className
return (
<>
- <div className="relative flex justify-center text-xs uppercase">
- <span className="text-muted-foreground">Or continue with</span>
- </div>
+ {showDivider && (
+ <div className="relative flex justify-center text-xs uppercase">
+ <span className="text-muted-foreground">{dividerText}</span>
+ </div>
+ )}
<div className={`flex flex-col gap-2 ${className}`}>
- <Button type="button" onClick={() => handleSocialAuth("google")}>
- <SiGoogle />
- Google
+ <Button type="button" onClick={() => handleSocialAuth("google")} className="h-11">
+ <Image src="/crawlers/Google.svg" alt="Google" width={16} height={16} />
+ Continue with Google
</Button>
- <Button type="button" onClick={() => handleSocialAuth("github")}>
+ <Button type="button" onClick={() => handleSocialAuth("github")} className="h-11">
<SiGithub />
- GitHub
+ Continue with GitHub
</Button>
</div>
</>
diff --git a/client/src/hooks/useTrack.ts b/client/src/hooks/useTrack.ts
index 166ad7ba6..eb6dd22b2 100644
--- a/client/src/hooks/useTrack.ts
+++ b/client/src/hooks/useTrack.ts
@@ -14,7 +14,7 @@ export function useTrack() {
const user = authClient.useSession();
useEffect(() => {
- if (typeof window !== "undefined" && user.data?.user?.id && window.rybbit && !isLoading && !isLoadingSites) {
+ if (typeof window !== "undefined" && user.data?.user?.id && window?.rybbit && !isLoading && !isLoadingSites) {
window.rybbit?.identify(user.data?.user?.id, {
email: user.data?.user?.email,
name: user.data?.user?.name,
@@ -23,12 +23,5 @@ export function useTrack() {
sites: sites?.sites.map(site => site.domain),
});
}
- }, [
- user.data?.user?.id,
- window.rybbit,
- subscription?.planName,
- isLoading,
- isPendingActiveOrganization,
- isPendingSites,
- ]);
+ }, [user.data?.user?.id, subscription?.planName, isLoading, isPendingActiveOrganization, isPendingSites]);
}