-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Stepper] Mobile version - fixes #7033 * Change classes.mobileStepper for classes.root * Use theme.spacing.unit rather than hard coded padding and dot width/height * Optimise use of classNames for dotClassName * Fixed classes.root tests * Added props backButtonText and nextButtonText * Added position prop making MobileStepper not fixed by default. * Fixed linting issues * [MobileStepper] Second iteration
- Loading branch information
1 parent
d200ce2
commit de4c31b
Showing
11 changed files
with
598 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
docs/src/pages/component-api/MobileStepper/MobileStepper.md
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,40 @@ | ||
# MobileStepper | ||
|
||
|
||
|
||
## Props | ||
| Name | Type | Default | Description | | ||
|:-----|:-----|:--------|:------------| | ||
| activeStep | number | 0 | Set the active step (zero based index). This will enable `Step` control helpers. | | ||
| backButtonText | node | 'Back' | Set the text that appears for the back button. | | ||
| classes | object | | Useful to extend the style applied to components. | | ||
| disableBack | bool | false | Set to true to disable the back button. | | ||
| disableNext | bool | false | Set to true to disable the next button. | | ||
| nextButtonText | node | 'Next' | Set the text that appears for the next button. | | ||
| <span style="color: #31a148">onBack *</span> | function | | Passed into the onTouchTap prop of the Back button. | | ||
| <span style="color: #31a148">onNext *</span> | function | | Passed into the onTouchTap prop of the Next button. | | ||
| position | enum: 'bottom'<br> 'top'<br> 'static'<br> | 'bottom' | Set the text that appears for the next button. | | ||
| <span style="color: #31a148">steps *</span> | number | | The total steps. | | ||
| type | enum: 'text'<br> 'dots'<br> 'progress'<br> | 'dots' | The type of mobile stepper to use. | | ||
|
||
Any other properties supplied will be spread to the root element. | ||
## Classes | ||
|
||
You can overrides all the class names injected by Material-UI thanks to the `classes` property. | ||
This property accepts the following keys: | ||
- `root` | ||
- `position-bottom` | ||
- `positon-top` | ||
- `position-static` | ||
- `button` | ||
- `dots` | ||
- `dot` | ||
- `dotActive` | ||
- `progress` | ||
|
||
Have a look at [overriding with class names](/customization/overrides#overriding-with-class-names) | ||
section for more detail. | ||
|
||
If using the `overrides` key of the theme as documented | ||
[here](/customization/themes#customizing-all-instances-of-a-component-type), | ||
you need to use the following style sheet name: `MuiMobileStepper`. |
54 changes: 54 additions & 0 deletions
54
docs/src/pages/component-demos/stepper/DotsMobileStepper.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,54 @@ | ||
// @flow | ||
|
||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles, createStyleSheet } from 'material-ui/styles'; | ||
import MobileStepper from 'material-ui/MobileStepper'; | ||
|
||
const styleSheet = createStyleSheet('DotsMobileStepper', { | ||
root: { | ||
maxWidth: 400, | ||
flexGrow: 1, | ||
}, | ||
}); | ||
|
||
class DotsMobileStepper extends Component { | ||
state = { | ||
activeStep: 0, | ||
}; | ||
|
||
handleNext = () => { | ||
this.setState({ | ||
activeStep: this.state.activeStep + 1, | ||
}); | ||
}; | ||
|
||
handleBack = () => { | ||
this.setState({ | ||
activeStep: this.state.activeStep - 1, | ||
}); | ||
}; | ||
|
||
render() { | ||
const classes = this.props.classes; | ||
return ( | ||
<MobileStepper | ||
type="dots" | ||
steps={6} | ||
position="static" | ||
activeStep={this.state.activeStep} | ||
className={classes.root} | ||
onBack={this.handleBack} | ||
onNext={this.handleNext} | ||
disableBack={this.state.activeStep === 0} | ||
disableNext={this.state.activeStep === 5} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
DotsMobileStepper.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styleSheet)(DotsMobileStepper); |
54 changes: 54 additions & 0 deletions
54
docs/src/pages/component-demos/stepper/ProgressMobileStepper.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,54 @@ | ||
// @flow | ||
|
||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles, createStyleSheet } from 'material-ui/styles'; | ||
import MobileStepper from 'material-ui/MobileStepper'; | ||
|
||
const styleSheet = createStyleSheet('ProgressMobileStepper', { | ||
root: { | ||
maxWidth: 400, | ||
flexGrow: 1, | ||
}, | ||
}); | ||
|
||
class ProgressMobileStepper extends Component { | ||
state = { | ||
activeStep: 0, | ||
}; | ||
|
||
handleNext = () => { | ||
this.setState({ | ||
activeStep: this.state.activeStep + 1, | ||
}); | ||
}; | ||
|
||
handleBack = () => { | ||
this.setState({ | ||
activeStep: this.state.activeStep - 1, | ||
}); | ||
}; | ||
|
||
render() { | ||
const classes = this.props.classes; | ||
return ( | ||
<MobileStepper | ||
type="progress" | ||
steps={6} | ||
position="static" | ||
activeStep={this.state.activeStep} | ||
className={classes.root} | ||
onBack={this.handleBack} | ||
onNext={this.handleNext} | ||
disableBack={this.state.activeStep === 0} | ||
disableNext={this.state.activeStep === 5} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
ProgressMobileStepper.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styleSheet)(ProgressMobileStepper); |
71 changes: 71 additions & 0 deletions
71
docs/src/pages/component-demos/stepper/TextMobileStepper.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,71 @@ | ||
// @flow | ||
|
||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles, createStyleSheet } from 'material-ui/styles'; | ||
import MobileStepper from 'material-ui/MobileStepper'; | ||
import Paper from 'material-ui/Paper'; | ||
import Typography from 'material-ui/Typography'; | ||
|
||
const styleSheet = createStyleSheet('TextMobileStepper', theme => ({ | ||
root: { | ||
maxWidth: 400, | ||
flexGrow: 1, | ||
}, | ||
header: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
height: 50, | ||
paddingLeft: theme.spacing.unit * 5, | ||
marginBottom: 20, | ||
background: theme.palette.background.default, | ||
}, | ||
})); | ||
|
||
class TextMobileStepper extends Component { | ||
state = { | ||
activeStep: 0, | ||
}; | ||
|
||
handleNext = () => { | ||
this.setState({ | ||
activeStep: this.state.activeStep + 1, | ||
}); | ||
}; | ||
|
||
handleBack = () => { | ||
this.setState({ | ||
activeStep: this.state.activeStep - 1, | ||
}); | ||
}; | ||
|
||
render() { | ||
const classes = this.props.classes; | ||
return ( | ||
<div className={classes.root}> | ||
<Paper square elevation={0} className={classes.header}> | ||
<Typography> | ||
Step {this.state.activeStep + 1} of 6 | ||
</Typography> | ||
</Paper> | ||
<MobileStepper | ||
type="text" | ||
steps={6} | ||
position="static" | ||
activeStep={this.state.activeStep} | ||
className={classes.mobileStepper} | ||
onBack={this.handleBack} | ||
onNext={this.handleNext} | ||
disableBack={this.state.activeStep === 0} | ||
disableNext={this.state.activeStep === 5} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
TextMobileStepper.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styleSheet)(TextMobileStepper); |
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,31 @@ | ||
--- | ||
components: MobileStepper | ||
--- | ||
|
||
# Stepper | ||
|
||
[Steppers](https://material.io/guidelines/components/steppers.html) convey progress through numbered steps. | ||
|
||
## Mobile Stepper | ||
|
||
The [mobile steps](https://material.io/guidelines/components/steppers.html#steppers-types-of-steps) implements a compact stepper suitable for a mobile device. | ||
|
||
### Mobile Stepper - Text | ||
|
||
This is essentially a back/next button positioned correctly. | ||
You must implement the textual description yourself however an example is provided below for reference. | ||
|
||
{{demo='pages/component-demos/stepper/TextMobileStepper.js'}} | ||
|
||
### Mobile Stepper - Dots | ||
|
||
Use dots when the number of steps isn’t large. | ||
|
||
{{demo='pages/component-demos/stepper/DotsMobileStepper.js'}} | ||
|
||
### Mobile Stepper - Progress | ||
|
||
Use a progress bar when there are many steps, or if there are steps that need to be inserted during the process (based on responses to earlier steps). | ||
|
||
{{demo='pages/component-demos/stepper/ProgressMobileStepper.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
Oops, something went wrong.