From c95422b682df677046d70e8df2fe0d737d307b39 Mon Sep 17 00:00:00 2001 From: Ben Phelps Date: Tue, 11 Oct 2022 15:02:38 +0300 Subject: [PATCH] impl. mdi icons with the possibility for others --- src/components/services/item.jsx | 42 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index 870eb4f4..ed0cef2d 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -9,19 +9,37 @@ import Docker from "widgets/docker/component"; import { SettingsContext } from "utils/contexts/settings"; function resolveIcon(icon) { - if (icon.startsWith("http")) { - return icon; + // direct or relative URLs + if (icon.startsWith("http") || icon.startsWith("/")) { + return logo; } - if (icon.startsWith("/")) { - return icon; + // mdi- prefixed, material design icons + if (icon.startsWith("mdi-")) { + const iconName = icon.replace("mdi-", "").replace(".svg", ""); + return ( +
+ ); } - if (icon.endsWith(".png")) { - return `https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${icon}`; - } - - return `https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${icon}.png`; + // fallback to dashboard-icons + const iconName = icon.replace(".png", ""); + return ( + logo + ); } export default function Item({ service }) { @@ -57,12 +75,10 @@ export default function Item({ service }) { rel="noreferrer" className="flex-shrink-0 flex items-center justify-center w-12 " > - logo + {resolveIcon(service.icon)} ) : ( -
- logo -
+
{resolveIcon(service.icon)}
))} {hasLink ? (