Merge branch 'benphelps:main' into main

This commit is contained in:
fredodiable 2023-07-27 00:31:32 +02:00 committed by GitHub
commit 3fb9ad8695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,11 +33,22 @@ export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "log
} }
// check mdi- or si- prefixed icons // check mdi- or si- prefixed icons
const prefix = icon.split("-")[0] const prefix = icon.split("-")[0];
if (prefix in iconSetURLs) { if (prefix in iconSetURLs) {
// get icon source // default to theme setting
const iconName = icon.replace(`${prefix}-`, "").replace(".svg", ""); let iconName = icon.replace(`${prefix}-`, "").replace(".svg", "");
let iconColor = settings.iconStyle === "theme" ?
`rgb(var(--color-${ theme === "dark" ? 300 : 900 }) / var(--tw-text-opacity, 1))` :
"linear-gradient(180deg, rgb(var(--color-logo-start)), rgb(var(--color-logo-stop)))";
// use custom hex color if provided
const colorMatches = icon.match(/[#][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/i)
if (colorMatches?.length) {
iconName = icon.replace(`${prefix}-`, "").replace(".svg", "").replace(`-${colorMatches[0]}`, "");
iconColor = `${colorMatches[0]}`;
}
const iconSource = `${iconSetURLs[prefix]}${iconName}.svg`; const iconSource = `${iconSetURLs[prefix]}${iconName}.svg`;
return ( return (
@ -47,9 +58,7 @@ export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "log
height, height,
maxWidth: '100%', maxWidth: '100%',
maxHeight: '100%', maxHeight: '100%',
background: settings.iconStyle === "theme" ? background: `${iconColor}`,
`rgb(var(--color-${ theme === "dark" ? 300 : 900 }) / var(--tw-text-opacity, 1))` :
"linear-gradient(180deg, rgb(var(--color-logo-start)), rgb(var(--color-logo-stop)))",
mask: `url(${iconSource}) no-repeat center / contain`, mask: `url(${iconSource}) no-repeat center / contain`,
WebkitMask: `url(${iconSource}) no-repeat center / contain`, WebkitMask: `url(${iconSource}) no-repeat center / contain`,
}} }}
@ -57,7 +66,6 @@ export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "log
); );
} }
// fallback to dashboard-icons // fallback to dashboard-icons
if (icon.endsWith(".svg")) { if (icon.endsWith(".svg")) {
const iconName = icon.replace(".svg", ""); const iconName = icon.replace(".svg", "");