2019-08-13 14:07:17 +08:00
|
|
|
import warning from '../../../../components/_util/warning';
|
2018-08-30 22:53:24 +08:00
|
|
|
|
2018-08-15 17:21:02 +08:00
|
|
|
// 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 = {
|
2018-12-07 16:17:45 +08:00
|
|
|
width: '1em',
|
|
|
|
height: '1em',
|
|
|
|
fill: 'currentColor',
|
2019-08-13 14:07:17 +08:00
|
|
|
'aria-hidden': true,
|
2018-12-07 16:17:45 +08:00
|
|
|
focusable: 'false',
|
2018-08-15 17:21:02 +08:00
|
|
|
};
|
2018-08-30 22:53:24 +08:00
|
|
|
|
|
|
|
const fillTester = /-fill$/;
|
|
|
|
const outlineTester = /-o$/;
|
|
|
|
const twoToneTester = /-twotone$/;
|
|
|
|
|
2019-08-13 14:07:17 +08:00
|
|
|
export function getThemeFromTypeName(type) {
|
|
|
|
let result = null;
|
2018-08-30 22:53:24 +08:00
|
|
|
if (fillTester.test(type)) {
|
2018-12-07 16:17:45 +08:00
|
|
|
result = 'filled';
|
2018-08-30 22:53:24 +08:00
|
|
|
} else if (outlineTester.test(type)) {
|
2018-12-07 16:17:45 +08:00
|
|
|
result = 'outlined';
|
2018-08-30 22:53:24 +08:00
|
|
|
} else if (twoToneTester.test(type)) {
|
2018-12-07 16:17:45 +08:00
|
|
|
result = 'twoTone';
|
2018-08-30 22:53:24 +08:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-08-13 14:07:17 +08:00
|
|
|
export function removeTypeTheme(type) {
|
2018-09-06 21:42:06 +08:00
|
|
|
return type
|
2018-12-07 16:17:45 +08:00
|
|
|
.replace(fillTester, '')
|
|
|
|
.replace(outlineTester, '')
|
|
|
|
.replace(twoToneTester, '');
|
2018-09-02 19:48:57 +08:00
|
|
|
}
|
|
|
|
|
2019-08-13 14:07:17 +08:00
|
|
|
export function withThemeSuffix(type, theme) {
|
2018-08-30 22:53:24 +08:00
|
|
|
let result = type;
|
2018-12-07 16:17:45 +08:00
|
|
|
if (theme === 'filled') {
|
|
|
|
result += '-fill';
|
|
|
|
} else if (theme === 'outlined') {
|
|
|
|
result += '-o';
|
|
|
|
} else if (theme === 'twoTone') {
|
|
|
|
result += '-twotone';
|
2018-09-02 19:48:57 +08:00
|
|
|
} else {
|
2019-02-27 15:32:29 +08:00
|
|
|
warning(false, 'Icon', `This icon '${type}' has unknown theme '${theme}'`);
|
2018-08-30 22:53:24 +08:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2018-11-06 11:39:49 +08:00
|
|
|
|
|
|
|
// For alias or compatibility
|
2019-08-13 14:07:17 +08:00
|
|
|
export function alias(type) {
|
2019-05-27 17:04:02 +08:00
|
|
|
let newType = type;
|
2018-11-06 11:39:49 +08:00
|
|
|
switch (type) {
|
|
|
|
case 'cross':
|
2019-05-27 17:04:02 +08:00
|
|
|
newType = 'close';
|
|
|
|
break;
|
|
|
|
// https://github.com/ant-design/ant-design/issues/13007
|
|
|
|
case 'interation':
|
|
|
|
newType = 'interaction';
|
|
|
|
break;
|
|
|
|
// https://github.com/ant-design/ant-design/issues/16810
|
|
|
|
case 'canlendar':
|
|
|
|
newType = 'calendar';
|
|
|
|
break;
|
2019-07-04 15:00:42 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/17448
|
|
|
|
case 'colum-height':
|
|
|
|
newType = 'column-height';
|
|
|
|
break;
|
2018-11-06 11:39:49 +08:00
|
|
|
default:
|
|
|
|
}
|
2019-05-27 17:04:02 +08:00
|
|
|
warning(
|
|
|
|
newType === type,
|
|
|
|
'Icon',
|
2019-07-07 22:08:46 +08:00
|
|
|
`Icon '${type}' was a typo and is now deprecated, please use '${newType}' instead.`,
|
2019-05-27 17:04:02 +08:00
|
|
|
);
|
|
|
|
return newType;
|
2018-11-06 11:39:49 +08:00
|
|
|
}
|