Skip to content

Commit

Permalink
put a border around the textarea while the file can be dropped on it
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathon Kelly committed Apr 7, 2016
1 parent 952c7db commit f89a7ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/index.js
Expand Up @@ -10,9 +10,23 @@ class MarkdownEditor extends React.Component {
constructor(props) {
super(props);

this.state = {
draggingOver: false,
};

this.onDragEnter = this.onDragEnter.bind(this);
this.onDragLeave = this.onDragLeave.bind(this);
this.onImageDrop = this.onImageDrop.bind(this);
}

onDragEnter() {
this.setState({ draggingOver: true });
}

onDragLeave() {
this.setState({ draggingOver: false });
}

onImageDrop(event) {
event.preventDefault();

Expand Down Expand Up @@ -50,15 +64,20 @@ class MarkdownEditor extends React.Component {
}

render() {
const textAreaClassName = this.state.draggingOver ? 'dragover' : null;

return (
<div className="markdown-editor">
<div>
<h2>Markdown</h2>

<TextArea
className={textAreaClassName}
value={this.props.value}
onChange={this.props.onChange}
onDrop={this.onImageDrop}
onDragEnter={this.onDragEnter}
onDragLeave={this.onDragLeave}
/>
</div>

Expand Down
4 changes: 4 additions & 0 deletions src/react-markdown-editor.styl
Expand Up @@ -22,3 +22,7 @@

:last-child
margin-bottom: 0;

.dragover
border 1px solid #c9ff00
box-shadow 0 0 10px #719ECE

0 comments on commit f89a7ef

Please sign in to comment.