Merge branch 'master' into antd-3.0

This commit is contained in:
afc163 2017-10-16 20:45:25 +08:00
commit 00bfa49031
11 changed files with 134 additions and 20 deletions

View File

@ -17,6 +17,7 @@ export interface BadgeProps {
dot?: boolean;
style?: React.CSSProperties;
prefixCls?: string;
scrollNumberPrefixCls?: string;
className?: string;
status?: 'success' | 'processing' | 'default' | 'error' | 'warning';
text?: string;
@ -25,6 +26,7 @@ export interface BadgeProps {
export default class Badge extends React.Component<BadgeProps, any> {
static defaultProps = {
prefixCls: 'ant-badge',
scrollNumberPrefixCls: 'ant-scroll-number',
count: null,
showZero: false,
dot: false,
@ -46,6 +48,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
count,
showZero,
prefixCls,
scrollNumberPrefixCls,
overflowCount,
className,
style,
@ -94,6 +97,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
const scrollNumber = hidden ? null : (
<ScrollNumber
prefixCls={scrollNumberPrefixCls}
data-show={!hidden}
className={scrollNumberCls}
count={displayCount}

View File

@ -253,7 +253,7 @@ exports[`renders ./components/layout/demo/fixed.md correctly 1`] = `
>
<div
class="ant-breadcrumb"
style="margin:12px 0"
style="margin:16px 0"
>
<span>
<span
@ -812,7 +812,7 @@ exports[`renders ./components/layout/demo/side.md correctly 1`] = `
>
<div
class="ant-breadcrumb"
style="margin:12px 0"
style="margin:16px 0"
>
<span>
<span
@ -901,7 +901,7 @@ exports[`renders ./components/layout/demo/top.md correctly 1`] = `
>
<div
class="ant-breadcrumb"
style="margin:12px 0"
style="margin:16px 0"
>
<span>
<span
@ -1001,7 +1001,7 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
>
<div
class="ant-breadcrumb"
style="margin:12px 0"
style="margin:16px 0"
>
<span>
<span
@ -1348,7 +1348,7 @@ exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = `
>
<div
class="ant-breadcrumb"
style="margin:12px 0"
style="margin:16px 0"
>
<span>
<span

View File

@ -34,7 +34,7 @@ ReactDOM.render(
</Menu>
</Header>
<Content style={{ padding: '0 50px', marginTop: 64 }}>
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb style={{ margin: '16px 0' }}>
<Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item>List</Breadcrumb.Item>
<Breadcrumb.Item>App</Breadcrumb.Item>

View File

@ -75,7 +75,7 @@ class SiderDemo extends React.Component {
<Layout>
<Header style={{ background: '#fff', padding: 0 }} />
<Content style={{ margin: '0 16px' }}>
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb style={{ margin: '16px 0' }}>
<Breadcrumb.Item>User</Breadcrumb.Item>
<Breadcrumb.Item>Bill</Breadcrumb.Item>
</Breadcrumb>

View File

@ -62,7 +62,7 @@ ReactDOM.render(
</Menu>
</Sider>
<Layout style={{ padding: '0 24px 24px' }}>
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb style={{ margin: '16px 0' }}>
<Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item>List</Breadcrumb.Item>
<Breadcrumb.Item>App</Breadcrumb.Item>

View File

@ -34,7 +34,7 @@ ReactDOM.render(
</Menu>
</Header>
<Content style={{ padding: '0 50px' }}>
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb style={{ margin: '16px 0' }}>
<Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item>List</Breadcrumb.Item>
<Breadcrumb.Item>App</Breadcrumb.Item>

View File

@ -40,7 +40,7 @@ ReactDOM.render(
</Menu>
</Header>
<Content style={{ padding: '0 50px' }}>
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb style={{ margin: '16px 0' }}>
<Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item>List</Breadcrumb.Item>
<Breadcrumb.Item>App</Breadcrumb.Item>

View File

@ -1,5 +1,79 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Upload List handle error 1`] = `
<span
class=""
>
<div
class="ant-upload ant-upload-select ant-upload-select-text"
>
<span
class="ant-upload"
role="button"
tabindex="0"
>
<input
accept=""
style="display: none;"
type="file"
/>
<button>
upload
</button>
</span>
</div>
<div
class="ant-upload-list ant-upload-list-text"
>
<div
class="ant-upload-list-item ant-upload-list-item-error"
>
<div
class="ant-upload-list-item-info"
>
<span>
<i
class="anticon anticon-paper-clip"
/>
<span
class="ant-upload-list-item-name"
title="foo.png"
>
foo.png
</span>
</span>
</div>
<i
class="anticon anticon-cross"
title="删除文件"
/>
<div
class="ant-upload-list-item-progress fade-leave"
>
<div
class="ant-progress ant-progress-line ant-progress-status-normal"
>
<div>
<div
class="ant-progress-outer"
>
<div
class="ant-progress-inner"
>
<div
class="ant-progress-bg"
style="width: 0%; height: 2px;"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</span>
`;
exports[`Upload List should be uploading when upload a file 1`] = `
<span
class=""
@ -100,7 +174,7 @@ exports[`Upload List should be uploading when upload a file 2`] = `
class="ant-upload-list ant-upload-list-text"
>
<div
class="ant-upload-list-item ant-upload-list-item-error"
class="ant-upload-list-item ant-upload-list-item-done"
>
<div
class="ant-upload-list-item-info"

View File

@ -0,0 +1,11 @@
export const successRequest = ({ onSuccess, file }) => {
setTimeout(() => {
onSuccess(null, file);
});
};
export const errorRequest = ({ onError }) => {
setTimeout(() => {
onError();
});
};

View File

@ -1,6 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
import Upload from '..';
import { errorRequest, successRequest } from './requests';
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
@ -63,23 +64,47 @@ describe('Upload List', () => {
it('should be uploading when upload a file', (done) => {
let wrapper;
let finished;
const onChange = ({ file }) => {
if (finished) {
done();
return;
}
if (file.status === 'uploading') {
expect(wrapper.render()).toMatchSnapshot();
}
if (file.status === 'error') {
if (file.status === 'done') {
expect(wrapper.render()).toMatchSnapshot();
finished = true;
done();
}
};
wrapper = mount(
<Upload action="http://jsonplaceholder.typicode.com/posts/" onChange={onChange}>
<Upload
action="http://jsonplaceholder.typicode.com/posts/"
onChange={onChange}
customRequest={successRequest}
>
<button>upload</button>
</Upload>
);
wrapper.find('input').simulate('change', {
target: {
files: [
{ filename: 'foo.png' },
],
},
});
});
it('handle error', (done) => {
let wrapper;
const onChange = ({ file }) => {
if (file.status !== 'uploading') {
expect(wrapper.render()).toMatchSnapshot();
done();
}
};
wrapper = mount(
<Upload
action="http://jsonplaceholder.typicode.com/posts/"
onChange={onChange}
customRequest={errorRequest}
>
<button>upload</button>
</Upload>
);

View File

@ -102,7 +102,7 @@ Password input box provides real time feedbacks on password strength and validit
<img class="preview-img inline" align="right" description="Validation in real time" src="https://os.alipayobjects.com/rmsportal/urCdIJFuNYCenqH.png">
<img class="preview-img inline" align="right" description="Validation after losing focus" src="https://os.alipayobjects.com/rmsportal/KkcSBkbTJirIxCw.png">
<img class="preview-img" align="right" description="When a "submit" button is clicked, the system will deal with user inputs and display feedbacks (the number of errors and the types of errors) on the page." src="https://zos.alipayobjects.com/rmsportal/xTtVSREbASRMstTggVGD.png">
<img class="preview-img" align="right" description='When a "submit" button is clicked, the system will deal with user inputs and display feedbacks (the number of errors and the types of errors) on the page.' src="https://zos.alipayobjects.com/rmsportal/xTtVSREbASRMstTggVGD.png">
Use different validation rules and a variety of feedbacks to help users correct errors before they click on a "submit" button.