feat: icon support custom icon #2245
parent
3f66cf4044
commit
8aea76b831
|
@ -1,7 +1,7 @@
|
||||||
import Wave from '../_util/wave';
|
import Wave from '../_util/wave';
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
import buttonTypes from './buttonTypes';
|
import buttonTypes from './buttonTypes';
|
||||||
import { filterEmpty, getListeners } from '../_util/props-util';
|
import { filterEmpty, getListeners, getComponentFromProp } from '../_util/props-util';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
|
|
||||||
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
|
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
|
||||||
|
@ -134,12 +134,14 @@ export default {
|
||||||
return child;
|
return child;
|
||||||
},
|
},
|
||||||
isNeedInserted() {
|
isNeedInserted() {
|
||||||
const { icon, $slots, type } = this;
|
const { $slots, type } = this;
|
||||||
|
const icon = getComponentFromProp(this, 'icon');
|
||||||
return $slots.default && $slots.default.length === 1 && !icon && type !== 'link';
|
return $slots.default && $slots.default.length === 1 && !icon && type !== 'link';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const { type, htmlType, classes, icon, disabled, handleClick, sLoading, $slots, $attrs } = this;
|
const { type, htmlType, classes, disabled, handleClick, sLoading, $slots, $attrs } = this;
|
||||||
|
const icon = getComponentFromProp(this, 'icon');
|
||||||
const buttonProps = {
|
const buttonProps = {
|
||||||
attrs: {
|
attrs: {
|
||||||
...$attrs,
|
...$attrs,
|
||||||
|
|
|
@ -3,7 +3,7 @@ export default () => ({
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
htmlType: PropTypes.oneOf(['button', 'submit', 'reset']).def('button'),
|
htmlType: PropTypes.oneOf(['button', 'submit', 'reset']).def('button'),
|
||||||
icon: PropTypes.string,
|
icon: PropTypes.any,
|
||||||
shape: PropTypes.oneOf(['circle', 'circle-outline', 'round']),
|
shape: PropTypes.oneOf(['circle', 'circle-outline', 'round']),
|
||||||
size: PropTypes.oneOf(['small', 'large', 'default']).def('default'),
|
size: PropTypes.oneOf(['small', 'large', 'default']).def('default'),
|
||||||
loading: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
loading: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
||||||
|
|
Loading…
Reference in New Issue