parent
bd39b76799
commit
b391f65e3c
@ -1,10 +0,0 @@
|
|||||||
import PropTypes from 'prop-types';
|
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
export default function InlineSVG({ src }) {
|
|
||||||
return <svg id={src} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
InlineSVG.propTypes = {
|
|
||||||
src: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
|
|
||||||
};
|
|
@ -0,0 +1,15 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
interface IInlineSVG {
|
||||||
|
loader?: JSX.Element,
|
||||||
|
}
|
||||||
|
|
||||||
|
const InlineSVG: React.FC<IInlineSVG> = ({ loader }): JSX.Element => {
|
||||||
|
if (loader) {
|
||||||
|
return loader;
|
||||||
|
} else {
|
||||||
|
throw 'You used react-inlinesvg without a loader! This will cause jumpy loading during render.';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default InlineSVG;
|
@ -0,0 +1,15 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
import { render, screen } from '../../../../jest/test-helpers';
|
||||||
|
import SvgIcon from '../svg-icon';
|
||||||
|
|
||||||
|
describe('<SvgIcon />', () => {
|
||||||
|
it('renders loading element with default size', () => {
|
||||||
|
render(<SvgIcon className='text-primary-500' src={require('@tabler/icons/icons/code.svg')} />);
|
||||||
|
|
||||||
|
const svg = screen.getByTestId('svg-icon-loader');
|
||||||
|
expect(svg.getAttribute('width')).toBe('24');
|
||||||
|
expect(svg.getAttribute('height')).toBe('24');
|
||||||
|
expect(svg.getAttribute('class')).toBe('text-primary-500');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in new issue