mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-17 15:24:19 +00:00
feat(studio): use specific phosphor icons for each file type in tree
This commit is contained in:
committed by
Miguel Ángel
parent
9662d32468
commit
559ac81749
@@ -7,10 +7,15 @@ import {
|
||||
FileTs,
|
||||
FileTsx,
|
||||
FileTxt,
|
||||
FileMd,
|
||||
FileSvg,
|
||||
FilePng,
|
||||
FileJpg,
|
||||
FileVideo,
|
||||
FileCode,
|
||||
File,
|
||||
FilmStrip,
|
||||
MusicNote,
|
||||
Waveform,
|
||||
TextAa,
|
||||
Image as PhImage,
|
||||
} from "@phosphor-icons/react";
|
||||
import { ChevronDown, ChevronRight } from "../../icons/SystemIcons";
|
||||
@@ -22,27 +27,36 @@ interface FileTreeProps {
|
||||
}
|
||||
|
||||
const SZ = 14;
|
||||
const W = "duotone" as const;
|
||||
|
||||
function FileIcon({ path }: { path: string }) {
|
||||
const ext = path.split(".").pop()?.toLowerCase() ?? "";
|
||||
const d = { size: SZ, weight: "duotone" as const, className: "flex-shrink-0" };
|
||||
if (ext === "html") return <FileHtml {...d} color="#E44D26" />;
|
||||
if (ext === "css") return <FileCss {...d} color="#264DE4" />;
|
||||
if (ext === "js" || ext === "mjs" || ext === "cjs") return <FileJs {...d} color="#F0DB4F" />;
|
||||
if (ext === "jsx") return <FileJsx {...d} color="#61DAFB" />;
|
||||
if (ext === "ts" || ext === "mts") return <FileTs {...d} color="#3178C6" />;
|
||||
if (ext === "tsx") return <FileTsx {...d} color="#3178C6" />;
|
||||
if (ext === "txt" || ext === "md" || ext === "mdx") return <FileTxt {...d} color="#9CA3AF" />;
|
||||
if (ext === "json" || ext === "svg") return <FileCode {...d} color="#22C55E" />;
|
||||
if (ext === "wav" || ext === "mp3" || ext === "ogg" || ext === "m4a")
|
||||
return <MusicNote size={SZ} color="#3CE6AC" className="flex-shrink-0" />;
|
||||
const c = "flex-shrink-0";
|
||||
if (ext === "html") return <FileHtml size={SZ} weight={W} color="#E44D26" className={c} />;
|
||||
if (ext === "css") return <FileCss size={SZ} weight={W} color="#264DE4" className={c} />;
|
||||
if (ext === "js" || ext === "mjs" || ext === "cjs")
|
||||
return <FileJs size={SZ} weight={W} color="#F0DB4F" className={c} />;
|
||||
if (ext === "jsx") return <FileJsx size={SZ} weight={W} color="#61DAFB" className={c} />;
|
||||
if (ext === "ts" || ext === "mts")
|
||||
return <FileTs size={SZ} weight={W} color="#3178C6" className={c} />;
|
||||
if (ext === "tsx") return <FileTsx size={SZ} weight={W} color="#3178C6" className={c} />;
|
||||
if (ext === "json") return <FileCode size={SZ} weight={W} color="#4ADE80" className={c} />;
|
||||
if (ext === "svg") return <FileSvg size={SZ} weight={W} color="#F97316" className={c} />;
|
||||
if (ext === "md" || ext === "mdx")
|
||||
return <FileMd size={SZ} weight={W} color="#9CA3AF" className={c} />;
|
||||
if (ext === "txt") return <FileTxt size={SZ} weight={W} color="#9CA3AF" className={c} />;
|
||||
if (ext === "png") return <FilePng size={SZ} weight={W} color="#22C55E" className={c} />;
|
||||
if (ext === "jpg" || ext === "jpeg")
|
||||
return <FileJpg size={SZ} weight={W} color="#22C55E" className={c} />;
|
||||
if (ext === "webp" || ext === "gif" || ext === "ico")
|
||||
return <PhImage size={SZ} weight={W} color="#22C55E" className={c} />;
|
||||
if (ext === "mp4" || ext === "webm" || ext === "mov")
|
||||
return <FilmStrip size={SZ} color="#A855F7" className="flex-shrink-0" />;
|
||||
if (ext === "png" || ext === "jpg" || ext === "jpeg" || ext === "webp" || ext === "gif")
|
||||
return <PhImage size={SZ} color="#22C55E" className="flex-shrink-0" />;
|
||||
return <FileVideo size={SZ} weight={W} color="#A855F7" className={c} />;
|
||||
if (ext === "mp3" || ext === "wav" || ext === "ogg" || ext === "m4a")
|
||||
return <Waveform size={SZ} weight={W} color="#3CE6AC" className={c} />;
|
||||
if (ext === "woff" || ext === "woff2" || ext === "ttf" || ext === "otf")
|
||||
return <File size={SZ} weight="duotone" color="#6B7280" className="flex-shrink-0" />;
|
||||
return <File size={SZ} weight="duotone" color="#6B7280" className="flex-shrink-0" />;
|
||||
return <TextAa size={SZ} weight={W} color="#6B7280" className={c} />;
|
||||
return <File size={SZ} weight={W} color="#6B7280" className={c} />;
|
||||
}
|
||||
|
||||
interface TreeNode {
|
||||
|
||||
Reference in New Issue
Block a user