Skip to content

Commit

Permalink
move className and style to ant-upload-drag (ant-design#19987)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyo837 authored and afc163 committed Nov 28, 2019
1 parent 965bc58 commit c824569
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 1 addition & 3 deletions components/form/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4151,9 +4151,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
<span
class="ant-form-item-children"
>
<span
class=""
>
<span>
<div
class="ant-upload ant-upload-drag"
/>
Expand Down
21 changes: 14 additions & 7 deletions components/upload/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class Upload extends React.Component<UploadProps, UploadState> {
type,
disabled,
children,
style,
} = this.props;
const { fileList, dragState } = this.state;

Expand All @@ -298,6 +299,7 @@ class Upload extends React.Component<UploadProps, UploadState> {
};

delete rcUploadProps.className;
delete rcUploadProps.style;

const uploadList = showUploadList ? (
<LocaleReceiver componentName="Upload" defaultLocale={defaultLocale.Upload}>
Expand All @@ -306,19 +308,24 @@ class Upload extends React.Component<UploadProps, UploadState> {
) : null;

if (type === 'drag') {
const dragCls = classNames(prefixCls, {
[`${prefixCls}-drag`]: true,
[`${prefixCls}-drag-uploading`]: fileList.some(file => file.status === 'uploading'),
[`${prefixCls}-drag-hover`]: dragState === 'dragover',
[`${prefixCls}-disabled`]: disabled,
});
const dragCls = classNames(
prefixCls,
{
[`${prefixCls}-drag`]: true,
[`${prefixCls}-drag-uploading`]: fileList.some(file => file.status === 'uploading'),
[`${prefixCls}-drag-hover`]: dragState === 'dragover',
[`${prefixCls}-disabled`]: disabled,
},
className,
);
return (
<span className={className}>
<span>
<div
className={dragCls}
onDrop={this.onFileDrop}
onDragOver={this.onFileDrop}
onDragLeave={this.onFileDrop}
style={style}
>
<RcUpload {...rcUploadProps} ref={this.saveUpload} className={`${prefixCls}-btn`}>
<div className={`${prefixCls}-drag-container`}>{children}</div>
Expand Down
4 changes: 1 addition & 3 deletions components/upload/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ exports[`renders ./components/upload/demo/directory.md correctly 1`] = `
`;

exports[`renders ./components/upload/demo/drag.md correctly 1`] = `
<span
class=""
>
<span>
<div
class="ant-upload ant-upload-drag"
/>
Expand Down

0 comments on commit c824569

Please sign in to comment.