Skip to content

Instantly share code, notes, and snippets.

@NoamELB
Last active December 7, 2017 15:16
Show Gist options
  • Save NoamELB/581ffd86354b0bab37779e4c6a56b124 to your computer and use it in GitHub Desktop.
Save NoamELB/581ffd86354b0bab37779e4c6a56b124 to your computer and use it in GitHub Desktop.
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