From 92ef8fb3f3d81b57cc573faf0b3d4502ef4ce878 Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Thu, 22 Jan 2026 23:49:23 -0800 Subject: [PATCH] add differentiating file icons and colors to code view --- src/components/Shakespeare/FileTree.tsx | 51 ++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/components/Shakespeare/FileTree.tsx b/src/components/Shakespeare/FileTree.tsx index af5f6877..cca14538 100644 --- a/src/components/Shakespeare/FileTree.tsx +++ b/src/components/Shakespeare/FileTree.tsx @@ -3,7 +3,8 @@ import { useTranslation } from 'react-i18next'; import { useProjectsManager } from '@/hooks/useProjectsManager'; import { useFS } from '@/hooks/useFS'; import { useGitStatus } from '@/hooks/useGitStatus'; -import { ChevronRight, ChevronDown, File, Folder, Search } from 'lucide-react'; +import { ChevronRight, ChevronDown, File, Folder, Search, Code, FileText, Image, FileJson, Palette, Settings, FileCode } from 'lucide-react'; +import type { LucideIcon } from 'lucide-react'; import { cn } from '@/lib/utils'; import { createGitignoreFilter, normalizePathForGitignore } from '@/lib/gitignore'; import { Input } from '@/components/ui/input'; @@ -22,6 +23,49 @@ interface FileNode { isOpen?: boolean; } +// Helper function to get file icon based on extension +function getFileIcon(fileName: string): { icon: LucideIcon; color: string } { + const ext = fileName.split('.').pop()?.toLowerCase() || ''; + + // Image files - subtle blue hint + if (['jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'ico', 'bmp', 'tiff'].includes(ext)) { + return { icon: Image, color: 'text-blue-400/60' }; + } + + // Code files - subtle amber hint + if (['js', 'jsx', 'ts', 'tsx', 'py', 'java', 'cpp', 'c', 'cs', 'php', 'rb', 'go', 'rs', 'swift', 'kt', 'scala', 'dart'].includes(ext)) { + return { icon: Code, color: 'text-amber-400/60' }; + } + + // Web files - subtle orange hint + if (['html', 'htm', 'xhtml'].includes(ext)) { + return { icon: FileCode, color: 'text-orange-400/60' }; + } + + // CSS files - subtle purple hint + if (['css', 'scss', 'sass', 'less', 'styl'].includes(ext)) { + return { icon: Palette, color: 'text-purple-400/60' }; + } + + // Data/Config files - subtle green hint + if (['json', 'jsonc'].includes(ext)) { + return { icon: FileJson, color: 'text-green-400/60' }; + } + + // Config files - subtle amber hint + if (['xml', 'yaml', 'yml', 'toml', 'ini', 'conf', 'config'].includes(ext)) { + return { icon: Settings, color: 'text-amber-400/60' }; + } + + // Text/Markdown files - subtle amber hint + if (['txt', 'md', 'markdown', 'rst', 'log'].includes(ext)) { + return { icon: FileText, color: 'text-amber-400/60' }; + } + + // Default file icon - subtle amber hint + return { icon: File, color: 'text-amber-400/60' }; +} + export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProps) { const { t } = useTranslation(); const [tree, setTree] = useState([]); @@ -264,7 +308,10 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp ) : ( <>
{/* Spacer for alignment */} - + {(() => { + const { icon: Icon, color } = getFileIcon(node.name); + return ; + })()} )} {node.name}