Author SHA1 Message Date
P. Reis 2474609a5a Fix SignupDialog: remove scrollbar, left-align title, add rounded corners to buttons 2025-09-22 17:28:34 -03:00
P. Reis ea5932490a Improve SignupDialog key icon: make larger, add grey background, fix scrollbar 2025-09-22 17:03:58 -03:00
P. Reis 3db5148780 add back tutorial when generating a new key 2025-09-22 16:18:41 -03:00
P. Reis a0bd6729ae Refactor SignupDialog to match Soapbox design with improved UX
- Simplify SignupDialog UI to clean Soapbox-style layout with key emoji
- Fix button width to match text size instead of full width
- Implement proper key generation flow using existing generateSecretKey code
- Replace toast message with direct login modal opening for 'I already have a key'
- Remove duplicate NostrExtensionIndicator (LoginDialog already handles extensions)
- Update LoginArea to handle modal transitions between signup and login
- Maintain 3-step flow: key selection → generation → confirmation
- Reuse existing MKStack functionality instead of reinventing wheel
2025-09-22 14:31:39 -03:00
P. Reis 05c0ec92f7 Remake SignupDialog with simplified Soapbox-style design
- Replace complex multi-step signup flow with simple key-focused design
- Add NostrExtensionIndicator component for browser extension detection
- Simplify UI to match Soapbox key-step design with emoji and clean layout
- Remove unused profile setup, key generation, and download functionality
- Keep extension login and placeholder for future key generation
- Maintain existing props interface for compatibility with LoginArea
2025-09-22 13:04:41 -03:00
2 changed files with 121 additions and 285 deletions

No files matched your search

