Skip to content

Commit 8aea76b

Browse files
committed
feat: icon support custom icon #2245
1 parent 3f66cf4 commit 8aea76b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

components/button/button.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Wave from '../_util/wave';
22
import Icon from '../icon';
33
import buttonTypes from './buttonTypes';
4-
import { filterEmpty, getListeners } from '../_util/props-util';
4+
import { filterEmpty, getListeners, getComponentFromProp } from '../_util/props-util';
55
import { ConfigConsumerProps } from '../config-provider';
66

77
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
@@ -134,12 +134,14 @@ export default {
134134
return child;
135135
},
136136
isNeedInserted() {
137-
const { icon, $slots, type } = this;
137+
const { $slots, type } = this;
138+
const icon = getComponentFromProp(this, 'icon');
138139
return $slots.default && $slots.default.length === 1 && !icon && type !== 'link';
139140
},
140141
},
141142
render() {
142-
const { type, htmlType, classes, icon, disabled, handleClick, sLoading, $slots, $attrs } = this;
143+
const { type, htmlType, classes, disabled, handleClick, sLoading, $slots, $attrs } = this;
144+
const icon = getComponentFromProp(this, 'icon');
143145
const buttonProps = {
144146
attrs: {
145147
...$attrs,

components/button/buttonTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export default () => ({
33
prefixCls: PropTypes.string,
44
type: PropTypes.string,
55
htmlType: PropTypes.oneOf(['button', 'submit', 'reset']).def('button'),
6-
icon: PropTypes.string,
6+
icon: PropTypes.any,
77
shape: PropTypes.oneOf(['circle', 'circle-outline', 'round']),
88
size: PropTypes.oneOf(['small', 'large', 'default']).def('default'),
99
loading: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),

0 commit comments

Comments
 (0)