Last active
August 29, 2015 14:27
-
-
Save ryngonzalez/f92b2d26abccfb04760f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ######################################### | |
// 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