Streamline code for custom icon colors in resolvedicon.jsx
Removed redundant if statement when defaulting to theme colors if no custom icon color code is provided
This commit is contained in:
parent
50146dc08e
commit
5264ffd071
@ -36,7 +36,6 @@ export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "log
|
|||||||
const prefix = icon.split("-")[0];
|
const prefix = icon.split("-")[0];
|
||||||
const suffix = icon.split("-")[icon.split("-").length - 1];
|
const suffix = icon.split("-")[icon.split("-").length - 1];
|
||||||
|
|
||||||
// get icon source
|
|
||||||
if (prefix in iconSetURLs) {
|
if (prefix in iconSetURLs) {
|
||||||
// check whether icon ends with color code
|
// check whether icon ends with color code
|
||||||
if (!(suffix.match(`[#][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]`) == null)) {
|
if (!(suffix.match(`[#][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]`) == null)) {
|
||||||
@ -58,8 +57,7 @@ export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "log
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
// default to theme setting if no custom icon color code is provided
|
||||||
if (suffix.match(`[#][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]`) == null) {
|
|
||||||
const iconColor = settings.iconStyle === "theme" ?
|
const iconColor = settings.iconStyle === "theme" ?
|
||||||
`rgb(var(--color-${ theme === "dark" ? 300 : 900 }) / var(--tw-text-opacity, 1))` :
|
`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)))";
|
"linear-gradient(180deg, rgb(var(--color-logo-start)), rgb(var(--color-logo-stop)))";
|
||||||
@ -78,7 +76,7 @@ export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "log
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback to dashboard-icons
|
// fallback to dashboard-icons
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user