mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add clone repo page, fix deleting a local repo directory
This commit is contained in:
1 parent
a092d924fc
commit
ddca65019d
6 files changed
+494
-310
No files matched your search
@@ -2,6 +2,7 @@ import { BrowserRouter, Route, Routes } from "react-router-dom";
|
||||
import { ScrollToTop } from "./components/ScrollToTop";
|
||||
|
||||
import Index from "./pages/Index";
|
||||
import Clone from "./pages/Clone";
|
||||
import { NIP19Page } from "./pages/NIP19Page";
|
||||
import NotFound from "./pages/NotFound";
|
||||
import { ProjectView } from "./pages/ProjectView";
|
||||
@@ -12,6 +13,7 @@ export function AppRouter() {
|
||||
<ScrollToTop />
|
||||
<Routes>
|
||||
<Route path="/" element={<Index />} />
|
||||
<Route path="/clone" element={<Clone />} />
|
||||
<Route path="/project/:projectId" element={<ProjectView />} />
|
||||
{/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */}
|
||||
<Route path="/:nip19" element={<NIP19Page />} />
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { type Project } from '@/lib/ProjectsManager';
|
||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||
import { ProjectSidebar } from '@/components/ProjectSidebar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Menu, Columns2 } from 'lucide-react';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface AppLayoutProps {
|
||||
children: React.ReactNode;
|
||||
selectedProject?: Project | null;
|
||||
title?: string;
|
||||
showSidebar?: boolean;
|
||||
headerContent?: React.ReactNode;
|
||||
}
|
||||
|
||||
export function AppLayout({
|
||||
children,
|
||||
selectedProject = null,
|
||||
title = "Shakespeare",
|
||||
showSidebar = true,
|
||||
headerContent
|
||||
}: AppLayoutProps) {
|
||||
const [projects, setProjects] = useState<Project[]>([]);
|
||||
const projectsManager = useProjectsManager();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const [isSidebarVisible, setIsSidebarVisible] = useState(() => {
|
||||
// Check if we're on mobile immediately to set correct initial state
|
||||
if (typeof window !== 'undefined') {
|
||||
return window.innerWidth >= 768; // Desktop starts open, mobile starts closed
|
||||
}
|
||||
return false; // Default to closed for SSR
|
||||
});
|
||||
|
||||
const loadProjects = useCallback(async () => {
|
||||
try {
|
||||
await projectsManager.init();
|
||||
const projectList = await projectsManager.getProjects();
|
||||
setProjects(projectList);
|
||||
} catch (error) {
|
||||
console.error('Failed to load projects:', error);
|
||||
}
|
||||
}, [projectsManager]);
|
||||
|
||||
useEffect(() => {
|
||||
loadProjects();
|
||||
}, [loadProjects]);
|
||||
|
||||
const handleProjectSelect = (project: Project | null) => {
|
||||
if (project) {
|
||||
setIsSidebarVisible(false); // Collapse sidebar on mobile navigation
|
||||
navigate(`/project/${project.id}`);
|
||||
} else {
|
||||
navigate('/');
|
||||
}
|
||||
};
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<div className="min-h-dvh bg-gradient-to-br from-primary/5 to-accent/5">
|
||||
{/* Mobile Header */}
|
||||
<header className="border-b bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 backdrop-blur px-4 py-3 flex items-center justify-between">
|
||||
<div className="flex items-center space-x-2">
|
||||
{showSidebar && projects.length > 0 && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setIsSidebarVisible(!isSidebarVisible)}
|
||||
>
|
||||
<Menu className="h-4 w-4" />
|
||||
</Button>
|
||||
)}
|
||||
<h1 className="text-lg font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
{title}
|
||||
</h1>
|
||||
</div>
|
||||
{headerContent}
|
||||
</header>
|
||||
|
||||
{/* Mobile Sidebar Overlay - only show if user has local projects and showSidebar is true */}
|
||||
{showSidebar && projects.length > 0 && isSidebarVisible && (
|
||||
<div className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm">
|
||||
{/* Backdrop - only covers the area not occupied by the sidebar */}
|
||||
<div
|
||||
className="absolute inset-0"
|
||||
onClick={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
{/* Sidebar - positioned above the backdrop */}
|
||||
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<ProjectSidebar
|
||||
selectedProject={selectedProject}
|
||||
onSelectProject={(project) => {
|
||||
setIsSidebarVisible(false); // Always collapse sidebar on mobile navigation
|
||||
handleProjectSelect(project);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="container mx-auto px-4 py-6 md:py-8">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex bg-background">
|
||||
{/* Fixed Sidebar - only show if user has created local projects and showSidebar is true */}
|
||||
{showSidebar && projects.length > 0 && (
|
||||
<div className={cn("w-80 border-r bg-sidebar transition-all duration-300", isSidebarVisible ? "block" : "hidden")}>
|
||||
<ProjectSidebar
|
||||
selectedProject={selectedProject}
|
||||
onSelectProject={handleProjectSelect}
|
||||
className="h-screen sticky top-0"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Main Content Area */}
|
||||
<div className="flex-1 flex flex-col bg-background">
|
||||
<div className="min-h-screen bg-gradient-to-br from-primary/5 to-accent/5">
|
||||
{/* Header - only show toggle button if user has local projects and showSidebar is true */}
|
||||
{!isSidebarVisible && showSidebar && projects.length > 0 && (
|
||||
<header className="border-b bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 backdrop-blur px-4 py-3 flex items-center">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setIsSidebarVisible(true)}
|
||||
className="h-8 w-8 p-0"
|
||||
aria-label="Toggle sidebar"
|
||||
>
|
||||
<Columns2 className="h-4 w-4" />
|
||||
</Button>
|
||||
<h1 className="text-lg font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent ml-4">
|
||||
{title}
|
||||
</h1>
|
||||
<div className="ml-auto">
|
||||
{headerContent}
|
||||
</div>
|
||||
</header>
|
||||
)}
|
||||
|
||||
<div className="container mx-auto px-4 py-6 md:py-8">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Plus, Loader2, Info, MoreVertical, Trash2, Eye, Star, Bug, Folder, Download } from 'lucide-react';
|
||||
import { Plus, Loader2, Info, MoreVertical, Trash2, Eye, Star, Bug, Folder, Download, GitBranch } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Label } from '@/components/ui/label';
|
||||
@@ -309,6 +309,13 @@ export function ProjectSidebar({
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
<DropdownMenuItem
|
||||
onClick={() => navigate('/clone')}
|
||||
className="flex items-center gap-2 w-full"
|
||||
>
|
||||
<GitBranch className="h-4 w-4" />
|
||||
Import Repository
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={handleExportFiles}
|
||||
disabled={isExporting}
|
||||
|
||||
+24
-29
@@ -36,13 +36,24 @@ export class ProjectsManager {
|
||||
}
|
||||
|
||||
async createProject(name: string): Promise<Project> {
|
||||
return this.cloneProject(name, GIT_TEMPLATE_URL);
|
||||
}
|
||||
|
||||
async cloneProject(name: string, repoUrl: string): Promise<Project> {
|
||||
const id = await this.generateUniqueProjectId(name);
|
||||
const projectPath = `${this.dir}/${id}`;
|
||||
|
||||
await this.fs.mkdir(projectPath);
|
||||
|
||||
// Clone the template first
|
||||
await this.cloneTemplate(projectPath);
|
||||
// Clone the repository
|
||||
await git.clone({
|
||||
fs: this.fs,
|
||||
http,
|
||||
dir: projectPath,
|
||||
url: repoUrl,
|
||||
singleBranch: true,
|
||||
depth: 1,
|
||||
});
|
||||
|
||||
// Get filesystem stats for timestamps
|
||||
const stats = await this.fs.stat(projectPath);
|
||||
@@ -57,16 +68,7 @@ export class ProjectsManager {
|
||||
};
|
||||
}
|
||||
|
||||
async cloneTemplate(projectPath: string) {
|
||||
await git.clone({
|
||||
fs: this.fs,
|
||||
http,
|
||||
dir: projectPath,
|
||||
url: GIT_TEMPLATE_URL,
|
||||
singleBranch: true,
|
||||
depth: 1,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async getProjects(): Promise<Project[]> {
|
||||
try {
|
||||
@@ -187,27 +189,20 @@ export class ProjectsManager {
|
||||
}
|
||||
|
||||
private async deleteDirectory(dirPath: string): Promise<void> {
|
||||
try {
|
||||
const files = await this.fs.readdir(dirPath);
|
||||
const files = await this.fs.readdir(dirPath);
|
||||
|
||||
for (const file of files) {
|
||||
const fullPath = `${dirPath}/${file}`;
|
||||
const stat = await this.fs.stat(fullPath);
|
||||
for (const file of files) {
|
||||
const fullPath = `${dirPath}/${file}`;
|
||||
const stat = await this.fs.lstat(fullPath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
await this.deleteDirectory(fullPath);
|
||||
} else {
|
||||
await this.fs.unlink(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
await this.fs.rmdir(dirPath);
|
||||
} catch (error) {
|
||||
const fsError = error as NodeJS.ErrnoException;
|
||||
if (fsError.code !== 'ENOENT') {
|
||||
throw error;
|
||||
if (stat.isDirectory()) {
|
||||
await this.deleteDirectory(fullPath);
|
||||
} else {
|
||||
await this.fs.unlink(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
await this.fs.rmdir(dirPath);
|
||||
}
|
||||
|
||||
private async generateUniqueProjectId(name: string): Promise<string> {
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { AppLayout } from '@/components/AppLayout';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { GitBranch, Loader2, AlertCircle } from 'lucide-react';
|
||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
|
||||
import { useSeoMeta } from '@unhead/react';
|
||||
|
||||
export default function Clone() {
|
||||
const [repoUrl, setRepoUrl] = useState('');
|
||||
const [isCloning, setIsCloning] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const navigate = useNavigate();
|
||||
const projectsManager = useProjectsManager();
|
||||
const { toast } = useToast();
|
||||
|
||||
useSeoMeta({
|
||||
title: 'Import Repository - Shakespeare',
|
||||
description: 'Import a Git repository into your Shakespeare workspace',
|
||||
});
|
||||
|
||||
const extractRepoName = (url: string): string => {
|
||||
try {
|
||||
// Handle different URL formats
|
||||
const cleanUrl = url.trim();
|
||||
|
||||
// Extract from GitHub URLs, GitLab URLs, etc.
|
||||
const match = cleanUrl.match(/\/([^/]+?)(?:\.git)?(?:\/)?$/);
|
||||
if (match && match[1]) {
|
||||
return match[1];
|
||||
}
|
||||
|
||||
// Fallback: use the last part of the URL
|
||||
const parts = cleanUrl.split('/').filter(Boolean);
|
||||
const lastPart = parts[parts.length - 1];
|
||||
return lastPart.replace('.git', '') || 'imported-repo';
|
||||
} catch {
|
||||
return 'imported-repo';
|
||||
}
|
||||
};
|
||||
|
||||
const validateGitUrl = (url: string): boolean => {
|
||||
if (!url.trim()) return false;
|
||||
|
||||
// Basic URL validation
|
||||
try {
|
||||
new URL(url);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if it looks like a git repository URL
|
||||
const gitUrlPattern = /^https?:\/\/.*\.git$|^https?:\/\/github\.com\/.*\/.*$|^https?:\/\/gitlab\.com\/.*\/.*$/i;
|
||||
return gitUrlPattern.test(url) || url.includes('github.com') || url.includes('gitlab.com');
|
||||
};
|
||||
|
||||
const handleClone = async () => {
|
||||
if (!repoUrl.trim()) {
|
||||
setError('Please enter a repository URL');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validateGitUrl(repoUrl)) {
|
||||
setError('Please enter a valid Git repository URL (e.g., https://github.com/user/repo.git)');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsCloning(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// Extract repository name from URL
|
||||
const repoName = extractRepoName(repoUrl);
|
||||
|
||||
// Clone the repository using ProjectsManager
|
||||
await projectsManager.init();
|
||||
const project = await projectsManager.cloneProject(repoName, repoUrl.trim());
|
||||
|
||||
toast({
|
||||
title: "Repository imported successfully",
|
||||
description: `"${repoName}" has been cloned and is ready for development.`,
|
||||
});
|
||||
|
||||
// Navigate to the new project
|
||||
navigate(`/project/${project.id}`);
|
||||
} catch (error) {
|
||||
console.error('Failed to clone repository:', error);
|
||||
|
||||
let errorMessage = 'Failed to clone repository';
|
||||
if (error instanceof Error) {
|
||||
if (error.message.includes('404') || error.message.includes('not found')) {
|
||||
errorMessage = 'Repository not found. Please check the URL and try again.';
|
||||
} else if (error.message.includes('403') || error.message.includes('forbidden')) {
|
||||
errorMessage = 'Access denied. The repository may be private or require authentication.';
|
||||
} else if (error.message.includes('network') || error.message.includes('fetch')) {
|
||||
errorMessage = 'Network error. Please check your connection and try again.';
|
||||
} else {
|
||||
errorMessage = error.message;
|
||||
}
|
||||
}
|
||||
|
||||
setError(errorMessage);
|
||||
|
||||
toast({
|
||||
title: "Failed to import repository",
|
||||
description: errorMessage,
|
||||
variant: "destructive",
|
||||
});
|
||||
} finally {
|
||||
setIsCloning(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter' && !isCloning) {
|
||||
handleClone();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<AppLayout title="Import Repository">
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<div className="text-center mb-8">
|
||||
<div className="text-4xl mb-4">
|
||||
<GitBranch className="h-12 w-12 mx-auto text-primary" />
|
||||
</div>
|
||||
<h1 className="text-3xl font-bold mb-3 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
Import Repository
|
||||
</h1>
|
||||
<p className="text-lg text-muted-foreground">
|
||||
Clone a Git repository into your Shakespeare workspace
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Card className="bg-gradient-to-br from-card to-card/50 border-primary/20 shadow-lg">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-xl">Repository URL</CardTitle>
|
||||
<CardDescription className="text-base">
|
||||
Enter the HTTPS URL of the Git repository you want to import
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="repo-url">Git Repository URL</Label>
|
||||
<Input
|
||||
id="repo-url"
|
||||
type="url"
|
||||
placeholder="https://github.com/username/repository.git"
|
||||
value={repoUrl}
|
||||
onChange={(e) => {
|
||||
setRepoUrl(e.target.value);
|
||||
setError(null); // Clear error when user types
|
||||
}}
|
||||
onKeyDown={handleKeyDown}
|
||||
disabled={isCloning}
|
||||
className="text-base"
|
||||
/>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Supports GitHub, GitLab, and other Git hosting services
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-md">
|
||||
<AlertCircle className="h-4 w-4 text-destructive flex-shrink-0" />
|
||||
<p className="text-sm text-destructive">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Button
|
||||
onClick={handleClone}
|
||||
disabled={!repoUrl.trim() || isCloning}
|
||||
className="w-full focus-ring bg-gradient-to-r from-primary to-primary/90 hover:from-primary/90 hover:to-primary/80 shadow-lg"
|
||||
size="lg"
|
||||
>
|
||||
{isCloning ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
|
||||
Cloning Repository...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<GitBranch className="mr-2 h-4 w-4" />
|
||||
Import Repository
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
<div className="mt-6 p-4 bg-muted/50 rounded-lg">
|
||||
<h3 className="font-medium mb-2">Supported Repository Types</h3>
|
||||
<ul className="text-sm text-muted-foreground space-y-1">
|
||||
<li>• Public GitHub repositories</li>
|
||||
<li>• Public GitLab repositories</li>
|
||||
<li>• Any public Git repository accessible via HTTPS</li>
|
||||
</ul>
|
||||
<p className="text-xs text-muted-foreground mt-2">
|
||||
Note: Private repositories requiring authentication are not currently supported.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</AppLayout>
|
||||
);
|
||||
}
|
||||
+94
-280
@@ -1,29 +1,24 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useState, useEffect } 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 { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { ProjectSidebar } from '@/components/ProjectSidebar';
|
||||
import { AppLayout } from '@/components/AppLayout';
|
||||
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 { Plus, Menu, Columns2, Sparkles } from 'lucide-react';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { Plus, Sparkles } from 'lucide-react';
|
||||
import { useSeoMeta } from '@unhead/react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export default function Index() {
|
||||
const [prompt, setPrompt] = useState('');
|
||||
const [projects, setProjects] = useState<Project[]>([]);
|
||||
const [isCreating, setIsCreating] = useState(false);
|
||||
const [storedPrompt, setStoredPrompt] = useLocalStorage('shakespeare-draft-prompt', '');
|
||||
const navigate = useNavigate();
|
||||
const projectsManager = useProjectsManager();
|
||||
const isMobile = useIsMobile();
|
||||
const { user: _user } = useCurrentUser();
|
||||
const {
|
||||
hasCompletedOnboarding,
|
||||
@@ -35,33 +30,11 @@ export default function Index() {
|
||||
handleCompleteOnboarding,
|
||||
} = useOnboarding();
|
||||
|
||||
const [isSidebarVisible, setIsSidebarVisible] = useState(() => {
|
||||
// Check if we're on mobile immediately to set correct initial state
|
||||
if (typeof window !== 'undefined') {
|
||||
return window.innerWidth >= 768; // Desktop starts open, mobile starts closed
|
||||
}
|
||||
return false; // Default to closed for SSR
|
||||
});
|
||||
|
||||
useSeoMeta({
|
||||
title: 'Shakespeare - AI-Powered Nostr Development',
|
||||
description: 'Build custom Nostr websites with AI assistance using Shakespeare, an AI-powered development environment.',
|
||||
});
|
||||
|
||||
const loadProjects = useCallback(async () => {
|
||||
try {
|
||||
await projectsManager.init();
|
||||
const projectList = await projectsManager.getProjects();
|
||||
setProjects(projectList);
|
||||
} catch (error) {
|
||||
console.error('Failed to load projects:', error);
|
||||
}
|
||||
}, [projectsManager]);
|
||||
|
||||
useEffect(() => {
|
||||
loadProjects();
|
||||
}, [loadProjects]);
|
||||
|
||||
// Restore prompt from local storage on mount
|
||||
useEffect(() => {
|
||||
if (storedPrompt) {
|
||||
@@ -93,155 +66,99 @@ export default function Index() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleProjectSelect = (project: Project | null) => {
|
||||
if (project) {
|
||||
setIsSidebarVisible(false); // Collapse sidebar on mobile navigation
|
||||
navigate(`/project/${project.id}`);
|
||||
}
|
||||
};
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<div className="min-h-dvh bg-gradient-to-br from-primary/5 to-accent/5">
|
||||
{/* Mobile Header */}
|
||||
<header className="border-b bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 backdrop-blur px-4 py-3 flex items-center justify-between">
|
||||
{projects.length > 0 ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setIsSidebarVisible(!isSidebarVisible)}
|
||||
>
|
||||
<Menu className="h-4 w-4" />
|
||||
</Button>
|
||||
) : (
|
||||
<div className="w-8" /> /* Spacer when no sidebar */
|
||||
)}
|
||||
<h1 className="text-lg font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
Shakespeare
|
||||
</h1>
|
||||
<div className="w-8" /> {/* Spacer */}
|
||||
</header>
|
||||
|
||||
{/* Mobile Sidebar Overlay - only show if user has local projects */}
|
||||
{projects.length > 0 && isSidebarVisible && (
|
||||
<div className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm">
|
||||
{/* Backdrop - only covers the area not occupied by the sidebar */}
|
||||
<div
|
||||
className="absolute inset-0"
|
||||
onClick={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
{/* Sidebar - positioned above the backdrop */}
|
||||
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<ProjectSidebar
|
||||
selectedProject={null}
|
||||
onSelectProject={(project) => {
|
||||
setIsSidebarVisible(false); // Always collapse sidebar on mobile navigation
|
||||
handleProjectSelect(project);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="container mx-auto px-4 py-6 md:py-8">
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<div className="text-center mb-8 md:mb-12">
|
||||
<div className="text-4xl md:text-6xl mb-4 md:mb-6">🎭</div>
|
||||
<h1 className="text-3xl md:text-4xl font-bold mb-3 md:mb-4 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
Shakespeare
|
||||
</h1>
|
||||
<p className="text-lg md:text-xl text-muted-foreground mb-2">
|
||||
Build custom Nostr websites with AI assistance
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
<a href="https://soapbox.pub/mkstack" className="hover:underline focus-ring text-primary">
|
||||
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">
|
||||
<Card className="bg-gradient-to-br from-card to-card/50 border-primary/20 shadow-lg">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-3 mb-2">
|
||||
<div className="p-2 bg-primary/10 rounded-lg">
|
||||
<Plus className="h-5 w-5 text-primary" />
|
||||
</div>
|
||||
<div>
|
||||
<CardTitle className="text-xl">Create a New Project</CardTitle>
|
||||
<CardDescription className="text-base">
|
||||
Describe what kind of Nostr website you want to build
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</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..."
|
||||
value={prompt}
|
||||
onChange={handlePromptChange}
|
||||
className="min-h-[120px] touch-action-manipulation overscroll-contain text-base leading-relaxed"
|
||||
disabled={isCreating}
|
||||
/>
|
||||
<Button
|
||||
onClick={handleCreateProject}
|
||||
disabled={!prompt.trim() || isCreating}
|
||||
className="w-full focus-ring bg-gradient-to-r from-primary to-primary/90 hover:from-primary/90 hover:to-primary/80 shadow-lg"
|
||||
size="lg"
|
||||
>
|
||||
{isCreating ? (
|
||||
<>
|
||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
|
||||
Creating Project...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
Create Project
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<OnboardingDialog
|
||||
open={isOnboardingOpen}
|
||||
onOpenChange={setIsOnboardingOpen}
|
||||
currentStep={currentStep}
|
||||
onNextStep={handleNextStep}
|
||||
onPreviousStep={handlePreviousStep}
|
||||
onComplete={handleCompleteOnboarding}
|
||||
initialPrompt={storedPrompt}
|
||||
onProjectCreated={(projectId) => {
|
||||
console.log('Project created during onboarding:', projectId);
|
||||
setStoredPrompt('');
|
||||
loadProjects();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const headerContent = (
|
||||
<>
|
||||
{hasCompletedOnboarding && (
|
||||
<Button
|
||||
onClick={() => setIsOnboardingOpen(true)}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="gap-2"
|
||||
>
|
||||
<Sparkles className="h-4 w-4" />
|
||||
Restart Onboarding
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppLayout headerContent={headerContent}>
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<div className="text-center mb-8 md:mb-12">
|
||||
<div className="text-4xl md:text-6xl mb-4 md:mb-6">🎭</div>
|
||||
<h1 className="text-3xl md:text-4xl font-bold mb-3 md:mb-4 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
Shakespeare
|
||||
</h1>
|
||||
<p className="text-lg md:text-xl text-muted-foreground mb-2">
|
||||
Build custom Nostr websites with AI assistance
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
<a href="https://soapbox.pub/mkstack" className="hover:underline focus-ring text-primary">
|
||||
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">
|
||||
<Card className="bg-gradient-to-br from-card to-card/50 border-primary/20 shadow-lg">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-3 mb-2">
|
||||
<div className="p-2 bg-primary/10 rounded-lg">
|
||||
<Plus className="h-5 w-5 text-primary" />
|
||||
</div>
|
||||
<div>
|
||||
<CardTitle className="text-xl">Create a New Project</CardTitle>
|
||||
<CardDescription className="text-base">
|
||||
Describe what kind of Nostr website you want to build
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</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..."
|
||||
value={prompt}
|
||||
onChange={handlePromptChange}
|
||||
className="min-h-[120px] touch-action-manipulation overscroll-contain text-base leading-relaxed"
|
||||
disabled={isCreating}
|
||||
/>
|
||||
<Button
|
||||
onClick={handleCreateProject}
|
||||
disabled={!prompt.trim() || isCreating}
|
||||
className="w-full focus-ring bg-gradient-to-r from-primary to-primary/90 hover:from-primary/90 hover:to-primary/80 shadow-lg"
|
||||
size="lg"
|
||||
>
|
||||
{isCreating ? (
|
||||
<>
|
||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
|
||||
Creating Project...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
Create Project
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</AppLayout>
|
||||
|
||||
<OnboardingDialog
|
||||
open={isOnboardingOpen}
|
||||
onOpenChange={setIsOnboardingOpen}
|
||||
@@ -251,113 +168,10 @@ export default function Index() {
|
||||
onComplete={handleCompleteOnboarding}
|
||||
initialPrompt={storedPrompt}
|
||||
onProjectCreated={(projectId) => {
|
||||
// Handle project creation during onboarding
|
||||
console.log('Project created during onboarding:', projectId);
|
||||
setStoredPrompt(''); // Clear stored prompt after project creation
|
||||
loadProjects();
|
||||
setStoredPrompt('');
|
||||
}}
|
||||
/>
|
||||
<div className="min-h-screen flex bg-background">
|
||||
{/* Fixed Sidebar - only show if user has created local projects */}
|
||||
{projects.length > 0 && (
|
||||
<div className={cn("w-80 border-r bg-sidebar transition-all duration-300", isSidebarVisible ? "block" : "hidden")}>
|
||||
<ProjectSidebar
|
||||
selectedProject={null}
|
||||
onSelectProject={handleProjectSelect}
|
||||
className="h-screen sticky top-0"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Main Content Area */}
|
||||
<div className="flex-1 flex flex-col bg-background">
|
||||
<div className="min-h-screen bg-gradient-to-br from-primary/5 to-accent/5">
|
||||
{/* Header - only show toggle button if user has local projects */}
|
||||
{!isSidebarVisible && projects.length > 0 && (
|
||||
<header className="border-b bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 backdrop-blur px-4 py-3 flex items-center">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setIsSidebarVisible(true)}
|
||||
className="h-8 w-8 p-0"
|
||||
aria-label="Toggle sidebar"
|
||||
>
|
||||
<Columns2 className="h-4 w-4" />
|
||||
</Button>
|
||||
<h1 className="text-lg font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent ml-4">
|
||||
Shakespeare
|
||||
</h1>
|
||||
</header>
|
||||
)}
|
||||
|
||||
<div className="container mx-auto px-4 py-6 md:py-8">
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<div className="text-center mb-8 md:mb-12">
|
||||
<div className="text-4xl md:text-6xl mb-4 md:mb-6">🎭</div>
|
||||
<h1 className="text-3xl md:text-4xl font-bold mb-3 md:mb-4 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
Shakespeare
|
||||
</h1>
|
||||
<p className="text-lg md:text-xl text-muted-foreground mb-2">
|
||||
Build custom Nostr websites with AI assistance
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
<a href="https://soapbox.pub/mkstack" className="hover:underline focus-ring text-primary">
|
||||
Vibed with MKStack
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mb-8 md:mb-12">
|
||||
<Card className="bg-gradient-to-br from-card to-card/50 border-primary/20 shadow-lg">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-3 mb-2">
|
||||
<div className="p-2 bg-primary/10 rounded-lg">
|
||||
<Plus className="h-5 w-5 text-primary" />
|
||||
</div>
|
||||
<div>
|
||||
<CardTitle className="text-xl">Create a New Project</CardTitle>
|
||||
<CardDescription className="text-base">
|
||||
Describe what kind of Nostr website you want to build
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</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..."
|
||||
value={prompt}
|
||||
onChange={handlePromptChange}
|
||||
className="min-h-[120px] touch-action-manipulation overscroll-contain text-base leading-relaxed"
|
||||
disabled={isCreating}
|
||||
/>
|
||||
<Button
|
||||
onClick={handleCreateProject}
|
||||
disabled={!prompt.trim() || isCreating}
|
||||
className="w-full focus-ring bg-gradient-to-r from-primary to-primary/90 hover:from-primary/90 hover:to-primary/80 shadow-lg"
|
||||
size="lg"
|
||||
>
|
||||
{isCreating ? (
|
||||
<>
|
||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
|
||||
Creating Project...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
Create Project
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user