From 0b2aab0527ce236281c7999d96228acaece9c68a Mon Sep 17 00:00:00 2001 From: Chad Curtis Date: Fri, 25 Jul 2025 16:51:49 +0000 Subject: [PATCH] baseline onboarding flow --- src/components/onboarding/AISettingsStep.tsx | 178 ++++++++++++++++++ .../onboarding/OnboardingDialog.tsx | 133 +++++++++++++ src/components/onboarding/ProjectStep.tsx | 113 +++++++++++ src/components/onboarding/WelcomeStep.tsx | 83 ++++++++ src/components/onboarding/index.ts | 4 + src/hooks/useOnboarding.ts | 48 +++++ src/pages/Index.tsx | 40 +++- 7 files changed, 597 insertions(+), 2 deletions(-) create mode 100644 src/components/onboarding/AISettingsStep.tsx create mode 100644 src/components/onboarding/OnboardingDialog.tsx create mode 100644 src/components/onboarding/ProjectStep.tsx create mode 100644 src/components/onboarding/WelcomeStep.tsx create mode 100644 src/components/onboarding/index.ts create mode 100644 src/hooks/useOnboarding.ts diff --git a/src/components/onboarding/AISettingsStep.tsx b/src/components/onboarding/AISettingsStep.tsx new file mode 100644 index 00000000..f36ab4be --- /dev/null +++ b/src/components/onboarding/AISettingsStep.tsx @@ -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 ( +
+
+
+ +
+

+ Configure AI Settings +

+

+ Set up your AI provider to start building with AI assistance. +

+
+ + + +
+ + AI Provider +
+ + We recommend OpenRouter for easy setup + +
+ +
+
+ + setLocalSettings({ ...localSettings, apiKey: e.target.value })} + className="font-mono text-sm h-9" + /> +

+ Stored locally, never shared +

+
+ +
+ + setLocalSettings({ ...localSettings, baseUrl: e.target.value })} + className="text-sm h-9" + /> +
+ +
+ + setLocalSettings({ ...localSettings, model: e.target.value })} + className="text-sm h-9" + /> +
+
+ + {isConfigured && ( +
+ + Configured +
+ )} + +
+ +
+
+
+ +
+ + +
+ +
+ +
+
+ ); +} \ No newline at end of file diff --git a/src/components/onboarding/OnboardingDialog.tsx b/src/components/onboarding/OnboardingDialog.tsx new file mode 100644 index 00000000..997620b9 --- /dev/null +++ b/src/components/onboarding/OnboardingDialog.tsx @@ -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 ( + + ); + case 'ai-settings': + return ( + + ); + case 'project': + return ( + + ); + default: + return null; + } + }; + + return ( + + +
+ Getting Started Onboarding + Complete the onboarding process to get started with Shakespeare +
+
+

Getting Started

+ + Step {currentStep + 1} of {STEPS.length} + +
+
+ +
+
+ {STEPS.map((step, index) => ( + + {step.title} + + ))} +
+
+
+ +
+ {renderStep()} +
+
+
+ ); +} \ No newline at end of file diff --git a/src/components/onboarding/ProjectStep.tsx b/src/components/onboarding/ProjectStep.tsx new file mode 100644 index 00000000..a08d1644 --- /dev/null +++ b/src/components/onboarding/ProjectStep.tsx @@ -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 ( +
+
+
+ +
+

+ Create Your First Project +

+

+ Our AI will help you create it step by step. +

+
+ + + +
+ + Project Description +
+ + Be as detailed as possible about what you want to build + +
+ +