baseline style v2

This commit is contained in:
Chad Curtis committed 2025-07-21 01:50:10 +00:00
1 parent 13ff6c5a65
commit 53adc58592
7 files changed
+799 -163

No files matched your search

+4 -4
View File
@@ -62,7 +62,7 @@
"react-day-picker": "^8.10.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.0",
"react-resizable-panels": "^2.1.3",
"react-resizable-panels": "^3.0.3",
"react-router-dom": "^6.26.2",
"recharts": "^2.12.7",
"sonner": "^1.5.0",
@@ -7327,9 +7327,9 @@
}
},
"node_modules/react-resizable-panels": {
"version": "2.1.9",
"resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-2.1.9.tgz",
"integrity": "sha512-z77+X08YDIrgAes4jl8xhnUu1LNIRp4+E7cv4xHmLOxxUPO/ML7PSrE813b90vj7xvQ1lcf7g2uA9GeMZonjhQ==",
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-3.0.3.tgz",
"integrity": "sha512-7HA8THVBHTzhDK4ON0tvlGXyMAJN1zBeRpuyyremSikgYh2ku6ltD7tsGQOcXx4NKPrZtYCm/5CBr+dkruTGQw==",
"license": "MIT",
"peerDependencies": {
"react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
+1 -1
View File
@@ -64,7 +64,7 @@
"react-day-picker": "^8.10.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.0",
"react-resizable-panels": "^2.1.3",
"react-resizable-panels": "^3.0.3",
"react-router-dom": "^6.26.2",
"recharts": "^2.12.7",
"sonner": "^1.5.0",
+323
View File
@@ -0,0 +1,323 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Plus, Loader2, Info, MoreVertical, Trash2, Eye, Star, Bug, Folder } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { Label } from '@/components/ui/label';
import { Badge } from '@/components/ui/badge';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog';
import { LoginArea } from '@/components/auth/LoginArea';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { useToast } from '@/hooks/useToast';
import type { Project } from '@/lib/ProjectsManager';
import { cn } from '@/lib/utils';
interface ProjectSidebarProps {
selectedProject: Project | null;
onSelectProject: (project: Project | null) => void;
className?: string;
}
export function ProjectSidebar({
selectedProject,
onSelectProject,
className
}: ProjectSidebarProps) {
const [projects, setProjects] = useState<Project[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [isDeleting, setIsDeleting] = useState(false);
const [favorites, setFavorites] = useLocalStorage<string[]>('project-favorites', []);
const projectsManager = useProjectsManager();
const navigate = useNavigate();
const { toast } = useToast();
// Load projects on mount
React.useEffect(() => {
const loadProjects = async () => {
try {
await projectsManager.init();
const projectList = await projectsManager.getProjects();
setProjects(projectList);
} catch (error) {
console.error('Failed to load projects:', error);
} finally {
setIsLoading(false);
}
};
loadProjects();
}, [projectsManager]);
const handleNewProject = () => {
navigate('/');
};
const handleDeleteProject = async (project: Project) => {
setIsDeleting(true);
try {
await projectsManager.deleteProject(project.id);
// Remove from local state
setProjects(prev => prev.filter(p => p.id !== project.id));
// If the deleted project was selected, deselect it
if (selectedProject?.id === project.id) {
onSelectProject(null);
navigate('/');
}
toast({
title: "Project deleted",
description: `"${project.name}" has been permanently deleted.`,
});
} catch (error) {
toast({
title: "Failed to delete project",
description: error instanceof Error ? error.message : "An unexpected error occurred",
variant: "destructive",
});
} finally {
setIsDeleting(false);
}
};
const handleToggleFavorite = (project: Project) => {
const wasFavorite = favorites.includes(project.id);
const newFavorites = wasFavorite
? favorites.filter(id => id !== project.id)
: [...favorites, project.id];
setFavorites(newFavorites);
toast({
title: wasFavorite ? "Project Unfavorited" : "Project Favorited",
description: `"${project.name}" has been ${wasFavorite ? 'removed from' : 'added to'} your favorites.`,
});
};
const isFavorite = (projectId: string) => favorites.includes(projectId);
// Sort projects: favorites first, then by lastModified (newest first)
const sortedProjects = projects.sort((a, b) => {
const aIsFavorite = isFavorite(a.id);
const bIsFavorite = isFavorite(b.id);
if (aIsFavorite && !bIsFavorite) return -1;
if (!aIsFavorite && bIsFavorite) return 1;
return b.lastModified.getTime() - a.lastModified.getTime();
});
return (
<div className={cn("flex flex-col h-full bg-gradient-to-b from-sidebar to-sidebar/95", className)}>
{/* Header with Logo */}
<div className="p-4 border-b border-sidebar-border bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10">
<button
onClick={() => navigate('/')}
className="flex items-center gap-3 hover:opacity-80 transition-opacity w-full text-left"
>
<span className="text-2xl">🎭</span>
<h1 className="text-xl font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
Shakespeare
</h1>
</button>
</div>
{/* Info Section */}
<div className="p-4 border-b border-sidebar-border bg-gradient-to-r from-primary/5 to-accent/5">
<div className="space-y-2">
<div className="flex items-center justify-between">
<Label className="text-xs font-medium text-primary/80 uppercase tracking-wide">
Projects
</Label>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" className="h-4 w-4 p-0 hover:bg-primary/10">
<MoreVertical className="h-3 w-3 text-primary/60 hover:text-primary" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-48">
<DropdownMenuItem asChild>
<a href="https://soapbox.pub/mkstack" target="_blank" rel="noopener noreferrer" className="flex items-center gap-2 w-full">
<Info className="h-4 w-4" />
About MKStack
</a>
</DropdownMenuItem>
<DropdownMenuItem asChild>
<a href="https://github.com/soapbox-pub/mkstack/issues" target="_blank" rel="noopener noreferrer" className="flex items-center gap-2 w-full">
<Bug className="h-4 w-4" />
Report an Issue
</a>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
</div>
<div className="flex-1 overflow-y-auto">
<div className="p-2">
<div className="mb-2">
<Button
size="sm"
className="w-full bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90"
onClick={handleNewProject}
>
<Plus className="h-4 w-4 mr-2" />
New Project
</Button>
</div>
{isLoading ? (
<div className="space-y-1">
{Array.from({ length: 3 }).map((_, i) => (
<div key={i} className="p-3 rounded-lg">
<div className="flex items-center gap-3">
<Skeleton className="w-2 h-2 rounded-full bg-sidebar-accent" />
<Skeleton className="h-4 flex-1 bg-sidebar-accent" />
</div>
</div>
))}
</div>
) : projects.length === 0 ? (
<div className="text-center p-6 text-muted-foreground">
<Folder className="h-8 w-8 mx-auto mb-2 opacity-50" />
<p className="text-sm">No projects yet</p>
<p className="text-xs">Create your first project to get started</p>
</div>
) : (
<TooltipProvider>
<div className="space-y-1">
{sortedProjects.map((project) => (
<div
key={project.id}
className={cn(
"group relative rounded-lg transition-all duration-200 hover:bg-gradient-to-r hover:from-primary/10 hover:to-accent/10",
selectedProject?.id === project.id && "bg-gradient-to-r from-primary/15 to-accent/15 shadow-sm"
)}
>
<button
onClick={() => {
onSelectProject(project);
navigate(`/project/${project.id}`);
}}
className="w-full p-3 text-left text-sidebar-foreground"
>
<div className="flex items-center gap-3">
<Tooltip>
<TooltipTrigger asChild>
<div className="relative flex items-center">
<div className="w-2 h-2 rounded-full shrink-0 bg-green-500" />
</div>
</TooltipTrigger>
<TooltipContent>
<p>Ready</p>
</TooltipContent>
</Tooltip>
<div className="flex items-start justify-between gap-2 flex-1 min-w-0">
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2 mb-1">
<h3 className="font-medium text-sm truncate">
{project.name}
</h3>
<div className="flex items-center gap-1 ml-auto">
{isFavorite(project.id) && (
<Star className="h-3 w-3 text-yellow-500 fill-current" />
)}
<Badge variant="secondary" className="text-xs flex-shrink-0">
{project.lastModified.toLocaleDateString()}
</Badge>
</div>
</div>
</div>
{/* Dropdown Menu */}
<div className="flex-shrink-0 -mt-1 -mr-1">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="sm"
className="h-6 w-6 p-0 hover:bg-primary/20"
onClick={(e) => e.stopPropagation()}
>
<MoreVertical className="h-3 w-3" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-48">
<DropdownMenuItem
onClick={() => handleToggleFavorite(project)}
>
<Star className={cn(
"h-4 w-4 mr-2",
isFavorite(project.id) ? "text-yellow-500 fill-current" : "text-muted-foreground"
)} />
{isFavorite(project.id) ? "Unfavorite" : "Favorite"}
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => navigate(`/project/${project.id}`)}
>
<Eye className="h-4 w-4 mr-2" />
Open Project
</DropdownMenuItem>
<AlertDialog>
<AlertDialogTrigger asChild>
<DropdownMenuItem
className="text-destructive focus:text-destructive cursor-pointer"
onSelect={(e) => e.preventDefault()}
>
<Trash2 className="h-4 w-4 mr-2" />
Delete Project
</DropdownMenuItem>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete Project</AlertDialogTitle>
<AlertDialogDescription>
Are you sure you want to delete "{project.name}"? This action cannot be undone and will permanently delete all project data including files.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={() => handleDeleteProject(project)}
disabled={isDeleting}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{isDeleting ? (
<>
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
Deleting...
</>
) : (
'Delete Project'
)}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
</div>
</button>
</div>
))}
</div>
</TooltipProvider>
)}
</div>
</div>
{/* Account Selector at Bottom */}
<div className="p-4 border-t border-sidebar-border bg-gradient-to-r from-primary/5 to-accent/5 mt-auto">
<LoginArea className="w-full" />
</div>
</div>
);
}
+1 -1
View File
@@ -40,4 +40,4 @@ const ResizableHandle = ({
</ResizablePrimitive.PanelResizeHandle>
)
export { ResizablePanelGroup, ResizablePanel, ResizableHandle }
export { ResizablePanelGroup, ResizablePanel, ResizableHandle }
+31
View File
@@ -179,6 +179,37 @@ export class ProjectsManager {
}
}
async deleteProject(projectId: string): Promise<void> {
const projectPath = `${this.dir}/${projectId}`;
// Recursively delete the project directory
await this.deleteDirectory(projectPath);
}
private async deleteDirectory(dirPath: string): Promise<void> {
try {
const files = await this.fs.readdir(dirPath);
for (const file of files) {
const fullPath = `${dirPath}/${file}`;
const stat = await this.fs.stat(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;
}
}
}
private generateProjectId(name: string): string {
const timestamp = Date.now().toString(36);
const slug = name
+310 -110
View File
@@ -2,20 +2,26 @@ 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 { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable';
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 } from 'lucide-react';
import { Plus, Folder, Menu, Columns2 } from 'lucide-react';
import { useIsMobile } from '@/hooks/useIsMobile';
import { useSeoMeta } from '@unhead/react';
import { cn } from '@/lib/utils';
export default function Index() {
const [prompt, setPrompt] = useState('');
const [projects, setProjects] = useState<Project[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [isCreating, setIsCreating] = useState(false);
const [isSidebarVisible, setIsSidebarVisible] = useState(true);
const navigate = useNavigate();
const projectsManager = useProjectsManager();
const isMobile = useIsMobile();
useSeoMeta({
title: 'Shakespeare - AI-Powered Nostr Development',
@@ -56,126 +62,320 @@ export default function Index() {
navigate(`/project/${projectId}`);
};
return (
<div className="min-h-dvh bg-gradient-to-br from-primary/5 to-accent/5">
<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>
const handleProjectSelect = (project: Project | null) => {
if (project) {
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">
<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">
Shakespeare
</h1>
<div className="w-8" /> {/* Spacer */}
</header>
{/* Mobile Sidebar Overlay */}
{isSidebarVisible && (
<div className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm">
<div className="fixed left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg">
<ProjectSidebar
selectedProject={null}
onSelectProject={handleProjectSelect}
/>
</div>
<div
className="absolute inset-0"
onClick={() => setIsSidebarVisible(false)}
/>
</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={(e) => setPrompt(e.target.value)}
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 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>
<h2 className="text-xl md:text-2xl font-semibold mb-4 md:mb-6">Your Projects</h2>
{isLoading ? (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{[...Array(6)].map((_, i) => (
<Card key={i}>
<CardContent className="p-4 md:p-6">
<Skeleton className="h-4 w-3/4 mb-2" />
<Skeleton className="h-3 w-1/2" />
</CardContent>
</Card>
))}
</div>
) : projects.length === 0 ? (
<Card className="bg-gradient-to-br from-muted/50 to-muted/20 border-dashed border-2 border-muted-foreground/20">
<CardContent className="text-center py-8 md:py-12">
<div className="flex items-center justify-center gap-2 mb-4">
<Folder className="h-10 w-10 md:h-12 md:w-12 text-muted-foreground" />
<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>
<p className="text-muted-foreground text-sm md:text-base">No projects yet. Create your first project above!</p>
</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={(e) => setPrompt(e.target.value)}
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 className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{projects.map((project) => (
<Card
key={project.id}
className="cursor-pointer hover:shadow-xl hover:shadow-primary/10 transition-all duration-300 focus-ring bg-gradient-to-br from-card to-card/80 border-primary/10 hover:border-primary/20 hover:scale-[1.02]"
onClick={() => handleProjectClick(project.id)}
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
handleProjectClick(project.id);
}
}}
>
<CardHeader className="pb-2">
<CardTitle className="text-base md:text-lg">{project.name}</CardTitle>
<CardDescription className="text-sm">
Created {project.createdAt.toLocaleDateString()}
</CardDescription>
</div>
<div>
<h2 className="text-xl md:text-2xl font-semibold mb-4 md:mb-6">Your Projects</h2>
{isLoading ? (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{[...Array(6)].map((_, i) => (
<Card key={i}>
<CardContent className="p-4 md:p-6">
<Skeleton className="h-4 w-3/4 mb-2" />
<Skeleton className="h-3 w-1/2" />
</CardContent>
</Card>
))}
</div>
) : projects.length === 0 ? (
<Card className="bg-gradient-to-br from-muted/50 to-muted/20 border-dashed border-2 border-muted-foreground/20">
<CardContent className="text-center py-8 md:py-12">
<div className="flex items-center justify-center gap-2 mb-4">
<Folder className="h-10 w-10 md:h-12 md:w-12 text-muted-foreground" />
</div>
<p className="text-muted-foreground text-sm md:text-base">No projects yet. Create your first project above!</p>
</CardContent>
</Card>
) : (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{projects.map((project) => (
<Card
key={project.id}
className="cursor-pointer hover:shadow-xl hover:shadow-primary/10 transition-all duration-300 focus-ring bg-gradient-to-br from-card to-card/80 border-primary/10 hover:border-primary/20 hover:scale-[1.02]"
onClick={() => handleProjectClick(project.id)}
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
handleProjectClick(project.id);
}
}}
>
<CardHeader className="pb-2">
<CardTitle className="text-base md:text-lg">{project.name}</CardTitle>
<CardDescription className="text-sm">
Created {project.createdAt.toLocaleDateString()}
</CardDescription>
</CardHeader>
<CardContent className="pt-0">
<p className="text-xs md:text-sm text-muted-foreground">
Last modified {project.lastModified.toLocaleDateString()}
</p>
</CardContent>
</Card>
))}
</div>
)}
</div>
</div>
</div>
</div>
);
}
return (
<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
selectedProject={null}
onSelectProject={handleProjectSelect}
className="h-full"
/>
</div>
{/* Main Content Area */}
<div className="flex-1 flex flex-col overflow-hidden bg-background">
<div className="min-h-full bg-gradient-to-br from-primary/5 to-accent/5">
{/* Header */}
{!isSidebarVisible && (
<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="pt-0">
<p className="text-xs md:text-sm text-muted-foreground">
Last modified {project.lastModified.toLocaleDateString()}
</p>
<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={(e) => setPrompt(e.target.value)}
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>
<h2 className="text-xl md:text-2xl font-semibold mb-4 md:mb-6">Your Projects</h2>
{isLoading ? (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{[...Array(6)].map((_, i) => (
<Card key={i}>
<CardContent className="p-4 md:p-6">
<Skeleton className="h-4 w-3/4 mb-2" />
<Skeleton className="h-3 w-1/2" />
</CardContent>
</Card>
))}
</div>
) : projects.length === 0 ? (
<Card className="bg-gradient-to-br from-muted/50 to-muted/20 border-dashed border-2 border-muted-foreground/20">
<CardContent className="text-center py-8 md:py-12">
<div className="flex items-center justify-center gap-2 mb-4">
<Folder className="h-10 w-10 md:h-12 md:w-12 text-muted-foreground" />
</div>
<p className="text-muted-foreground text-sm md:text-base">No projects yet. Create your first project above!</p>
</CardContent>
</Card>
) : (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{projects.map((project) => (
<Card
key={project.id}
className="cursor-pointer hover:shadow-xl hover:shadow-primary/10 transition-all duration-300 focus-ring bg-gradient-to-br from-card to-card/80 border-primary/10 hover:border-primary/20 hover:scale-[1.02]"
onClick={() => handleProjectClick(project.id)}
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
handleProjectClick(project.id);
}
}}
>
<CardHeader className="pb-2">
<CardTitle className="text-base md:text-lg">{project.name}</CardTitle>
<CardDescription className="text-sm">
Created {project.createdAt.toLocaleDateString()}
</CardDescription>
</CardHeader>
<CardContent className="pt-0">
<p className="text-xs md:text-sm text-muted-foreground">
Last modified {project.lastModified.toLocaleDateString()}
</p>
</CardContent>
</Card>
))}
</div>
)}
</div>
</div>
)}
</div>
</div>
</div>
</div>
</div>
);
}
}
+129 -47
View File
@@ -4,8 +4,10 @@ import { type Project } from '@/lib/ProjectsManager';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { ChatPane } from '@/components/Shakespeare/ChatPane';
import { PreviewPane } from '@/components/Shakespeare/PreviewPane';
import { ProjectSidebar } from '@/components/ProjectSidebar';
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable';
import { Button } from '@/components/ui/button';
import { ArrowLeft, MessageSquare, Eye, Code } from 'lucide-react';
import { ArrowLeft, MessageSquare, Eye, Code, Menu, Columns2 } from 'lucide-react';
import { useNavigate } from 'react-router-dom';
import { AISettingsDialog } from '@/components/ai/AISettingsDialog';
import { useIsMobile } from '@/hooks/useIsMobile';
@@ -16,6 +18,7 @@ export function ProjectView() {
const [isLoading, setIsLoading] = useState(true);
const [activeTab, setActiveTab] = useState<'preview' | 'code'>('preview');
const [mobileView, setMobileView] = useState<'chat' | 'preview' | 'code'>('preview');
const [isSidebarVisible, setIsSidebarVisible] = useState(true);
const projectsManager = useProjectsManager();
const navigate = useNavigate();
const isMobile = useIsMobile();
@@ -67,9 +70,9 @@ export function ProjectView() {
<Button
variant="ghost"
size="sm"
onClick={() => navigate('/')}
onClick={() => setIsSidebarVisible(!isSidebarVisible)}
>
<ArrowLeft className="h-4 w-4" />
<Menu className="h-4 w-4" />
</Button>
<div className="min-w-0 flex-1">
<h1 className="text-sm font-semibold truncate">{project.name}</h1>
@@ -79,6 +82,30 @@ export function ProjectView() {
<AISettingsDialog />
</header>
{/* Mobile Sidebar Overlay */}
{isSidebarVisible && (
<div className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm">
<div className="fixed left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg">
<ProjectSidebar
selectedProject={project}
onSelectProject={(selectedProject) => {
setProject(selectedProject);
setIsSidebarVisible(false);
if (selectedProject) {
navigate(`/project/${selectedProject.id}`);
} else {
navigate('/');
}
}}
/>
</div>
<div
className="absolute inset-0"
onClick={() => setIsSidebarVisible(false)}
/>
</div>
)}
<div className="flex-1 overflow-hidden">
{mobileView === 'chat' && (
<ChatPane projectId={project.id} projectName={project.name} />
@@ -127,52 +154,107 @@ export function ProjectView() {
}
return (
<div className="h-screen flex flex-col bg-background">
<header className="border-b bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 backdrop-blur supports-[backdrop-filter]:bg-gradient-to-r supports-[backdrop-filter]:from-primary/10 supports-[backdrop-filter]:via-accent/5 supports-[backdrop-filter]:to-primary/10 px-4 py-3 flex items-center justify-between">
<div className="flex items-center space-x-4">
<Button
variant="ghost"
size="sm"
onClick={() => navigate('/')}
>
<ArrowLeft className="h-4 w-4" />
</Button>
<div>
<h1 className="text-lg font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">{project.name}</h1>
<p className="text-sm text-muted-foreground">{project.id}</p>
</div>
</div>
<div className="h-screen flex bg-background">
{/* Fixed Sidebar */}
<div className={`w-80 border-r bg-sidebar transition-all duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}>
<ProjectSidebar
selectedProject={project}
onSelectProject={(selectedProject) => {
setProject(selectedProject);
if (selectedProject) {
navigate(`/project/${selectedProject.id}`);
} else {
navigate('/');
}
}}
className="h-full"
/>
</div>
<div className="flex items-center space-x-2">
<AISettingsDialog />
<div className="flex space-x-2">
<Button
variant={activeTab === 'preview' ? 'default' : 'ghost'}
size="sm"
onClick={() => setActiveTab('preview')}
>
Preview
</Button>
<Button
variant={activeTab === 'code' ? 'default' : 'ghost'}
size="sm"
onClick={() => setActiveTab('code')}
>
Code
</Button>
</div>
</div>
</header>
{/* Main Content Area */}
<div className="flex-1 flex flex-col overflow-hidden bg-background">
<div className="flex-1 overflow-hidden">
<ResizablePanelGroup direction="horizontal" className="h-full">
{/* Chat Panel */}
<ResizablePanel defaultSize={50} minSize={30}>
<div className="h-full flex flex-col">
{/* Chat Header */}
<div className="px-4 border-b flex-shrink-0">
<div className="flex items-center justify-between h-12">
{/* Left side - Sidebar toggle */}
<div className="flex items-center gap-2">
<Button
variant="ghost"
size="sm"
onClick={() => setIsSidebarVisible(!isSidebarVisible)}
className="h-8 w-8 p-0"
aria-label="Toggle sidebar"
>
<Columns2 className="h-4 w-4" />
</Button>
</div>
<div className="flex-1 flex overflow-hidden">
<div className="w-1/3 border-r">
<ChatPane projectId={project.id} projectName={project.name} />
</div>
<div className="flex-1">
<PreviewPane
projectId={project.id}
activeTab={activeTab}
/>
{/* Center - Project title */}
<div className="flex-1 min-w-0 ml-2 px-4">
<div className="flex items-center justify-center md:justify-start gap-2">
<h2 className="font-semibold text-lg truncate">
{project.name}
</h2>
</div>
</div>
{/* Right side - AI Settings */}
<div className="flex items-center gap-2">
<AISettingsDialog />
</div>
</div>
</div>
{/* Chat Content */}
<div className="flex-1 overflow-hidden">
<ChatPane projectId={project.id} projectName={project.name} />
</div>
</div>
</ResizablePanel>
{/* Resizable Handle */}
<ResizableHandle withHandle />
{/* Preview/Code Panel */}
<ResizablePanel defaultSize={50} minSize={30}>
<div className="h-full flex flex-col">
{/* Preview Header */}
<div className="px-4 border-b flex-shrink-0">
<div className="flex items-center justify-between h-12">
<div className="flex space-x-2">
<Button
variant={activeTab === 'preview' ? 'default' : 'ghost'}
size="sm"
onClick={() => setActiveTab('preview')}
>
Preview
</Button>
<Button
variant={activeTab === 'code' ? 'default' : 'ghost'}
size="sm"
onClick={() => setActiveTab('code')}
>
Code
</Button>
</div>
</div>
</div>
{/* Preview Content */}
<div className="flex-1 overflow-hidden">
<PreviewPane
projectId={project.id}
activeTab={activeTab}
/>
</div>
</div>
</ResizablePanel>
</ResizablePanelGroup>
</div>
</div>
</div>