Skip to content

Commit

Permalink
Added react-dropzone
Browse files Browse the repository at this point in the history
  • Loading branch information
iamraffe committed Apr 5, 2016
1 parent f91b7c6 commit cb47af8
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"react": "^0.14.7",
"react-dom": "^0.14.7",
"webfontloader": "^1.6.24",
"react-autocomplete": "1.0.0-rc1"
"react-autocomplete": "1.0.0-rc1",
"react-dropzone": "^3.3.1"
},
"peerDependencies": {
},
Expand Down
2 changes: 2 additions & 0 deletions src/Designer.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ class Designer extends Component {

getObjectComponent(type) {
let {objectTypes} = this.props;
console.log("OBJECT COMPONENT => ",objectTypes[type], "TYPE => ", type)
return objectTypes[type];
}

Expand Down Expand Up @@ -530,6 +531,7 @@ class Designer extends Component {
...objectComponent.meta.initial,
...currentObject
};
console.log("OBJECT COMPONENT =>", objectComponent)
ObjectEditor = objectComponent.meta.editor;
}

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export Preview from './Preview';
export {Vector, Path, Rect, Circle, Text, Image} from './objects';
export {TextPanel, SizePanel, StylePanel, ArrangePanel} from './panels';
export {TextPanel, SizePanel, StylePanel, ArrangePanel, ImagePanel} from './panels';
export default from './Designer';
9 changes: 3 additions & 6 deletions src/objects/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@ export default class Image extends Vector {
icon: <Icon icon={'image'} size={30} />,
initial: {
width: 100,
height: 100
height: 100,
href: "https://placeholdit.imgix.net/~text?txtsize=10&txt=100x100&w=100&h=100"
}
};

// imageSrc(){
// return {__html: "xlink:href='https://placeholdit.imgix.net/~text?txtsize=10&txt=100x100&w=100&h=100'"}
// }

render() {
let {object, index} = this.props;
return (
<image style={this.getStyle()}
xlinkHref={'https://placeholdit.imgix.net/~text?txtsize=10&txt=100x100&w=100&h=100'}
xlinkHref={object.href}
{...this.getObjectAttributes()}
width={object.width}
height={object.height} />
Expand Down
3 changes: 2 additions & 1 deletion src/objects/Vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import Icon from '../Icon';
import _ from 'lodash';

import {SizePanel, TextPanel,
StylePanel, ArrangePanel} from '../panels';
StylePanel, ArrangePanel, ImagePanel} from '../panels';


export default class Vector extends Component {
static panels = [
SizePanel,
TextPanel,
StylePanel,
ImagePanel,
ArrangePanel
];

Expand Down
45 changes: 45 additions & 0 deletions src/panels/ImagePanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, {Component} from 'react';
import Radium from 'radium';
import _ from 'lodash';

import Icon from '../Icon';
import Panel from './Panel';

import styles from './styles';
import PropertyGroup from './PropertyGroup';
import Button from './Button';
import SwitchState from './SwitchState';
import Columns from './Columns';
import Column from './Column';
import Dropzone from 'react-dropzone';

export default class ImagePanel extends Panel {
state = {
files: []
}

onDrop (files) {
this.props.onChange("href", "/img/"+files[0].name);
console.log('Received files: ', files);
this.setState({
files: files
});
}

render() {
let {object} = this.props;
return (
<PropertyGroup object={object} showIf={_.has(object, 'href')}>
<div style={styles.columns}>
<Column>
<div className="dropzone--wrapper">
<Dropzone onDrop={this.onDrop.bind(this)} multiple={false}>
<div>Try dropping some files here, or click to select files to upload.</div>
</Dropzone>
</div>
</Column>
</div>
</PropertyGroup>
);
}
}
1 change: 1 addition & 0 deletions src/panels/PanelList.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class PanelList extends Component {
left: offset.width + offset.x,
top: offset.y + window.scrollY,
};
console.log("OBJECT => ", object, "OBJECT COMPONENT => ", objectComponent)
return (
<Portal className="propertyPanel" closeOnEsc closeOnOutsideClick isOpened={true}>
<div style={[styles.propertyPanel, style]}>
Expand Down
3 changes: 2 additions & 1 deletion src/panels/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export TextPanel from './TextPanel';
export ArrangePanel from './ArrangePanel';
export StylePanel from './StylePanel';
export SizePanel from './SizePanel';
export InsertMenu from './InsertMenu';
export InsertMenu from './InsertMenu';
export ImagePanel from './ImagePanel';

0 comments on commit cb47af8

Please sign in to comment.