Skip to content

Commit

Permalink
Hoisted iconContent check to avoid duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
srietkerk committed Aug 30, 2023
1 parent 05bf37d commit cf1aa66
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions webapp/src/toolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -767,13 +767,13 @@ export class TreeRow extends data.Component<TreeRowProps, {}> {
// Icon
let iconClass = `blocklyTreeIcon${subns ? 'more' : icon ? (nameid || icon).toLowerCase() : 'Default'}`.replace(/\s/g, '');
let iconContent = subns ? pxt.toolbox.getNamespaceIcon('more') : icon || pxt.toolbox.getNamespaceIcon('default');
const isImageIcon = iconContent.length > 1; // It's probably an image icon, and not an icon code
let iconImageStyle: React.CSSProperties = {
"--image-icon-url": `url("${Util.pathJoin(pxt.webConfig.commitCdnUrl, encodeURI(icon))}")!important`,
"--image-icon-url": isImageIcon ? `url("${Util.pathJoin(pxt.webConfig.commitCdnUrl, encodeURI(icon))}")!important`: undefined,
display: "inline-block"
} as React.CSSProperties;

if (iconContent.length > 1) {
// It's probably an image icon, and not an icon code
if (isImageIcon) {
iconClass += ' image-icon';
iconContent = undefined;
}
Expand Down

0 comments on commit cf1aa66

Please sign in to comment.