mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
Greatly simplify the login and signup dialogs
This commit is contained in:
6 files changed
+243
-640
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
// NOTE: This file is stable and usually should not be modified.
|
// NOTE: This file is stable and usually should not be modified.
|
||||||
// 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 { ChevronDown, LogOut, UserIcon, UserPlus, Wallet } from 'lucide-react';
|
import { ChevronDown, LogOut, UserIcon, UserPlus } from 'lucide-react';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/components/ui/dropdown-menu.tsx';
|
} from '@/components/ui/dropdown-menu.tsx';
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar.tsx';
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar.tsx';
|
||||||
import { WalletModal } from '@/components/WalletModal';
|
|
||||||
import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts';
|
import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts';
|
||||||
import { genUserName } from '@/lib/genUserName';
|
import { genUserName } from '@/lib/genUserName';
|
||||||
|
|
||||||
@@ -60,15 +59,6 @@ export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) {
|
|||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
))}
|
))}
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<WalletModal>
|
|
||||||
<DropdownMenuItem
|
|
||||||
className='flex items-center gap-2 cursor-pointer p-2 rounded-md'
|
|
||||||
onSelect={(e) => e.preventDefault()}
|
|
||||||
>
|
|
||||||
<Wallet className='w-4 h-4' />
|
|
||||||
<span>Wallet Settings</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</WalletModal>
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={onAddAccountClick}
|
onClick={onAddAccountClick}
|
||||||
className='flex items-center gap-2 cursor-pointer p-2 rounded-md'
|
className='flex items-center gap-2 cursor-pointer p-2 rounded-md'
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// 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 { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { User, UserPlus } from 'lucide-react';
|
|
||||||
import { Button } from '@/components/ui/button.tsx';
|
import { Button } from '@/components/ui/button.tsx';
|
||||||
import LoginDialog from './LoginDialog';
|
import LoginDialog from './LoginDialog';
|
||||||
import SignupDialog from './SignupDialog';
|
import SignupDialog from './SignupDialog';
|
||||||
@@ -34,15 +33,13 @@ export function LoginArea({ className }: LoginAreaProps) {
|
|||||||
onClick={() => setLoginDialogOpen(true)}
|
onClick={() => setLoginDialogOpen(true)}
|
||||||
className='flex items-center gap-2 px-4 py-2 rounded-full bg-primary text-primary-foreground w-full font-medium transition-all hover:bg-primary/90 animate-scale-in'
|
className='flex items-center gap-2 px-4 py-2 rounded-full bg-primary text-primary-foreground w-full font-medium transition-all hover:bg-primary/90 animate-scale-in'
|
||||||
>
|
>
|
||||||
<User className='w-4 h-4' />
|
|
||||||
<span className='truncate'>Log in</span>
|
<span className='truncate'>Log in</span>
|
||||||
</Button><Button
|
</Button><Button
|
||||||
onClick={() => setSignupDialogOpen(true)}
|
onClick={() => setSignupDialogOpen(true)}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="flex items-center gap-2 px-4 py-2 rounded-full font-medium transition-all"
|
className="flex items-center gap-2 px-4 py-2 rounded-full font-medium transition-all"
|
||||||
>
|
>
|
||||||
<UserPlus className="w-4 h-4" />
|
<span>Sign up</span>
|
||||||
<span>Sign Up</span>
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -51,7 +48,6 @@ export function LoginArea({ className }: LoginAreaProps) {
|
|||||||
isOpen={loginDialogOpen}
|
isOpen={loginDialogOpen}
|
||||||
onClose={() => setLoginDialogOpen(false)}
|
onClose={() => setLoginDialogOpen(false)}
|
||||||
onLogin={handleLogin}
|
onLogin={handleLogin}
|
||||||
onSignup={() => setSignupDialogOpen(true)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SignupDialog
|
<SignupDialog
|
||||||
|
|||||||
+151
-187
@@ -2,20 +2,20 @@
|
|||||||
// 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, { useRef, useState, useEffect } from 'react';
|
import React, { useRef, useState, useEffect } from 'react';
|
||||||
import { Shield, Upload, AlertTriangle, UserPlus, KeyRound, Sparkles, Cloud } from 'lucide-react';
|
import { Upload, AlertTriangle, ChevronDown } 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 { Dialog, DialogContent, DialogHeader, DialogDescription } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogHeader } from "@/components/ui/dialog";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||||
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
|
||||||
import { useLoginActions } from '@/hooks/useLoginActions';
|
import { useLoginActions } from '@/hooks/useLoginActions';
|
||||||
import { cn } from '@/lib/utils';
|
import { DialogTitle } from '@radix-ui/react-dialog';
|
||||||
|
|
||||||
interface LoginDialogProps {
|
interface LoginDialogProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onLogin: () => void;
|
onLogin: () => void;
|
||||||
onSignup?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const validateNsec = (nsec: string) => {
|
const validateNsec = (nsec: string) => {
|
||||||
@@ -26,7 +26,7 @@ const validateBunkerUri = (uri: string) => {
|
|||||||
return uri.startsWith('bunker://');
|
return uri.startsWith('bunker://');
|
||||||
};
|
};
|
||||||
|
|
||||||
const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onSignup }) => {
|
const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin }) => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isFileLoading, setIsFileLoading] = useState(false);
|
const [isFileLoading, setIsFileLoading] = useState(false);
|
||||||
const [nsec, setNsec] = useState('');
|
const [nsec, setNsec] = useState('');
|
||||||
@@ -170,203 +170,167 @@ const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onS
|
|||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSignupClick = () => {
|
const hasExtension = 'nostr' in window;
|
||||||
onClose();
|
const [isMoreOptionsOpen, setIsMoreOptionsOpen] = useState(false);
|
||||||
if (onSignup) {
|
|
||||||
onSignup();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultTab = 'nostr' in window ? 'extension' : 'key';
|
const renderTabs = () => (
|
||||||
|
<Tabs defaultValue="key" className="w-full">
|
||||||
|
<TabsList className="grid w-full grid-cols-2 bg-muted/80 rounded-lg mb-4">
|
||||||
|
<TabsTrigger value="key" className="flex items-center gap-2">
|
||||||
|
<span>Secret Key</span>
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="bunker" className="flex items-center gap-2">
|
||||||
|
<span>Remote Signer</span>
|
||||||
|
</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
|
|
||||||
|
<TabsContent value='key' className='space-y-4'>
|
||||||
|
<form onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
handleKeyLogin();
|
||||||
|
}} className='space-y-4'>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<Input
|
||||||
|
id='nsec'
|
||||||
|
type="password"
|
||||||
|
value={nsec}
|
||||||
|
onChange={(e) => {
|
||||||
|
setNsec(e.target.value);
|
||||||
|
if (errors.nsec) setErrors(prev => ({ ...prev, nsec: undefined }));
|
||||||
|
}}
|
||||||
|
className={`rounded-lg ${
|
||||||
|
errors.nsec ? 'border-red-500 focus-visible:ring-red-500' : ''
|
||||||
|
}`}
|
||||||
|
placeholder='nsec1...'
|
||||||
|
autoComplete="off"
|
||||||
|
/>
|
||||||
|
{errors.nsec && (
|
||||||
|
<p className="text-sm text-red-500">{errors.nsec}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex space-x-2">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
size="lg"
|
||||||
|
disabled={isLoading || !nsec.trim()}
|
||||||
|
className="flex-1"
|
||||||
|
>
|
||||||
|
{isLoading ? 'Verifying...' : 'Log in'}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
accept=".txt"
|
||||||
|
className="hidden"
|
||||||
|
ref={fileInputRef}
|
||||||
|
onChange={handleFileUpload}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="lg"
|
||||||
|
onClick={() => fileInputRef.current?.click()}
|
||||||
|
disabled={isLoading || isFileLoading}
|
||||||
|
className="px-3"
|
||||||
|
>
|
||||||
|
<Upload className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{errors.file && (
|
||||||
|
<p className="text-sm text-red-500 text-center">{errors.file}</p>
|
||||||
|
)}
|
||||||
|
</form>
|
||||||
|
</TabsContent>
|
||||||
|
|
||||||
|
<TabsContent value='bunker' className='space-y-4'>
|
||||||
|
<form onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
handleBunkerLogin();
|
||||||
|
}} className='space-y-4'>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<Input
|
||||||
|
id='bunkerUri'
|
||||||
|
value={bunkerUri}
|
||||||
|
onChange={(e) => {
|
||||||
|
setBunkerUri(e.target.value);
|
||||||
|
if (errors.bunker) setErrors(prev => ({ ...prev, bunker: undefined }));
|
||||||
|
}}
|
||||||
|
className={`rounded-lg border-gray-300 dark:border-gray-700 focus-visible:ring-primary ${
|
||||||
|
errors.bunker ? 'border-red-500' : ''
|
||||||
|
}`}
|
||||||
|
placeholder='bunker://'
|
||||||
|
autoComplete="off"
|
||||||
|
/>
|
||||||
|
{errors.bunker && (
|
||||||
|
<p className="text-sm text-red-500">{errors.bunker}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
size="lg"
|
||||||
|
className='w-full'
|
||||||
|
disabled={isLoading || !bunkerUri.trim()}
|
||||||
|
>
|
||||||
|
{isLoading ? 'Connecting...' : 'Log in'}
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
</TabsContent>
|
||||||
|
</Tabs>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||||
<DialogContent
|
<DialogContent className="max-w-[95vw] sm:max-w-sm max-h-[90dvh] p-0 gap-6 overflow-hidden rounded-2xl overflow-y-auto">
|
||||||
className={cn("max-w-[95vw] sm:max-w-md max-h-[90vh] max-h-[90dvh] p-0 overflow-hidden rounded-2xl overflow-y-scroll")}
|
<DialogHeader className="px-6 pt-6">
|
||||||
>
|
<DialogTitle className="text-lg font-semibold leading-none tracking-tight text-center">
|
||||||
<DialogHeader className={cn('px-6 pt-6 pb-1 relative')}>
|
Log in
|
||||||
|
</DialogTitle>
|
||||||
<DialogDescription className="text-center">
|
|
||||||
Sign up or log in to continue
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className='px-6 pt-2 pb-4 space-y-4 overflow-y-auto flex-1'>
|
|
||||||
{/* Prominent Sign Up Section */}
|
|
||||||
<div className='relative p-4 rounded-2xl bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-blue-950/50 dark:to-indigo-950/50 border border-blue-200 dark:border-blue-800 overflow-hidden'>
|
|
||||||
<div className='relative z-10 text-center space-y-3'>
|
|
||||||
<div className='flex justify-center items-center gap-2 mb-2'>
|
|
||||||
<Sparkles className='w-5 h-5 text-blue-600' />
|
|
||||||
<span className='font-semibold text-blue-800 dark:text-blue-200'>
|
|
||||||
New to Nostr?
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p className='text-sm text-blue-700 dark:text-blue-300'>
|
|
||||||
Create a new account to get started. It's free and open.
|
|
||||||
</p>
|
|
||||||
<Button
|
|
||||||
onClick={handleSignupClick}
|
|
||||||
className='w-full rounded-full py-3 text-base 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 border-0'
|
|
||||||
>
|
|
||||||
<UserPlus className='w-4 h-4 mr-2' />
|
|
||||||
<span>Sign Up</span>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Divider */}
|
<div className="flex size-40 text-8xl bg-primary/10 rounded-full items-center justify-center justify-self-center">
|
||||||
<div className='relative'>
|
🔑
|
||||||
<div className='absolute inset-0 flex items-center'>
|
</div>
|
||||||
<div className='w-full border-t border-gray-300 dark:border-gray-600'></div>
|
|
||||||
</div>
|
|
||||||
<div className='relative flex justify-center text-sm'>
|
|
||||||
<span className='px-3 bg-background text-muted-foreground'>
|
|
||||||
<span>Or log in</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Login Methods */}
|
<div className='px-6 pb-6 space-y-4 overflow-y-auto'>
|
||||||
<Tabs defaultValue={defaultTab} className="w-full">
|
{/* Extension Login Button - shown if extension is available */}
|
||||||
<TabsList className="grid w-full grid-cols-3 bg-muted/80 rounded-lg mb-4">
|
{hasExtension && (
|
||||||
<TabsTrigger value="extension" className="flex items-center gap-2">
|
<div className="space-y-4">
|
||||||
<Shield className="w-4 h-4" />
|
|
||||||
<span>Extension</span>
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger value="key" className="flex items-center gap-2">
|
|
||||||
<KeyRound className="w-4 h-4" />
|
|
||||||
<span>Key</span>
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger value="bunker" className="flex items-center gap-2">
|
|
||||||
<Cloud className="w-4 h-4" />
|
|
||||||
<span>Bunker</span>
|
|
||||||
</TabsTrigger>
|
|
||||||
</TabsList>
|
|
||||||
<TabsContent value='extension' className='space-y-3 bg-muted'>
|
|
||||||
{errors.extension && (
|
{errors.extension && (
|
||||||
<Alert variant="destructive">
|
<Alert variant="destructive">
|
||||||
<AlertTriangle className="h-4 w-4" />
|
<AlertTriangle className="h-4 w-4" />
|
||||||
<AlertDescription>{errors.extension}</AlertDescription>
|
<AlertDescription>{errors.extension}</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
<div className='text-center p-4 rounded-lg bg-gray-50 dark:bg-gray-800'>
|
<Button
|
||||||
<Shield className='w-12 h-12 mx-auto mb-3 text-primary' />
|
className="w-full h-12 px-9"
|
||||||
<p className='text-sm text-gray-600 dark:text-gray-300 mb-4'>
|
onClick={handleExtensionLogin}
|
||||||
Login with one click using the browser extension
|
disabled={isLoading}
|
||||||
</p>
|
>
|
||||||
<div className="flex justify-center">
|
{isLoading ? 'Logging in...' : 'Log in with Extension'}
|
||||||
<Button
|
</Button>
|
||||||
className='w-full rounded-full py-4'
|
</div>
|
||||||
onClick={handleExtensionLogin}
|
)}
|
||||||
disabled={isLoading}
|
|
||||||
>
|
|
||||||
{isLoading ? 'Logging in...' : 'Login with Extension'}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value='key' className='space-y-4'>
|
{/* Tabs - wrapped in collapsible if extension is available, otherwise shown directly */}
|
||||||
<div className='space-y-4'>
|
{hasExtension ? (
|
||||||
<div className='space-y-2'>
|
<Collapsible className="space-y-4" open={isMoreOptionsOpen} onOpenChange={setIsMoreOptionsOpen}>
|
||||||
<label htmlFor='nsec' className='text-sm font-medium'>
|
<CollapsibleTrigger asChild>
|
||||||
Secret Key (nsec)
|
<button className="w-full flex items-center justify-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors">
|
||||||
</label>
|
<span>More Options</span>
|
||||||
<Input
|
<ChevronDown className={`w-4 h-4 transition-transform ${isMoreOptionsOpen ? 'rotate-180' : ''}`} />
|
||||||
id='nsec'
|
</button>
|
||||||
type="password"
|
</CollapsibleTrigger>
|
||||||
value={nsec}
|
|
||||||
onChange={(e) => {
|
|
||||||
setNsec(e.target.value);
|
|
||||||
if (errors.nsec) setErrors(prev => ({ ...prev, nsec: undefined }));
|
|
||||||
}}
|
|
||||||
className={`rounded-lg ${
|
|
||||||
errors.nsec ? 'border-red-500 focus-visible:ring-red-500' : ''
|
|
||||||
}`}
|
|
||||||
placeholder='nsec1...'
|
|
||||||
autoComplete="off"
|
|
||||||
/>
|
|
||||||
{errors.nsec && (
|
|
||||||
<p className="text-sm text-red-500">{errors.nsec}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Button
|
<CollapsibleContent>
|
||||||
className='w-full rounded-full py-3'
|
{renderTabs()}
|
||||||
onClick={handleKeyLogin}
|
</CollapsibleContent>
|
||||||
disabled={isLoading || !nsec.trim()}
|
</Collapsible>
|
||||||
>
|
) : (
|
||||||
{isLoading ? 'Verifying...' : 'Log In'}
|
renderTabs()
|
||||||
</Button>
|
)}
|
||||||
|
|
||||||
<div className='relative'>
|
|
||||||
<div className='absolute inset-0 flex items-center'>
|
|
||||||
<div className='w-full border-t border-muted'></div>
|
|
||||||
</div>
|
|
||||||
<div className='relative flex justify-center text-xs'>
|
|
||||||
<span className='px-2 bg-background text-muted-foreground'>
|
|
||||||
or
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='text-center'>
|
|
||||||
<input
|
|
||||||
type='file'
|
|
||||||
accept='.txt'
|
|
||||||
className='hidden'
|
|
||||||
ref={fileInputRef}
|
|
||||||
onChange={handleFileUpload}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
variant='outline'
|
|
||||||
className='w-full'
|
|
||||||
onClick={() => fileInputRef.current?.click()}
|
|
||||||
disabled={isLoading || isFileLoading}
|
|
||||||
>
|
|
||||||
<Upload className='w-4 h-4 mr-2' />
|
|
||||||
{isFileLoading ? 'Reading File...' : 'Upload Your Key File'}
|
|
||||||
</Button>
|
|
||||||
{errors.file && (
|
|
||||||
<p className="text-sm text-red-500 mt-2">{errors.file}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value='bunker' className='space-y-3 bg-muted'>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<label htmlFor='bunkerUri' className='text-sm font-medium text-gray-700 dark:text-gray-400'>
|
|
||||||
Bunker URI
|
|
||||||
</label>
|
|
||||||
<Input
|
|
||||||
id='bunkerUri'
|
|
||||||
value={bunkerUri}
|
|
||||||
onChange={(e) => {
|
|
||||||
setBunkerUri(e.target.value);
|
|
||||||
if (errors.bunker) setErrors(prev => ({ ...prev, bunker: undefined }));
|
|
||||||
}}
|
|
||||||
className={`rounded-lg border-gray-300 dark:border-gray-700 focus-visible:ring-primary ${
|
|
||||||
errors.bunker ? 'border-red-500' : ''
|
|
||||||
}`}
|
|
||||||
placeholder='bunker://'
|
|
||||||
autoComplete="off"
|
|
||||||
/>
|
|
||||||
{errors.bunker && (
|
|
||||||
<p className="text-sm text-red-500">{errors.bunker}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-center">
|
|
||||||
<Button
|
|
||||||
className='w-full rounded-full py-4'
|
|
||||||
onClick={handleBunkerLogin}
|
|
||||||
disabled={isLoading || !bunkerUri.trim()}
|
|
||||||
>
|
|
||||||
{isLoading ? 'Connecting...' : 'Login with Bunker'}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -2,35 +2,26 @@
|
|||||||
// 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, Upload, Eye, EyeOff } 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';
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
|
||||||
import { toast } from '@/hooks/useToast';
|
import { toast } from '@/hooks/useToast';
|
||||||
import { useLoginActions } from '@/hooks/useLoginActions';
|
import { useLoginActions } from '@/hooks/useLoginActions';
|
||||||
import { useNostrPublish } from '@/hooks/useNostrPublish';
|
import { useNostrPublish } from '@/hooks/useNostrPublish';
|
||||||
import { useUploadFile } from '@/hooks/useUploadFile';
|
import { useUploadFile } from '@/hooks/useUploadFile';
|
||||||
import { generateSecretKey, nip19 } from 'nostr-tools';
|
import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools';
|
||||||
import { cn } from '@/lib/utils';
|
|
||||||
|
|
||||||
interface SignupDialogProps {
|
interface SignupDialogProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onComplete?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const sanitizeFilename = (filename: string) => {
|
const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose }) => {
|
||||||
return filename.replace(/[^a-z0-9_.-]/gi, '_');
|
const [step, setStep] = useState<'generate' | 'download' | 'profile'>('generate');
|
||||||
}
|
|
||||||
|
|
||||||
const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete }) => {
|
|
||||||
const [step, setStep] = useState<'welcome' | 'generate' | 'download' | 'profile' | 'done'>('welcome');
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
const [nsec, setNsec] = useState('');
|
const [nsec, setNsec] = useState('');
|
||||||
const [showSparkles, setShowSparkles] = useState(false);
|
const [showKey, setShowKey] = useState(false);
|
||||||
const [keySecured, setKeySecured] = useState<'none' | 'downloaded'>('none');
|
|
||||||
const [profileData, setProfileData] = useState({
|
const [profileData, setProfileData] = useState({
|
||||||
name: '',
|
name: '',
|
||||||
about: '',
|
about: '',
|
||||||
@@ -43,34 +34,9 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
|
|
||||||
// Generate a proper nsec key using nostr-tools
|
// Generate a proper nsec key using nostr-tools
|
||||||
const generateKey = () => {
|
const generateKey = () => {
|
||||||
setIsLoading(true);
|
const sk = generateSecretKey();
|
||||||
setShowSparkles(true);
|
setNsec(nip19.nsecEncode(sk));
|
||||||
|
setStep('download');
|
||||||
// Add a dramatic pause for the key generation effect
|
|
||||||
setTimeout(() => {
|
|
||||||
try {
|
|
||||||
// Generate a new secret key
|
|
||||||
const sk = generateSecretKey();
|
|
||||||
|
|
||||||
// Convert to nsec format
|
|
||||||
setNsec(nip19.nsecEncode(sk));
|
|
||||||
setStep('download');
|
|
||||||
|
|
||||||
toast({
|
|
||||||
title: 'Your Secret Key is Ready!',
|
|
||||||
description: 'A new secret key has been generated for you.',
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
toast({
|
|
||||||
title: 'Error',
|
|
||||||
description: 'Failed to generate key. Please try again.',
|
|
||||||
variant: 'destructive',
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
setShowSparkles(false);
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadKey = () => {
|
const downloadKey = () => {
|
||||||
@@ -79,8 +45,14 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
const blob = new Blob([nsec], { type: 'text/plain; charset=utf-8' });
|
const blob = new Blob([nsec], { type: 'text/plain; charset=utf-8' });
|
||||||
const url = globalThis.URL.createObjectURL(blob);
|
const url = globalThis.URL.createObjectURL(blob);
|
||||||
|
|
||||||
// Sanitize filename
|
const decoded = nip19.decode(nsec);
|
||||||
const filename = sanitizeFilename('nostr-nsec-key.txt');
|
if (decoded.type !== 'nsec') {
|
||||||
|
throw new Error('Invalid nsec key');
|
||||||
|
}
|
||||||
|
|
||||||
|
const pubkey = getPublicKey(decoded.data);
|
||||||
|
const npub = nip19.npubEncode(pubkey);
|
||||||
|
const filename = `nostr-${location.hostname.replaceAll(/\./g, '-')}-${npub.slice(5, 9)}.nsec.txt`;
|
||||||
|
|
||||||
// Create a temporary link element and trigger download
|
// Create a temporary link element and trigger download
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
@@ -94,32 +66,13 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
globalThis.URL.revokeObjectURL(url);
|
globalThis.URL.revokeObjectURL(url);
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
|
|
||||||
// Mark as secured
|
// Continue to profile step
|
||||||
setKeySecured('downloaded');
|
|
||||||
|
|
||||||
toast({
|
|
||||||
title: 'Secret Key Saved!',
|
|
||||||
description: 'Your key has been safely stored.',
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
toast({
|
|
||||||
title: 'Download failed',
|
|
||||||
description: 'Could not download the key file. Please copy it manually.',
|
|
||||||
variant: 'destructive',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const finishKeySetup = () => {
|
|
||||||
try {
|
|
||||||
login.nsec(nsec);
|
login.nsec(nsec);
|
||||||
setStep('profile');
|
setStep('profile');
|
||||||
} catch {
|
} catch {
|
||||||
toast({
|
toast({
|
||||||
title: 'Login Failed',
|
title: 'Download failed',
|
||||||
description: 'Failed to login with the generated key. Please try again.',
|
description: 'Could not download the key file. Please copy it manually.',
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -158,10 +111,6 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
const url = tags[0]?.[1];
|
const url = tags[0]?.[1];
|
||||||
if (url) {
|
if (url) {
|
||||||
setProfileData(prev => ({ ...prev, picture: url }));
|
setProfileData(prev => ({ ...prev, picture: url }));
|
||||||
toast({
|
|
||||||
title: 'Avatar uploaded!',
|
|
||||||
description: 'Your avatar has been uploaded successfully.',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
toast({
|
toast({
|
||||||
@@ -173,9 +122,6 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
};
|
};
|
||||||
|
|
||||||
const finishSignup = async (skipProfile = false) => {
|
const finishSignup = async (skipProfile = false) => {
|
||||||
// Mark signup completion time for fallback welcome modal
|
|
||||||
localStorage.setItem('signup_completed', Date.now().toString());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Publish profile if user provided information
|
// Publish profile if user provided information
|
||||||
if (!skipProfile && (profileData.name || profileData.about || profileData.picture)) {
|
if (!skipProfile && (profileData.name || profileData.about || profileData.picture)) {
|
||||||
@@ -188,30 +134,6 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
kind: 0,
|
kind: 0,
|
||||||
content: JSON.stringify(metadata),
|
content: JSON.stringify(metadata),
|
||||||
});
|
});
|
||||||
|
|
||||||
toast({
|
|
||||||
title: 'Profile Created!',
|
|
||||||
description: 'Your profile has been set up.',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close signup and show welcome modal
|
|
||||||
onClose();
|
|
||||||
if (onComplete) {
|
|
||||||
// Add a longer delay to ensure login state has fully propagated
|
|
||||||
setTimeout(() => {
|
|
||||||
onComplete();
|
|
||||||
}, 600);
|
|
||||||
} else {
|
|
||||||
// Fallback for when used without onComplete
|
|
||||||
setStep('done');
|
|
||||||
setTimeout(() => {
|
|
||||||
onClose();
|
|
||||||
toast({
|
|
||||||
title: 'Welcome!',
|
|
||||||
description: 'Your account is ready.',
|
|
||||||
});
|
|
||||||
}, 3000);
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
toast({
|
toast({
|
||||||
@@ -219,372 +141,111 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
description: 'Your account was created but profile setup failed. You can update it later.',
|
description: 'Your account was created but profile setup failed. You can update it later.',
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
// Still proceed to completion even if profile failed
|
|
||||||
onClose();
|
onClose();
|
||||||
if (onComplete) {
|
|
||||||
// Add a longer delay to ensure login state has fully propagated
|
|
||||||
setTimeout(() => {
|
|
||||||
onComplete();
|
|
||||||
}, 600);
|
|
||||||
} else {
|
|
||||||
// Fallback for when used without onComplete
|
|
||||||
setStep('done');
|
|
||||||
setTimeout(() => {
|
|
||||||
onClose();
|
|
||||||
toast({
|
|
||||||
title: 'Welcome!',
|
|
||||||
description: 'Your account is ready.',
|
|
||||||
});
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTitle = () => {
|
const getTitle = () => {
|
||||||
if (step === 'welcome') return (
|
if (step === 'generate') return 'Sign up';
|
||||||
<span className="flex items-center justify-center gap-2">
|
if (step === 'download') return 'Secret Key';
|
||||||
Create Your Account
|
if (step === 'profile') return 'Create Your Profile';
|
||||||
</span>
|
|
||||||
);
|
|
||||||
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('generate');
|
||||||
setIsLoading(false);
|
|
||||||
setNsec('');
|
setNsec('');
|
||||||
setShowSparkles(false);
|
setShowKey(false);
|
||||||
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="max-w-[95vw] sm:max-w-sm max-h-[90dvh] p-0 gap-6 overflow-hidden rounded-2xl overflow-y-auto">
|
||||||
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="px-6 pt-6">
|
||||||
>
|
<DialogTitle className="text-lg font-semibold leading-none tracking-tight text-center">
|
||||||
<DialogHeader className={cn('px-6 pt-6 pb-1 relative flex-shrink-0')}>
|
|
||||||
<DialogTitle className={cn('font-semibold text-center 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 pb-6 space-y-4 overflow-y-auto flex-1'>
|
||||||
<div className='grid grid-cols-1 gap-2 text-sm'>
|
{/* Generate Step */}
|
||||||
<div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'>
|
|
||||||
<Shield className='w-4 h-4' />
|
|
||||||
Decentralized and censorship-resistant
|
|
||||||
</div>
|
|
||||||
<div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'>
|
|
||||||
<User className='w-4 h-4' />
|
|
||||||
You are in control of your data
|
|
||||||
</div>
|
|
||||||
<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 className='space-y-3'>
|
|
||||||
<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'
|
|
||||||
onClick={() => setStep('generate')}
|
|
||||||
>
|
|
||||||
<LogIn className='w-5 h-5 mr-2' />
|
|
||||||
Get Started
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Generate Step - Enhanced with animations */}
|
|
||||||
{step === 'generate' && (
|
{step === 'generate' && (
|
||||||
<div className='text-center space-y-4'>
|
<div className='text-center space-y-6'>
|
||||||
<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="flex size-40 text-8xl bg-primary/10 rounded-full items-center justify-center justify-self-center">
|
||||||
{/* Animated background elements */}
|
🔑
|
||||||
{showSparkles && (
|
|
||||||
<div className='absolute inset-0'>
|
|
||||||
{[...Array(12)].map((_, i) => (
|
|
||||||
<Sparkles
|
|
||||||
key={i}
|
|
||||||
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 && (
|
<Button className="w-full h-12 px-9" onClick={generateKey}>
|
||||||
<Button
|
Generate key
|
||||||
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'
|
</Button>
|
||||||
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='space-y-4'>
|
||||||
{/* Key reveal */}
|
<div className="flex size-16 text-4xl bg-primary/10 rounded-full items-center justify-center justify-self-center">
|
||||||
<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'>
|
🔑
|
||||||
{/* Sparkles */}
|
|
||||||
<div className='absolute inset-0 pointer-events-none'>
|
|
||||||
<Sparkles className='absolute top-3 left-4 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '0s'}} />
|
|
||||||
<Sparkles className='absolute top-6 right-6 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '0.5s'}} />
|
|
||||||
<Sparkles className='absolute bottom-4 left-6 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '1s'}} />
|
|
||||||
<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 */}
|
<div className="relative">
|
||||||
|
<Input
|
||||||
|
type={showKey ? "text" : "password"}
|
||||||
{/* Security options */}
|
value={nsec}
|
||||||
<div className='space-y-3'>
|
readOnly
|
||||||
|
className="pr-10 font-mono text-sm"
|
||||||
|
/>
|
||||||
<div className='grid grid-cols-1 gap-2'>
|
|
||||||
{/* Download Option */}
|
|
||||||
<Card className={`cursor-pointer transition-all duration-200 ${
|
|
||||||
keySecured === 'downloaded'
|
|
||||||
? 'ring-2 ring-green-500 bg-green-50 dark:bg-green-950/20'
|
|
||||||
: 'hover:bg-primary/5 hover:border-primary/20'
|
|
||||||
}`}>
|
|
||||||
<CardContent className='p-3'>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
className='w-full h-auto p-0 justify-start hover:bg-transparent'
|
|
||||||
onClick={downloadKey}
|
|
||||||
>
|
|
||||||
<div className='flex items-center gap-3 w-full'>
|
|
||||||
<div className={`p-1.5 rounded-lg ${
|
|
||||||
keySecured === 'downloaded'
|
|
||||||
? 'bg-green-100 dark:bg-green-900'
|
|
||||||
: 'bg-primary/10'
|
|
||||||
}`}>
|
|
||||||
{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>
|
|
||||||
</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 ${
|
type="button"
|
||||||
keySecured === 'downloaded'
|
variant="ghost"
|
||||||
? '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'
|
size="icon"
|
||||||
: 'bg-gradient-to-r from-blue-600/60 to-indigo-600/60 text-muted cursor-not-allowed'
|
className="absolute right-0 top-0 h-full px-3 hover:bg-transparent"
|
||||||
}`}
|
onClick={() => setShowKey(!showKey)}
|
||||||
onClick={finishKeySetup}
|
|
||||||
disabled={keySecured !== 'downloaded'}
|
|
||||||
>
|
>
|
||||||
<LogIn className='w-4 h-4 mr-2 flex-shrink-0' />
|
{showKey ? (
|
||||||
<span className="text-center leading-tight">
|
<EyeOff className="h-4 w-4 text-muted-foreground" />
|
||||||
{keySecured === 'none' ? (
|
) : (
|
||||||
<>
|
<Eye className="h-4 w-4 text-muted-foreground" />
|
||||||
Please download your key first
|
)}
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<span className="hidden sm:inline">My Key is Safe - Continue</span>
|
|
||||||
<span className="sm:hidden">Key Secured - Continue</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
className="w-full h-12 px-9"
|
||||||
|
onClick={downloadKey}
|
||||||
|
>
|
||||||
|
<Download className="size-4" />
|
||||||
|
Download key
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<div className='mx-auto max-w-sm'>
|
||||||
|
<div className='p-3 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-800'>
|
||||||
|
<div className='flex items-center gap-2 mb-1'>
|
||||||
|
<span className='text-xs font-semibold text-amber-800 dark:text-amber-200'>
|
||||||
|
Important Warning
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p className='text-xs text-amber-900 dark:text-amber-300'>
|
||||||
|
This key is your primary and only means of accessing your account. Store it safely and securely. Please download your key to continue.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Profile Step - Optional profile setup */}
|
{/* Profile Step */}
|
||||||
{step === 'profile' && (
|
{step === 'profile' && (
|
||||||
<div className='text-center space-y-4'>
|
<div className='text-center space-y-4'>
|
||||||
{/* Profile setup 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 overflow-hidden'>
|
|
||||||
{/* Sparkles */}
|
|
||||||
<div className='absolute inset-0 pointer-events-none'>
|
|
||||||
<Sparkles className='absolute top-3 left-4 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '0s'}} />
|
|
||||||
<Sparkles className='absolute top-6 right-6 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '0.5s'}} />
|
|
||||||
<Sparkles className='absolute bottom-4 left-6 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '1s'}} />
|
|
||||||
</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>
|
|
||||||
|
|
||||||
{/* Publishing status indicator */}
|
{/* Publishing status indicator */}
|
||||||
{isPublishing && (
|
{isPublishing && (
|
||||||
<div className='relative p-4 rounded-xl bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/30 dark:to-indigo-950/30 border border-blue-200 dark:border-blue-800'>
|
<div className='p-4 rounded-lg bg-muted border'>
|
||||||
<div className='flex items-center justify-center gap-3'>
|
<div className='flex items-center justify-center gap-3'>
|
||||||
<div className='w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full animate-spin' />
|
<div className='w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin' />
|
||||||
<span className='text-sm font-medium text-blue-700 dark:text-blue-300'>
|
<span className='text-sm font-medium'>
|
||||||
Publishing your profile...
|
Publishing your profile...
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -602,7 +263,6 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
value={profileData.name}
|
value={profileData.name}
|
||||||
onChange={(e) => setProfileData(prev => ({ ...prev, name: e.target.value }))}
|
onChange={(e) => setProfileData(prev => ({ ...prev, name: e.target.value }))}
|
||||||
placeholder='Your name'
|
placeholder='Your name'
|
||||||
className='rounded-lg'
|
|
||||||
disabled={isPublishing}
|
disabled={isPublishing}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -616,7 +276,7 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
value={profileData.about}
|
value={profileData.about}
|
||||||
onChange={(e) => setProfileData(prev => ({ ...prev, about: e.target.value }))}
|
onChange={(e) => setProfileData(prev => ({ ...prev, about: e.target.value }))}
|
||||||
placeholder='Tell others about yourself...'
|
placeholder='Tell others about yourself...'
|
||||||
className='rounded-lg resize-none'
|
className='resize-none'
|
||||||
rows={3}
|
rows={3}
|
||||||
disabled={isPublishing}
|
disabled={isPublishing}
|
||||||
/>
|
/>
|
||||||
@@ -632,7 +292,7 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
value={profileData.picture}
|
value={profileData.picture}
|
||||||
onChange={(e) => setProfileData(prev => ({ ...prev, picture: e.target.value }))}
|
onChange={(e) => setProfileData(prev => ({ ...prev, picture: e.target.value }))}
|
||||||
placeholder='https://example.com/your-avatar.jpg'
|
placeholder='https://example.com/your-avatar.jpg'
|
||||||
className='rounded-lg flex-1'
|
className='flex-1'
|
||||||
disabled={isPublishing}
|
disabled={isPublishing}
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
@@ -648,7 +308,6 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
size='icon'
|
size='icon'
|
||||||
onClick={() => avatarFileInputRef.current?.click()}
|
onClick={() => avatarFileInputRef.current?.click()}
|
||||||
disabled={isUploading || isPublishing}
|
disabled={isUploading || isPublishing}
|
||||||
className='rounded-lg shrink-0'
|
|
||||||
title='Upload avatar image'
|
title='Upload avatar image'
|
||||||
>
|
>
|
||||||
{isUploading ? (
|
{isUploading ? (
|
||||||
@@ -664,7 +323,7 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
{/* Action buttons */}
|
{/* Action buttons */}
|
||||||
<div className='space-y-3'>
|
<div className='space-y-3'>
|
||||||
<Button
|
<Button
|
||||||
className='w-full rounded-full py-4 text-base 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 disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none'
|
className='w-full'
|
||||||
onClick={() => finishSignup(false)}
|
onClick={() => finishSignup(false)}
|
||||||
disabled={isPublishing || isUploading}
|
disabled={isPublishing || isUploading}
|
||||||
>
|
>
|
||||||
@@ -674,24 +333,18 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
|||||||
Creating Profile...
|
Creating Profile...
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
'Create profile'
|
||||||
<User className='w-4 h-4 mr-2' />
|
|
||||||
Create Profile & Finish
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant='outline'
|
variant='outline'
|
||||||
className='w-full rounded-full py-3 disabled:opacity-50 disabled:cursor-not-allowed'
|
className='w-full'
|
||||||
onClick={() => finishSignup(true)}
|
onClick={() => finishSignup(true)}
|
||||||
disabled={isPublishing || isUploading}
|
disabled={isPublishing || isUploading}
|
||||||
>
|
>
|
||||||
{isPublishing ? (
|
{isPublishing ? (
|
||||||
<>
|
'Setting up account...'
|
||||||
<div className='w-4 h-4 mr-2 border-2 border-current border-t-transparent rounded-full animate-spin' />
|
|
||||||
Setting up account...
|
|
||||||
</>
|
|
||||||
) : (
|
) : (
|
||||||
'Skip for now'
|
'Skip for now'
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const DialogContent = React.forwardRef<
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||||
<X className="h-4 w-4" />
|
<X className="size-5" />
|
||||||
<span className="sr-only">Close</span>
|
<span className="sr-only">Close</span>
|
||||||
</DialogPrimitive.Close>
|
</DialogPrimitive.Close>
|
||||||
</DialogPrimitive.Content>
|
</DialogPrimitive.Content>
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@
|
|||||||
--input: 214.3 31.8% 91.4%;
|
--input: 214.3 31.8% 91.4%;
|
||||||
--ring: 222.2 84% 4.9%;
|
--ring: 222.2 84% 4.9%;
|
||||||
|
|
||||||
--radius: 0.5rem;
|
--radius: 0.75rem;
|
||||||
|
|
||||||
--sidebar-background: 0 0% 98%;
|
--sidebar-background: 0 0% 98%;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user