Open macabeus opened 4 years ago
Thanks for opening this issue and providing some context.
I don't think we want to make them optional to indicate that you should take care of the next and previous button.
It seems like you already identified a workaround. Could you show example code why this workaround does not work or works badly?
@eps1lon Of course. Here's my workaround:
import MobileStepper from '@material-ui/core/MobileStepper'
import { makeStyles } from '@material-ui/core/styles'
import React, { FunctionComponent } from 'react'
const useStyles = makeStyles(theme => ({
// we should remove padding and background
progress: {
padding: 0,
background: null
},
// as well as set width as 100%
linearProgress: {
width: '100%'
}
}))
interface Props {
countSteps: number
activeStep: number
}
const Progress: FunctionComponent<Props> = ({ countSteps, activeStep }) => {
const classes = useStyles({})
return (
<MobileStepper
variant='progress'
steps={countSteps}
position='static'
activeStep={activeStep}
nextButton={null} // set as null these buttons
backButton={null}
className={classes.progress} // set this class
LinearProgressProps={{
className: classes.linearProgress // and set this class
}}
/>
)
}
export default Progress
If we set these props as optional, we could remove ~10 lines of a workaround code, improving its readability.
I second this. Just had to pass empty Fragments as arguments to the button props (Typescript wouldn't let me pass null). It's not a hard or lengthy workaround, but it's not something that's easy to understand from the perspective of someone looking at the code for the first time.
31stJuly2022 - from macabeus comment below the backButton={null} type in this... sx={{ '& .MuiLinearProgress-root' : { width: '100%' } }}
I hope this helped somebody!! ✌️
Summary 💡
Currently we have many components to display a progress to user. One of these components is
MobileStepper
.This component is good, but I think that it could be more flexible if we change its interface seting
nextButton
andbackButton
as optional and, when these props isn't set, should changeLinearProgressProps
's style towidth: '100%'
Examples 🌈
Motivation 🔦
It's because sometimes we want to use this component, but displaying "next" and "back" buttons on others place of screen.
I know that sometimes we could just use
LinearProgress
component, butMobileStepper
has one variant with a very different visual and its interface is better to this case.