@fluentui/react-icons-mdl2
Version:
SVG icon components for @fluentui/react
29 lines • 1.25 kB
JavaScript
import * as React from 'react';
import { css, getNativeProps, htmlElementProperties } from '@fluentui/utilities';
import * as classes from './SvgIcon.scss';
import { useIconSubset } from '@fluentui/react-icon-provider';
const createSvgIcon = ({ svg, displayName, }) => {
const Component = props => {
var _a;
const { className, style = {} } = props;
const icons = useIconSubset(); // TODO: handle fontFace and styles
const nativeProps = getNativeProps(props, htmlElementProperties);
const containerProps = props['aria-label'] || props['aria-labelledby'] || props.title
? {
role: 'img',
}
: {
['aria-hidden']: true,
};
return React.createElement('span', {
...containerProps,
...nativeProps,
className: css(classes.root, className),
style,
}, ((_a = icons === null || icons === void 0 ? void 0 : icons.icons) === null || _a === void 0 ? void 0 : _a[displayName]) ? icons.icons[displayName] : svg({ classes, props }));
};
Component.displayName = displayName;
return Component;
};
export default createSvgIcon;
//# sourceMappingURL=createSvgIcon.js.map