Skip to content
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 9 commits into from
Jun 5, 2017
Merged

Conversation

alexhayes
Copy link
Contributor

@alexhayes alexhayes commented Jun 3, 2017

As discussed in issue #7033 this PR implements the three variations of mobile stepper outlined in the material guidelines.

Closes #7033.

  • PR has tests / docs demo, and is linted.
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

Screenshots taken from the included docs;

Dots

image

Text

image

Progress

image

@alexhayes alexhayes changed the title WIP - Fixes #7033 - [Stepper] Mobile version [Stepper] Mobile version Jun 3, 2017
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thanks a lot for working on that! 🙏 💯
That's a first quite review. I need to spend more time on it

@@ -96,6 +96,7 @@ to discuss the approach before submitting a PR.
- [Steppers](https://www.google.com/design/spec/components/steppers.html)
- [Horizontal](https://www.google.com/design/spec/components/steppers.html#steppers-types-of-steppers)
- [Vertical](https://www.google.com/design/spec/components/steppers.html#steppers-types-of-steppers)
- [MobileStepper](https://www.google.com/design/spec/components/mobile-stepper.html)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it's merged :)

import { LinearProgress } from '../Progress';

export const styleSheet = createStyleSheet('MuiMobileStepper', theme => ({
mobileStepper: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather call it root to follow the other components convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do - just an FYI tho, I was basing my work on the AppBar component which uses appBar not root.

left: 0,
zIndex: theme.zIndex.mobileStepper,
backgroundColor: theme.palette.background.paper,
padding: '6px',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following work just fine. Also, I'm wondering if we shouldn't use the standard 8 px spacing with theme.spacing.unit.

padding: 6,

dot: {
backgroundColor: theme.palette.action.disabled,
borderRadius: '50%',
width: '10px',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same we can use a number here.

function MobileStepper(props) {
const {
activeStep,
buttonClassName: buttonClassNameProp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need that property as already accessible with classes.button.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same though for the other properties.

return (
<Paper square elevation={0} className={className} {...other}>
<Button className={buttonClassName} onClick={onBack} disabled={disableBack}>
<KeyboardArrowLeft /> Back
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about i118n? Maybe some label property?

{Array.from(Array(steps)).map((_, step) => {
const dotClassName = classNames(
{
[classes.dot]: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's always true, you can pass is as an argument, that's simpler.

@@ -12,4 +12,5 @@ export default {
popover: 2100,
snackbar: 2900,
tooltip: 3000,
mobileStepper: 1100,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We sort theme by index value, not the right position.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are referring to this conversation but this is not related - I've done this because I envisaged this being sticky & fixed to the bottom of the mobile device.

position: 'fixed',
bottom: 0,
left: 0,
zIndex: theme.zIndex.mobileStepper,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I would rather not have any positioning property in our low-level components. One might position his element using flexbox only and not fixed positioning. (that's what we do, that would conflict). Maybe we could add a fix position option? (Would also help with the demos!) I'm tempted to say that de default option should not be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had a bit of a think about this and I think perhaps by default I'll remove the fixed positioning, however I think a very common use case would be for it to be fixed either at the top or bottom so I'll add flags to trigger this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a prop position in 65c70e3 which can be either bottom or top. By default MobileStepper is now not fixed.

@oliviertassinari oliviertassinari added the component: stepper This is the name of the generic UI component, not the React module! label Jun 3, 2017
@alexhayes
Copy link
Contributor Author

@oliviertassinari FYI I think I've addressed your concerns - I'll await your input when you're ready.

@oliviertassinari
Copy link
Member

@alexhayes Thanks! I took the liberty to make some changes. Let me know what you think.

@alexhayes
Copy link
Contributor Author

@oliviertassinari sorry yes I saw that but didn't have time to comment today before you merged. I'll comment now anyway and I'll create a separate PR if you think it's necessary.

Copy link
Contributor Author

@alexhayes alexhayes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliviertassinari let us know if you'd like me to submit any of these as a PR.

| 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. |
| activeStep | number | 0 | Set the active step (zero based index). This will enable `Step` control helpers. |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the last sentence, This will enable Step control helpers., makes much sense.

activeStep doesn't enable something, it more sets something (in this case, the active property on a dot or the position on the progress component).

| 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. |
Copy link
Contributor Author

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 of onTouchTap in either the docs or the Button or BaseButton components in the next branch.

I think either the docs need to state onClick or the code needs to be changed to use onTouchTap if that is still the way to do it.

Copy link
Member

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.

| 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. |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

@@ -17,22 +17,24 @@ export const styleSheet = createStyleSheet('MuiMobileStepper', theme => ({
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
width: '100%',
backgroundColor: theme.palette.background.paper,
padding: theme.spacing.unit,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of this means the padding on hover now looks out;

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops.

| <span style="color: #31a148">onNext *</span> | function | | Passed into the onTouchTap prop of the Next button. |
| position | enum:&nbsp;'bottom'<br>&nbsp;'top'<br>&nbsp;'static'<br> | 'bottom' | Set the text that appears for the next button. |
| <span style="color: #31a148">steps *</span> | number | | The total steps. |
| type | enum:&nbsp;'text'<br>&nbsp;'dots'<br>&nbsp;'progress'<br> | 'dots' | The type of mobile stepper to use. |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what is gained here by using the &nbsp; apart from making it harder to read (when viewed raw).

I tried out a simple mixed with the <br> and it worked fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is automatically generated with yarn build:docs.


const styleSheet = createStyleSheet('DotsMobileStepper', {
root: {
maxWidth: 400,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

});
};

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 square elevation={0} className={classes.header}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This no longer lines up with the < BACK button.

While it's an issue with the docs and not an issue with the material-ui codebase I think it does look a little off.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capture d ecran 2017-06-05 a 14 28 31

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how it should line up.


## 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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this reads a little oddly. Perhaps;

This component implements a compact stepper suitable for a mobile device. See mobile steps for it's inspiration.

@oliviertassinari
Copy link
Member

@alexhayes Thanks for the feedback. Would you mind submitting a PR to address those? 😄 .

@alexhayes
Copy link
Contributor Author

@oliviertassinari Yep I should have some more time this week to submit that.

@oliviertassinari
Copy link
Member

Awesome!

@oliviertassinari
Copy link
Member

@alexhayes Any luck? I will do it otherwise.

@alexhayes
Copy link
Contributor Author

Sorry, I've had a busy week and haven't had a chance yet. I should get some time mid this week.

alexhayes added a commit to alexhayes/material-ui that referenced this pull request Jun 19, 2017
@alexhayes alexhayes mentioned this pull request Jun 19, 2017
3 tasks
oliviertassinari pushed a commit that referenced this pull request Jun 19, 2017
* [MobileStepper] Ensure correct spacing around buttons in MobileStepper.

* [MobileStepper] Documentation changes as per discussion on #7043.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: stepper This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Stepper] Mobile version
2 participants