Skip to content

Commit

Permalink
Merge pull request #3 from pangolindex/feat/init
Browse files Browse the repository at this point in the history
  • Loading branch information
SarjuHansaliya authored Nov 10, 2021
2 parents e46ead4 + c435fe7 commit 6b1e3dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/components/Steps/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IconDot, StepCounter, StepItem, StepName } from './styles';
import { StepProps } from './types';

const Step: React.FC<StepProps> = (props) => {
const { active, completed, stepNumber, disabled, title, progressDot } = props;
const { active, completed, stepNumber, disabled, title, progressDot, stepIndex, onStepClick } = props;

const renderIconNode = () => {
let iconNode;
Expand All @@ -21,12 +21,12 @@ const Step: React.FC<StepProps> = (props) => {
return iconNode;
};

// const onClick: React.MouseEventHandler<HTMLDivElement> = () => {
// onStepClick && onStepClick(stepIndex || 0);
// };
const onClick: React.MouseEventHandler<HTMLDivElement> = () => {
onStepClick && onStepClick(stepIndex || 0);
};

return (
<StepItem completed={completed} active={active} disabled={disabled} progressDot={progressDot}>
<StepItem completed={completed} active={active} onClick={onClick} disabled={disabled} progressDot={progressDot}>
{renderIconNode()}
{active && <StepName> {title}</StepName>}
</StepItem>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Steps/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { StepWrapper } from './styles';
import { StepsProps } from './types';

const Steps: React.FC<StepsProps> = (props) => {
const { children, current, progressDot, onChange } = props;
const { children, current, progressDot, onChange, allowChangeOnClick = true } = props;

const onStepClick = (next: number) => {
if (onChange && current !== next) {
if (onChange && current !== next && allowChangeOnClick) {
onChange(next);
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/Steps/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ export interface StepsProps {
current?: number;
initial?: number;
progressDot?: boolean;
allowChangeOnClick?: boolean;
onChange?: (current: number) => void;
children?: React.ReactNode;
}

export interface StepProps {
// onStepClick?: (index: number) => void;
onStepClick?: (index: number) => void;
disabled?: boolean;
title?: React.ReactNode;
completed?: boolean;
Expand Down

0 comments on commit 6b1e3dd

Please sign in to comment.