feat: expand file extension icon mappings and use dynamic icons in dashboard cards

- Add comprehensive file extension mappings organized by category (text, web, programming, data, config, shell, documents, images, audio, video, archives, fonts)
- Add support for 100+ file extensions including modern languages (Rust, Go, Swift, Kotlin, Zig, etc.)
- Add media file support (images, audio, video) with appropriate icons
- Add archive and font file type mappings
- Replace hardcoded SVG in dashboard cards with dynamic icon
This commit is contained in:
Bruno Charest 2026-03-30 23:00:35 -04:00
parent 4ede1a4fb1
commit 01841b8abe

View File

@ -59,32 +59,35 @@
// File extension → Lucide icon mapping // File extension → Lucide icon mapping
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
const EXT_ICONS = { const EXT_ICONS = {
// Text files
".md": "file-text", ".md": "file-text",
".txt": "file-text", ".txt": "file-text",
".log": "file-text", ".log": "file-text",
".py": "file-code", ".readme": "file-text",
".js": "file-code", ".rst": "file-text",
".ts": "file-code", ".adoc": "file-text",
".jsx": "file-code",
".tsx": "file-code", // Web development
".html": "file-code", ".html": "file-code",
".htm": "file-code",
".css": "file-code", ".css": "file-code",
".scss": "file-code", ".scss": "file-code",
".sass": "file-code",
".less": "file-code", ".less": "file-code",
".json": "file-json", ".js": "file-code",
".yaml": "file-cog", ".jsx": "file-code",
".yml": "file-cog", ".ts": "file-code",
".toml": "file-cog", ".tsx": "file-code",
".xml": "file-code", ".vue": "file-code",
".sh": "terminal", ".svelte": "file-code",
".bash": "terminal",
".zsh": "terminal", // Programming languages
".bat": "terminal", ".py": "file-code",
".cmd": "terminal",
".ps1": "terminal",
".java": "file-code", ".java": "file-code",
".c": "file-code", ".c": "file-code",
".cpp": "file-code", ".cpp": "file-code",
".cc": "file-code",
".cxx": "file-code",
".h": "file-code", ".h": "file-code",
".hpp": "file-code", ".hpp": "file-code",
".cs": "file-code", ".cs": "file-code",
@ -92,12 +95,164 @@
".rs": "file-code", ".rs": "file-code",
".rb": "file-code", ".rb": "file-code",
".php": "file-code", ".php": "file-code",
".sql": "database", ".swift": "file-code",
".kt": "file-code",
".scala": "file-code",
".r": "file-code",
".m": "file-code",
".pl": "file-code",
".lua": "file-code",
".dart": "file-code",
".nim": "file-code",
".zig": "file-code",
".odin": "file-code",
".v": "file-code",
".cr": "file-code",
".ex": "file-code",
".exs": "file-code",
".elm": "file-code",
".purs": "file-code",
".hs": "file-code",
".ml": "file-code",
".ocaml": "file-code",
".fs": "file-code",
".fsx": "file-code",
".vb": "file-code",
".pas": "file-code",
".pp": "file-code",
".inc": "file-code",
// Data formats
".json": "file-json",
".yaml": "file-cog",
".yml": "file-cog",
".toml": "file-cog",
".xml": "file-code",
".csv": "table", ".csv": "table",
".tsv": "table",
".sql": "database",
".db": "database",
".sqlite": "database",
".sqlite3": "database",
".parquet": "database",
".avro": "database",
// Configuration files
".ini": "file-cog", ".ini": "file-cog",
".cfg": "file-cog", ".cfg": "file-cog",
".conf": "file-cog", ".conf": "file-cog",
".env": "file-cog", ".env": "file-cog",
".dockerfile": "file-cog",
".gitignore": "file-cog",
".gitattributes": "file-cog",
".editorconfig": "file-cog",
".eslintrc": "file-cog",
".prettierrc": "file-cog",
".babelrc": "file-cog",
".tsconfig": "file-cog",
"package.json": "file-cog",
"package-lock.json": "file-cog",
"yarn.lock": "file-cog",
"composer.json": "file-cog",
"requirements.txt": "file-cog",
"pipfile": "file-cog",
"gemfile": "file-cog",
"cargo.toml": "file-cog",
"go.mod": "file-cog",
"go.sum": "file-cog",
"pom.xml": "file-cog",
"build.gradle": "file-cog",
"cmakelists.txt": "file-cog",
"makefile": "file-cog",
// Shell scripts
".sh": "terminal",
".bash": "terminal",
".zsh": "terminal",
".fish": "terminal",
".bat": "terminal",
".cmd": "terminal",
".ps1": "terminal",
".psm1": "terminal",
".psd1": "terminal",
// Document formats
".pdf": "file-text",
".doc": "file-text",
".docx": "file-text",
".rtf": "file-text",
".odt": "file-text",
".tex": "file-text",
".latex": "file-text",
// Image files
".png": "file-image",
".jpg": "file-image",
".jpeg": "file-image",
".gif": "file-image",
".svg": "file-image",
".webp": "file-image",
".bmp": "file-image",
".ico": "file-image",
".tiff": "file-image",
".tif": "file-image",
// Audio files
".mp3": "file-music",
".wav": "file-music",
".flac": "file-music",
".aac": "file-music",
".ogg": "file-music",
".m4a": "file-music",
".wma": "file-music",
// Video files
".mp4": "play",
".avi": "play",
".mov": "play",
".wmv": "play",
".flv": "play",
".webm": "play",
".mkv": "play",
".m4v": "play",
".3gp": "play",
// Archive files
".zip": "file-archive",
".rar": "file-archive",
".7z": "file-archive",
".tar": "file-archive",
".gz": "file-archive",
".tgz": "file-archive",
".bz2": "file-archive",
".xz": "file-archive",
".deb": "file-archive",
".rpm": "file-archive",
".dmg": "file-archive",
".pkg": "file-archive",
".msi": "file-archive",
".exe": "file-archive",
// Font files
".ttf": "file-type",
".otf": "file-type",
".woff": "file-type",
".woff2": "file-type",
".eot": "file-type",
// Other common files
".key": "file-cog",
".pem": "file-cog",
".crt": "file-cog",
".cert": "file-cog",
".p12": "file-cog",
".pfx": "file-cog",
".lock": "file-cog",
".tmp": "file",
".bak": "file",
".old": "file",
".orig": "file",
".save": "file",
}; };
function getFileIcon(name) { function getFileIcon(name) {
@ -3054,8 +3209,8 @@
const icon = document.createElement("div"); const icon = document.createElement("div");
icon.className = "dashboard-card-icon"; icon.className = "dashboard-card-icon";
icon.innerHTML = const fileIconName = getFileIcon(file.path);
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>'; icon.appendChild(icon(fileIconName, 24));
const badge = document.createElement("span"); const badge = document.createElement("span");
badge.className = "dashboard-vault-badge"; badge.className = "dashboard-vault-badge";