= ({
const {isDesktopOrBigger} = useScreenSize();
const {height, ref} = useElementDimensions();
const textContainerHeight = height;
- const previousIndexRef = React.useRef(currentIndex);
- const isBack = previousIndexRef.current > currentIndex;
- if (currentIndex !== previousIndexRef.current) {
- previousIndexRef.current = currentIndex;
- }
+ const [step, setStep] = React.useState(Math.ceil(currentIndex));
+ const [isBack, setIsBack] = React.useState(false);
+
+ React.useEffect(() => {
+ const newStep = Math.ceil(currentIndex);
+ if (step !== newStep) {
+ setIsBack(newStep < step);
+ setStep(newStep);
+ }
+ }, [currentIndex, steps, step]);
return (
= ({
{...getPrefixedDataAttributes(dataAttributes, 'Stepper')}
>
{steps.map((text, index) => {
- const isCurrent = index === currentIndex;
+ const isCurrent = index === step;
const isLastStep = index === steps.length - 1;
- const isCompleted = index < currentIndex;
- const hasAnimation = index === currentIndex - 1;
+ const isCompleted = index < step;
+ const hasAnimation = index === step - 1;
return (
diff --git a/src/theme.tsx b/src/theme.tsx
index 134dd37a78..cbf307d38c 100644
--- a/src/theme.tsx
+++ b/src/theme.tsx
@@ -41,6 +41,8 @@ const TEXTS_ES = {
playIconButtonLabel: 'Reproducir',
pauseIconButtonLabel: 'Pausar',
sheetConfirmButton: 'Continuar',
+ progressBarCompletedLabel: 'completo',
+ progressBarStepLabel: 'Paso 1$s de 2$s',
pinFieldInputLabel: 'Dígito 1$s de 2$s',
};
@@ -78,6 +80,8 @@ const TEXTS_EN: ThemeTexts = {
playIconButtonLabel: 'Play',
pauseIconButtonLabel: 'Pause',
sheetConfirmButton: 'Continue',
+ progressBarCompletedLabel: 'completed',
+ progressBarStepLabel: 'Step 1$s of 2$s',
pinFieldInputLabel: 'Digit 1$s of 2$s',
};
@@ -115,6 +119,8 @@ const TEXTS_DE: ThemeTexts = {
playIconButtonLabel: 'Abspielen',
pauseIconButtonLabel: 'Pausieren',
sheetConfirmButton: 'Fortfahren',
+ progressBarCompletedLabel: 'vollendet',
+ progressBarStepLabel: 'Schritt 1$s von 2$s',
pinFieldInputLabel: 'Ziffer 1$s von 2$s',
};
@@ -152,6 +158,8 @@ const TEXTS_PT: ThemeTexts = {
playIconButtonLabel: 'Reproduzir',
pauseIconButtonLabel: 'Pausar',
sheetConfirmButton: 'Continuar',
+ progressBarCompletedLabel: 'concluído',
+ progressBarStepLabel: 'Etapa 1$s de 2$s',
pinFieldInputLabel: 'Dígito 1$s de 2$s',
};