A Pen by Nick Hudkins on CodePen.
Created
May 6, 2014 02:21
-
-
Save nickhudkins/11552094 to your computer and use it in GitHub Desktop.
A Pen by Nick Hudkins.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="contentguy"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comments = [{author:'One', comment: 'Hi!'},{author:'two', comment:'fuck yeah!'}] | |
CommentItem = React.createClass | |
getInitialState: -> | |
clicked: false | |
onClickHandler: (e)-> | |
this.setState | |
clicked: !this.state.clicked | |
render: -> | |
React.DOM.li | |
className: if this.state.clicked then 'listypoo__item listypoo__item--clicked' else 'listypoo__item' | |
children: this.props.author + " - " + this.props.comment | |
onClick: this.onClickHandler | |
CommentBox = React.createClass | |
render: ()-> | |
React.DOM.div | |
className: 'container', | |
children: | |
React.DOM.ul | |
className: 'listypoo__list', | |
children: this.props.data.map (item)-> | |
return CommentItem item | |
React.renderComponent CommentBox({data:comments}), | |
document.getElementById('contentguy') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.listypoo__item--clicked{ | |
background-color:red; | |
} | |
.listypoo__item{ | |
&:hover{ | |
cursor: pointer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment