2024-08-22 15:07:05 +00:00
|
|
|
import type { Meta } from "@storybook/react";
|
2024-08-21 15:14:40 +00:00
|
|
|
import { Upload } from "../src/components/Upload/Upload";
|
2024-08-22 18:04:24 +00:00
|
|
|
import { fn } from "@storybook/test";
|
2024-08-23 13:31:37 +00:00
|
|
|
import "./Upload.stories.css";
|
2024-09-30 10:45:06 +00:00
|
|
|
import { CodexDataSdk, CodexDataSlowSdk, CodexDataErrorSdk } from "./sdk";
|
2024-08-20 13:57:58 +00:00
|
|
|
|
|
|
|
const meta = {
|
|
|
|
title: "Advanced/Upload",
|
|
|
|
component: Upload,
|
|
|
|
parameters: {
|
|
|
|
layout: "centered",
|
|
|
|
},
|
|
|
|
tags: ["autodocs"],
|
|
|
|
argTypes: {},
|
2024-08-22 18:04:24 +00:00
|
|
|
args: {
|
|
|
|
onMouseEnter: fn(),
|
|
|
|
onMouseLeave: fn(),
|
|
|
|
onClick: fn(),
|
|
|
|
onSuccess: fn(),
|
|
|
|
onDeleteItem: fn(),
|
|
|
|
onFileChange: fn(),
|
|
|
|
},
|
2024-08-20 13:57:58 +00:00
|
|
|
} satisfies Meta<typeof Upload>;
|
|
|
|
|
|
|
|
export default meta;
|
|
|
|
|
2024-08-22 18:04:24 +00:00
|
|
|
type Props = {
|
|
|
|
onClick?: () => void;
|
|
|
|
|
|
|
|
onMouseEnter?: () => void;
|
|
|
|
|
|
|
|
onMouseLeave?: () => void;
|
|
|
|
|
|
|
|
onSuccess?: () => void;
|
|
|
|
|
|
|
|
onDeletedItem?: () => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
const Template = (p: Props) => {
|
2024-09-30 10:45:06 +00:00
|
|
|
return <Upload multiple {...p} codexData={CodexDataSdk} />;
|
2024-08-20 13:57:58 +00:00
|
|
|
};
|
|
|
|
|
2024-08-21 15:14:40 +00:00
|
|
|
export const Multiple = Template.bind({});
|
2024-08-20 13:57:58 +00:00
|
|
|
|
2024-08-22 18:04:24 +00:00
|
|
|
const SlowTemplate = (p: Props) => {
|
2024-08-20 13:57:58 +00:00
|
|
|
return (
|
|
|
|
<div className="demo">
|
2024-09-30 10:45:06 +00:00
|
|
|
<Upload multiple codexData={CodexDataSlowSdk} {...p} />
|
2024-08-20 13:57:58 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-08-21 15:14:40 +00:00
|
|
|
export const Slow = SlowTemplate.bind({});
|
2024-08-20 13:57:58 +00:00
|
|
|
|
2024-08-22 18:04:24 +00:00
|
|
|
const SingleTemplate = (p: Props) => {
|
2024-08-20 13:57:58 +00:00
|
|
|
return (
|
|
|
|
<div className="demo">
|
2024-09-30 10:45:06 +00:00
|
|
|
{
|
|
|
|
<Upload
|
|
|
|
multiple={false}
|
|
|
|
editable={false}
|
|
|
|
codexData={CodexDataSlowSdk}
|
|
|
|
{...p}
|
|
|
|
/>
|
|
|
|
}
|
2024-08-20 13:57:58 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-08-21 15:14:40 +00:00
|
|
|
export const Single = SingleTemplate.bind({});
|
2024-09-30 10:45:06 +00:00
|
|
|
|
|
|
|
const ErrorTemplate = (p: Props) => {
|
|
|
|
return (
|
|
|
|
<div className="demo">
|
|
|
|
{
|
|
|
|
<Upload
|
|
|
|
multiple={false}
|
|
|
|
editable={false}
|
|
|
|
codexData={CodexDataErrorSdk}
|
|
|
|
{...p}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Error = ErrorTemplate.bind({});
|