2024-08-20 13:57:58 +00:00
|
|
|
import type { Meta, StoryObj } from "@storybook/react";
|
2024-08-21 15:14:40 +00:00
|
|
|
import { Stepper } from "../src/components/Stepper/Stepper";
|
|
|
|
import React, { useState } from "react";
|
2024-08-20 13:57:58 +00:00
|
|
|
|
|
|
|
const meta = {
|
|
|
|
title: "Advanced/Stepper",
|
|
|
|
component: Stepper,
|
|
|
|
parameters: {
|
|
|
|
layout: "fullscreen",
|
|
|
|
},
|
|
|
|
tags: ["autodocs"],
|
|
|
|
argTypes: {},
|
|
|
|
// args: { onClick: fn() },
|
|
|
|
} satisfies Meta<typeof Stepper>;
|
|
|
|
|
|
|
|
export default meta;
|
|
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
|
|
|
|
const Template = () => {
|
|
|
|
const [step, setStep] = useState(0);
|
|
|
|
const [progress, setProgress] = useState(false);
|
|
|
|
|
|
|
|
const titles = ["Hello world", "Hello world 2", "Hello world 3"];
|
|
|
|
const title = titles[step];
|
|
|
|
|
|
|
|
const onChangeStep = (newStep: number, event: "before" | "end") => {
|
|
|
|
if (event === "before") {
|
|
|
|
setProgress(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setProgress(false);
|
|
|
|
setStep(newStep);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Stepper
|
|
|
|
Body={() => React.createElement("p", {}, title)}
|
|
|
|
titles={titles}
|
|
|
|
onChangeStep={onChangeStep}
|
|
|
|
progress={progress}
|
|
|
|
step={step}
|
|
|
|
isNextDisable={progress || step === 2}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-08-21 15:14:40 +00:00
|
|
|
export const Default = Template.bind({});
|