Skip to content

Expose goto func as Prop to renderSteps#6

Open
francois06 wants to merge 2 commits into
JoaoCnh:masterfrom
53js:master
Open

Expose goto func as Prop to renderSteps#6
francois06 wants to merge 2 commits into
JoaoCnh:masterfrom
53js:master

Conversation

@francois06
Copy link
Copy Markdown

It allows to call goto function when you customize renderSteps :

<Loki
   onFinish={onFinish}
   noActions
   renderSteps={(props) => <CustomSteps steps={steps} {...props} />}
   steps={steps}
/>
const CustomSteps = ({ steps, currentStep, goto }) => {
       // now you can use goto
	const customSteps = steps.map((step, index) => {
		const isActive = currentStep === index + 1;
		const isNext = currentStep < index + 1;
		const handleClick = (e) => {
			e.preventDefault();
			if (isNext) return false;
			return goto(index + 1);
		};
		return (
			<li key={step.label} className={clsx('card-box', { current: isActive })}>
				<a href="#" onClick={handleClick} className={clsx({ disabled: isNext })} disabled={!!isNext}>
					<div className="label">{step.label}</div>
					<div className="step-indicator">{step.number}</div>
				</a>
			</li>
		);
	});

	return (
		<div className="horizontal">
			<ul className="steps-indicator">{customSteps}</ul>
		</div>
	);
};

@francois06 francois06 mentioned this pull request May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant