diff --git a/src/components/quicklaunch.jsx b/src/components/quicklaunch.jsx index 077e6c5c0..1836e9b76 100644 --- a/src/components/quicklaunch.jsx +++ b/src/components/quicklaunch.jsx @@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next"; import { useEffect, useState, useRef, useCallback, useContext } from "react"; import classNames from "classnames"; -import { resolveIcon } from "./services/item"; +import ResolvedIcon from "./resolvedicon"; import { SettingsContext } from "utils/contexts/settings"; @@ -135,7 +135,7 @@ export default function QuickLaunch({servicesAndBookmarks, searchString, setSear )} onClick={handleItemClick}>
- {r.icon && resolveIcon(r.icon)} + {r.icon && } {r.abbr && r.abbr}
diff --git a/src/components/resolvedicon.jsx b/src/components/resolvedicon.jsx new file mode 100644 index 000000000..d5aa8c880 --- /dev/null +++ b/src/components/resolvedicon.jsx @@ -0,0 +1,35 @@ +import Image from "next/future/image"; + +export default function ResolvedIcon({ icon }) { + // direct or relative URLs + if (icon.startsWith("http") || icon.startsWith("/")) { + return logo; + } + + // mdi- prefixed, material design icons + if (icon.startsWith("mdi-")) { + const iconName = icon.replace("mdi-", "").replace(".svg", ""); + return ( +
+ ); + } + + // fallback to dashboard-icons + const iconName = icon.replace(".png", ""); + return ( + logo + ); +} \ No newline at end of file diff --git a/src/components/services/group.jsx b/src/components/services/group.jsx index daae19094..13b745fdd 100644 --- a/src/components/services/group.jsx +++ b/src/components/services/group.jsx @@ -1,6 +1,7 @@ import classNames from "classnames"; import List from "components/services/list"; +import ResolvedIcon from "components/resolvedicon"; export default function ServicesGroup({ services, layout }) { return ( @@ -11,7 +12,14 @@ export default function ServicesGroup({ services, layout }) { "flex-1 p-1" )} > -

{services.name}

+
+ {layout?.icon && +
+ +
+ } +

{services.name}

+
); diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index ea3bc6a0e..56ed2b4b1 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -1,4 +1,3 @@ -import Image from "next/future/image"; import classNames from "classnames"; import { useContext, useState } from "react"; @@ -7,40 +6,7 @@ import Widget from "./widget"; import Docker from "widgets/docker/component"; import { SettingsContext } from "utils/contexts/settings"; - -export function resolveIcon(icon) { - // direct or relative URLs - if (icon.startsWith("http") || icon.startsWith("/")) { - return logo; - } - - // mdi- prefixed, material design icons - if (icon.startsWith("mdi-")) { - const iconName = icon.replace("mdi-", "").replace(".svg", ""); - return ( -
- ); - } - - // fallback to dashboard-icons - const iconName = icon.replace(".png", ""); - return ( - logo - ); -} +import ResolvedIcon from "components/resolvedicon"; export default function Item({ service }) { const hasLink = service.href && service.href !== "#"; @@ -75,10 +41,12 @@ export default function Item({ service }) { rel="noreferrer" className="flex-shrink-0 flex items-center justify-center w-12 " > - {resolveIcon(service.icon)} + ) : ( -
{resolveIcon(service.icon)}
+
+ +
))} {hasLink ? (