mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 23:35:38 +08:00
338ec7dad7
* pref: better code style for production * refactor `devWarning` * don't use `useEffect` only wrap `devWarning` * chore: add 'noop' to coverage * chore: add test cases for devWarning * chore: add test case * chore: update test cases for devWarning * chore: restore test script command * fix: remove 'throw new Error' * should not use `throw` for browser * chore: update test case for AutoComplete * perf: add prefix for `devWarning` * update RegExp for UMD * add prefix for ES and CJS * chore: better code style * perf: * upgrade antd-tools * remove `injectWarningCondition` * rename `devWarning` to `warning` * chore: better code style * chore: better code style * chore: restore hasValidName
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import warning from '../../../../components/_util/warning';
|
|
|
|
// 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 const svgBaseProps = {
|
|
width: '1em',
|
|
height: '1em',
|
|
fill: 'currentColor',
|
|
'aria-hidden': true,
|
|
focusable: 'false',
|
|
};
|
|
|
|
const fillTester = /-fill$/;
|
|
const outlineTester = /-o$/;
|
|
const twoToneTester = /-twotone$/;
|
|
|
|
export function getThemeFromTypeName(type) {
|
|
let result = null;
|
|
if (fillTester.test(type)) {
|
|
result = 'filled';
|
|
} else if (outlineTester.test(type)) {
|
|
result = 'outlined';
|
|
} else if (twoToneTester.test(type)) {
|
|
result = 'twoTone';
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function removeTypeTheme(type) {
|
|
return type.replace(fillTester, '').replace(outlineTester, '').replace(twoToneTester, '');
|
|
}
|
|
|
|
export function withThemeSuffix(type, theme) {
|
|
let result = type;
|
|
if (theme === 'filled') {
|
|
result += '-fill';
|
|
} else if (theme === 'outlined') {
|
|
result += '-o';
|
|
} else if (theme === 'twoTone') {
|
|
result += '-twotone';
|
|
} else {
|
|
warning(false, 'Icon', `This icon '${type}' has unknown theme '${theme}'`);
|
|
}
|
|
return result;
|
|
}
|