mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Simplify code tabs on desktop
This commit is contained in:
3 files changed
+77
-98
No files matched your search
@@ -7,7 +7,7 @@ import { useBuildProject } from '@/hooks/useBuildProject';
|
||||
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
||||
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { FolderOpen, ArrowLeft, X, Bug, Copy, Check, Play, Loader2, MenuIcon } from 'lucide-react';
|
||||
import { FolderOpen, ArrowLeft, X, Bug, Copy, Check, Play, Loader2, MenuIcon, Code } from 'lucide-react';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { GitStatusIndicator } from '@/components/GitStatusIndicator';
|
||||
import { BrowserAddressBar } from '@/components/ui/browser-address-bar';
|
||||
@@ -27,6 +27,7 @@ const IFRAME_DOMAIN = import.meta.env.VITE_IFRAME_DOMAIN || 'local-shakespeare.d
|
||||
interface PreviewPaneProps {
|
||||
projectId: string;
|
||||
activeTab: 'preview' | 'code';
|
||||
onToggleView?: () => void;
|
||||
}
|
||||
|
||||
interface JSONRPCRequest {
|
||||
@@ -65,7 +66,7 @@ interface ConsoleMessage {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
export function PreviewPane({ projectId, activeTab, onToggleView }: PreviewPaneProps) {
|
||||
const { t } = useTranslation();
|
||||
const [selectedFile, setSelectedFile] = useState<string | null>(null);
|
||||
const [fileContent, setFileContent] = useState<string>('');
|
||||
@@ -518,6 +519,15 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
{(!isMobile && onToggleView) && (
|
||||
<DropdownMenuItem
|
||||
onClick={onToggleView}
|
||||
className="gap-2"
|
||||
>
|
||||
<Code className="h-4 w-4" />
|
||||
View Code
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={handleBuildProject}
|
||||
disabled={isBuildLoading}
|
||||
@@ -541,7 +551,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
<TabsContent value="preview" className="h-full mt-0">
|
||||
{hasBuiltProject ? (
|
||||
<div className="h-full w-full flex flex-col relative">
|
||||
<div className="flex items-center border-b w-full">
|
||||
<div className="h-12 flex items-center w-full">
|
||||
<BrowserAddressBar
|
||||
currentPath={currentPath}
|
||||
onNavigate={navigateToPath}
|
||||
@@ -666,38 +676,57 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="h-full flex">
|
||||
<div className="w-1/3 border-r">
|
||||
<ScrollArea className="h-[calc(100%-60px)]">
|
||||
<ScrollBar orientation="horizontal" />
|
||||
<div className="min-w-max">
|
||||
<FileTree
|
||||
projectId={projectId}
|
||||
onFileSelect={handleFileSelect}
|
||||
selectedFile={selectedFile}
|
||||
/>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
<div className="h-full flex flex-col">
|
||||
{/* Code view header with back button */}
|
||||
{!isMobile && onToggleView && (
|
||||
<div className="h-12 px-4 border-b flex items-center bg-gradient-to-r from-muted/20 to-background">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={onToggleView}
|
||||
className="gap-2 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
{t('backToPreview')}
|
||||
</Button>
|
||||
<div className="flex-1" />
|
||||
<GitStatusIndicator projectId={projectId} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex-1">
|
||||
{selectedFile ? (
|
||||
<FileEditor
|
||||
filePath={selectedFile}
|
||||
content={fileContent}
|
||||
onSave={handleFileSave}
|
||||
isLoading={isLoading}
|
||||
projectId={projectId}
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
<p className="text-muted-foreground">
|
||||
{t('selectFileFromExplorer')}
|
||||
</p>
|
||||
<div className="flex-1 flex min-h-0">
|
||||
<div className="w-1/3 border-r flex flex-col">
|
||||
<ScrollArea className="flex-1">
|
||||
<ScrollBar orientation="horizontal" />
|
||||
<div className="min-w-max">
|
||||
<FileTree
|
||||
projectId={projectId}
|
||||
onFileSelect={handleFileSelect}
|
||||
selectedFile={selectedFile}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</ScrollArea>
|
||||
</div>
|
||||
|
||||
<div className="flex-1">
|
||||
{selectedFile ? (
|
||||
<FileEditor
|
||||
filePath={selectedFile}
|
||||
content={fileContent}
|
||||
onSave={handleFileSave}
|
||||
isLoading={isLoading}
|
||||
projectId={projectId}
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
<p className="text-muted-foreground">
|
||||
{t('selectFileFromExplorer')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -107,6 +107,7 @@ const resources = {
|
||||
chat: 'Chat',
|
||||
preview: 'Preview',
|
||||
code: 'Code',
|
||||
backToPreview: 'Back to Preview',
|
||||
|
||||
// Preview Pane
|
||||
projectPreview: 'Project Preview',
|
||||
@@ -399,6 +400,7 @@ const resources = {
|
||||
chat: 'Chat',
|
||||
preview: 'Visualização',
|
||||
code: 'Código',
|
||||
backToPreview: 'Voltar à Visualização',
|
||||
|
||||
// Preview Pane
|
||||
projectPreview: 'Visualização do Projeto',
|
||||
@@ -691,6 +693,7 @@ const resources = {
|
||||
chat: '聊天',
|
||||
preview: '预览',
|
||||
code: '代码',
|
||||
backToPreview: '返回预览',
|
||||
|
||||
// Preview Pane
|
||||
projectPreview: '项目预览',
|
||||
|
||||
+12
-65
@@ -83,8 +83,6 @@ export function ProjectView() {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleNewChat = () => {
|
||||
// Reset to chat view on mobile when starting new chat
|
||||
if (isMobile) {
|
||||
@@ -411,70 +409,19 @@ export function ProjectView() {
|
||||
|
||||
{/* Preview/Code Panel */}
|
||||
<ResizablePanel defaultSize={60} minSize={30}>
|
||||
<div className="h-full flex flex-col">
|
||||
{/* Preview Header */}
|
||||
<div className="h-12 px-4 border-b flex-shrink-0 bg-gradient-to-r from-background via-muted/20 to-background">
|
||||
<div className="flex items-center justify-between h-12">
|
||||
<div className="flex">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setActiveTab('preview')}
|
||||
disabled={!project}
|
||||
className={`
|
||||
relative px-4 py-2 rounded-none border-b-2 transition-all duration-200 ease-in-out
|
||||
${activeTab === 'preview'
|
||||
? 'border-primary bg-primary/5 text-primary font-medium shadow-sm'
|
||||
: 'border-transparent hover:border-muted-foreground/20 hover:bg-muted/50 text-muted-foreground hover:text-foreground'
|
||||
}
|
||||
`}
|
||||
>
|
||||
<Eye className="h-4 w-4 mr-2" />
|
||||
{t('preview')}
|
||||
{activeTab === 'preview' && (
|
||||
<div className="absolute bottom-0 left-0 right-0 h-0.5 bg-gradient-to-r from-primary/50 via-primary to-primary/50 rounded-full" />
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setActiveTab('code')}
|
||||
disabled={!project}
|
||||
className={`
|
||||
relative px-4 py-2 rounded-none border-b-2 transition-all duration-200 ease-in-out
|
||||
${activeTab === 'code'
|
||||
? 'border-primary bg-primary/5 text-primary font-medium shadow-sm'
|
||||
: 'border-transparent hover:border-muted-foreground/20 hover:bg-muted/50 text-muted-foreground hover:text-foreground'
|
||||
}
|
||||
`}
|
||||
>
|
||||
<Code className="h-4 w-4 mr-2" />
|
||||
{t('code')}
|
||||
{activeTab !== 'code' && project && (
|
||||
<GitStatusIndicator projectId={project.id} className="ml-1" />
|
||||
)}
|
||||
{activeTab === 'code' && (
|
||||
<div className="absolute bottom-0 left-0 right-0 h-0.5 bg-gradient-to-r from-primary/50 via-primary to-primary/50 rounded-full" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="h-full">
|
||||
{project ? (
|
||||
<PreviewPane
|
||||
projectId={project.id}
|
||||
activeTab={activeTab}
|
||||
onToggleView={() => setActiveTab(activeTab === 'preview' ? 'code' : 'preview')}
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full p-4 space-y-4">
|
||||
<Skeleton className="h-8 w-32" />
|
||||
<Skeleton className="h-full w-full" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Preview Content */}
|
||||
<div className="flex-1 overflow-hidden">
|
||||
{project ? (
|
||||
<PreviewPane
|
||||
projectId={project.id}
|
||||
activeTab={activeTab}
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full p-4 space-y-4">
|
||||
<Skeleton className="h-8 w-32" />
|
||||
<Skeleton className="h-full w-full" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ResizablePanel>
|
||||
</ResizablePanelGroup>
|
||||
|
||||
Reference in new issue
Block a user