Skip to content

Commit 83df015

Browse files
Fix progress bar overflow in onboarding steps (#726)
* fixed progress bar overflow in onboarding steps Co-authored-by: Rahul Harpal <51887323+rahulharpal1603@users.noreply.github.com>
1 parent 81286fa commit 83df015

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ import { AppFeatures } from '@/components/OnboardingSteps/AppFeatures';
2222
interface AvatarNameSelectionStepProps {
2323
stepIndex: number;
2424
totalSteps: number;
25+
currentStepDisplayIndex: number;
2526
}
2627

2728
export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
2829
stepIndex,
2930
totalSteps,
31+
currentStepDisplayIndex,
3032
}) => {
3133
const dispatch = useDispatch();
3234

@@ -65,14 +67,18 @@ export const AvatarSelectionStep: React.FC<AvatarNameSelectionStepProps> = ({
6567
<CardHeader className="p-3">
6668
<div className="text-muted-foreground mb-1 flex justify-between text-xs">
6769
<span>
68-
Step {stepIndex + 1} of {totalSteps}
70+
Step {currentStepDisplayIndex + 1} of {totalSteps}
71+
</span>
72+
<span>
73+
{Math.round(((currentStepDisplayIndex + 1) / totalSteps) * 100)}%
6974
</span>
70-
<span>{Math.round(((stepIndex + 1) / totalSteps) * 100)}%</span>
7175
</div>
7276
<div className="bg-muted mb-2 h-1.5 w-full rounded-full">
7377
<div
7478
className="bg-primary h-full rounded-full transition-all duration-300"
75-
style={{ width: `${((stepIndex + 1) / totalSteps) * 100}%` }}
79+
style={{
80+
width: `${((currentStepDisplayIndex + 1) / totalSteps) * 100}%`,
81+
}}
7682
/>
7783
</div>
7884
<CardTitle className="mt-1 text-xl font-semibold">

frontend/src/components/OnboardingSteps/FolderSetupStep.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import { useEffect, useState } from 'react';
1919
interface FolderSetupStepProps {
2020
stepIndex: number;
2121
totalSteps: number;
22+
currentStepDisplayIndex: number;
2223
}
2324

2425
export function FolderSetupStep({
2526
stepIndex,
2627
totalSteps,
28+
currentStepDisplayIndex,
2729
}: FolderSetupStepProps) {
2830
const dispatch = useDispatch<AppDispatch>();
2931

@@ -64,15 +66,17 @@ export function FolderSetupStep({
6466
if (localStorage.getItem('folderChosen') === 'true') {
6567
return null;
6668
}
67-
const progressPercent = Math.round(((stepIndex + 1) / totalSteps) * 100);
69+
const progressPercent = Math.round(
70+
((currentStepDisplayIndex + 1) / totalSteps) * 100,
71+
);
6872

6973
return (
7074
<>
7175
<Card className="flex max-h-full w-1/2 flex-col border p-4">
7276
<CardHeader className="p-3">
7377
<div className="text-muted-foreground mb-1 flex justify-between text-xs">
7478
<span>
75-
Step {stepIndex + 1} of {totalSteps}
79+
Step {currentStepDisplayIndex + 1} of {totalSteps}
7680
</span>
7781
<span>{progressPercent}%</span>
7882
</div>

frontend/src/components/OnboardingSteps/OnboardingStep.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ export const OnboardingStep: React.FC<OnboardingStepProps> = ({
2323
stepIndex,
2424
stepName,
2525
}) => {
26+
const visibleStepIndex = VISIBLE_STEPS.indexOf(stepName);
27+
2628
const sharedProps = {
2729
stepIndex,
2830
totalSteps: VISIBLE_STEPS.length,
31+
currentStepDisplayIndex: visibleStepIndex,
2932
};
3033

3134
const renderStepComponent = () => {

frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ import { useTheme } from '@/contexts/ThemeContext';
2121
interface ThemeSelectionStepProps {
2222
stepIndex: number;
2323
totalSteps: number;
24+
currentStepDisplayIndex: number;
2425
}
2526

2627
export const ThemeSelectionStep: React.FC<ThemeSelectionStepProps> = ({
2728
stepIndex,
2829
totalSteps,
30+
currentStepDisplayIndex,
2931
}) => {
3032
const { setTheme, theme } = useTheme();
3133
const dispatch = useDispatch<AppDispatch>();
@@ -51,14 +53,16 @@ export const ThemeSelectionStep: React.FC<ThemeSelectionStepProps> = ({
5153
return null;
5254
}
5355

54-
const progressPercent = Math.round(((stepIndex + 1) / totalSteps) * 100);
56+
const progressPercent = Math.round(
57+
((currentStepDisplayIndex + 1) / totalSteps) * 100,
58+
);
5559
return (
5660
<>
5761
<Card className="flex max-h-full w-1/2 flex-col border p-4">
5862
<CardHeader className="p-3">
5963
<div className="text-muted-foreground mb-1 flex justify-between text-xs">
6064
<span>
61-
Step {stepIndex + 1} of {totalSteps}
65+
Step {currentStepDisplayIndex + 1} of {totalSteps}
6266
</span>
6367
<span>{progressPercent}%</span>
6468
</div>

0 commit comments

Comments
 (0)