yantd
Version:
React component library
29 lines (28 loc) • 1.89 kB
JavaScript
import { useContext, useEffect } from 'react';
import warn from 'rc-util/lib/warning';
import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS';
import IconContext from './Context';
export function warning(valid, message) {
warn(valid, "[@ant-design/icons] " + message);
}
// These props make sure that the SVG behaviours like general text.
// Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
export var svgBaseProps = {
width: '1em',
height: '1em',
fill: 'currentColor',
'aria-hidden': 'true',
focusable: 'false',
};
export var iconStyles = "\n.anticon {\n display: inline-block;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n";
export var useInsertStyles = function (styleStr) {
if (styleStr === void 0) { styleStr = iconStyles; }
var csp = useContext(IconContext).csp;
useEffect(function () {
updateCSS(styleStr, '-design-icons', {
prepend: true,
csp: csp
});
return;
}, []);
};