import { useState, useEffect } from "react"; import { X, ChevronRight, Loader2, AlertCircle } from "lucide-react"; import { BlackskyIcon, NorthskyIcon, BlueskyIcon, TopphieIcon } from "./Icons"; import { startSignup } from "../api/client"; import logo from "../assets/logo.svg"; const RECOMMENDED_PROVIDER = { id: "margin", name: "Margin", service: "https://pds.margin.at", Icon: null, description: "Hosted by Margin, the easiest way to get started", isMargin: true, }; const OTHER_PROVIDERS = [ { id: "bluesky", name: "Bluesky", service: "https://bsky.social", Icon: BlueskyIcon, description: "The main network", }, { id: "blacksky", name: "Blacksky", service: "https://blacksky.app", Icon: BlackskyIcon, description: "For the Culture. A safe space for Black users and allies", }, { id: "northsky", name: "Northsky", service: "https://northsky.social", Icon: NorthskyIcon, description: "A Canadian-based worker-owned cooperative", }, { id: "topphie", name: "Topphie", service: "https://tophhie.social", Icon: TopphieIcon, description: "A welcoming and friendly community", }, { id: "altq", name: "AltQ", service: "https://altq.net", Icon: null, description: "An independent, self-hosted PDS instance", }, { id: "custom", name: "Custom", service: "", custom: true, Icon: null, description: "Connect to your own or another custom PDS", }, ]; export default function SignUpModal({ onClose }) { const [showOtherProviders, setShowOtherProviders] = useState(false); const [showCustomInput, setShowCustomInput] = useState(false); const [customService, setCustomService] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { document.body.style.overflow = "hidden"; return () => { document.body.style.overflow = "unset"; }; }, []); const handleProviderSelect = async (provider) => { if (provider.custom) { setShowCustomInput(true); return; } setLoading(true); setError(null); try { const result = await startSignup(provider.service); if (result.authorizationUrl) { window.location.href = result.authorizationUrl; } } catch (err) { console.error(err); setError("Could not connect to this provider. Please try again."); setLoading(false); } }; const handleCustomSubmit = async (e) => { e.preventDefault(); if (!customService.trim()) return; setLoading(true); setError(null); let serviceUrl = customService.trim(); if (!serviceUrl.startsWith("http")) { serviceUrl = `https://${serviceUrl}`; } try { const result = await startSignup(serviceUrl); if (result.authorizationUrl) { window.location.href = result.authorizationUrl; } } catch (err) { console.error(err); setError("Could not connect to this PDS. Please check the URL."); setLoading(false); } }; return (
Connecting to provider...
Margin uses the AT Protocol — the same decentralized network that powers Bluesky. Your account will be hosted on a server of your choice.
{error && (