Icon: Restore default fa-spin to spinner in icon (#77205)

Restore default fa-spin to spinner in icon
This commit is contained in:
Josh Hunt
2023-10-26 12:17:39 +00:00
committed by GitHub
parent 61f056fe15
commit db40c90eed
2 changed files with 19 additions and 1 deletions

View File

@ -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(<Button icon="spinner">Loading...</Button>);
expect(container.querySelector('.fa-spin')).toBeInTheDocument();
});
});

View File

@ -51,6 +51,13 @@ export const Icon = React.forwardRef<SVGElement, IconProps>(
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 (
<SVG
innerRef={ref}
@ -58,7 +65,7 @@ export const Icon = React.forwardRef<SVGElement, IconProps>(
width={svgWid}
height={svgHgt}
title={title}
className={cx(styles.icon, className, type === 'mono' ? { [styles.orange]: name === 'favorite' } : '')}
className={composedClassName}
style={style}
{...rest}
/>