diff --git a/components/button/__tests__/__snapshots__/demo.test.js.snap b/components/button/__tests__/__snapshots__/demo.test.js.snap index 698f70d3a5..4eb2065b2c 100644 --- a/components/button/__tests__/__snapshots__/demo.test.js.snap +++ b/components/button/__tests__/__snapshots__/demo.test.js.snap @@ -27,13 +27,29 @@ exports[`renders ./components/button/demo/basic.md correctly 1`] = ` + + + + +
+ + +
+ +
@@ -208,13 +276,29 @@ exports[`renders ./components/button/demo/ghost.md correctly 1`] = ` + + +
+ + -
-
- - -
`; diff --git a/components/button/button.tsx b/components/button/button.tsx index dee06d1818..6b9477dd96 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -9,6 +9,7 @@ import omit from 'omit.js'; import Group from './button-group'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import Wave from '../_util/wave'; +import warning from '../_util/warning'; import { Omit, tuple } from '../_util/type'; const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/; @@ -65,16 +66,7 @@ function spaceChildren(children: React.ReactNode, needInserted: boolean) { ); } -const ButtonTypes = tuple( - 'default', - 'primary', - 'ghost', - 'dashed', - 'danger', - 'danger-link', - 'danger-default', - 'link', -); +const ButtonTypes = tuple('default', 'primary', 'ghost', 'dashed', 'danger', 'link'); export type ButtonType = typeof ButtonTypes[number]; const ButtonShapes = tuple('circle', 'circle-outline', 'round'); export type ButtonShape = typeof ButtonShapes[number]; @@ -92,6 +84,7 @@ export interface BaseButtonProps { prefixCls?: string; className?: string; ghost?: boolean; + danger?: boolean; block?: boolean; children?: React.ReactNode; } @@ -158,6 +151,11 @@ class Button extends React.Component { componentDidMount() { this.fixTwoCNChar(); + warning( + !('type' in this.props && this.props.type === 'danger'), + 'Button', + '`type="danger"` is deprecated, please use `danger` instead.', + ); } componentDidUpdate(prevProps: ButtonProps) { @@ -227,6 +225,7 @@ class Button extends React.Component { const { prefixCls: customizePrefixCls, type, + danger, shape, size, className, @@ -266,6 +265,7 @@ class Button extends React.Component { [`${prefixCls}-background-ghost`]: ghost, [`${prefixCls}-two-chinese-chars`]: hasTwoCNChar && autoInsertSpace, [`${prefixCls}-block`]: block, + [`${prefixCls}-dangerous`]: !!danger, }); const iconNode = loading ? : icon || null; @@ -305,7 +305,7 @@ class Button extends React.Component { ); - if (type === 'link' || type === 'danger-link') { + if (type === 'link') { return buttonNode; } diff --git a/components/button/demo/basic.md b/components/button/demo/basic.md index f15bd9004d..7ab7c9d150 100644 --- a/components/button/demo/basic.md +++ b/components/button/demo/basic.md @@ -21,9 +21,13 @@ ReactDOM.render( - - - + + + , mountNode, diff --git a/components/button/demo/block.md b/components/button/demo/block.md index 51ceef16ad..0f0b27a1e0 100644 --- a/components/button/demo/block.md +++ b/components/button/demo/block.md @@ -25,13 +25,13 @@ ReactDOM.render( - - -
- - +
- - +
diff --git a/components/button/demo/ghost.md b/components/button/demo/ghost.md index e7a3091cbf..14f8f399b4 100644 --- a/components/button/demo/ghost.md +++ b/components/button/demo/ghost.md @@ -22,13 +22,13 @@ ReactDOM.render( Primary - - -
- - -