Skip to content

Commit

Permalink
Add active
Browse files Browse the repository at this point in the history
  • Loading branch information
casesandberg committed Oct 12, 2016
1 parent ca8d36e commit 456212d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/active.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

export const active = Component => {
return class Active extends React.Component {
state = { active: false }
handleMouseDown = () => this.setState({ active: true })
handleMouseUp = () => this.setState({ active: false })

render = () => (
<span onMouseDown={ this.handleMouseDown } onMouseUp={ this.handleMouseUp }>
<Component { ...this.props } { ...this.state } />
</span>
)
}
}

export default active

0 comments on commit 456212d

Please sign in to comment.