diff --git a/components/alert/__tests__/__snapshots__/demo.test.js.snap b/components/alert/__tests__/__snapshots__/demo.test.js.snap index 0406835d7..f2a8a2261 100644 --- a/components/alert/__tests__/__snapshots__/demo.test.js.snap +++ b/components/alert/__tests__/__snapshots__/demo.test.js.snap @@ -42,6 +42,37 @@ exports[`renders ./components/alert/demo/banner.md correctly 1`] = ` /> +
+
+ + Warning text without icon + + +
+
+
+ + + Error text + + +
`; diff --git a/components/alert/demo/banner.md b/components/alert/demo/banner.md index 9883b4cb2..7e3a30b57 100644 --- a/components/alert/demo/banner.md +++ b/components/alert/demo/banner.md @@ -1,6 +1,6 @@ --- order: 6 -iframe: true +iframe: 250 title: zh-CN: 顶部公告 en-US: Banner @@ -22,6 +22,10 @@ ReactDOM.render(
+
+ +
+ , mountNode); ```` diff --git a/components/alert/index.en-US.md b/components/alert/index.en-US.md index 8e9986453..a499c9551 100644 --- a/components/alert/index.en-US.md +++ b/components/alert/index.en-US.md @@ -15,11 +15,11 @@ Alert component for feedback. | Property | Description | Type | Default | |----------- |--------------------------------------------------------- | ---------- |-------| -| type | Type of Alert styles, options:`success`, `info`, `warning`, `error` | string | `info` | +| type | Type of Alert styles, options:`success`, `info`, `warning`, `error` | string | `info`, in `banner` mode it's `warning` | | closable | Whether Alert can be closed | boolean | - | | closeText | Close text to show | string\|ReactNode | - | | message | Content of Alert | string\|ReactNode | - | | description | Additional content of Alert | string\|ReactNode | - | | onClose | Callback when close Alert | Function | - | -| showIcon | Whether to show icon | boolean | false | +| showIcon | Whether to show icon | boolean | false, in `banner` mode it's true | | banner | Whether to show as banner | boolean | false | diff --git a/components/alert/index.tsx b/components/alert/index.tsx index fb08917c9..82ca38392 100755 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -30,9 +30,6 @@ export interface AlertProps { } export default class Alert extends React.Component { - static defaultProps = { - type: 'info', - }; constructor(props) { super(props); this.state = { @@ -66,9 +63,9 @@ export default class Alert extends React.Component { } = this.props; // banner模式默认有 Icon - showIcon = showIcon || banner; + showIcon = banner && showIcon === undefined ? true : showIcon; // banner模式默认为警告 - type = banner ? 'warning' : type; + type = banner && type === undefined ? 'warning' : type || 'info'; let iconType = ''; switch (type) { diff --git a/components/alert/index.zh-CN.md b/components/alert/index.zh-CN.md index d9f5e0f0a..d47c93b96 100644 --- a/components/alert/index.zh-CN.md +++ b/components/alert/index.zh-CN.md @@ -16,12 +16,12 @@ title: Alert | 参数 | 说明 | 类型 | 默认值 | |----------- |--------------------------------------------------------- | ---------- |-------| -| type | 指定警告提示的样式,有四种选择 `success`、`info`、`warning`、`error` | string | `info` | +| type | 指定警告提示的样式,有四种选择 `success`、`info`、`warning`、`error` | string | `info`,`banner` 模式下默认值为 `warning` | | closable | 默认不显示关闭按钮 | boolean | 无 | | closeText | 自定义关闭按钮 | string\|ReactNode | 无 | | message | 警告提示内容 | string\|ReactNode | 无 | | description | 警告提示的辅助性文字介绍 | string\|ReactNode | 无 | | onClose | 关闭时触发的回调函数 | Function | 无 | -| showIcon | 是否显示辅助图标 | boolean | false | +| showIcon | 是否显示辅助图标 | boolean | false,`banner` 模式下默认值为 true | | banner | 是否用作顶部公告 | boolean | false |