Author SHA1 Message Date
lemonknowsall 0df8d23477 Edit with Shakespeare Agent Instruction 2025-09-21 00:10:16 -07:00
3 changed files with 313 additions and 123 deletions

No files matched your search

+26
View File
@@ -108,6 +108,32 @@ The AI assistant's behavior and knowledge is defined by the AGENTS.md file, whic
When building the site for the first time, include "Vibed with MKStack" somewhere in the UI, linked to this URL: https://soapbox.pub/mkstack When building the site for the first time, include "Vibed with MKStack" somewhere in the UI, linked to this URL: https://soapbox.pub/mkstack
## "Edit with Shakespeare"
When building the site for the first time, also include "Edit with Shakespeare" somewhere in the UI, linked to this URL template:
http://act2.shakespeare.diy/clone?url=${base_url}/sourcecode.zip
Replace `${base_url}` with the base url of the deployed site.
**Example implementation:**
```tsx
<div className="flex items-center gap-4 text-sm text-muted-foreground">
<a
href="https://soapbox.pub/mkstack"
className="hover:text-foreground transition-colors"
>
Vibed with MKStack
</a>
<a
href={`http://act2.shakespeare.diy/clone?url=${window.location.origin}/sourcecode.zip`}
className="hover:text-foreground transition-colors"
>
Edit with Shakespeare
</a>
</div>
```
## Nostr Protocol Integration ## Nostr Protocol Integration
This project comes with custom hooks for querying and publishing events on the Nostr network. This project comes with custom hooks for querying and publishing events on the Nostr network.
-5
View File
@@ -57,11 +57,6 @@ 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>
); );
+287 -118
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, CheckCircle, User, Upload } from 'lucide-react'; import { Download, Key, UserPlus, FileText, Shield, User, Sparkles, LogIn, CheckCircle, Upload, Globe } 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, onLogin, onOpenLogin }) => { const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete }) => {
const [step, setStep] = useState<'key' | 'keygen' | 'download' | 'profile' | 'done'>('key'); 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 [keySecured, setKeySecured] = useState<'none' | 'downloaded'>('none'); const [keySecured, setKeySecured] = useState<'none' | 'downloaded'>('none');
const [profileData, setProfileData] = useState({ const [profileData, setProfileData] = useState({
name: '', name: '',
@@ -41,8 +41,10 @@ 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);
const handleGenerateKey = () => { // Generate a proper nsec key using nostr-tools
setStep('keygen'); const generateKey = () => {
setIsLoading(true);
setShowSparkles(true);
// Add a dramatic pause for the key generation effect // Add a dramatic pause for the key generation effect
setTimeout(() => { setTimeout(() => {
@@ -64,18 +66,13 @@ 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',
}); });
setStep('key'); } finally {
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
@@ -113,6 +110,8 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
} }
}; };
const finishKeySetup = () => { const finishKeySetup = () => {
try { try {
login.nsec(nsec); login.nsec(nsec);
@@ -243,154 +242,302 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
}; };
const getTitle = () => { const getTitle = () => {
if (step === 'key') return 'Sign up'; if (step === 'welcome') return (
if (step === 'keygen') return 'Generating Your Key'; <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>
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('key'); setStep('welcome');
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-left text-lg')}> <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>
<div className='px-6 pt-2 pb-6 space-y-6 flex-1'> {/* Benefits */}
{/* Initial Key Step - Soapbox style */} <div className='grid grid-cols-1 gap-2 text-sm'>
{step === 'key' && ( <div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'>
<div className='flex flex-col items-center space-y-6'> <Shield className='w-4 h-4' />
<p className='text-center font-semibold'> Decentralized and censorship-resistant
You need a key to continue </div>
</p> <div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'>
<User className='w-4 h-4' />
<div className='rounded-full bg-gray-100 p-8 dark:bg-gray-800'> You are in control of your data
<div className='text-8xl'> </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> </div>
<div className='flex flex-col items-center space-y-3 w-full'> <div className='space-y-3'>
<Button <Button
className='bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-2xl' 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'
size='lg' onClick={() => setStep('generate')}
onClick={handleGenerateKey}
> >
Generate key <LogIn className='w-5 h-5 mr-2' />
</Button> Get Started
<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>
)} )}
{/* Key Generation Step */} {/* Generate Step - Enhanced with animations */}
{step === 'keygen' && ( {step === 'generate' && (
<div className='text-center space-y-4'> <div className='text-center space-y-4'>
<div className='space-y-2'> <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'>
<p className='text-lg font-semibold'> {/* Animated background elements */}
Generating your secret key... {showSparkles && (
</p> <div className='absolute inset-0'>
<p className='text-sm text-muted-foreground'> {[...Array(12)].map((_, i) => (
Creating your secure key <Sparkles
</p> 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>
<div className='flex justify-center'> {!isLoading && (
<div className='w-8 h-8 border-4 border-blue-600 border-t-transparent rounded-full animate-spin'></div> <Button
</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'
onClick={generateKey}
disabled={isLoading}
>
<Sparkles className='w-5 h-5 mr-2' />
Generate My Secret Key
</Button>
)}
</div> </div>
)} )}
{/* Download Step */} {/* Download Step - Whimsical and magical */}
{step === 'download' && ( {step === 'download' && (
<div className='text-center space-y-4'> <div className='text-center space-y-4'>
<div className='space-y-2'> {/* Key reveal */}
<p className='text-lg font-semibold'> <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'>
Your secret key has been generated! {/* Sparkles */}
</p> <div className='absolute inset-0 pointer-events-none'>
<p className='text-sm text-muted-foreground'> <Sparkles className='absolute top-3 left-4 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '0s'}} />
Please download and save your key securely. <Sparkles className='absolute top-6 right-6 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '0.5s'}} />
</p> <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>
<div className='space-y-3'> {/* Key vault */}
<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>
{/* Security options */}
<div className='space-y-3'>
<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 ${ 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 hover:scale-105' ? '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/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>
@@ -398,16 +545,38 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
</div> </div>
)} )}
{/* Profile Setup Step */} {/* Profile Step - Optional profile setup */}
{step === 'profile' && ( {step === 'profile' && (
<div className='text-center space-y-4'> <div className='text-center space-y-4'>
<div className='space-y-2'> {/* Profile setup illustration */}
<p className='text-lg font-semibold'> <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'>
Almost there! Let's set up your profile {/* Sparkles */}
</p> <div className='absolute inset-0 pointer-events-none'>
<p className='text-sm text-muted-foreground'> <Sparkles className='absolute top-3 left-4 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '0s'}} />
Your profile is your identity on Nostr. <Sparkles className='absolute top-6 right-6 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '0.5s'}} />
</p> <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> </div>
{/* Publishing status indicator */} {/* Publishing status indicator */}