Last active
December 7, 2017 15:16
-
-
Save NoamELB/581ffd86354b0bab37779e4c6a56b124 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
getHeader(tabs) { | |
return tabs.map((tab, i) => { | |
const style = this.isSelected(tab) ? activeTabHeaderStyle : tabHeaderStyle; | |
return ( | |
<span | |
key={tab.props.value} | |
onClick={e => this.selectTab(e, tab.props.value)} | |
style={i === 0 ? style : Object.assign({}, style, sideHeaderStyle)} | |
> | |
{tab.props.header} | |
</span> | |
); | |
}); | |
} | |
render() { | |
const { children } = this.props; | |
const tabs = Children.toArray(children); | |
return ( | |
<div style={tabsStyle}> | |
<div style={tabsHeaderStyle}>{this.getHeader(tabs)}</div> | |
<div style={tabsContentStyle}> | |
{_.find(tabs, tab => this.isSelected(tab))} | |
</div> | |
</div> | |
); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment