Grafana/ui: Update IconRenderer (#87914)

This commit is contained in:
Alex Khomenko 2024-05-15 15:27:05 +02:00 committed by GitHub
parent a6d64c6ed5
commit 6c1e9a9717
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 6 deletions

View File

@ -37,6 +37,7 @@ export const availableIconsIndex = {
'arrows-v': true,
asserts: true,
'expand-arrows': true,
'expand-arrows-alt': true,
at: true,
ai: true,
backward: true,
@ -75,6 +76,7 @@ export const availableIconsIndex = {
'comment-alt-share': true,
'comments-alt': true,
compass: true,
'compress-arrows': true,
copy: true,
'corner-down-right-alt': true,
'create-dashboard': true,

View File

@ -1,7 +1,7 @@
import { css, cx } from '@emotion/css';
import React, { AnchorHTMLAttributes, ButtonHTMLAttributes } from 'react';
import { GrafanaTheme2, isIconName, ThemeRichColor } from '@grafana/data';
import { GrafanaTheme2, ThemeRichColor } from '@grafana/data';
import { useTheme2 } from '../../themes';
import { getFocusStyles, getMouseFocusStyles } from '../../themes/mixins';
@ -161,17 +161,16 @@ interface IconRendererProps {
iconType?: IconType;
}
export const IconRenderer = ({ icon, size, className, iconType }: IconRendererProps) => {
if (!icon) {
return null;
}
if (React.isValidElement(icon)) {
return React.cloneElement(icon, {
className,
size,
});
}
if (isIconName(icon)) {
return <Icon name={icon} size={size} className={className} type={iconType} />;
}
return null;
return <Icon name={icon} size={size} className={className} type={iconType} />;
};
export interface StyleProps {