mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
fix the default theme outlined
This commit is contained in:
parent
4ceeab77d1
commit
3859a60d3e
@ -3,7 +3,10 @@ import classNames from 'classnames';
|
||||
import * as allIcons from '@ant-design/icons';
|
||||
import ReactIcon from '@ant-design/icons-react';
|
||||
import createFromIconfontCN from './IconFont';
|
||||
import { svgBaseProps, withThemeSuffix } from './utils';
|
||||
import {
|
||||
svgBaseProps, withThemeSuffix,
|
||||
removeTypeTheme, getThemeFromTypeName,
|
||||
} from './utils';
|
||||
import warning from '../_util/warning';
|
||||
import { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor';
|
||||
|
||||
@ -115,8 +118,15 @@ const Icon: React.SFC<IconProps> = (props) => {
|
||||
if (typeof type === 'string') {
|
||||
let computedType = type;
|
||||
if (theme) {
|
||||
computedType = withThemeSuffix(type, theme);
|
||||
const alreadyHaveTheme = getThemeFromTypeName(type);
|
||||
warning(!alreadyHaveTheme,
|
||||
`This icon already has a theme '${alreadyHaveTheme}'.` +
|
||||
` The prop 'theme' ${theme} will be ignored.`);
|
||||
}
|
||||
computedType = withThemeSuffix(
|
||||
removeTypeTheme(type),
|
||||
theme || 'outlined',
|
||||
);
|
||||
return (
|
||||
<i className={classString} title={title} style={style} onClick={onClick}>
|
||||
<ReactIcon
|
||||
|
@ -26,22 +26,20 @@ export function getThemeFromTypeName(type: string): ThemeType | null {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function removeTypeTheme(type: string) {
|
||||
return type.replace(fillTester, '').replace(outlineTester, '').replace(twoToneTester, '');
|
||||
}
|
||||
|
||||
export function withThemeSuffix(type: string, theme: ThemeType) {
|
||||
const alreadyHaveTheme = getThemeFromTypeName(type);
|
||||
warning(!alreadyHaveTheme,
|
||||
`This icon already has a theme '${alreadyHaveTheme}'.` +
|
||||
` The prop 'theme' will be ignored.`);
|
||||
let result = type;
|
||||
if (!alreadyHaveTheme) {
|
||||
if (theme === 'filled') {
|
||||
result += '-fill';
|
||||
} else if (theme === 'outlined') {
|
||||
result += '-o';
|
||||
} else if (theme === 'twoTone') {
|
||||
result += '-twotone';
|
||||
} else {
|
||||
warning(false, `This icon '${type}' has unknown theme '${theme}'`);
|
||||
}
|
||||
if (theme === 'filled') {
|
||||
result += '-fill';
|
||||
} else if (theme === 'outlined') {
|
||||
result += '-o';
|
||||
} else if (theme === 'twoTone') {
|
||||
result += '-twotone';
|
||||
} else {
|
||||
warning(false, `This icon '${type}' has unknown theme '${theme}'`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user