Skip to content

Instantly share code, notes, and snippets.

@nickhudkins
Created May 6, 2014 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickhudkins/11552094 to your computer and use it in GitHub Desktop.
Save nickhudkins/11552094 to your computer and use it in GitHub Desktop.
A Pen by Nick Hudkins.
<div id="contentguy"></div>
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')
.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