feat: use new hook to make stepper responsive
This commit is contained in:
parent
5ca1529dc1
commit
48a0166f00
|
@ -3,6 +3,7 @@ import { useDispatch } from 'react-redux'
|
||||||
|
|
||||||
import { setActiveStep } from '../../../redux/ValidatorOnboarding/slice'
|
import { setActiveStep } from '../../../redux/ValidatorOnboarding/slice'
|
||||||
import { FORM_STEPS } from '../../../constants'
|
import { FORM_STEPS } from '../../../constants'
|
||||||
|
import { useWindowSize } from '../../../hooks/useWindowSize'
|
||||||
import './FormStepper.css'
|
import './FormStepper.css'
|
||||||
|
|
||||||
type FormStepperProps = {
|
type FormStepperProps = {
|
||||||
|
@ -11,15 +12,28 @@ type FormStepperProps = {
|
||||||
|
|
||||||
const FormStepper = ({ activeStep }: FormStepperProps) => {
|
const FormStepper = ({ activeStep }: FormStepperProps) => {
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
|
const windowSize = useWindowSize()
|
||||||
|
|
||||||
const isStepVisible = (index: number) => {
|
const isStepVisible = (index: number) => {
|
||||||
// if (windowWidth < 1025) {
|
if (windowSize.width < 774) {
|
||||||
// const start = activeStep - 1
|
const start = Math.min(3, activeStep - 1)
|
||||||
// const end = Math.min(FORM_STEPS.length - 1, activeStep + 1)
|
const end = Math.max(FORM_STEPS.length - 5, activeStep + 1)
|
||||||
// return index >= start && index <= end
|
return index >= start && index <= end
|
||||||
// } else {
|
} else if (windowSize.width < 963) {
|
||||||
|
const start = Math.min(2, activeStep - 1)
|
||||||
|
const end = Math.max(FORM_STEPS.length - 4, activeStep + 1)
|
||||||
|
return index >= start && index <= end
|
||||||
|
} else if (windowSize.width < 1152) {
|
||||||
|
const start = Math.min(1, activeStep - 1)
|
||||||
|
const end = Math.max(FORM_STEPS.length - 3, activeStep + 1)
|
||||||
|
return index >= start && index <= end
|
||||||
|
} else if (windowSize.width < 1300) {
|
||||||
|
const start = Math.min(0, activeStep - 1)
|
||||||
|
const end = Math.max(FORM_STEPS.length - 2, activeStep + 1)
|
||||||
|
return index >= start && index <= end
|
||||||
|
} else {
|
||||||
return true
|
return true
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeStepOnClickHandler = (index: number) => {
|
const changeStepOnClickHandler = (index: number) => {
|
||||||
|
|
Loading…
Reference in New Issue