Skip to content

Instantly share code, notes, and snippets.

@ryngonzalez
Last active August 29, 2015 14:27
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 ryngonzalez/f92b2d26abccfb04760f to your computer and use it in GitHub Desktop.
Save ryngonzalez/f92b2d26abccfb04760f to your computer and use it in GitHub Desktop.
// #########################################
// protocols/listlike.jsx
// #########################################
import { Root, Children, conforms, ProtocolStyle } from 'style-protocol'
import Listable from 'protocols/listable'
export default class Listlike extends HierarchyProtocol {
hierarchy() {
return (
<Root>
<Child is={conforms([Listable])} count="*"></Child>
</Root>
)
}
where(state) {
return state.scrollable
}
}
// #########################################
// components/my-list.jsx
// #########################################
import Listlike from 'protocols/Listlike'
import ListItem from './ListItem'
const initialState = {
scrollable: true
}
const myStyle = {
'overflow': 'scroll',
'height': '100%'
}
@conforms([{
protocol: Listlike,
style: myStyle
}])
class MyModal extends Component {
constructor(state = initialState) {
//…
}
render() {
let cells = this.props.stuff.map(item => {
return (
<ListItem>{item.name}</ListItem>
)
})
return (
<div>
{cells}
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment