diff --git a/packages/grafana-ui/src/components/Button/Button.test.tsx b/packages/grafana-ui/src/components/Button/Button.test.tsx new file mode 100644 index 00000000000..68d4e1e55c4 --- /dev/null +++ b/packages/grafana-ui/src/components/Button/Button.test.tsx @@ -0,0 +1,11 @@ +import { render } from '@testing-library/react'; +import React from 'react'; + +import { Button } from './Button'; + +describe('Button', () => { + it('spins the spinner when specified as an icon', () => { + const { container } = render(); + expect(container.querySelector('.fa-spin')).toBeInTheDocument(); + }); +}); diff --git a/packages/grafana-ui/src/components/Icon/Icon.tsx b/packages/grafana-ui/src/components/Icon/Icon.tsx index b0388e6da11..8e08714225c 100644 --- a/packages/grafana-ui/src/components/Icon/Icon.tsx +++ b/packages/grafana-ui/src/components/Icon/Icon.tsx @@ -51,6 +51,13 @@ export const Icon = React.forwardRef( const subDir = getIconSubDir(iconName, type); const svgPath = `${iconRoot}${subDir}/${iconName}.svg`; + const composedClassName = cx( + styles.icon, + className, + type === 'mono' ? { [styles.orange]: name === 'favorite' } : '', + iconName === 'spinner' && 'fa-spin' + ); + return ( ( width={svgWid} height={svgHgt} title={title} - className={cx(styles.icon, className, type === 'mono' ? { [styles.orange]: name === 'favorite' } : '')} + className={composedClassName} style={style} {...rest} />