-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Stepper] Mobile version #7043
[Stepper] Mobile version #7043
Changes from all commits
d5e4b19
ad89ff4
0aa9036
ec9275a
5fbada3
c9b9011
65c70e3
ee8c615
85150f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. |
||
| 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. | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really sure what is gained here by using the I tried out a simple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is automatically generated with |
||
|
||
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`. |
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! |
||
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); |
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); |
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); |
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this reads a little oddly. Perhaps;
|
||
|
||
### 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'}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually passed into the
onClick
of the button. I did this because I couldn't find any mention ofonTouchTap
in either the docs or theButton
orBaseButton
components in thenext
branch.I think either the docs need to state
onClick
or the code needs to be changed to useonTouchTap
if that is still the way to do it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we need to use
onClick
.