Skip to content

Commit

Permalink
(feat): add total steps number prop (#317)
Browse files Browse the repository at this point in the history
* feat: add totalStepsNumber at interface

* feat: add totalStepsNumber impl
  • Loading branch information
Duduzera1997 authored May 2, 2024
1 parent b12b7ab commit 18f0bcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/contexts/CopilotProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface CopilotContextType {
isFirstStep: boolean;
isLastStep: boolean;
currentStepNumber: number;
totalStepsNumber: number;
}

/*
Expand All @@ -67,6 +68,7 @@ export const CopilotProvider = ({
const {
currentStep,
currentStepNumber,
totalStepsNumber,
getFirstStep,
getPrevStep,
getNextStep,
Expand Down Expand Up @@ -199,6 +201,7 @@ export const CopilotProvider = ({
isFirstStep,
isLastStep,
currentStepNumber,
totalStepsNumber,
}),
[
registerStep,
Expand All @@ -214,6 +217,7 @@ export const CopilotProvider = ({
isFirstStep,
isLastStep,
currentStepNumber,
totalStepsNumber,
]
);

Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useStepsMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const useStepsMap = () => {
[currentStep, stepIndex]
);

const totalStepsNumber = useMemo(() => orderedSteps.length, [orderedSteps]);

const getFirstStep = useCallback(() => orderedSteps[0], [orderedSteps]);

const getLastStep = useCallback(
Expand Down Expand Up @@ -93,6 +95,7 @@ export const useStepsMap = () => {

return {
currentStepNumber,
totalStepsNumber,
getFirstStep,
getLastStep,
getPrevStep,
Expand Down

0 comments on commit 18f0bcc

Please sign in to comment.