-
-
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
Merged
Merged
[Stepper] Mobile version #7043
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d5e4b19
[Stepper] Mobile version - fixes #7033
alexhayes ad89ff4
Change classes.mobileStepper for classes.root
alexhayes 0aa9036
Use theme.spacing.unit rather than hard coded padding and dot width/h…
alexhayes ec9275a
Optimise use of classNames for dotClassName
alexhayes 5fbada3
Fixed classes.root tests
alexhayes c9b9011
Added props backButtonText and nextButtonText
alexhayes 65c70e3
Added position prop making MobileStepper not fixed by default.
alexhayes ee8c615
Fixed linting issues
alexhayes 85150f1
[MobileStepper] Second iteration
oliviertassinari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
# MobileStepper | ||
|
||
|
||
|
||
## Props | ||
| Name | Type | Default | Description | | ||
|:-----|:-----|:--------|:------------| | ||
| activeStep | number | `0` | Specifies the currently active step. | | ||
| disableBack | bool | `false` | Set to disable the back button. | | ||
| disableNext | bool | `false` | Set to disable the next button. | | ||
| kind | `text`, `dots` or `progress` | `dots` | Defines the kind of mobile stepper to use. | | ||
| onBack | function | | Supplied to the onClick attribute of the back button. | | ||
| onNext | function | | Supplied to the onClick attribute of the next button. | | ||
| steps | number | | The total amount of steps. | | ||
| buttonClassName | string | | Specify an extra class to be put on back/next buttons | | ||
| className | string | | Specify an extra class to be put on the root element | | ||
| dotClassName | string | | Specify an extra class to be put on each dot element | | ||
| dotsClassName | string | | Specify an extra class to be put the container that holds the dots | | ||
| progressClassname | string | | Specify an extra class to be put the container that holds the <LinearProgress /> component. | | ||
|
||
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: | ||
- `mobileStepper` | ||
- `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: `MuiAppBar`. |
61 changes: 61 additions & 0 deletions
61
docs/src/pages/component-demos/mobile-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,61 @@ | ||
// @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: { | ||
position: 'relative', | ||
marginTop: 30, | ||
width: '100%', | ||
}, | ||
mobileStepper: { | ||
position: 'relative', | ||
}, | ||
}); | ||
|
||
class DotsMobileStepper extends Component { | ||
static propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
state = { | ||
activeStep: 0, | ||
}; | ||
|
||
handleOnNext = () => { | ||
const activeStep = this.state.activeStep === 5 ? 5 : this.state.activeStep + 1; | ||
this.setState({ | ||
activeStep, | ||
}); | ||
}; | ||
|
||
handleOnBack = () => { | ||
const activeStep = this.state.activeStep === 0 ? 0 : this.state.activeStep - 1; | ||
this.setState({ | ||
activeStep, | ||
}); | ||
}; | ||
|
||
render() { | ||
const classes = this.props.classes; | ||
return ( | ||
<div className={classes.root}> | ||
<MobileStepper | ||
kind="dots" | ||
steps={6} | ||
activeStep={this.state.activeStep} | ||
className={classes.mobileStepper} | ||
onBack={this.handleOnBack} | ||
onNext={this.handleOnNext} | ||
disableBack={this.state.activeStep === 0} | ||
disableNext={this.state.activeStep === 5} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withStyles(styleSheet)(DotsMobileStepper); |
61 changes: 61 additions & 0 deletions
61
docs/src/pages/component-demos/mobile-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,61 @@ | ||
// @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: { | ||
position: 'relative', | ||
marginTop: 30, | ||
width: '100%', | ||
}, | ||
mobileStepper: { | ||
position: 'relative', | ||
}, | ||
}); | ||
|
||
class ProgressMobileStepper extends Component { | ||
static propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
state = { | ||
activeStep: 0, | ||
}; | ||
|
||
handleOnNext = () => { | ||
const activeStep = this.state.activeStep === 5 ? 5 : this.state.activeStep + 1; | ||
this.setState({ | ||
activeStep, | ||
}); | ||
}; | ||
|
||
handleOnBack = () => { | ||
const activeStep = this.state.activeStep === 0 ? 0 : this.state.activeStep - 1; | ||
this.setState({ | ||
activeStep, | ||
}); | ||
}; | ||
|
||
render() { | ||
const classes = this.props.classes; | ||
return ( | ||
<div className={classes.root}> | ||
<MobileStepper | ||
kind="progress" | ||
steps={6} | ||
activeStep={this.state.activeStep} | ||
className={classes.mobileStepper} | ||
onBack={this.handleOnBack} | ||
onNext={this.handleOnNext} | ||
disableBack={this.state.activeStep === 0} | ||
disableNext={this.state.activeStep === 5} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withStyles(styleSheet)(ProgressMobileStepper); |
78 changes: 78 additions & 0 deletions
78
docs/src/pages/component-demos/mobile-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,78 @@ | ||
// @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'; | ||
|
||
const styleSheet = createStyleSheet('TextMobileStepper', { | ||
root: { | ||
position: 'relative', | ||
marginTop: 30, | ||
width: '100%', | ||
}, | ||
mobileStepper: { | ||
position: 'relative', | ||
}, | ||
textualDescription: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
width: '100%', | ||
position: 'relative', | ||
height: '50px', | ||
left: 0, | ||
fontSize: '14px', | ||
paddingLeft: '28px', | ||
marginBottom: '20px', | ||
}, | ||
}); | ||
|
||
class TextMobileStepper extends Component { | ||
static propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
state = { | ||
activeStep: 0, | ||
}; | ||
|
||
handleOnNext = () => { | ||
const activeStep = this.state.activeStep === 5 ? 5 : this.state.activeStep + 1; | ||
this.setState({ | ||
activeStep, | ||
}); | ||
}; | ||
|
||
handleOnBack = () => { | ||
const activeStep = this.state.activeStep === 0 ? 0 : this.state.activeStep - 1; | ||
this.setState({ | ||
activeStep, | ||
}); | ||
}; | ||
|
||
render() { | ||
const classes = this.props.classes; | ||
return ( | ||
<div className={classes.root}> | ||
<Paper square elevation={0} className={classes.textualDescription}> | ||
Step {this.state.activeStep + 1} of 6 | ||
</Paper> | ||
<MobileStepper | ||
kind="text" | ||
steps={6} | ||
activeStep={this.state.activeStep} | ||
className={classes.mobileStepper} | ||
onBack={this.handleOnBack} | ||
onNext={this.handleOnNext} | ||
disableBack={this.state.activeStep === 0} | ||
disableNext={this.state.activeStep === 5} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withStyles(styleSheet)(TextMobileStepper); |
22 changes: 22 additions & 0 deletions
22
docs/src/pages/component-demos/mobile-stepper/mobile-stepper.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,22 @@ | ||
--- | ||
components: MobileStepper | ||
--- | ||
|
||
# MobileStepper | ||
|
||
The [MobileStepper](https://material.io/guidelines/layout/structure.html#structure-mobile-stepper) implements a compact stepper suitable for a mobile device. | ||
|
||
## Mobile Stepper - Dots | ||
|
||
{{demo='pages/component-demos/mobile-stepper/DotsMobileStepper.js'}} | ||
|
||
## 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/mobile-stepper/TextMobileStepper.js'}} | ||
|
||
## Mobile Stepper - Progress | ||
|
||
{{demo='pages/component-demos/mobile-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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I guess we could mark it done?
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.
When it's merged :)