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 (
+
+ );
+}
\ 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
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/src/components/onboarding/WelcomeStep.tsx b/src/components/onboarding/WelcomeStep.tsx
new file mode 100644
index 00000000..f1fa1071
--- /dev/null
+++ b/src/components/onboarding/WelcomeStep.tsx
@@ -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 (
+
+
+
🎭
+
+ Welcome to Shakespeare
+
+
+ Build custom Nostr websites with AI assistance. Let's get you set up in just a few steps.
+
+
+
+
+
+
+
+
+
+ AI-Powered
+
+ Describe your vision and let AI build your Nostr website
+
+
+
+
+
+
+
+
+
+ Decentralized
+
+ Built with the Nostr protocol for censorship resistance
+
+
+
+
+
+
+
+ Customizable
+
+ Edit code directly or let AI make changes based on your feedback
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/src/components/onboarding/index.ts b/src/components/onboarding/index.ts
new file mode 100644
index 00000000..23e054dc
--- /dev/null
+++ b/src/components/onboarding/index.ts
@@ -0,0 +1,4 @@
+export { OnboardingDialog } from './OnboardingDialog';
+export { WelcomeStep } from './WelcomeStep';
+export { AISettingsStep } from './AISettingsStep';
+export { ProjectStep } from './ProjectStep';
\ No newline at end of file
diff --git a/src/hooks/useOnboarding.ts b/src/hooks/useOnboarding.ts
new file mode 100644
index 00000000..25aaca0e
--- /dev/null
+++ b/src/hooks/useOnboarding.ts
@@ -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,
+ };
+}
\ No newline at end of file
diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx
index 13e47767..3bc5401d 100644
--- a/src/pages/Index.tsx
+++ b/src/pages/Index.tsx
@@ -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
+ {hasCompletedOnboarding && (
+
+ )}
@@ -237,7 +259,20 @@ export default function Index() {
}
return (
-
+ <>
+
{
+ // Handle project creation during onboarding
+ console.log('Project created during onboarding:', projectId);
+ }}
+ />
+
+ >
);
}
\ No newline at end of file