More optimizations
All checks were successful
Docker Deploy / build-and-push (push) Successful in 5m6s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 5m6s
This commit is contained in:
35
src/utils/icons.ts
Normal file
35
src/utils/icons.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user