+5
View File
@@ -57,6 +57,11 @@ export function LoginArea({ className }: LoginAreaProps) {
<SignupDialog <SignupDialog
isOpen={signupDialogOpen} isOpen={signupDialogOpen}
onClose={() => setSignupDialogOpen(false)} onClose={() => setSignupDialogOpen(false)}
onLogin={handleLogin}
onOpenLogin={() => {
setSignupDialogOpen(false);
setLoginDialogOpen(true);
}}
/> />
</div> </div>
); );
+116 -285
View File
@@ -2,7 +2,7 @@
// It is important that all functionality in this file is preserved, and should only be modified if explicitly requested. // It is important that all functionality in this file is preserved, and should only be modified if explicitly requested.
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { Download, Key, UserPlus, FileText, Shield, User, Sparkles, LogIn, CheckCircle, Upload, Globe } from 'lucide-react'; import { Download, CheckCircle, User, Upload } from 'lucide-react';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea'; import { Textarea } from '@/components/ui/textarea';
@@ -19,17 +19,17 @@ interface SignupDialogProps {
isOpen: boolean; isOpen: boolean;
onClose: () => void; onClose: () => void;
onComplete?: () => void; onComplete?: () => void;
onLogin?: () => void;
onOpenLogin?: () => void;
} }
const sanitizeFilename = (filename: string) => { const sanitizeFilename = (filename: string) => {
return filename.replace(/[^a-z0-9_.-]/gi, '_'); return filename.replace(/[^a-z0-9_.-]/gi, '_');
} }
const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete }) => { const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete, onLogin, onOpenLogin }) => {
const [step, setStep] = useState<'welcome' | 'generate' | 'download' | 'profile' | 'done'>('welcome'); const [step, setStep] = useState<'key' | 'keygen' | 'download' | 'profile' | 'done'>('key');
const [isLoading, setIsLoading] = useState(false);
const [nsec, setNsec] = useState(''); const [nsec, setNsec] = useState('');
const [showSparkles, setShowSparkles] = useState(false);
const [keySecured, setKeySecured] = useState<'none' | 'downloaded'>('none'); const [keySecured, setKeySecured] = useState<'none' | 'downloaded'>('none');
const [profileData, setProfileData] = useState({ const [profileData, setProfileData] = useState({
name: '', name: '',
@@ -41,10 +41,8 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
const { mutateAsync: uploadFile, isPending: isUploading } = useUploadFile(); const { mutateAsync: uploadFile, isPending: isUploading } = useUploadFile();
const avatarFileInputRef = useRef<HTMLInputElement>(null); const avatarFileInputRef = useRef<HTMLInputElement>(null);
// Generate a proper nsec key using nostr-tools const handleGenerateKey = () => {
const generateKey = () => { setStep('keygen');
setIsLoading(true);
setShowSparkles(true);
// Add a dramatic pause for the key generation effect // Add a dramatic pause for the key generation effect
setTimeout(() => { setTimeout(() => {
@@ -66,13 +64,18 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
description: 'Failed to generate key. Please try again.', description: 'Failed to generate key. Please try again.',
variant: 'destructive', variant: 'destructive',
}); });
} finally { setStep('key');
setIsLoading(false);
setShowSparkles(false);
} }
}, 2000); }, 2000);
}; };
const handleHasKey = () => {
onClose();
if (onOpenLogin) {
onOpenLogin();
}
};
const downloadKey = () => { const downloadKey = () => {
try { try {
// Create a blob with the key text // Create a blob with the key text
@@ -110,8 +113,6 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
} }
}; };
const finishKeySetup = () => { const finishKeySetup = () => {
try { try {
login.nsec(nsec); login.nsec(nsec);
@@ -242,302 +243,154 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
}; };
const getTitle = () => { const getTitle = () => {
if (step === 'welcome') return ( if (step === 'key') return 'Sign up';
<span className="flex items-center justify-center gap-2"> if (step === 'keygen') return 'Generating Your Key';
Create Your Account if (step === 'download') return 'Secret Key';
</span> if (step === 'profile') return 'Create Your Profile';
); return 'Welcome!';
if (step === 'generate') return (
<span className="flex items-center justify-center gap-2">
Generating Your Key
</span>
);
if (step === 'download') return (
<span className="flex items-center justify-center gap-2">
Secret Key
</span>
);
if (step === 'profile') return (
<span className="flex items-center justify-center gap-2">
Create Your Profile
</span>
);
return (
<span className="flex items-center justify-center gap-2">
Welcome!
</span>
);
}; };
// Reset state when dialog opens // Reset state when dialog opens
useEffect(() => { useEffect(() => {
if (isOpen) { if (isOpen) {
setStep('welcome'); setStep('key');
setIsLoading(false);
setNsec(''); setNsec('');
setShowSparkles(false);
setKeySecured('none'); setKeySecured('none');
setProfileData({ name: '', about: '', picture: '' }); setProfileData({ name: '', about: '', picture: '' });
} }
}, [isOpen]); }, [isOpen]);
// Add sparkle animation effect
useEffect(() => {
if (showSparkles) {
const interval = setInterval(() => {
// This will trigger re-renders for sparkle animation
}, 100);
return () => clearInterval(interval);
}
}, [showSparkles]);
return ( return (
<Dialog open={isOpen} onOpenChange={onClose}> <Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent <DialogContent
className={cn("max-w-[95vw] sm:max-w-md max-h-[90vh] max-h-[90dvh] p-0 overflow-hidden rounded-2xl flex flex-col")} className={cn("max-w-[95vw] sm:max-w-md max-h-[90vh] max-h-[90dvh] p-0 overflow-hidden rounded-2xl flex flex-col")}
> >
<DialogHeader className={cn('px-6 pt-6 pb-1 relative flex-shrink-0')}> <DialogHeader className={cn('px-6 pt-6 pb-1 relative flex-shrink-0')}>
<DialogTitle className={cn('font-semibold text-center text-lg')}> <DialogTitle className={cn('font-semibold text-left text-lg')}>
{getTitle()} {getTitle()}
</DialogTitle> </DialogTitle>
</DialogHeader> </DialogHeader>
<div className='px-6 pt-2 pb-4 space-y-4 overflow-y-scroll flex-1'>
{/* Welcome Step - New engaging introduction */}
{step === 'welcome' && (
<div className='text-center space-y-4'>
{/* Hero illustration */}
<div className='relative p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-blue-950/50 dark:to-indigo-950/50'>
<div className='flex justify-center items-center space-x-4 mb-3'>
<div className='relative'>
<UserPlus className='w-12 h-12 text-blue-600' />
<Sparkles className='w-4 h-4 text-yellow-500 absolute -top-1 -right-1 animate-pulse' />
</div>
<Globe className='w-16 h-16 text-blue-700 animate-spin-slow' />
<div className='relative'>
<FileText className='w-12 h-12 text-blue-600' />
<Sparkles className='w-4 h-4 text-yellow-500 absolute -top-1 -left-1 animate-pulse' style={{animationDelay: '0.3s'}} />
</div>
</div>
{/* Benefits */} <div className='px-6 pt-2 pb-6 space-y-6 flex-1'>
<div className='grid grid-cols-1 gap-2 text-sm'> {/* Initial Key Step - Soapbox style */}
<div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'> {step === 'key' && (
<Shield className='w-4 h-4' /> <div className='flex flex-col items-center space-y-6'>
Decentralized and censorship-resistant <p className='text-center font-semibold'>
</div> You need a key to continue
<div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'> </p>
<User className='w-4 h-4' />
You are in control of your data <div className='rounded-full bg-gray-100 p-8 dark:bg-gray-800'>
</div> <div className='text-8xl'>
<div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'> 🔑
<Globe className='w-4 h-4' />
Join a global network
</div>
</div> </div>
</div> </div>
<div className='space-y-3'> <div className='flex flex-col items-center space-y-3 w-full'>
<Button <Button
className='w-full rounded-full py-6 text-lg font-semibold bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 transform transition-all duration-200 hover:scale-105 shadow-lg' className='bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-2xl'
onClick={() => setStep('generate')} size='lg'
onClick={handleGenerateKey}
> >
<LogIn className='w-5 h-5 mr-2' /> Generate key
Get Started </Button>
<Button
variant='ghost'
className='text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 rounded-2xl'
onClick={handleHasKey}
>
I already have a key
</Button> </Button>
</div> </div>
</div> </div>
)} )}
{/* Generate Step - Enhanced with animations */} {/* Key Generation Step */}
{step === 'generate' && ( {step === 'keygen' && (
<div className='text-center space-y-4'> <div className='text-center space-y-4'>
<div className='relative p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-purple-100 dark:from-blue-950/50 dark:to-purple-950/50 overflow-hidden'> <div className='space-y-2'>
{/* Animated background elements */} <p className='text-lg font-semibold'>
{showSparkles && ( Generating your secret key...
<div className='absolute inset-0'> </p>
{[...Array(12)].map((_, i) => ( <p className='text-sm text-muted-foreground'>
<Sparkles Creating your secure key
key={i} </p>
className={`absolute w-4 h-4 text-yellow-400 animate-ping`}
style={{
left: `${Math.random() * 80 + 10}%`,
top: `${Math.random() * 80 + 10}%`,
animationDelay: `${Math.random() * 2}s`
}}
/>
))}
</div>
)}
<div className='relative z-10'>
{isLoading ? (
<div className='space-y-3'>
<div className='relative'>
<Key className='w-20 h-20 text-primary mx-auto animate-pulse' />
<div className='absolute inset-0 flex items-center justify-center'>
<div className='w-24 h-24 border-4 border-yellow-400 border-t-transparent rounded-full animate-spin'></div>
</div>
</div>
<div className='space-y-2'>
<p className='text-lg font-semibold text-primary flex items-center justify-center gap-2'>
<Sparkles className='w-5 h-5' />
Generating your secret key...
</p>
<p className='text-sm text-muted-foreground'>
Creating your secure key
</p>
</div>
</div>
) : (
<div className='space-y-3'>
<Key className='w-20 h-20 text-primary mx-auto' />
<div className='space-y-2'>
<p className='text-lg font-semibold'>
Ready to generate your secret key?
</p>
<p className='text-sm text-muted-foreground px-5'>
This key will be your password to access applications within the Nostr network.
</p>
</div>
</div>
)}
</div>
</div> </div>
{!isLoading && ( <div className='flex justify-center'>
<Button <div className='w-8 h-8 border-4 border-blue-600 border-t-transparent rounded-full animate-spin'></div>
className='w-full rounded-full py-6 text-lg font-semibold bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 transform transition-all duration-200 hover:scale-105 shadow-lg' </div>
onClick={generateKey}
disabled={isLoading}
>
<Sparkles className='w-5 h-5 mr-2' />
Generate My Secret Key
</Button>
)}
</div> </div>
)} )}
{/* Download Step - Whimsical and magical */} {/* Download Step */}
{step === 'download' && ( {step === 'download' && (
<div className='text-center space-y-4'> <div className='text-center space-y-4'>
{/* Key reveal */} <div className='space-y-2'>
<div className='relative p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-blue-950/50 dark:to-indigo-950/50 overflow-hidden'> <p className='text-lg font-semibold'>
{/* Sparkles */} Your secret key has been generated!
<div className='absolute inset-0 pointer-events-none'> </p>
<Sparkles className='absolute top-3 left-4 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '0s'}} /> <p className='text-sm text-muted-foreground'>
<Sparkles className='absolute top-6 right-6 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '0.5s'}} /> Please download and save your key securely.
<Sparkles className='absolute bottom-4 left-6 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '1s'}} /> </p>
<Sparkles className='absolute bottom-3 right-4 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '1.5s'}} />
</div>
<div className='relative z-10 flex justify-center items-center mb-3'>
<div className='relative'>
<div className='w-16 h-16 bg-gradient-to-br from-blue-200 to-indigo-300 rounded-full flex items-center justify-center shadow-lg animate-pulse'>
<Key className='w-8 h-8 text-indigo-800' />
</div>
<div className='absolute -top-1 -right-1 w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center animate-bounce'>
<Sparkles className='w-3 h-3 text-white' />
</div>
</div>
</div>
<div className='relative z-10 space-y-2'>
<p className='text-base font-semibold'>
Your secret key has been generated!
</p>
{/* Warning */}
<div className='relative mx-auto max-w-sm'>
<div className='p-3 bg-gradient-to-r from-amber-100 via-yellow-50 to-amber-100 dark:from-amber-950/40 dark:via-yellow-950/20 dark:to-amber-950/40 rounded-lg border-2 border-amber-300 dark:border-amber-700 shadow-md'>
<div className='flex items-center gap-2 mb-1'>
<FileText className='w-3 h-3 text-amber-700' />
<span className='text-xs font-bold text-amber-800 dark:text-amber-200'>
Important Warning
</span>
</div>
<p className='text-xs text-red-700 dark:text-amber-300 italic'>
This key is your primary and only means of accessing your account. Store it safely and securely.
</p>
</div>
</div>
</div>
</div> </div>
{/* Key vault */}
{/* Security options */}
<div className='space-y-3'> <div className='space-y-3'>
<Card className={`cursor-pointer transition-all duration-200 ${
keySecured === 'downloaded'
<div className='grid grid-cols-1 gap-2'> ? 'ring-2 ring-green-500 bg-green-50 dark:bg-green-950/20'
{/* Download Option */} : 'hover:bg-primary/5 hover:border-primary/20'
<Card className={`cursor-pointer transition-all duration-200 ${ }`}>
keySecured === 'downloaded' <CardContent className='p-3'>
? 'ring-2 ring-green-500 bg-green-50 dark:bg-green-950/20' <Button
: 'hover:bg-primary/5 hover:border-primary/20' variant="ghost"
}`}> className='w-full h-auto p-0 justify-start hover:bg-transparent'
<CardContent className='p-3'> onClick={downloadKey}
<Button >
variant="ghost" <div className='flex items-center gap-3 w-full'>
className='w-full h-auto p-0 justify-start hover:bg-transparent' <div className={`p-1.5 rounded-lg ${
onClick={downloadKey} keySecured === 'downloaded'
> ? 'bg-green-100 dark:bg-green-900'
<div className='flex items-center gap-3 w-full'> : 'bg-primary/10'
<div className={`p-1.5 rounded-lg ${ }`}>
keySecured === 'downloaded' {keySecured === 'downloaded' ? (
? 'bg-green-100 dark:bg-green-900' <CheckCircle className='w-4 h-4 text-green-600' />
: 'bg-primary/10' ) : (
}`}> <Download className='w-4 h-4 text-primary' />
{keySecured === 'downloaded' ? ( )}
<CheckCircle className='w-4 h-4 text-green-600' />
) : (
<Download className='w-4 h-4 text-primary' />
)}
</div>
<div className='flex-1 text-left'>
<div className='font-medium text-sm'>
Download as File
</div>
<div className='text-xs text-muted-foreground'>
Save as nostr-nsec-key.txt file
</div>
</div>
{keySecured === 'downloaded' && (
<div className='text-xs font-medium text-green-600'>
✓ Downloaded
</div>
)}
</div> </div>
</Button> <div className='flex-1 text-left'>
</CardContent> <div className='font-medium text-sm'>
</Card> Download as File
</div>
<div className='text-xs text-muted-foreground'>
Save as nostr-nsec-key.txt file
</div>
</div>
{keySecured === 'downloaded' && (
<div className='text-xs font-medium text-green-600'>
✓ Downloaded
</div>
)}
</div>
</Button>
</CardContent>
</Card>
</div>
{/* Continue button */}
<Button <Button
className={`w-full rounded-full py-4 text-base font-semibold transform transition-all duration-200 shadow-lg ${ className={`w-full rounded-full py-4 text-base font-semibold transform transition-all duration-200 shadow-lg ${
keySecured === 'downloaded' keySecured === 'downloaded'
? 'bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 dark:from-blue-950/50 dark:to-purple-950/50 hover:scale-105' ? 'bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 hover:scale-105'
: 'bg-gradient-to-r from-blue-600/60 to-indigo-600/60 text-muted cursor-not-allowed' : 'bg-gradient-to-r from-blue-600/60 to-indigo-600/60 text-muted cursor-not-allowed'
}`} }`}
onClick={finishKeySetup} onClick={finishKeySetup}
disabled={keySecured !== 'downloaded'} disabled={keySecured !== 'downloaded'}
> >
<LogIn className='w-4 h-4 mr-2 flex-shrink-0' />
<span className="text-center leading-tight"> <span className="text-center leading-tight">
{keySecured === 'none' ? ( {keySecured === 'none' ? (
<> 'Please download your key first'
Please download your key first
</>
) : ( ) : (
<> 'My Key is Safe - Continue'
<span className="hidden sm:inline">My Key is Safe - Continue</span>
<span className="sm:hidden">Key Secured - Continue</span>
</>
)} )}
</span> </span>
</Button> </Button>
@@ -545,38 +398,16 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
</div> </div>
)} )}
{/* Profile Step - Optional profile setup */} {/* Profile Setup Step */}
{step === 'profile' && ( {step === 'profile' && (
<div className='text-center space-y-4'> <div className='text-center space-y-4'>
{/* Profile setup illustration */} <div className='space-y-2'>
<div className='relative p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-blue-950/50 dark:to-indigo-950/50 overflow-hidden'> <p className='text-lg font-semibold'>
{/* Sparkles */} Almost there! Let's set up your profile
<div className='absolute inset-0 pointer-events-none'> </p>
<Sparkles className='absolute top-3 left-4 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '0s'}} /> <p className='text-sm text-muted-foreground'>
<Sparkles className='absolute top-6 right-6 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '0.5s'}} /> Your profile is your identity on Nostr.
<Sparkles className='absolute bottom-4 left-6 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '1s'}} /> </p>
</div>
<div className='relative z-10 flex justify-center items-center mb-3'>
<div className='relative'>
<div className='w-16 h-16 bg-gradient-to-br from-blue-200 to-indigo-300 rounded-full flex items-center justify-center shadow-lg'>
<User className='w-8 h-8 text-blue-800' />
</div>
<div className='absolute -top-1 -right-1 w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center animate-bounce'>
<Sparkles className='w-3 h-3 text-white' />
</div>
</div>
</div>
<div className='relative z-10 space-y-2'>
<p className='text-base font-semibold'>
Almost there! Let's set up your profile
</p>
<p className='text-sm text-muted-foreground'>
Your profile is your identity on Nostr.
</p>
</div>
</div> </div>
{/* Publishing status indicator */} {/* Publishing status indicator */}