use only in phone view

This commit is contained in:
Hristo Nedelkov 2024-01-09 13:18:07 +02:00
parent f7f275c202
commit 17af464ccd
3 changed files with 29 additions and 19 deletions

View File

@ -16,32 +16,29 @@ const steps = [
type FormStepperProps = { type FormStepperProps = {
activeStep: number activeStep: number
windowWidth: number
} }
const FormStepper = ({ activeStep }: FormStepperProps) => { const FormStepper = ({ activeStep, windowWidth }: FormStepperProps) => {
const isStepVisible = (index: number) => { const isStepVisible = (index: number) => {
if (activeStep === 0) { if (windowWidth < 650) {
// Show the first three steps if the active step is the first one const start = Math.max(0, activeStep - 1)
return index <= 2; const end = Math.min(steps.length - 1, activeStep + 1)
} else if (activeStep === steps.length - 1) { return index >= start && index <= end
// Show the last three steps if the active step is the last one
return index >= steps.length - 3;
} else { } else {
// Otherwise, show the previous, current, and next steps return true
return index === activeStep || index === activeStep - 1 || index === activeStep + 1;
} }
} }
const dispatch = useDispatch() const dispatch = useDispatch()
const changeStepOnClickHandler = (index: number) => { const changeStepOnClickHandler = (index: number) => {
if (activeStep > index) { if (activeStep > index) {
dispatch(setActiveStep(index)) dispatch(setActiveStep(index))
} }
} }
const visibleSteps = steps.filter((_, index) => isStepVisible(index)); const visibleSteps = steps.filter((_, index) => isStepVisible(index))
return ( return (
<Stepper <Stepper
activeStep={activeStep} activeStep={activeStep}
@ -51,14 +48,14 @@ const FormStepper = ({ activeStep }: FormStepperProps) => {
style={{ style={{
fontSize: '14px', fontSize: '14px',
zIndex: 1, zIndex: 1,
width: '1200px', width: '100%',
padding: 0, padding: 0,
marginBottom: '3rem', marginBottom: '3rem',
overflow: 'hidden', overflow: 'hidden',
}} }}
> >
{visibleSteps.map((step) => { {visibleSteps.map(step => {
const originalIndex = steps.indexOf(step); const originalIndex = steps.indexOf(step)
return ( return (
<Step <Step
key={originalIndex} key={originalIndex}
@ -69,7 +66,7 @@ const FormStepper = ({ activeStep }: FormStepperProps) => {
data-subtitle={step.subtitle} data-subtitle={step.subtitle}
data-step={step.label} data-step={step.label}
/> />
); )
})} })}
</Stepper> </Stepper>
) )

View File

@ -5,7 +5,10 @@ import OverviewCard from './OverviewCard'
import LinkWithArrow from '../../../components/General/LinkWithArrow' import LinkWithArrow from '../../../components/General/LinkWithArrow'
import OverviewWrapper from './OverviewWrapper' import OverviewWrapper from './OverviewWrapper'
import './overviewLayout.css' import './overviewLayout.css'
const Overview = () => { const Overview = () => {
return ( return (
<> <>
<OverviewWrapper <OverviewWrapper

View File

@ -22,8 +22,18 @@ import './layoutGradient.css'
import Deposit from './Deposit/Deposit' import Deposit from './Deposit/Deposit'
import './layoutGradient.css' import './layoutGradient.css'
import { useEffect, useState } from 'react'
const ValidatorOnboarding = () => { const ValidatorOnboarding = () => {
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
useEffect(() => {
const handleResize = () => {
setWindowWidth(window.innerWidth)
}
window.addEventListener('resize', handleResize)
return () => window.removeEventListener('resize', handleResize)
}, [])
const { activeStep, subStepValidatorSetup } = useSelector( const { activeStep, subStepValidatorSetup } = useSelector(
(state: RootState) => state.validatorOnboarding, (state: RootState) => state.validatorOnboarding,
) )
@ -44,7 +54,7 @@ const ValidatorOnboarding = () => {
titleSize={19} titleSize={19}
subtitle="Earn Rewards for securing the Ethereum Network" subtitle="Earn Rewards for securing the Ethereum Network"
/> />
<FormStepper activeStep={activeStep} /> <FormStepper activeStep={activeStep} windowWidth={windowWidth} />
<ValidatorBoxWrapper> <ValidatorBoxWrapper>
{activeStep === 0 && <Overview />} {activeStep === 0 && <Overview />}
{activeStep === 1 && <Advisories />} {activeStep === 1 && <Advisories />}