Skip to content

Instantly share code, notes, and snippets.

@Eyongkevin
Created July 2, 2020 18:09
Show Gist options
  • Save Eyongkevin/c9fd97ca9398561a5aa8ba385be74376 to your computer and use it in GitHub Desktop.
Save Eyongkevin/c9fd97ca9398561a5aa8ba385be74376 to your computer and use it in GitHub Desktop.
sample code for the tut `Build a Shopping Cart with React, Redux, and React-DnD`
class Phone extends Component{
render(){
const { brand } = this.props;
const { isDragging, connectDragSource } = this.props;
const opacity = isDragging? 0.4: 1;
const style={
opacity: opacity
};
const phoneClass = isDragging? 'ui card phone drag': 'ui card phone';
return connectDragSource(
<div className={phoneClass} style={style}>
<div className="image"><img src="/images/phone.jpg" /></div>
<div className="content">
<div className="phone-name">{ brand }</div>
<div className="meta">8G RAM, 16G memory</div>
</div>
<div className="extra content">
<a>
<i aria-hidden="true" className="money icon"></i>
$ 80
</a>
</div>
</div>
)
}
}
export default DragSource(ItemTypes.PHONE, phoneSpec, collect)(Phone);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment