From ae0dc50b021eb00a9904ea3acf912ba07234091d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 30 Aug 2025 16:52:34 -0500 Subject: [PATCH] Also color-code editor pane titles with their git state --- src/components/Shakespeare/FileEditor.tsx | 32 ++++++++++++++++++++-- src/components/Shakespeare/PreviewPane.tsx | 2 ++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/components/Shakespeare/FileEditor.tsx b/src/components/Shakespeare/FileEditor.tsx index d1ca1fd9..05ae0ab4 100644 --- a/src/components/Shakespeare/FileEditor.tsx +++ b/src/components/Shakespeare/FileEditor.tsx @@ -4,18 +4,21 @@ import { Textarea } from '@/components/ui/textarea'; import { CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Save, Loader2 } from 'lucide-react'; import { cn } from '@/lib/utils'; +import { useGitStatus } from '@/hooks/useGitStatus'; interface FileEditorProps { filePath: string; content: string; onSave: (content: string) => void; isLoading: boolean; + projectId?: string; } -export function FileEditor({ filePath, content, onSave, isLoading }: FileEditorProps) { +export function FileEditor({ filePath, content, onSave, isLoading, projectId }: FileEditorProps) { const [editedContent, setEditedContent] = useState(content); const [isSaving, setIsSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); + const { data: gitStatus } = useGitStatus(projectId || null); useEffect(() => { setEditedContent(content); @@ -64,11 +67,36 @@ export function FileEditor({ filePath, content, onSave, isLoading }: FileEditorP return 'font-mono text-sm'; }; + // Helper function to get git status for the current file + const getFileGitStatus = (filePath: string) => { + if (!gitStatus?.changedFiles) return null; + const fileChange = gitStatus.changedFiles.find(change => change.filepath === filePath); + return fileChange?.status || null; + }; + + // Helper function to get styling classes based on git status + const getGitStatusClasses = (status: string | null) => { + switch (status) { + case 'added': + case 'untracked': + return 'text-green-600 dark:text-green-400'; + case 'modified': + case 'staged': + return 'text-yellow-600 dark:text-yellow-400'; + default: + return ''; + } + }; + + // Get git status for the current file + const currentFileGitStatus = getFileGitStatus(filePath); + const gitStatusClasses = getGitStatusClasses(currentFileGitStatus); + return (
- {filePath} + {filePath}
{hasChanges && ( Unsaved changes diff --git a/src/components/Shakespeare/PreviewPane.tsx b/src/components/Shakespeare/PreviewPane.tsx index d37be593..59dc0aa7 100644 --- a/src/components/Shakespeare/PreviewPane.tsx +++ b/src/components/Shakespeare/PreviewPane.tsx @@ -385,6 +385,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) { content={fileContent} onSave={handleFileSave} isLoading={isLoading} + projectId={projectId} /> ) : (
@@ -430,6 +431,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) { content={fileContent} onSave={handleFileSave} isLoading={isLoading} + projectId={projectId} /> ) : (