64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
// Optimized library assets only. No handcrafted SVG or runtime icon requests.
|
|||
|
|
import search from "@fluentui/svg-icons/icons/search_24_regular.svg?raw";
|
||
|
|
import settings from "@fluentui/svg-icons/icons/settings_20_regular.svg?raw";
|
||
|
|
import filter from "@fluentui/svg-icons/icons/filter_20_regular.svg?raw";
|
||
|
|
import dismiss from "@fluentui/svg-icons/icons/dismiss_20_regular.svg?raw";
|
||
|
|
import folder from "@fluentui/svg-icons/icons/folder_24_regular.svg?raw";
|
||
|
|
import folderAdd from "@fluentui/svg-icons/icons/folder_add_20_regular.svg?raw";
|
||
|
|
import document from "@fluentui/svg-icons/icons/document_24_regular.svg?raw";
|
||
|
|
import pdf from "@fluentui/svg-icons/icons/document_pdf_24_regular.svg?raw";
|
||
|
|
import code from "@fluentui/svg-icons/icons/code_24_regular.svg?raw";
|
||
|
|
import lock from "@fluentui/svg-icons/icons/lock_closed_20_regular.svg?raw";
|
||
|
|
import arrowUp from "@fluentui/svg-icons/icons/arrow_up_16_regular.svg?raw";
|
||
|
|
import arrowDown from "@fluentui/svg-icons/icons/arrow_down_16_regular.svg?raw";
|
||
|
|
import open from "@fluentui/svg-icons/icons/open_20_regular.svg?raw";
|
||
|
|
import chevron from "@fluentui/svg-icons/icons/chevron_down_16_regular.svg?raw";
|
||
|
|
import sparkles from "@fluentui/svg-icons/icons/sparkle_20_regular.svg?raw";
|
||
|
|
|
||
|
|
const assets = {
|
||
|
|
search,
|
||
|
|
settings,
|
||
|
|
filter,
|
||
|
|
dismiss,
|
||
|
|
folder,
|
||
|
|
folderAdd,
|
||
|
|
document,
|
||
|
|
pdf,
|
||
|
|
code,
|
||
|
|
lock,
|
||
|
|
arrowUp,
|
||
|
|
arrowDown,
|
||
|
|
open,
|
||
|
|
chevron,
|
||
|
|
sparkles,
|
||
|
|
};
|
||
|
|
export function icon(name: keyof typeof assets) {
|
||
|
|
return `<span class="icon" aria-hidden="true">${assets[name]}</span>`;
|
||
|
|
}
|
||
|
|
export function fileIcon(filename: string) {
|
||
|
|
const extension = filename.split(".").pop()?.toLowerCase();
|
||
|
|
if (extension === "pdf") return { html: icon("pdf"), type: "pdf" };
|
||
|
|
if (
|
||
|
|
extension &&
|
||
|
|
[
|
||
|
|
"rs",
|
||
|
|
"js",
|
||
|
|
"ts",
|
||
|
|
"tsx",
|
||
|
|
"py",
|
||
|
|
"json",
|
||
|
|
"html",
|
||
|
|
"css",
|
||
|
|
"toml",
|
||
|
|
"yaml",
|
||
|
|
"yml",
|
||
|
|
].includes(extension)
|
||
|
|
)
|
||
|
|
return { html: icon("code"), type: "code" };
|
||
|
|
return {
|
||
|
|
html: icon("document"),
|
||
|
|
type: ["doc", "docx"].includes(extension || "")
|
||
|
|
? "document-word"
|
||
|
|
: "document",
|
||
|
|
};
|
||
|
|
}
|