Skip to content

Commit

Permalink
refactor: move getfileicons to seperate file
Browse files Browse the repository at this point in the history
  • Loading branch information
pnxl committed Aug 13, 2023
1 parent 44888f6 commit 62ddbc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 1 addition & 13 deletions src/routes/dashboard/[workspace_id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import IconAccountMultipleOutline from "~icons/mdi/account-multiple-outline";
import IconTrashCanOutline from "~icons/mdi/trash-can-outline";
import IconAccount from "~icons/mdi/account";
import IconMenuDown from "~icons/mdi/menu-down";
import IconFileOutline from "~icons/mdi/file-outline";
import IconFileImageOutline from "~icons/mdi/file-image-outline";
import IconDownload from "~icons/mdi/download";
import IconDeleteOutline from "~icons/mdi/delete-outline";
import IconDotsHorizontal from "~icons/mdi/dots-horizontal";
Expand All @@ -32,6 +30,7 @@ import IconClose from "~icons/mdi/close";
import cattoDriveLogo from "@/assets/icon/logo.png";

import FullscreenLoader from "@/components/FullscreenLoader";
import { getFileIcon } from "@/utils/getFileIcons";

import { DropdownMenu, Dialog } from "@kobalte/core";

Expand Down Expand Up @@ -89,17 +88,6 @@ const Page: Component = () => {
}
};

const getFileIcon = (file: any) => {
const fileExtension = file.name.split(".").pop().toLowerCase();
const imageFileExtensions = ["png", "jpg", "jpeg", "gif", "webp"];

if (imageFileExtensions.indexOf(fileExtension) !== -1) {
return <IconFileImageOutline class="text-xl" />;
} else {
return <IconFileOutline class="text-xl" />;
}
};

createEffect(() => {
window.scrollTo(0, 0);
});
Expand Down
13 changes: 13 additions & 0 deletions src/utils/getFileIcons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import IconFileOutline from "~icons/mdi/file-outline";
import IconFileImageOutline from "~icons/mdi/file-image-outline";

export const getFileIcon = (file: any) => {
const fileExtension = file.name.split(".").pop().toLowerCase();
const imageFileExtensions = ["png", "jpg", "jpeg", "gif", "webp"];

if (imageFileExtensions.indexOf(fileExtension) !== -1) {
return <IconFileImageOutline class="text-xl" />;
} else {
return <IconFileOutline class="text-xl" />;
}
};

0 comments on commit 62ddbc6

Please sign in to comment.