mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 02:59:04 +08:00
Merge branch 'master' into develop-0.11.0
This commit is contained in:
commit
3639f048f5
@ -8,9 +8,8 @@
|
||||
|
||||
````jsx
|
||||
import { Alert } from 'antd';
|
||||
const link = <a href="#">不再提醒</a>;
|
||||
|
||||
ReactDOM.render(
|
||||
<Alert message="消息提示的文案" type="info" closeText={link} />
|
||||
<Alert message="消息提示的文案" type="info" closeText="不再提醒" />
|
||||
, document.getElementById('components-alert-demo-close-type'));
|
||||
````
|
||||
|
@ -2,11 +2,15 @@ import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import Animate from 'rc-animate';
|
||||
import Icon from '../icon';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export default React.createClass({
|
||||
getDefaultProps() {
|
||||
return {
|
||||
prefixCls: 'ant-alert'
|
||||
prefixCls: 'ant-alert',
|
||||
showIcon: false,
|
||||
closeText: <Icon type="cross" />,
|
||||
onClose() {}
|
||||
};
|
||||
},
|
||||
getInitialState() {
|
||||
@ -26,9 +30,7 @@ export default React.createClass({
|
||||
this.setState({
|
||||
closing: false
|
||||
});
|
||||
if (this.props.onClose) {
|
||||
this.props.onClose.call(this, e);
|
||||
}
|
||||
this.props.onClose.call(this, e);
|
||||
},
|
||||
animationEnd() {
|
||||
this.setState({
|
||||
@ -37,10 +39,12 @@ export default React.createClass({
|
||||
});
|
||||
},
|
||||
render() {
|
||||
let iconClass = this.props.description ?
|
||||
'ant-alert-with-description-icon' : 'ant-alert-icon';
|
||||
let {
|
||||
closable, description, type, prefixCls, message, closeText
|
||||
} = this.props;
|
||||
|
||||
let iconType = '';
|
||||
switch (this.props.type) {
|
||||
switch (type) {
|
||||
case 'success':
|
||||
iconType = 'check-circle';
|
||||
break;
|
||||
@ -56,44 +60,32 @@ export default React.createClass({
|
||||
default:
|
||||
iconType = 'default';
|
||||
}
|
||||
let html;
|
||||
let closeName = !this.state.closing ? ' ' + this.props.prefixCls + '-close' : '';
|
||||
if (this.props.description) {
|
||||
let close = this.props.closable ?
|
||||
<a onClick={this.handleClose} className={'ant-alert-with-description-close-icon'}>
|
||||
<span className="ant-alert-with-description-close-icon-x"></span>
|
||||
</a> : '';
|
||||
html = <div data-show={this.state.closing} className={'ant-alert-with-description ant-alert-with-description-' + this.props.type + closeName}>
|
||||
<Icon className={iconClass} type={iconType} />
|
||||
<p className={'ant-alert-with-description-message'}>{this.props.message}</p>
|
||||
<span className={'ant-alert-with-description-description'}>{this.props.description}</span>
|
||||
{close}
|
||||
</div>;
|
||||
} else {
|
||||
if (this.props.closeText) {
|
||||
html = <div data-show={this.state.closing} className={'ant-alert ant-alert-' + this.props.type + closeName}>
|
||||
<Icon className={iconClass} type={iconType} />
|
||||
<span className={'ant-alert-description'}>{this.props.message}</span>
|
||||
<span onClick={this.handleClose} className={'ant-alert-close-text'}>{this.props.closeText}</span>
|
||||
</div>;
|
||||
} else {
|
||||
let close = this.props.closable ?
|
||||
<a onClick={this.handleClose} className={'ant-alert-close-icon'}>
|
||||
<span className="ant-alert-close-icon-x"></span>
|
||||
</a> : '';
|
||||
html = <div data-show={this.state.closing} className={'ant-alert ant-alert-' + this.props.type + closeName}>
|
||||
<Icon className={iconClass} type={iconType} />
|
||||
<span className={'ant-alert-description'}>{this.props.message}</span>
|
||||
{close}
|
||||
</div>;
|
||||
}
|
||||
|
||||
let alertCls = classNames({
|
||||
[prefixCls]: true,
|
||||
[prefixCls + '-' + type]: true,
|
||||
[prefixCls + '-close']: !this.state.closing,
|
||||
[prefixCls + '-with-description']: !!description,
|
||||
});
|
||||
|
||||
if (closeText) {
|
||||
closable = true;
|
||||
}
|
||||
return this.state.closed ? null : <Animate
|
||||
component=""
|
||||
showProp="data-show"
|
||||
transitionName="slide-up"
|
||||
onEnd={this.animationEnd}>
|
||||
{html}
|
||||
</Animate>;
|
||||
|
||||
return this.state.closed ? null : (
|
||||
<Animate component=""
|
||||
showProp="data-show"
|
||||
transitionName="slide-up"
|
||||
onEnd={this.animationEnd}>
|
||||
<div data-show={this.state.closing} className={alertCls}>
|
||||
<Icon className="ant-alert-icon" type={iconType} />
|
||||
<span className={prefixCls + '-message'}>{message}</span>
|
||||
<span className={prefixCls + '-description'}>{description}</span>
|
||||
{closable ? <a onClick={this.handleClose} className={prefixCls + '-close-icon'}>
|
||||
{closeText}
|
||||
</a> : null}
|
||||
</div>
|
||||
</Animate>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ class TreeDemo extends React.Component {
|
||||
<TreeNode key="p10" title="leaf"/>
|
||||
<TreeNode title="parent 1-1" key="p11">
|
||||
<TreeNode title="parent 2-1" key="p21">
|
||||
<TreeNode>test</TreeNode>
|
||||
<TreeNode title="test" />
|
||||
<TreeNode title={<span>sss</span>}/>
|
||||
</TreeNode>
|
||||
<TreeNode key="p22" title="leaf"/>
|
||||
|
@ -20,13 +20,15 @@
|
||||
|
||||
&-description {
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
color: @legend-color;
|
||||
line-height: 21px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
&-success {
|
||||
border: 1px solid tint(@success-color, 80%);
|
||||
background-color: tint(@success-color, 90%);
|
||||
.anticon {
|
||||
.@{alert-prefix-cls}-icon {
|
||||
color: @success-color;
|
||||
}
|
||||
}
|
||||
@ -34,7 +36,7 @@
|
||||
&-info {
|
||||
border: 1px solid tint(@primary-color, 80%);
|
||||
background-color: tint(@primary-color, 90%);
|
||||
.anticon {
|
||||
.@{alert-prefix-cls}-icon {
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
@ -42,7 +44,7 @@
|
||||
&-warn {
|
||||
border: 1px solid tint(@warning-color, 80%);
|
||||
background-color: tint(@warning-color, 90%);
|
||||
.anticon {
|
||||
.@{alert-prefix-cls}-icon {
|
||||
color: @warning-color;
|
||||
}
|
||||
}
|
||||
@ -50,38 +52,29 @@
|
||||
&-error {
|
||||
border: 1px solid tint(@error-color, 80%);
|
||||
background-color: tint(@error-color, 90%);
|
||||
.anticon {
|
||||
.@{alert-prefix-cls}-icon {
|
||||
color: @error-color;
|
||||
}
|
||||
}
|
||||
|
||||
&-close-icon,
|
||||
&-with-description-close-icon {
|
||||
&-close-icon {
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
right: 16px;
|
||||
top: 50%;
|
||||
margin-top: -6px;
|
||||
transition: color .3s ease;
|
||||
color: #999;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
line-height: 12px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
|
||||
&-x {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
&:before {
|
||||
font-weight: 700;
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
content: "\e62d";
|
||||
font-family: "anticon";
|
||||
.anticon-cross {
|
||||
color: @legend-color;
|
||||
transition: color .3s ease;
|
||||
&:hover {
|
||||
color: #444;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #444;
|
||||
}
|
||||
}
|
||||
|
||||
&-close-text {
|
||||
@ -95,69 +88,38 @@
|
||||
border-radius: @border-radius-base;
|
||||
margin-bottom: 10px;
|
||||
color: @text-color;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
&-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 24px;
|
||||
margin-top: -15px;
|
||||
font-size: 29px;
|
||||
}
|
||||
&-with-description &-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 24px;
|
||||
margin-top: -15px;
|
||||
font-size: 29px;
|
||||
}
|
||||
|
||||
&-close-icon {
|
||||
position: absolute;
|
||||
top: 17px;
|
||||
right: 16px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
&-with-description &-close-icon {
|
||||
position: absolute;
|
||||
top: 17px;
|
||||
right: 16px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&-message {
|
||||
font-size: 14px;
|
||||
color: @text-color;
|
||||
}
|
||||
&-with-description &-message {
|
||||
font-size: 14px;
|
||||
color: @text-color;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&-description {
|
||||
font-size: 12px;
|
||||
color: @legend-color;
|
||||
}
|
||||
|
||||
&-success {
|
||||
border: 1px solid tint(@success-color, 80%);
|
||||
background-color: tint(@success-color, 90%);
|
||||
.anticon {
|
||||
color: @success-color;
|
||||
}
|
||||
}
|
||||
|
||||
&-info {
|
||||
border: 1px solid tint(@primary-color, 80%);
|
||||
background-color: tint(@primary-color, 90%);
|
||||
.anticon {
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
&-warn {
|
||||
border: 1px solid tint(@warning-color, 80%);
|
||||
background-color: tint(@warning-color, 90%);
|
||||
.anticon {
|
||||
color: @warning-color;
|
||||
}
|
||||
}
|
||||
|
||||
&-error {
|
||||
border: 1px solid tint(@error-color, 80%);
|
||||
background-color: tint(@error-color, 90%);
|
||||
.anticon {
|
||||
color: @error-color;
|
||||
}
|
||||
}
|
||||
&-with-description &-description {
|
||||
display: block;
|
||||
}
|
||||
|
||||
&-close {
|
||||
height: 0 !important;
|
||||
opacity: 0 !important;
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
margin: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
|
Loading…
Reference in New Issue
Block a user