Skip to content

Commit

Permalink
✨ Add subtitles icon
Browse files Browse the repository at this point in the history
  • Loading branch information
journey-ad committed Jun 22, 2024
1 parent 522c7ee commit 2d11985
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 331 deletions.
42 changes: 3 additions & 39 deletions components/FileTypeIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,16 @@
"use client";

import {
FileTypeAudioIcon,
FileTypeBookIcon,
FileTypeFileIcon,
FileTypeFolderIcon,
FileTypeImageIcon,
FileTypeVideoIcon,
FileTypeWebIcon,
FileTypeArchiveIcon,
FileTypeDiskIcon,
FileTypeExecutableIcon,
} from "@/components/icons";

const fileTypeIcons = {
folder: <FileTypeFolderIcon />, // 📁
file: <FileTypeFileIcon />, // 📄,
image: <FileTypeImageIcon />, // 🖼️,
video: <FileTypeVideoIcon />, // 🎞️,
audio: <FileTypeAudioIcon />, // 🎵,
book: <FileTypeBookIcon />, // 📚,
web: <FileTypeWebIcon />, // 🌐,
archive: <FileTypeArchiveIcon />, // 📦️,
disk: <FileTypeDiskIcon />, // 💿,
executable: <FileTypeExecutableIcon />, // ⚙️,
};

const extensionMap = {
folder: "folder",
audio: "mp3,wav,ogg,m4a,flac,wma,aac,mid,midi,cue",
image: "jpg,jpeg,png,gif,bmp,svg,webp,tiff,ico,heic,raw,psd,ai",
video: "mp4,mkv,webm,avi,mov,flv,wmv,mpeg,mpg,3gp,3g2,m4v,rm,rmvb,ts,m2ts",
video: "mp4,mkv,webm,avi,mov,flv,wmv,mpeg,mpg,3gp,m4v,rm,rmvb,ts,m2ts,pmp",
book: "pdf,epub,fb2,mobi,azw,azw3,cbr,cbz,chm",
web: "torrent,html,htm,php,url,asp,aspx,jsp",
archive: "zip,rar,7z,gz,bz2,tar,xpi,rpm,cab,lzh,dmg,z,lz,xz,tgz,tbz2",
disk: "iso,img,vmdk,vdi",
executable: "exe,msi,apk,xpi,deb,bat,sh,bin,dll,so,cmd,com,run,vbs,app",
subtitle: "srt,sub,ssa,ass,vtt,rt,rtx,smi",
};

const extensionArr = Object.fromEntries(
Expand All @@ -56,12 +31,6 @@ const getFileType = (extension?: string) => {
return "file"; // Default type for unknown file extensions
};

const getFileTypeIcon = (extension?: string) => {
const type = getFileType(extension);

return fileTypeIcons[type as keyof typeof fileTypeIcons];
};

export default function FileTypeIcon({
extension,
className,
Expand All @@ -70,16 +39,11 @@ export default function FileTypeIcon({
className?: string;
}) {
const type = getFileType(extension);
// const icon = getFileTypeIcon(extension);

const defaultClassName = "file-type-icon";

if (!className) className = defaultClassName;
else className = `${defaultClassName} ${className}`;

return (
<span className={className} data-icon={type}>
{/* {icon} */}
</span>
);
return <span className={className} data-icon={type} />;
}
Loading

0 comments on commit 2d11985

Please sign in to comment.