-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-tabs): Replace Tab component with react-bootstrap
* Gives us more out of the box * Still wrapped in our own API [Finishes #85440704] Signed-off-by: Geoff Pleiss <gpleiss@pivotal.io>
- Loading branch information
Paul Meskers
authored and
Geoff Pleiss
committed
Jan 7, 2015
1 parent
f8acd0e
commit f1c575c
Showing
4 changed files
with
23 additions
and
205 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,33 @@ | ||
'use strict'; | ||
|
||
var React = require('react/addons'); | ||
var _ = require('lodash'); | ||
var React = require('react'); | ||
var TabbedArea = require('react-bootstrap/TabbedArea'); | ||
var TabPane = require('react-bootstrap/TabPane'); | ||
|
||
var classSet = React.addons.classSet; | ||
var Tab = TabPane; | ||
|
||
var TabMenu = React.createClass({ | ||
var SimpleAltTabs = React.createClass({ | ||
render: function () { | ||
var tabs = _.map(this.props.tabs, function(tab, index) { | ||
var classes = classSet({ | ||
'active': index === this.props.activeIndex | ||
}); | ||
var key = "tab-control-" + index; | ||
return ( | ||
<li key={key} className={classes}> | ||
<a onClick={_.partial(this.props.updateTabs, index)}>{tab}</a> | ||
</li> | ||
); | ||
}, this); | ||
|
||
return ( | ||
<ul className="nav nav-tabs"> | ||
{tabs} | ||
</ul> | ||
); | ||
} | ||
}); | ||
|
||
var TabContents = React.createClass({ | ||
render: function () { | ||
var panels = _.map(this.props.children, function(panel, index) { | ||
var classes = classSet({ | ||
'tab-pane': true, | ||
'fade': true, | ||
'active in': this.props.activeIndex === index | ||
}); | ||
|
||
var key = "tab-panel-" + index; | ||
|
||
return ( | ||
<div key={key} className={classes}> | ||
{panel.props.children} | ||
</div> | ||
); | ||
}, this); | ||
|
||
return ( | ||
<div className="tab-content"> | ||
{panels} | ||
<div className="tab-simple-alt"> | ||
<TabbedArea {...this.props} /> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var Tabs = React.createClass({ | ||
getInitialState: function () { | ||
return { | ||
activeIndex: 0 | ||
}; | ||
}, | ||
componentWillMount: function () { | ||
if (this.props.activeTab) { | ||
this.setState({ activeIndex: this.props.activeTab }); | ||
} | ||
}, | ||
updateTabs: function (tabIndex) { | ||
this.setState({ activeIndex: tabIndex }); | ||
}, | ||
var SimpleTabs = React.createClass({ | ||
render: function () { | ||
var tabLinks = _.pluck(_.pluck(this.props.children, 'props'), 'heading'); | ||
var classes = classSet({ | ||
'tab-simple': !this.props.alt, | ||
'tab-simple-alt': this.props.alt | ||
}); | ||
|
||
return ( | ||
<div className={classes}> | ||
<TabMenu tabs={tabLinks} activeIndex={this.state.activeIndex} updateTabs={this.updateTabs}/> | ||
<TabContents activeIndex={this.state.activeIndex}>{this.props.children}</TabContents> | ||
<div className="tab-simple"> | ||
<TabbedArea {...this.props} /> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var Tab = React.createClass({ | ||
render: function () { | ||
return ( | ||
<div> | ||
{this.props.children} | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var AltTabs = React.createClass({ | ||
render: function () { | ||
return ( | ||
<Tabs alt="true"> | ||
{this.props.children} | ||
</Tabs> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = { | ||
Tabs: Tabs, | ||
AltTabs: AltTabs, | ||
SimpleAltTabs: SimpleAltTabs, | ||
SimpleTabs: SimpleTabs, | ||
Tab: Tab | ||
}; |
This file was deleted.
Oops, something went wrong.