Skip to content

Commit

Permalink
Merge pull request #1907 from oliviertassinari/tabs-swipeable
Browse files Browse the repository at this point in the history
[Docs] Add an example of tabs with a slide effect
  • Loading branch information
oliviertassinari committed Oct 29, 2015
2 parents 3304889 + f69ad2d commit 9be7261
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"react-addons-transition-group": "^0.14.0",
"react-addons-update": "^0.14.0",
"react-dom": "^0.14.0",
"react-motion": "^0.3.1",
"react-swipeable-views": "^0.3.0",
"react-tap-event-plugin": "^0.2.0"
},
"devDependencies": {
Expand Down
40 changes: 38 additions & 2 deletions docs/src/app/components/pages/components/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ let {IconButton, Slider, Styles, Tab, Tabs } = require('material-ui');
let ComponentDoc = require('../../component-doc');
let { Colors, Typography } = Styles;
let Code = require('tabs-code');

const SwipeableViews = require('react-swipeable-views');

export default class TabsPage extends React.Component {

constructor(props) {
super(props);
this._handleTabActive = this._handleTabActive.bind(this);
this.state = {tabsValue: 'a'};
this.state = {
tabsValue: 'a',
slideIndex: 0,
};
}

render(){
Expand Down Expand Up @@ -150,6 +153,9 @@ export default class TabsPage extends React.Component {
position: 'relative',
paddingLeft: padding,
},
slide: {
padding: 10,
},
};

return (
Expand Down Expand Up @@ -227,11 +233,41 @@ export default class TabsPage extends React.Component {
</Tab>
</Tabs>
</div>
<br />
<Tabs onChange={this._handleChangeTabs.bind(this)} value={this.state.slideIndex + ''}>
<Tab label="Tab One" value="0" />
<Tab label="Tab Two" value="1" />
<Tab label="Tab Three" value="2" />
</Tabs>
<SwipeableViews index={this.state.slideIndex} onChangeIndex={this._handleChangeIndex.bind(this)}>
<div>
<h2 style={styles.headline}>Tabs with slide effect</h2>
Swipe to see the next slide.<br />
</div>
<div style={styles.slide}>
slide n°2
</div>
<div style={styles.slide}>
slide n°3
</div>
</SwipeableViews>
</CodeExample>
</ComponentDoc>
);
}

_handleChangeIndex(index) {
this.setState({
slideIndex: index,
});
}

_handleChangeTabs(value) {
this.setState({
slideIndex: parseInt(value, 10),
});
}

_handleButtonClick() {
this.setState({tabsValue: 'c'});
}
Expand Down
19 changes: 19 additions & 0 deletions docs/src/app/components/raw-code/tabs-code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@
(Tab content...)
</Tab>
</Tabs>

// Tabs with slide effect
<Tabs onChange={this._handleChangeTabs.bind(this)} value={this.state.slideIndex + ''}>
<Tab label="Tab One" value="0" />
<Tab label="Tab Two" value="1" />
<Tab label="Tab Three" value="2" />
</Tabs>
<SwipeableViews index={this.state.slideIndex} onChangeIndex={this._handleChangeIndex.bind(this)}>
<div>
<h2 style={styles.headline}>Tabs with slide effect</h2>
Swipe to see the next slide.<br />
</div>
<div style={styles.slide}>
slide n°2
</div>
<div style={styles.slide}>
slide n°3
</div>
</SwipeableViews>

0 comments on commit 9be7261

Please sign in to comment.