Skip to content

Commit

Permalink
Add event to next button (#832)
Browse files Browse the repository at this point in the history
* add event to next button

* version bump

Co-authored-by: Makda Sebahtu <sebhatumakda20gmail.com>
  • Loading branch information
Maki44 authored Oct 13, 2022
1 parent bf57692 commit 5931cc6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/green-panthers-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@web3uikit/core': patch
---

Version bump for stepper
5 changes: 4 additions & 1 deletion packages/core/src/lib/Stepper/Stepper.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const parentWrapper = {
export default {
title: '3.Layout/Stepper',
component: Stepper,
argTypes: { onComplete: { action: 'completed' } },
argTypes: {
onComplete: { action: 'completed' },
onNext: { action: 'Next Clicked' },
},
decorators: [(storyFn) => <div style={parentWrapper}>{storyFn()}</div>],
} as ComponentMeta<typeof Stepper>;

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/lib/Stepper/Stepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const Stepper: React.FC<StepperProps> = ({
completeTitle = 'all done, nice!',
completeMessage = 'You should tell the user what to do next, or use the onComplete function to programmatically fire an event',
onComplete = () => null,
onNext,
headerWidth,
...props
}) => {
Expand Down Expand Up @@ -60,6 +61,7 @@ const Stepper: React.FC<StepperProps> = ({
return;
}
setStep(myStepRef.current + 1);
onNext && onNext(activeStep);
};

const handleContentClick = (event: React.MouseEvent<HTMLElement>) => {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/lib/Stepper/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export interface StepperProps {
*/
onComplete?: () => void;

/**
* This event will fire when next button clicked
*/
onNext?: (stepNumber: number) => void;

/**
* Pass the step the user should start on
* 0 = loading
Expand Down

0 comments on commit 5931cc6

Please sign in to comment.