-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding demo of Mobile Stepper - Text with Carousel effect
- Loading branch information
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
docs/src/pages/demos/steppers/SwipeableTextMobileStepper.js
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from 'material-ui/styles'; | ||
import MobileStepper from 'material-ui/MobileStepper'; | ||
import Paper from 'material-ui/Paper'; | ||
import Typography from 'material-ui/Typography'; | ||
import Button from 'material-ui/Button'; | ||
import KeyboardArrowLeft from '@material-ui/icons/KeyboardArrowLeft'; | ||
import KeyboardArrowRight from '@material-ui/icons/KeyboardArrowRight'; | ||
import SwipeableViews from 'react-swipeable-views'; | ||
import tutorialData from './steppersData'; | ||
|
||
const styles = theme => ({ | ||
root: { | ||
maxWidth: 400, | ||
flexGrow: 1, | ||
}, | ||
header: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
height: 50, | ||
paddingLeft: theme.spacing.unit * 4, | ||
marginBottom: 20, | ||
backgroundColor: theme.palette.background.default, | ||
}, | ||
img: { | ||
height: 255, | ||
maxWidth: 400, | ||
overflow: 'hidden', | ||
width: '100%', | ||
}, | ||
}); | ||
|
||
class SwipeableTextMobileStepper extends React.Component { | ||
state = { | ||
activeStep: 0, | ||
}; | ||
|
||
handleNext = () => { | ||
this.setState(prevState => ({ | ||
activeStep: prevState.activeStep + 1, | ||
})); | ||
}; | ||
|
||
handleBack = () => { | ||
this.setState(prevState => ({ | ||
activeStep: prevState.activeStep - 1, | ||
})); | ||
}; | ||
|
||
handleStepChange = activeStep => { | ||
this.setState({ activeStep }); | ||
}; | ||
|
||
render() { | ||
const { classes, theme } = this.props; | ||
const { activeStep } = this.state; | ||
|
||
const maxSteps = tutorialData.length; | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Paper square elevation={0} className={classes.header}> | ||
<Typography>{tutorialData[activeStep].label}</Typography> | ||
</Paper> | ||
<SwipeableViews | ||
onChangeIndex={this.handleStepChange} | ||
enableMouseEvents | ||
index={this.state.activeStep} | ||
> | ||
{tutorialData.map(step => ( | ||
<img className={classes.img} src={step.imgPath} alt={step.label} /> | ||
))} | ||
</SwipeableViews> | ||
<MobileStepper | ||
variant="text" | ||
steps={maxSteps} | ||
position="static" | ||
activeStep={activeStep} | ||
className={classes.mobileStepper} | ||
nextButton={ | ||
<Button size="small" onClick={this.handleNext} disabled={activeStep === maxSteps - 1}> | ||
Next | ||
{theme.direction === 'rtl' ? <KeyboardArrowLeft /> : <KeyboardArrowRight />} | ||
</Button> | ||
} | ||
backButton={ | ||
<Button size="small" onClick={this.handleBack} disabled={activeStep === 0}> | ||
{theme.direction === 'rtl' ? <KeyboardArrowRight /> : <KeyboardArrowLeft />} | ||
Back | ||
</Button> | ||
} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
SwipeableTextMobileStepper.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
theme: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles, { withTheme: true })(SwipeableTextMobileStepper); |
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