1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix: more random fixes related to incorrect parsing svg-icon content, added static Icon.isSvg(content: string)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2022-02-08 11:53:22 +02:00
parent 5b88f23a5f
commit 81560d5357
6 changed files with 10 additions and 6 deletions

View File

@ -25,7 +25,7 @@ interface Props<T extends CatalogEntity> {
@observer
export class CatalogEntityDetails<T extends CatalogEntity> extends Component<Props<T>> {
categoryIcon(category: CatalogCategory) {
if (category.metadata.icon.includes("<svg")) {
if (Icon.isSvg(category.metadata.icon)) {
return <Icon svg={category.metadata.icon} smallest />;
} else {
return <Icon material={category.metadata.icon} smallest />;

View File

@ -65,7 +65,7 @@ export class CatalogEntityDrawerMenu<T extends CatalogEntity> extends React.Comp
continue;
}
const key = menuItem.icon.includes("<svg") ? "svg" : "material";
const key = Icon.isSvg(menuItem.icon) ? "svg" : "material";
items.push(
<MenuItem key={menuItem.title} onClick={() => this.onMenuItemClick(menuItem)}>

View File

@ -28,7 +28,7 @@ function getCategoryIcon(category: CatalogCategory) {
const { icon } = category.metadata ?? {};
if (typeof icon === "string") {
return icon.includes("<svg")
return Icon.isSvg(icon)
? <Icon small svg={icon}/>
: <Icon small material={icon}/>;
}

View File

@ -47,7 +47,7 @@ export class HotbarEntityIcon extends React.Component<Props> {
return <Icon material="bug_report" className={className} />;
}
if (category.metadata.icon.includes("svg+xml")) {
if (Icon.isSvg(category.metadata.icon)) {
return <Icon svg={category.metadata.icon} className={className} />;
} else {
return <Icon material={category.metadata.icon} className={className} />;

View File

@ -37,6 +37,10 @@ export class Icon extends React.PureComponent<IconProps> {
focusable: true,
};
static isSvg(content: string){
return String(content).includes("svg+xml"); // data-url for raw svg-icon
}
get isInteractive() {
const { interactive, onClick, href, link } = this.props;

View File

@ -33,8 +33,8 @@ export function createDevServer(lensProxyPort: number): WebpackDevServer {
}
},
client: {
// don't show warnings and errors on top of rendered app view
overlay: false,
overlay: false, // don't show warnings and errors on top of rendered app view
logging: "error",
},
}, compiler);
}