Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
],
"dependencies": {
"babel-runtime": "6.x",
"classnames": "^2.2.5",
"warning": "2.x"
}
}
17 changes: 11 additions & 6 deletions src/AjaxUploader.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* eslint react/no-is-mounted:0*/

import request from './request';
import React, { PropTypes } from 'react';
import classNames from 'classnames';
import request from './request';
import getUid from './uid';

const AjaxUploader = React.createClass({
propTypes: {
component: PropTypes.string,
style: PropTypes.object,
prefixCls: PropTypes.string,
className: PropTypes.string,
multiple: PropTypes.bool,
disabled: PropTypes.bool,
accept: PropTypes.string,
Expand Down Expand Up @@ -157,13 +159,15 @@ const AjaxUploader = React.createClass({

render() {
const {
component: Tag, prefixCls, disabled,
component: Tag, prefixCls, className, disabled,
style, multiple, accept, children,
} = this.props;
const events = disabled ? {
className: `${prefixCls} ${prefixCls}-disabled`,
} : {
className: `${prefixCls}`,
const cls = classNames({
[prefixCls]: true,
[`${prefixCls}-disabled`]: disabled,
[className]: className,
});
const events = disabled ? {} : {
onClick: this.onClick,
onKeyDown: this.onKeyDown,
onDrop: this.onFileDrop,
Expand All @@ -173,6 +177,7 @@ const AjaxUploader = React.createClass({
return (
<Tag
{...events}
className={cls}
role="button"
style={style}
>
Expand Down
12 changes: 9 additions & 3 deletions src/IframeUploader.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { PropTypes } from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import getUid from './uid';
import warning from 'warning';

Expand All @@ -19,6 +20,7 @@ const IframeUploader = React.createClass({
style: PropTypes.object,
disabled: PropTypes.bool,
prefixCls: PropTypes.string,
className: PropTypes.string,
accept: PropTypes.string,
onStart: PropTypes.func,
multiple: PropTypes.bool,
Expand Down Expand Up @@ -249,17 +251,21 @@ const IframeUploader = React.createClass({

render() {
const {
component: Tag, disabled,
component: Tag, disabled, className,
prefixCls, children, style,
} = this.props;
const iframeStyle = {
...IFRAME_STYLE,
display: this.state.uploading || disabled ? 'none' : '',
};

const cls = classNames({
[prefixCls]: true,
[`${prefixCls}-disabled`]: disabled,
[className]: className,
});
return (
<Tag
className={disabled ? `${prefixCls} ${prefixCls}-disabled` : `${prefixCls}`}
className={cls}
style={{ position: 'relative', zIndex: 0, ...style }}
>
<iframe
Expand Down