Files
atridotdad/src/utils/icons.ts
Atridad Lahiji 0512645035
All checks were successful
Docker Deploy / build-and-push (push) Successful in 5m6s
More optimizations
2026-01-24 23:58:30 -07:00

36 lines
1.0 KiB
TypeScript

import { mdiEmail, mdiPhone, mdiDownload, mdiLink } from "@mdi/js";
import * as simpleIcons from "simple-icons";
export function getSimpleIconPath(network: string): string {
try {
const slug = network.toLowerCase().normalize("NFKD").replace(/[^\w]/g, "");
const iconKey = `si${slug.charAt(0).toUpperCase()}${slug.slice(1)}`;
const icon = (simpleIcons as any)[iconKey];
return icon ? icon.path : "";
} catch (error) {
console.warn(`Error finding icon for network: ${network}`, error);
return "";
}
}
export function getMdiIconPath(iconName: string): string {
const iconMap: { [key: string]: string } = {
"mdi:email": mdiEmail,
"mdi:phone": mdiPhone,
"mdi:download": mdiDownload,
"mdi:link": mdiLink,
};
return iconMap[iconName] || "";
}
export const fetchProfileIcons = (profiles: any[]) => {
const profileIcons: { [key: string]: string } = {};
if (profiles) {
for (const profile of profiles) {
profileIcons[profile.network] = getSimpleIconPath(profile.network);
}
}
return profileIcons;
};