baseline onboarding flow

This commit is contained in:
Chad Curtis authored and Alex Gleason committed 2025-07-25 12:55:44 -05:00
1 parent ad8844d8c4
commit 0b2aab0527
7 files changed
+597 -2

No files matched your search

@@ -0,0 +1,178 @@
import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { ArrowLeft, ArrowRight, Settings, CheckCircle, Bot } from 'lucide-react';
import { useAISettings } from '@/hooks/useAISettings';
interface AISettingsStepProps {
onNext: () => void;
onPrevious: () => void;
onSkip: () => void;
}
export function AISettingsStep({ onNext, onPrevious, onSkip }: AISettingsStepProps) {
const { settings, updateSettings, isConfigured } = useAISettings();
const [localSettings, setLocalSettings] = useState(settings);
const [isTesting, setIsTesting] = useState(false);
const handleSave = () => {
updateSettings(localSettings);
onNext();
};
const handleTestConnection = async () => {
setIsTesting(true);
try {
// Basic validation - in a real app, you'd test the API connection
if (!localSettings.apiKey.trim()) {
throw new Error('API key is required');
}
if (!localSettings.baseUrl.trim()) {
throw new Error('Base URL is required');
}
if (!localSettings.model.trim()) {
throw new Error('Model is required');
}
// Simulate API test
await new Promise(resolve => setTimeout(resolve, 1000));
// If we get here, save the settings
updateSettings(localSettings);
} catch (error) {
console.error('Failed to test connection:', error);
} finally {
setIsTesting(false);
}
};
const isValid = localSettings.apiKey.trim() && localSettings.baseUrl.trim() && localSettings.model.trim();
return (
<div className="space-y-4">
<div className="text-center space-y-2">
<div className="flex justify-center mb-2">
<Bot className="h-8 w-8 text-primary" />
</div>
<h1 className="text-2xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
Configure AI Settings
</h1>
<p className="text-sm text-muted-foreground max-w-lg mx-auto">
Set up your AI provider to start building with AI assistance.
</p>
</div>
<Card className="max-w-lg mx-auto">
<CardHeader className="pb-3">
<div className="flex items-center gap-2">
<Settings className="h-4 w-4 text-primary" />
<CardTitle className="text-lg">AI Provider</CardTitle>
</div>
<CardDescription className="text-xs">
We recommend OpenRouter for easy setup
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-3">
<div className="space-y-1">
<Label htmlFor="apiKey" className="text-sm">API Key *</Label>
<Input
id="apiKey"
type="password"
placeholder="sk-... or your-api-key"
value={localSettings.apiKey}
onChange={(e) => setLocalSettings({ ...localSettings, apiKey: e.target.value })}
className="font-mono text-sm h-9"
/>
<p className="text-xs text-muted-foreground">
Stored locally, never shared
</p>
</div>
<div className="space-y-1">
<Label htmlFor="baseUrl" className="text-sm">Base URL *</Label>
<Input
id="baseUrl"
placeholder="https://openrouter.ai/api/v1"
value={localSettings.baseUrl}
onChange={(e) => setLocalSettings({ ...localSettings, baseUrl: e.target.value })}
className="text-sm h-9"
/>
</div>
<div className="space-y-1">
<Label htmlFor="model" className="text-sm">Model *</Label>
<Input
id="model"
placeholder="anthropic/claude-sonnet-4"
value={localSettings.model}
onChange={(e) => setLocalSettings({ ...localSettings, model: e.target.value })}
className="text-sm h-9"
/>
</div>
</div>
{isConfigured && (
<div className="flex items-center gap-2 text-green-600">
<CheckCircle className="h-3 w-3" />
<span className="text-xs font-medium">Configured</span>
</div>
)}
<div className="flex gap-2">
<Button
onClick={handleTestConnection}
disabled={!isValid || isTesting}
variant="outline"
size="sm"
className="flex-1 h-8 text-sm"
>
{isTesting ? (
<>
<div className="animate-spin rounded-full h-3 w-3 border-b-2 border-current mr-1"></div>
Testing...
</>
) : (
'Test & Save'
)}
</Button>
</div>
</CardContent>
</Card>
<div className="flex justify-center gap-3 pt-2">
<Button
onClick={onPrevious}
variant="outline"
size="sm"
className="gap-1 h-8 text-sm"
>
<ArrowLeft className="h-3 w-3" />
Back
</Button>
<Button
onClick={handleSave}
disabled={!isValid}
size="sm"
className="gap-1 h-8 text-sm bg-gradient-to-r from-primary to-primary/90"
>
Continue
<ArrowRight className="h-3 w-3" />
</Button>
</div>
<div className="text-center">
<Button
onClick={onSkip}
variant="ghost"
size="sm"
className="text-muted-foreground text-xs h-7"
>
Skip for now
</Button>
</div>
</div>
);
}
@@ -0,0 +1,133 @@
import { useState, useEffect } from 'react';
import { Dialog, DialogContent, DialogTitle, DialogDescription } from '@/components/ui/dialog';
import { Progress } from '@/components/ui/progress';
import { WelcomeStep } from './WelcomeStep';
import { AISettingsStep } from './AISettingsStep';
import { ProjectStep } from './ProjectStep';
interface OnboardingDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onProjectCreated?: (projectId: string) => void;
onComplete: () => void;
currentStep: number;
onNextStep: () => void;
onPreviousStep: () => void;
}
const STEPS = [
{ id: 'welcome', title: 'Welcome' },
{ id: 'ai-settings', title: 'AI Settings' },
{ id: 'project', title: 'Create Project' },
];
export function OnboardingDialog({
open,
onOpenChange,
onProjectCreated,
onComplete,
currentStep: propCurrentStep,
onNextStep,
onPreviousStep
}: OnboardingDialogProps) {
const [localStep, setLocalStep] = useState(propCurrentStep);
// Sync local step with prop when it changes
useEffect(() => {
setLocalStep(propCurrentStep);
}, [propCurrentStep]);
const currentStep = Math.min(localStep, STEPS.length - 1);
const progress = ((currentStep + 1) / STEPS.length) * 100;
const handleNext = () => {
if (currentStep < STEPS.length - 1) {
setLocalStep(prev => prev + 1);
onNextStep();
}
};
const handlePrevious = () => {
if (currentStep > 0) {
setLocalStep(prev => prev - 1);
onPreviousStep();
}
};
const handleSkip = () => {
onComplete();
onOpenChange(false);
};
const handleComplete = () => {
onComplete();
onOpenChange(false);
};
const renderStep = () => {
switch (STEPS[currentStep]?.id) {
case 'welcome':
return (
<WelcomeStep
onNext={handleNext}
onSkip={handleSkip}
/>
);
case 'ai-settings':
return (
<AISettingsStep
onNext={handleNext}
onPrevious={handlePrevious}
onSkip={handleSkip}
/>
);
case 'project':
return (
<ProjectStep
onNext={handleSkip} // Skip to complete
onPrevious={handlePrevious}
onComplete={handleComplete}
onProjectCreated={onProjectCreated}
/>
);
default:
return null;
}
};
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-4xl max-h-[85vh] overflow-y-auto p-0">
<div className="sticky top-0 bg-background border-b p-6 pb-4 z-10">
<DialogTitle className="sr-only">Getting Started Onboarding</DialogTitle>
<DialogDescription className="sr-only">Complete the onboarding process to get started with Shakespeare</DialogDescription>
<div className="space-y-2">
<div className="flex items-center justify-between">
<h2 className="text-lg font-semibold">Getting Started</h2>
<span className="text-sm text-muted-foreground">
Step {currentStep + 1} of {STEPS.length}
</span>
</div>
<div className="relative">
<Progress value={progress} className="h-2" />
</div>
<div className="flex justify-between text-xs text-muted-foreground">
{STEPS.map((step, index) => (
<span
key={step.id}
className={index <= currentStep ? 'text-primary font-medium' : ''}
>
{step.title}
</span>
))}
</div>
</div>
</div>
<div className="p-6 pt-4">
{renderStep()}
</div>
</DialogContent>
</Dialog>
);
}
+113
View File
@@ -0,0 +1,113 @@
import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Textarea } from '@/components/ui/textarea';
import { ArrowLeft, Plus, Sparkles } from 'lucide-react';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useNavigate } from 'react-router-dom';
interface ProjectStepProps {
onNext: () => void;
onPrevious: () => void;
onComplete: () => void;
onProjectCreated?: (projectId: string) => void;
}
export function ProjectStep({ onPrevious, onComplete, onProjectCreated }: ProjectStepProps) {
const [prompt, setPrompt] = useState('');
const [isCreating, setIsCreating] = useState(false);
const projectsManager = useProjectsManager();
const navigate = useNavigate();
const handleCreateProject = async () => {
if (!prompt.trim()) return;
setIsCreating(true);
try {
const project = await projectsManager.createProject(prompt.trim());
onProjectCreated?.(project.id);
onComplete();
navigate(`/project/${project.id}`);
} catch (error) {
console.error('Failed to create project:', error);
} finally {
setIsCreating(false);
}
};
return (
<div className="space-y-6">
<div className="text-center space-y-4">
<div className="flex justify-center mb-2">
<Sparkles className="h-8 w-8 text-primary" />
</div>
<h1 className="text-3xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
Create Your First Project
</h1>
<p className="text-base text-muted-foreground max-w-2xl mx-auto">
Our AI will help you create it step by step.
</p>
</div>
<Card className="max-w-2xl mx-auto">
<CardHeader>
<div className="flex items-center gap-2">
<Sparkles className="h-5 w-5 text-primary" />
<CardTitle>Project Description</CardTitle>
</div>
<CardDescription>
Be as detailed as possible about what you want to build
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<Textarea
placeholder="e.g., Create a farming equipment marketplace for local farmers to buy and sell tractors, tools, and supplies. Include user profiles, product listings with images, search functionality, and direct messaging between buyers and sellers..."
value={prompt}
onChange={(e) => setPrompt(e.target.value)}
className="min-h-[125px] text-sm leading-relaxed"
disabled={isCreating}
/>
<div className="space-y-2">
<h3 className="font-medium text-sm">Example prompts:</h3>
<ul className="text-sm text-muted-foreground space-y-1">
<li>• "Build a social media platform for photographers to share their work and connect with clients"</li>
<li>• "Create a blog platform with markdown support and Nostr-based comments"</li>
<li>• "Design a marketplace for vintage clothing with categories, filters, and user ratings"</li>
</ul>
</div>
</CardContent>
</Card>
<div className="flex justify-center gap-3 pt-2">
<Button
onClick={onPrevious}
variant="outline"
size="sm"
className="gap-1 h-8 text-sm"
>
<ArrowLeft className="h-3 w-3" />
Back
</Button>
<Button
onClick={handleCreateProject}
disabled={!prompt.trim() || isCreating}
size="sm"
className="gap-1 h-8 text-sm bg-gradient-to-r from-primary to-primary/90 hover:from-primary/90 hover:to-primary/80"
>
{isCreating ? (
<>
<div className="animate-spin rounded-full h-3 w-3 border-b-2 border-white mr-1"></div>
Creating...
</>
) : (
<>
<Plus className="h-3 w-3" />
Create Project
</>
)}
</Button>
</div>
</div>
);
}
+83
View File
@@ -0,0 +1,83 @@
import { Button } from '@/components/ui/button';
import { Card, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { ArrowRight, Zap, GlobeLock, Palette } from 'lucide-react';
interface WelcomeStepProps {
onNext: () => void;
onSkip: () => void;
}
export function WelcomeStep({ onNext, onSkip }: WelcomeStepProps) {
return (
<div className="space-y-6">
<div className="text-center space-y-4">
<div className="text-6xl mb-4">🎭</div>
<h1 className="text-3xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
Welcome to Shakespeare
</h1>
<p className="text-base text-muted-foreground max-w-2xl mx-auto">
Build custom Nostr websites with AI assistance. Let's get you set up in just a few steps.
</p>
</div>
<div className="grid md:grid-cols-3 gap-4 max-w-4xl mx-auto">
<Card className="text-center">
<CardHeader>
<div className="flex justify-center mb-2">
<Zap className="h-8 w-8 text-primary" />
</div>
<CardTitle className="text-lg">AI-Powered</CardTitle>
<CardDescription>
Describe your vision and let AI build your Nostr website
</CardDescription>
</CardHeader>
</Card>
<Card className="text-center">
<CardHeader>
<div className="flex justify-center mb-2">
<GlobeLock className="h-8 w-8 text-primary" />
</div>
<CardTitle className="text-lg">Decentralized</CardTitle>
<CardDescription>
Built with the Nostr protocol for censorship resistance
</CardDescription>
</CardHeader>
</Card>
<Card className="text-center">
<CardHeader>
<div className="flex justify-center mb-2">
<Palette className="h-8 w-8 text-primary" />
</div>
<CardTitle className="text-lg">Customizable</CardTitle>
<CardDescription>
Edit code directly or let AI make changes based on your feedback
</CardDescription>
</CardHeader>
</Card>
</div>
<div className="flex flex-col items-center gap-2 pt-4">
<Button
onClick={onNext}
size="lg"
className="gap-2 bg-gradient-to-r from-primary to-primary/90 hover:from-primary/90 hover:to-primary/80"
>
Get Started
<ArrowRight className="h-4 w-4" />
</Button>
<Button
onClick={onSkip}
variant="ghost"
size="sm"
className="text-muted-foreground text-xs h-7"
>
Skip for now
</Button>
</div>
</div>
);
}
+4
View File
@@ -0,0 +1,4 @@
export { OnboardingDialog } from './OnboardingDialog';
export { WelcomeStep } from './WelcomeStep';
export { AISettingsStep } from './AISettingsStep';
export { ProjectStep } from './ProjectStep';
+48
View File
@@ -0,0 +1,48 @@
import { useState, useEffect } from 'react';
import { useLocalStorage } from './useLocalStorage';
export function useOnboarding() {
const [hasCompletedOnboarding, setHasCompletedOnboarding] = useLocalStorage(
'shakespeare-onboarding-completed',
false
);
const [currentStep, setCurrentStep] = useState(0);
const [isOnboardingOpen, setIsOnboardingOpen] = useState(false);
// Check if onboarding should be shown on first load
useEffect(() => {
if (!hasCompletedOnboarding) {
setIsOnboardingOpen(true);
}
}, [hasCompletedOnboarding]);
const handleNextStep = () => {
setCurrentStep(prev => Math.min(prev + 1, 2));
};
const handlePreviousStep = () => {
setCurrentStep(prev => Math.max(prev - 1, 0));
};
const handleCompleteOnboarding = () => {
setHasCompletedOnboarding(true);
setIsOnboardingOpen(false);
setCurrentStep(0);
};
const handleRestartOnboarding = () => {
setCurrentStep(0);
setIsOnboardingOpen(true);
};
return {
hasCompletedOnboarding,
currentStep,
isOnboardingOpen,
setIsOnboardingOpen,
handleNextStep,
handlePreviousStep,
handleCompleteOnboarding,
handleRestartOnboarding,
};
}
+38 -2
View File
@@ -2,13 +2,15 @@ import { useState, useEffect, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { type Project } from '@/lib/ProjectsManager';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useOnboarding } from '@/hooks/useOnboarding';
import { ProjectSidebar } from '@/components/ProjectSidebar';
import { OnboardingDialog } from '@/components/onboarding';
import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Skeleton } from '@/components/ui/skeleton';
import { Plus, Folder, Menu, Columns2 } from 'lucide-react';
import { Plus, Folder, Menu, Columns2, Sparkles } from 'lucide-react';
import { useIsMobile } from '@/hooks/useIsMobile';
import { useSeoMeta } from '@unhead/react';
import { cn } from '@/lib/utils';
@@ -21,6 +23,15 @@ export default function Index() {
const navigate = useNavigate();
const projectsManager = useProjectsManager();
const isMobile = useIsMobile();
const {
hasCompletedOnboarding,
currentStep,
isOnboardingOpen,
setIsOnboardingOpen,
handleNextStep,
handlePreviousStep,
handleCompleteOnboarding,
} = useOnboarding();
const [isSidebarVisible, setIsSidebarVisible] = useState(() => {
// Check if we're on mobile immediately to set correct initial state
if (typeof window !== 'undefined') {
@@ -129,6 +140,17 @@ export default function Index() {
Vibed with MKStack
</a>
</p>
{hasCompletedOnboarding && (
<Button
onClick={() => setIsOnboardingOpen(true)}
variant="ghost"
size="sm"
className="mt-4 gap-2"
>
<Sparkles className="h-4 w-4" />
Restart Onboarding
</Button>
)}
</div>
<div className="mb-8 md:mb-12">
@@ -237,7 +259,20 @@ export default function Index() {
}
return (
<div className="h-screen flex bg-background">
<>
<OnboardingDialog
open={isOnboardingOpen}
onOpenChange={setIsOnboardingOpen}
currentStep={currentStep}
onNextStep={handleNextStep}
onPreviousStep={handlePreviousStep}
onComplete={handleCompleteOnboarding}
onProjectCreated={(projectId) => {
// Handle project creation during onboarding
console.log('Project created during onboarding:', projectId);
}}
/>
<div className="h-screen flex bg-background">
{/* Fixed Sidebar */}
<div className={cn("w-80 border-r bg-sidebar transition-all duration-300", isSidebarVisible ? "block" : "hidden")}>
<ProjectSidebar
@@ -389,5 +424,6 @@ export default function Index() {
</div>
</div>
</div>
</>
);
}