You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.1 KiB
61 lines
2.1 KiB
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import ReactIcon from './IconBase';
|
|
import { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor';
|
|
import { normalizeTwoToneColors } from '../utils'; // Initial setting
|
|
// should move it to antd main repo?
|
|
|
|
setTwoToneColor('#1890ff');
|
|
var Icon = React.forwardRef(function (props, ref) {
|
|
var className = props.className,
|
|
icon = props.icon,
|
|
spin = props.spin,
|
|
rotate = props.rotate,
|
|
tabIndex = props.tabIndex,
|
|
onClick = props.onClick,
|
|
twoToneColor = props.twoToneColor,
|
|
restProps = _objectWithoutProperties(props, ["className", "icon", "spin", "rotate", "tabIndex", "onClick", "twoToneColor"]);
|
|
|
|
var classString = classNames('anticon', _defineProperty({}, "anticon-".concat(icon.name), Boolean(icon.name)), className);
|
|
var svgClassString = classNames({
|
|
'anticon-spin': !!spin || icon.name === 'loading'
|
|
});
|
|
var iconTabIndex = tabIndex;
|
|
|
|
if (iconTabIndex === undefined && onClick) {
|
|
iconTabIndex = -1;
|
|
}
|
|
|
|
var svgStyle = rotate ? {
|
|
msTransform: "rotate(".concat(rotate, "deg)"),
|
|
transform: "rotate(".concat(rotate, "deg)")
|
|
} : undefined;
|
|
|
|
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
|
|
_normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2),
|
|
primaryColor = _normalizeTwoToneColo2[0],
|
|
secondaryColor = _normalizeTwoToneColo2[1];
|
|
|
|
return React.createElement("span", Object.assign({
|
|
role: "img",
|
|
"aria-label": icon.name
|
|
}, restProps, {
|
|
ref: ref,
|
|
tabIndex: iconTabIndex,
|
|
onClick: onClick,
|
|
className: classString
|
|
}), React.createElement(ReactIcon, {
|
|
className: svgClassString,
|
|
icon: icon,
|
|
primaryColor: primaryColor,
|
|
secondaryColor: secondaryColor,
|
|
style: svgStyle
|
|
}));
|
|
});
|
|
Icon.displayName = 'AntdIcon';
|
|
Icon.getTwoToneColor = getTwoToneColor;
|
|
Icon.setTwoToneColor = setTwoToneColor;
|
|
export default Icon; |